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

topics: Arbitrary nesting for help topics

parent 4e2b8deb
No related branches found
No related tags found
No related merge requests found
...@@ -71,18 +71,14 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); ...@@ -71,18 +71,14 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
</td> </td>
<td> <td>
<select name="pid"> <select name="pid">
<option value="">&mdash; Select Parent Topic &mdash;</option> <option value="">&mdash; Select Parent Topic &mdash;</option><?php
$topics = Topic::getHelpTopics();
while (list($id,$topic) = each($topics)) {
if ($id == $info['topic_id'])
continue; ?>
<option value="<?php echo $id; ?>"<?php echo ($info['topic_pid']==$id)?'selected':''; ?>><?php echo $topic; ?></option>
<?php <?php
$sql='SELECT topic_id, topic FROM '.TOPIC_TABLE } ?>
.' WHERE topic_pid=0 '
.' ORDER by topic';
if(($res=db_query($sql)) && db_num_rows($res)) {
while(list($id, $name)=db_fetch_row($res)) {
echo sprintf('<option value="%d" %s>%s</option>',
$id, (($info['pid'] && $id==$info['pid'])?'selected="selected"':'') ,$name);
}
}
?>
</select> <i class="help-tip icon-question-sign" href="#parent_topic"></i> </select> <i class="help-tip icon-question-sign" href="#parent_topic"></i>
&nbsp;<span class="error">&nbsp;<?php echo $errors['pid']; ?></span> &nbsp;<span class="error">&nbsp;<?php echo $errors['pid']; ?></span>
</td> </td>
......
...@@ -2,28 +2,38 @@ ...@@ -2,28 +2,38 @@
if(!defined('OSTADMININC') || !$thisstaff->isAdmin()) die('Access Denied'); if(!defined('OSTADMININC') || !$thisstaff->isAdmin()) die('Access Denied');
$sql='SELECT topic.* ' $sql='SELECT topic.* '
.', IF(ptopic.topic_pid IS NULL, topic.topic, CONCAT_WS(" / ", ptopic.topic, topic.topic)) as name '
.', dept.dept_name as department ' .', dept.dept_name as department '
.', priority_desc as priority ' .', priority_desc as priority '
.' FROM '.TOPIC_TABLE.' topic ' .' FROM '.TOPIC_TABLE.' topic '
.' LEFT JOIN '.TOPIC_TABLE.' ptopic ON (ptopic.topic_id=topic.topic_pid) '
.' LEFT JOIN '.DEPT_TABLE.' dept ON (dept.dept_id=topic.dept_id) ' .' LEFT JOIN '.DEPT_TABLE.' dept ON (dept.dept_id=topic.dept_id) '
.' LEFT JOIN '.TICKET_PRIORITY_TABLE.' pri ON (pri.priority_id=topic.priority_id) '; .' LEFT JOIN '.TICKET_PRIORITY_TABLE.' pri ON (pri.priority_id=topic.priority_id) ';
$sql.=' WHERE 1'; $sql.=' WHERE 1';
$order_by = ($cfg->getTopicSortMode() == 'm' ? '`sort`' : '`name`'); $order_by = ($cfg->getTopicSortMode() == 'm' ? '`sort`' : '`topic_id`');
$total=db_count('SELECT count(*) FROM '.TOPIC_TABLE.' topic '); $total=db_count('SELECT count(*) FROM '.TOPIC_TABLE.' topic ');
$page=($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1; $page=($_GET['p'] && is_numeric($_GET['p']))?$_GET['p']:1;
$pageNav=new Pagenate($total, $page, PAGE_LIMIT); $pageNav=new Pagenate($total, $page, PAGE_LIMIT);
$pageNav->setURL('helptopics.php'); $pageNav->setURL('helptopics.php');
//Ok..lets roll...create the actual query //Ok..lets roll...create the actual query
$query="$sql GROUP BY topic.topic_id ORDER BY $order_by LIMIT ".$pageNav->getStart().",".$pageNav->getLimit(); $query="$sql ORDER BY $order_by";
$res=db_query($query); $res=db_query($query);
if($res && ($num=db_num_rows($res))) if($res && ($num=db_num_rows($res)))
$showing=$pageNav->showing().' help topics'; $showing=$pageNav->showing().' help topics';
else else
$showing='No help topic found!'; $showing='No help topic found!';
// Get the full names and filter for this page
$topics = array();
while ($row = db_fetch_array($res))
$topics[] = $row;
foreach ($topics as &$t)
$t['name'] = Topic::getTopicName($t['topic_id']);
if ($cfg->getTopicSortMode() == 'a')
usort($topics, function($a, $b) { return strcmp($a['name'], $b['name']); });
$topics = array_slice($topics, $pageNav->getStart(), $pageNav->getLimit()+2);
?> ?>
<div style="width:700px;padding-top:5px; float:left;"> <div style="width:700px;padding-top:5px; float:left;">
<h2>Help Topics</h2> <h2>Help Topics</h2>
...@@ -49,11 +59,11 @@ else ...@@ -49,11 +59,11 @@ else
<thead> <thead>
<tr> <tr>
<th width="7" style="height:20px;">&nbsp;</th> <th width="7" style="height:20px;">&nbsp;</th>
<th style="padding-left:4px;vertical-align:middle" width="320">Help Topic</th> <th style="padding-left:4px;vertical-align:middle" width="360">Help Topic</th>
<th style="padding-left:4px;vertical-align:middle" width="80">Status</th> <th style="padding-left:4px;vertical-align:middle" width="80">Status</th>
<th style="padding-left:4px;vertical-align:middle" width="100">Type</th> <th style="padding-left:4px;vertical-align:middle" width="100">Type</th>
<th style="padding-left:4px;vertical-align:middle" width="100">Priority</th> <th style="padding-left:4px;vertical-align:middle" width="100">Priority</th>
<th style="padding-left:4px;vertical-align:middle" width="200">Department</th> <th style="padding-left:4px;vertical-align:middle" width="160">Department</th>
<th style="padding-left:4px;vertical-align:middle" width="150" nowrap>Last Updated</th> <th style="padding-left:4px;vertical-align:middle" width="150" nowrap>Last Updated</th>
</tr> </tr>
</thead> </thead>
...@@ -62,11 +72,11 @@ else ...@@ -62,11 +72,11 @@ else
<?php <?php
$total=0; $total=0;
$ids=($errors && is_array($_POST['ids']))?$_POST['ids']:null; $ids=($errors && is_array($_POST['ids']))?$_POST['ids']:null;
if($res && db_num_rows($res)): if (count($topics)):
$defaultDept = $cfg->getDefaultDept(); $defaultDept = $cfg->getDefaultDept();
$defaultPriority = $cfg->getDefaultPriority(); $defaultPriority = $cfg->getDefaultPriority();
$sort = 0; $sort = 0;
while ($row = db_fetch_array($res)) { foreach($topics as $row) {
$sort++; // Track initial order for transition $sort++; // Track initial order for transition
$sel=false; $sel=false;
if($ids && in_array($row['topic_id'],$ids)) if($ids && in_array($row['topic_id'],$ids))
......
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