From 8decc383aac0f501d40b9217e38b7662932a7746 Mon Sep 17 00:00:00 2001 From: Thomas Keller Date: Sat, 26 Jun 2010 00:07:56 +0200 Subject: [PATCH] bugfix: do not validate the custom branch field in the project creation formular if we should set the project up with another SCM --- src/IDF/Form/Admin/ProjectCreate.php | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/IDF/Form/Admin/ProjectCreate.php b/src/IDF/Form/Admin/ProjectCreate.php index 7f767e5..1a4887d 100644 --- a/src/IDF/Form/Admin/ProjectCreate.php +++ b/src/IDF/Form/Admin/ProjectCreate.php @@ -167,16 +167,29 @@ class IDF_Form_Admin_ProjectCreate extends Pluf_Form public function clean_mtn_master_branch() { + // do not validate, but empty the field if a different + // SCM should be used + if ($this->cleaned_data['scm'] != 'mtn') + return ''; + $mtn_master_branch = mb_strtolower($this->cleaned_data['mtn_master_branch']); - if (!preg_match('/^([\w\d]+([-][\w\d]+)*)(\.[\w\d]+([-][\w\d]+)*)*$/', $mtn_master_branch)) { - throw new Pluf_Form_Invalid(__('This master branch contains illegal characters, please use only letters, digits, dashs and dots as separators.')); + if (!preg_match('/^([\w\d]+([-][\w\d]+)*)(\.[\w\d]+([-][\w\d]+)*)*$/', + $mtn_master_branch)) { + throw new Pluf_Form_Invalid(__( + 'The master branch is empty or contains illegal characters, '. + 'please use only letters, digits, dashs and dots as separators.' + )); } - $sql = new Pluf_SQL('vkey=%s AND vdesc=%s', array("mtn_master_branch", $mtn_master_branch)); + $sql = new Pluf_SQL('vkey=%s AND vdesc=%s', + array("mtn_master_branch", $mtn_master_branch)); $l = Pluf::factory('IDF_Conf')->getList(array('filter'=>$sql->gen())); if ($l->count() > 0) { - throw new Pluf_Form_Invalid(__('This master branch is already used. Please select another one.')); + throw new Pluf_Form_Invalid(__( + 'This master branch is already used. Please select another one.' + )); } + return $mtn_master_branch; }