Fixed to allow the dash (-) in the shortname of a project.

The dash is not allowed as first or last character of the name.
dev
Loic d'Anterroches 2009-01-02 17:26:52 +01:00
parent c8d1b66c91
commit c949672e53
1 changed files with 7 additions and 1 deletions

View File

@ -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) {