diff --git a/include/class.config.php b/include/class.config.php index 5cfaed44f2bc7d806ff4838278c467662fafccf2..23772d05b8d48028e3ee55bd2da0793e90a4f58a 100644 --- a/include/class.config.php +++ b/include/class.config.php @@ -419,6 +419,13 @@ class OsticketConfig extends Config { return $this->get('default_priority_id'); } + function getDefaultPriority() { + if (!isset($this->defaultPriority)) + $this->defaultPriority = Priority::lookup($this->getDefaultPriorityId()); + + return $this->defaultPriority; + } + function getDefaultTemplateId() { return $this->get('default_template_id'); } diff --git a/include/class.dept.php b/include/class.dept.php index 04a0e1b72a43cbd6eaa8ce203698961a0813bfca..1ec4116fb92206c6308842cccd28869b60104104 100644 --- a/include/class.dept.php +++ b/include/class.dept.php @@ -327,6 +327,10 @@ class Dept { return $num; } + function __toString() { + return $this->getName(); + } + /*----Static functions-------*/ function getIdByName($name) { $id=0; diff --git a/include/class.priority.php b/include/class.priority.php index f4e7cf8c5485b8f0e039dcc41df2b57b33e22a72..63a7434c479f88075ec1170d2a6410768891a0ef 100644 --- a/include/class.priority.php +++ b/include/class.priority.php @@ -15,12 +15,12 @@ **********************************************************************/ class Priority { - + var $id; var $ht; function Priority($id){ - + $this->id =0; $this->load($id); } @@ -65,6 +65,10 @@ class Priority { return ($this->ht['ispublic']); } + function __toString() { + return $this->getDesc(); + } + /* ------------- Static ---------------*/ function lookup($id) { return ($id && is_numeric($id) && ($p=new Priority($id)) && $p->getId()==$id)?$p:null; diff --git a/include/class.topic.php b/include/class.topic.php index 8d4d460ab1dd915b3b53a047cc425e15541fb348..ad3b21a416f147ba443d2417c786f1bb7c6299b2 100644 --- a/include/class.topic.php +++ b/include/class.topic.php @@ -221,7 +221,7 @@ class Topic { elseif(($tid=self::getIdByName($vars['topic'], $vars['pid'])) && $tid!=$id) $errors['topic']='Topic already exists'; - if(!$vars['dept_id']) + if (!is_numeric($vars['dept_id'])) $errors['dept_id']='You must select a department'; if($errors) return false; @@ -234,8 +234,7 @@ class Topic { .',topic='.db_input($vars['topic']) .',topic_pid='.db_input($vars['pid']) .',dept_id='.db_input($vars['dept_id']) - .',priority_id='.db_input(isset($vars['priority_id']) - ? $vars['priority_id'] : 0) + .',priority_id='.db_input($vars['priority_id']) .',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/staff/helptopics.inc.php b/include/staff/helptopics.inc.php index 90eb45b453aaa200b8a4d7c37584fae8a3a9ea21..8395a29e3d723ed881405cfb8d06f96bbad728bc 100644 --- a/include/staff/helptopics.inc.php +++ b/include/staff/helptopics.inc.php @@ -61,7 +61,7 @@ else <caption><?php echo $showing; ?></caption> <thead> <tr> - <th width="7"> </th> + <th width="7"> </th> <th width="320"><a <?php echo $name_sort; ?> href="helptopics.php?<?php echo $qstr; ?>&sort=name">Help Topic</a></th> <th width="80"><a <?php echo $status_sort; ?> href="helptopics.php?<?php echo $qstr; ?>&sort=status">Status</a></th> <th width="100"><a <?php echo $type_sort; ?> href="helptopics.php?<?php echo $qstr; ?>&sort=type">Type</a></th> @@ -75,14 +75,25 @@ else $total=0; $ids=($errors && is_array($_POST['ids']))?$_POST['ids']:null; if($res && db_num_rows($res)): + $defaultDept = $cfg->getDefaultDept(); + $defaultPriority = $cfg->getDefaultPriority(); while ($row = db_fetch_array($res)) { $sel=false; if($ids && in_array($row['topic_id'],$ids)) $sel=true; + + if (!$row['dept_id'] && $defaultDept) { + $row['dept_id'] = $defaultDept->getId(); + $row['department'] = (string) $defaultDept; + } + + if (!$row['priority'] && $defaultPriority) + $row['priority'] = (string) $defaultPriority; + ?> <tr id="<?php echo $row['topic_id']; ?>"> <td width=7px> - <input type="checkbox" class="ckb" name="ids[]" value="<?php echo $row['topic_id']; ?>" + <input type="checkbox" class="ckb" name="ids[]" value="<?php echo $row['topic_id']; ?>" <?php echo $sel?'checked="checked"':''; ?>> </td> <td><a href="helptopics.php?id=<?php echo $row['topic_id']; ?>"><?php echo $row['name']; ?></a> </td>