diff --git a/include/class.filter.php b/include/class.filter.php index 5db16cdfe0830acfc2ac86b26a290297f2971b76..60431d55c01045cc72679c77237dddf09ab86165 100644 --- a/include/class.filter.php +++ b/include/class.filter.php @@ -21,6 +21,9 @@ class Filter { var $id; var $ht; + const FLAG_INACTIVE_HT = 0x0001; + const FLAG_INACTIVE_DEPT = 0x0002; + static $match_types = array( /* @trans */ 'User Information' => array( array('name' => /* @trans */ 'Name', @@ -138,6 +141,13 @@ class Filter { return $this->ht['topic_id']; } + public function setFlag($flag, $val) { + if ($val) + $this->ht['flags'] |= $flag; + else + $this->ht['flags'] &= ~$flag; + } + function stopOnMatch() { return ($this->ht['stop_onmatch']); } @@ -502,6 +512,7 @@ class Filter { $sql=' updated=NOW() ' .',isactive='.db_input($vars['isactive']) + .',flags='.db_input($vars['flags']) .',target='.db_input($vars['target']) .',name='.db_input($vars['name']) .',execorder='.db_input($vars['execorder']) diff --git a/include/staff/filters.inc.php b/include/staff/filters.inc.php index 6eb7f32310c965fbcb3f013a1666c6fbb99c3d43..f758c5ebcf1209bef0f2229c9130061fd7aca9fe 100644 --- a/include/staff/filters.inc.php +++ b/include/staff/filters.inc.php @@ -2,9 +2,11 @@ if(!defined('OSTADMININC') || !$thisstaff->isAdmin()) die('Access Denied'); $targets = Filter::getTargets(); $qs = array(); -$sql='SELECT filter.*,count(rule.id) as rules '. +$sql='SELECT filter.*,count(rule.id) as rules, topic.configuration AS topic, dept.configuration AS dept '. 'FROM '.FILTER_TABLE.' filter '. 'LEFT JOIN '.FILTER_RULE_TABLE.' rule ON(rule.filter_id=filter.id) '. + 'LEFT JOIN '.FILTER_ACTION_TABLE.' topic ON (topic.filter_id = filter.id AND topic.type = \'topic\') '. + 'LEFT JOIN '.FILTER_ACTION_TABLE.' dept ON (dept.filter_id = filter.id AND dept.type = \'dept\') '. "WHERE filter.`name` <> 'SYSTEM BAN LIST' ". 'GROUP BY filter.id'; $sortOptions=array('name'=>'filter.name','status'=>'filter.isactive','order'=>'filter.execorder','rules'=>'rules', @@ -104,6 +106,26 @@ else $ids=($errors && is_array($_POST['ids']))?$_POST['ids']:null; if($res && db_num_rows($res)): while ($row = db_fetch_array($res)) { + if ($row['topic']) { + $filter = Filter::lookup($row['id']); + if ($filter->ht['flags'] & !Filter::FLAG_INACTIVE_HT) { + $filter->setFlag(Filter::FLAG_INACTIVE_HT, true); + $vars = $filter->ht; + $vars['rules']= $filter->getRules(); + $filter->update($filter->ht, $errors); + } + } + + if ($row['dept']) { + $filter = Filter::lookup($row['id']); + if ($filter->ht['flags'] & !Filter::FLAG_INACTIVE_DEPT) { + $filter->setFlag(Filter::FLAG_INACTIVE_DEPT, true); + $vars = $filter->ht; + $vars['rules']= $filter->getRules(); + $filter->update($filter->ht, $errors); + } + } + $sel=false; if($ids && in_array($row['id'],$ids)) $sel=true; @@ -113,7 +135,17 @@ else <input type="checkbox" class="ckb" name="ids[]" value="<?php echo $row['id']; ?>" <?php echo $sel?'checked="checked"':''; ?>> </td> - <td> <a href="filters.php?id=<?php echo $row['id']; ?>"><?php echo Format::htmlchars($row['name']); ?></a></td> + <td> <a href="filters.php?id=<?php echo $row['id']; ?>"><?php echo Format::htmlchars($row['name']); ?></a> + <?php + if ($row['flags'] & Filter::FLAG_INACTIVE_DEPT) + echo '<a data-placement="bottom" data-toggle="tooltip" title="Inactive Department Selected" + <i class="pull-right icon-warning-sign"></a>'; + + if ($row['flags'] & Filter::FLAG_INACTIVE_HT) + echo '<a data-placement="bottom" data-toggle="tooltip" title="Inactive Help Topic Selected" + <i class="pull-right icon-warning-sign"></a>'; + ?> + </td> <td><?php echo $row['isactive']?__('Active'):'<b>'.__('Disabled').'</b>'; ?></td> <td style="text-align:right;padding-right:25px;"><?php echo $row['execorder']; ?> </td> <td style="text-align:right;padding-right:25px;"><?php echo $row['rules']; ?> </td>