diff --git a/include/class.ticket.php b/include/class.ticket.php index 3fe355de2a1e8f807e59d3d447e5513626c526c3..6854f6c64d863bbd262a240b49f43f21dc6ab9f6 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -139,6 +139,16 @@ class TicketModel extends VerySimpleModel { /* @trans */ 'Ability to delete tickets'), ); + // Ticket Sources + static protected $sources = array( + 'Phone' => + /* @trans */ 'Phone', + 'Email' => + /* @trans */ 'Email', + 'Other' => + /* @trans */ 'Other', + ); + function getId() { return $this->ticket_id; } @@ -199,6 +209,10 @@ EOF; static function getPermissions() { return self::$perms; } + + static function getSources() { + return self::$sources; + } } RolePermission::register(/* @trans */ 'Tickets', TicketModel::getPermissions(), true); @@ -3392,13 +3406,11 @@ implements RestrictedAccess, Threadable { return false; } - if ($vars['source'] && !in_array( - strtolower($vars['source']), array('email','phone','other')) - ) { - $errors['source'] = sprintf( - __('Invalid source given - %s'),Format::htmlchars($vars['source']) - ); - } + if (isset($vars['source']) // Check ticket source if provided + && !array_key_exists($vars['source'], Ticket::getSources())) + $errors['source'] = sprintf( __('Invalid source given - %s'), + Format::htmlchars($vars['source'])); + if (!$vars['uid']) { // Special validation required here diff --git a/include/staff/ticket-open.inc.php b/include/staff/ticket-open.inc.php index 3173d7e92bb2004149bfa209aefc84760cdb675a..b8330a0f53b997a34bc54aa818cc16f16ed9bbde 100644 --- a/include/staff/ticket-open.inc.php +++ b/include/staff/ticket-open.inc.php @@ -129,9 +129,14 @@ if ($_POST) </td> <td> <select name="source"> - <option value="Phone" selected="selected"><?php echo __('Phone'); ?></option> - <option value="Email" <?php echo ($info['source']=='Email')?'selected="selected"':''; ?>><?php echo __('Email'); ?></option> - <option value="Other" <?php echo ($info['source']=='Other')?'selected="selected"':''; ?>><?php echo __('Other'); ?></option> + <?php + $source = $info['source'] ?: 'Phone'; + foreach (Ticket::getSources() as $k => $v) + echo sprintf('<option value="%s" %s>%s</option>', + $k, + ($source == $k ) ? 'selected="selected"' : '', + $v); + ?> </select> <font class="error"><b>*</b> <?php echo $errors['source']; ?></font> </td> diff --git a/include/staff/ticket-view.inc.php b/include/staff/ticket-view.inc.php index 156b2c323556a57f4de5771baae88a64eb123fc0..9cddf094eec26419d64f52f64d72587b3de48aad 100644 --- a/include/staff/ticket-view.inc.php +++ b/include/staff/ticket-view.inc.php @@ -328,7 +328,7 @@ if($ticket->isOverdue()) <td><?php echo Format::htmlchars($ticket->getSource()); - if($ticket->getIP()) + if (!strcasecmp($ticket->getSource(), 'Web') && $ticket->getIP()) echo ' <span class="faded">('.$ticket->getIP().')</span>'; ?> </td>