diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php index fe55cd32cc6ebd69b2df889066cdcba11fa159ca..2ffbe145e3156d36fc7e903003ea92bcc53997d7 100644 --- a/include/class.dynamic_forms.php +++ b/include/class.dynamic_forms.php @@ -54,10 +54,13 @@ class DynamicForm extends VerySimpleModel { } function getDynamicFields() { - if (!isset($this->_dfields)) + if (!isset($this->_dfields)) { $this->_dfields = DynamicFormField::objects() ->filter(array('form_id'=>$this->id)) ->all(); + foreach ($this->_dfields as $f) + $f->setForm($this); + } return $this->_dfields; } @@ -148,22 +151,6 @@ class UserForm extends DynamicForm { return $os->filter(array('type'=>'U')); } - function getFields($cache=true) { - $fields = parent::getFields($cache); - foreach ($fields as $f) { - if ($f->get('name') == 'email') { - $f->getConfiguration(); - $f->_config['classes'] = 'auto email typeahead'; - $f->_config['autocomplete'] = false; - } - elseif ($f->get('name') == 'name') { - $f->getConfiguration(); - $f->_config['classes'] = 'auto name'; - } - } - return $fields; - } - static function getUserForm() { if (!isset(static::$form)) { $o = static::objects(); diff --git a/include/class.forms.php b/include/class.forms.php index c7810b10a6fb5cd442428f8b8394782502bddca0..c50c86d462c24f8b462adaa2d2237c5594649f13 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -836,13 +836,18 @@ class PriorityField extends ChoiceField { function hasIdValue() { return true; } + function isChangeable() { + return $this->getForm()->get('type') != 'T' || + $this->get('name') != 'priority'; + } function getChoices() { - $this->ht['default'] = 0; + global $cfg; + $this->ht['default'] = $cfg->getDefaultPriorityId(); $sql = 'SELECT priority_id, priority_desc FROM '.PRIORITY_TABLE .' ORDER BY priority_urgency DESC'; - $choices = array(0 => '— Default —'); + $choices = array(); if (!($res = db_query($sql))) return $choices; @@ -999,13 +1004,16 @@ class ChoicesWidget extends Widget { $config = $this->field->getConfiguration(); // Determine the value for the default (the one listed if nothing is // selected) - $def_key = $this->field->get('default'); $choices = $this->field->getChoices(); + $def_key = $this->field->get('default'); $have_def = isset($choices[$def_key]); if (!$have_def) $def_val = 'Select '.$this->field->get('label'); else $def_val = $choices[$def_key]; + $value = $this->value; + if ($value === null && $have_def) + $value = $def_key; ?> <span style="display:inline-block"> <select name="<?php echo $this->name; ?>"> <?php if (!$have_def) { ?> @@ -1016,7 +1024,7 @@ class ChoicesWidget extends Widget { if (!$have_def && $key == $def_key) continue; ?> <option value="<?php echo $key; ?>" <?php - if ($this->value == $key) echo 'selected="selected"'; + if ($value == $key) echo 'selected="selected"'; ?>><?php echo $name; ?></option> <?php } ?> </select> diff --git a/include/class.thread.php b/include/class.thread.php index 5e6c88ea7a9c9ccdb6a4074d0c550729136662f0..975a3a47294705ba3341851fd4dc53b2eb6d64a8 100644 --- a/include/class.thread.php +++ b/include/class.thread.php @@ -746,7 +746,7 @@ Class ThreadEntry { $subject = $mailinfo['subject']; $match = array(); if ($subject && $mailinfo['email'] - && preg_match("/#[\p{L}-]+?([0-9]{1,10})/u", $subject, $match) + && preg_match("/#(?:[\p{L}-]+)?([0-9]{1,10})/u", $subject, $match) && ($tid = Ticket::getIdByExtId((int)$match[1], $mailinfo['email'])) ) // Return last message for the thread diff --git a/include/class.ticket.php b/include/class.ticket.php index 1a1a822cc8b6865c2326a1ac2ae08c63ff5699dd..f4c8755e0e52b05e43865b7c2ee5886acfa881d2 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -209,7 +209,7 @@ class Ticket { function getAuthToken() { # XXX: Support variable email address (for CCs) - return md5($this->getId() . $this->getEmail() . SECRET_SALT); + return md5($this->getId() . strtolower($this->getEmail()) . SECRET_SALT); } function getName(){ diff --git a/include/class.topic.php b/include/class.topic.php index e4ac4c98cd2be7de94ea02a0e2aa5b7c6e2c1349..ee5ffc7194b78851bff6a12e912bd76f36b664ff 100644 --- a/include/class.topic.php +++ b/include/class.topic.php @@ -224,11 +224,8 @@ class Topic { if(!$vars['dept_id']) $errors['dept_id']='You must select a department'; - if(!$vars['priority_id']) - $errors['priority_id']='You must select a priority'; - if($errors) return false; - + foreach (array('sla_id','form_id','page_id','pid') as $f) if (!isset($vars[$f])) $vars[$f] = 0; @@ -237,7 +234,8 @@ class Topic { .',topic='.db_input($vars['topic']) .',topic_pid='.db_input($vars['pid']) .',dept_id='.db_input($vars['dept_id']) - .',priority_id='.db_input($vars['priority_id']) + .',priority_id='.db_input(isset($vars['priority_id']) + ? $vars['priority_id'] : 0) .',sla_id='.db_input($vars['sla_id']) .',form_id='.db_input($vars['form_id']) .',page_id='.db_input($vars['page_id']) diff --git a/include/client/open.inc.php b/include/client/open.inc.php index d47e07380273648661a4a2e898d0c4350ddb4e7c..75211c0982b687475e41e2b9bc4e738aab1d1a7d 100644 --- a/include/client/open.inc.php +++ b/include/client/open.inc.php @@ -48,16 +48,18 @@ $info=($_POST && $errors)?Format::htmlchars($_POST):$info; <tr><td colspan="2"><hr /></td></tr> <tr><td>Email:</td><td><?php echo $thisclient->getEmail(); ?></td></tr> <tr><td>Client:</td><td><?php echo $thisclient->getName(); ?></td></tr> - <?php } - $tform = TicketForm::getInstance()->getForm($_POST); - if ($_POST) $tform->isValid(); - $tform->render(false); ?> + <?php } ?> </tbody> <tbody id="dynamic-form"> <?php if ($form) { include(CLIENTINC_DIR . 'templates/dynamic-form.tmpl.php'); } ?> </tbody> + <tbody><?php + $tform = TicketForm::getInstance()->getForm($_POST); + if ($_POST) $tform->isValid(); + $tform->render(false); ?> + </tbody> <tbody> <?php if($cfg && $cfg->isCaptchaEnabled() && (!$thisclient || !$thisclient->isValid())) { @@ -79,7 +81,8 @@ $info=($_POST && $errors)?Format::htmlchars($_POST):$info; <tr><td colspan=2> </td></tr> </tbody> </table> - <p style="padding-left:150px;"> +<hr/> + <p style="text-align:center;"> <input type="submit" value="Create Ticket"> <input type="reset" value="Reset"> <input type="button" value="Cancel" onClick='window.location.href="index.php"'> diff --git a/include/staff/helptopic.inc.php b/include/staff/helptopic.inc.php index 39de0b76e4bcf48af7b9c82de365834fbcd38c00..9e9a34d142369997a3ccc32cc499045b4716de9e 100644 --- a/include/staff/helptopic.inc.php +++ b/include/staff/helptopic.inc.php @@ -106,12 +106,12 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); </td> </tr> <tr> - <td width="180" class="required"> + <td width="180"> Priority: </td> <td> <select name="priority_id"> - <option value="">— Select Priority —</option> + <option value="">— System Default —</option> <?php $sql='SELECT priority_id,priority_desc FROM '.PRIORITY_TABLE.' pri ORDER by priority_urgency DESC'; if(($res=db_query($sql)) && db_num_rows($res)){ @@ -122,7 +122,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); } ?> </select> - <span class="error">* <?php echo $errors['priority_id']; ?></span> + <span class="error"> <?php echo $errors['priority_id']; ?></span> </td> </tr> <tr> diff --git a/include/staff/ticket-open.inc.php b/include/staff/ticket-open.inc.php index 489d45ed425d67a85a81ec4132c212c030619247..7fe18f3820d783b5fff99a0e154dc131a174f245 100644 --- a/include/staff/ticket-open.inc.php +++ b/include/staff/ticket-open.inc.php @@ -66,7 +66,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); autocomplete="off" autocorrect="off" value="<?php echo $info['email']; ?>" /> </span> <font class="error">* <?php echo $errors['email']; ?></font> </td> - </td> + </tr> <tr> <td width="160" class="required"> Full Name: </td> <td> @@ -74,7 +74,7 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); <input type="text" size=45 name="name" id="user-name" value="<?php echo $info['name']; ?>" /> </span> <font class="error">* <?php echo $errors['name']; ?></font> </td> - </td> + </tr> <?php } ?> @@ -221,23 +221,23 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); </select> <span class='error'> <?php echo $errors['assignId']; ?></span> </td> </tr> - <?php - } - $tform = TicketForm::getInstance()->getForm($_POST); - if ($_POST) $tform->isValid(); - $tform->render(true); - ?> + <?php } ?> </tbody> <tbody id="dynamic-form"> <?php if ($form) $form->getForm()->render(true); ?> </tbody> + <tbody> <?php + $tform = TicketForm::getInstance()->getForm($_POST); + if ($_POST) $tform->isValid(); + $tform->render(true); + ?> + </tbody> <tbody> <?php //is the user allowed to post replies?? - if($thisstaff->canPostReply()) { - ?> + if($thisstaff->canPostReply()) { ?> <tr> <th colspan="2"> <em><strong>Response</strong>: Optional response to the above issue.</em>