Skip to content
Snippets Groups Projects
Commit 0df1e69a authored by Peter Rotich's avatar Peter Rotich
Browse files

Make department selection on help topic optional

parent f98ed0b4
No related branches found
No related tags found
No related merge requests found
......@@ -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');
}
......
......@@ -327,6 +327,10 @@ class Dept {
return $num;
}
function __toString() {
return $this->getName();
}
/*----Static functions-------*/
function getIdByName($name) {
$id=0;
......
......@@ -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;
......
......@@ -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'])
......
......@@ -61,7 +61,7 @@ else
<caption><?php echo $showing; ?></caption>
<thead>
<tr>
<th width="7">&nbsp;</th>
<th width="7">&nbsp;</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>&nbsp;</td>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment