diff --git a/include/class.config.php b/include/class.config.php index 79bb05fd4b354dd50e5ce167b69591c4e13a6ae6..8fdb403e983aa243de466fff7bfac91f98ef117a 100644 --- a/include/class.config.php +++ b/include/class.config.php @@ -981,6 +981,9 @@ class OsticketConfig extends Config { $errors['default_help_topic'] = 'Default help topic must be set to active'; } + if (!preg_match('`(?!<\\\)#`', $vars['number_format'])) + $errors['number_format'] = 'Ticket number format requires at least one hash character (#)'; + if(!Validator::process($f, $vars, $errors) || $errors) return false; diff --git a/include/class.topic.php b/include/class.topic.php index 940d9156b232a210042c1566bebcf771c8f36f51..703b8ff3bb053617db9d90b0cf6e9a88049334fe 100644 --- a/include/class.topic.php +++ b/include/class.topic.php @@ -341,6 +341,10 @@ class Topic { if (!is_numeric($vars['dept_id'])) $errors['dept_id']='You must select a department'; + if ($vars['custom-numbers'] && !preg_match('`(?!<\\\)#`', $vars['number_format'])) + $errors['number_format'] = + 'Ticket number format requires at least one hash character (#)'; + if($errors) return false; foreach (array('sla_id','form_id','page_id','topic_pid') as $f) diff --git a/include/staff/helptopic.inc.php b/include/staff/helptopic.inc.php index a13daf551d7fe1c323f17cb5e5a5b858e5364ee4..0eb7307a33d62be979acd7f9de59c5693278db4b 100644 --- a/include/staff/helptopic.inc.php +++ b/include/staff/helptopic.inc.php @@ -271,6 +271,7 @@ if ($info['form_id'] == Topic::FORM_USE_PARENT) echo 'selected="selected"'; $seq = new RandomSequence(); echo $seq->current($info['number_format']); } ?></span></span> + <div class="error"><?php echo $errors['number_format']; ?></div> </td> </tr> <tr> diff --git a/include/staff/settings-tickets.inc.php b/include/staff/settings-tickets.inc.php index 793b61b85ad39358768030783c1db4a26b8a926b..759d98dbfd4d1cf2276aebfa5d7145f6379f796a 100644 --- a/include/staff/settings-tickets.inc.php +++ b/include/staff/settings-tickets.inc.php @@ -31,6 +31,7 @@ if(!($maxfileuploads=ini_get('max_file_uploads'))) echo $seq->current($config['number_format']); ?></span></span> <i class="help-tip icon-question-sign" href="#number_format"></i> + <div class="error"><?php echo $errors['number_format']; ?></div> </td> </tr> <tr><td width="220">Default Ticket Number Sequence:</td> diff --git a/include/upgrader/streams/core/8f99b8bf-00000000.task.php b/include/upgrader/streams/core/8f99b8bf-00000000.task.php index 4644062a3c78f951e442d8393efe66d54d77a6ab..8a6b8d7f58827a7ccd4e6c837264317565554aa5 100644 --- a/include/upgrader/streams/core/8f99b8bf-00000000.task.php +++ b/include/upgrader/streams/core/8f99b8bf-00000000.task.php @@ -11,11 +11,10 @@ class SequenceLoader extends MigrationTask { $i18n = new Internationalization('en_US'); $sequences = $i18n->getTemplate('sequence.yaml')->getData(); foreach ($sequences as $s) { - Sequence::create($s); - $s->save(); + Sequence::create($s)->save(); } db_query('UPDATE '.SEQUENCE_TABLE.' SET `next`= ' - .'(SELECT MAX(ticket_id) FROM '.TICKET_TABLE.') ' + .'(SELECT MAX(ticket_id)+1 FROM '.TICKET_TABLE.') ' .'WHERE `id`=1'); } }