From c949672e53b2d1ff58577d9a8bc5c7316d9ab85f Mon Sep 17 00:00:00 2001 From: Loic d'Anterroches Date: Fri, 2 Jan 2009 17:26:52 +0100 Subject: [PATCH] Fixed to allow the dash (-) in the shortname of a project. The dash is not allowed as first or last character of the name. --- src/IDF/Form/Admin/ProjectCreate.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/IDF/Form/Admin/ProjectCreate.php b/src/IDF/Form/Admin/ProjectCreate.php index 8afd8b6..3521a7f 100644 --- a/src/IDF/Form/Admin/ProjectCreate.php +++ b/src/IDF/Form/Admin/ProjectCreate.php @@ -126,9 +126,15 @@ class IDF_Form_Admin_ProjectCreate extends Pluf_Form public function clean_shortname() { $shortname = $this->cleaned_data['shortname']; - if (preg_match('/[^A-Za-z0-9]/', $shortname)) { + if (preg_match('/[^\-A-Za-z0-9]/', $shortname)) { throw new Pluf_Form_Invalid(__('This shortname contains illegal characters, please use only letters and digits.')); } + if (mb_substr($shortname, 0, 1) == '-') { + throw new Pluf_Form_Invalid(__('The shortname cannot start with the dash (-) character.')); + } + if (mb_substr($shortname, -1) == '-') { + throw new Pluf_Form_Invalid(__('The shortname cannot end with the dash (-) character.')); + } $sql = new Pluf_SQL('shortname=%s', array($shortname)); $l = Pluf::factory('IDF_Project')->getList(array('filter'=>$sql->gen())); if ($l->count() > 0) {