From 36e351888b401d970b204a6b484f1ee854b20d58 Mon Sep 17 00:00:00 2001 From: Jared Hancock <gravydish@gmail.com> Date: Sat, 21 Jul 2012 16:24:09 -0500 Subject: [PATCH] Reuse list of filters which specify a canned response --- include/class.canned.php | 14 ++++++++++++++ include/staff/cannedreply.inc.php | 9 ++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/include/class.canned.php b/include/class.canned.php index e479c1873..202f9eeeb 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 f776ef7f5..1dc6766c2 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; ?>"> -- GitLab