Skip to content
Snippets Groups Projects
Commit 2fdba186 authored by Jared Hancock's avatar Jared Hancock
Browse files

Add validation errors for custom number formats

And fixup the migration patch
parent 7a182d35
Branches
Tags
No related merge requests found
......@@ -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;
......
......@@ -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)
......
......@@ -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>
......
......@@ -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>
......
......@@ -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');
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment