diff --git a/include/class.canned.php b/include/class.canned.php index e479c1873cf19165dbfc16b48e6b5d9760546b33..202f9eeebe447213d9c9cb5e9f3f2929a905cc03 100644 --- a/include/class.canned.php +++ b/include/class.canned.php @@ -96,6 +96,20 @@ class Canned { return $this->getHashtable(); } + function getFilters() { + if (!$this->_filters) { + $this->_filters = array(); + $res = db_query( + 'SELECT DISTINCT name' + .' FROM '.EMAIL_FILTER_TABLE + .' WHERE canned_response_id = '.db_input($this->getId()) + .' ORDER BY name'); + while ($row = db_fetch_row($res)) + $this->_filters[] = $row[0]; + } + return $this->_filters; + } + function update($vars, &$errors) { if(!$this->save($this->getId(),$vars,$errors)) diff --git a/include/staff/cannedreply.inc.php b/include/staff/cannedreply.inc.php index f776ef7f588a80b59dd8665a7f185cc7f6da240f..1dc6766c2b48bebe341f6272e3c6c27a08db3a9a 100644 --- a/include/staff/cannedreply.inc.php +++ b/include/staff/cannedreply.inc.php @@ -9,11 +9,6 @@ if($canned && $_REQUEST['a']!='add'){ $info=$canned->getInfo(); $info['id']=$canned->getId(); $qstr.='&id='.$canned->getId(); - $res = db_query( - 'SELECT GROUP_CONCAT(DISTINCT name ORDER BY name SEPARATOR ", ")' - .' FROM '.EMAIL_FILTER_TABLE - .' WHERE canned_response_id = '.db_input($canned->getId())); - $info['filter'] = ($res && ($row = db_fetch_row($res))) ? $row[0] : null; }else { $title='Add New Canned Reply'; $action='create'; @@ -112,10 +107,10 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); </tr> </tbody> </table> - <?php if ($info['filter']) { ?> + <?php if ($canned->getFilters()) { ?> <br/> <div id="msg_warning">Canned reply is in use by email filter(s): <?php - echo $info['filter']; ?></div> + echo implode(', ', $canned->getFilters()); ?></div> <?php } ?> <p style="padding-left:225px;"> <input type="submit" name="submit" value="<?php echo $submit_text; ?>">