Improved notifications on rule actions
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 4 Jun 2009 19:16:43 +0000 (13:16 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 4 Jun 2009 19:16:43 +0000 (13:16 -0600)
ingo/filters.php
ingo/lib/Storage.php

index d9deaca..1f538c7 100644 (file)
@@ -52,8 +52,10 @@ case 'rule_enable':
             header('Location: ' . Horde::applicationUrl('filters.php', true));
             exit;
         }
+
+        $tmp = $filters->getFilter($id);
         if ($filters->deleteRule($id)) {
-            $notification->push(_("Rule Deleted"), 'horde.success');
+            $notification->push(sprintf(_("Rule \"%s\" deleted."), $tmp['name']), 'horde.success');
         }
         break;
 
@@ -73,8 +75,11 @@ case 'rule_enable':
             }
             $notification->push($message, 'horde.error', array('content.raw'));
             break 2;
-        } elseif ($filters->copyRule($id)) {
-            $notification->push(_("Rule Copied"), 'horde.success');
+        } else {
+            $tmp = $filters->getFilter($id);
+            if ($filters->copyRule($id)) {
+                $notification->push(sprintf(_("Rule \"%s\" copied."), $tmp['name']), 'horde.success');
+            }
         }
         break;
 
@@ -89,13 +94,15 @@ case 'rule_enable':
         break;
 
     case 'rule_disable':
+        $tmp = $filters->getFilter($id);
         $filters->ruleDisable($id);
-        $notification->push(_("Rule Disabled"), 'horde.success');
+        $notification->push(sprintf(_("Rule \"%s\" disabled."), $tmp['name']), 'horde.success');
         break;
 
     case 'rule_enable':
+        $tmp = $filters->getFilter($id);
         $filters->ruleEnable($id);
-        $notification->push(_("Rule Enabled"), 'horde.success');
+        $notification->push(sprintf(_("Rule \"%s\" enabled."), $tmp['name']), 'horde.success');
         break;
     }
 
index bb2f119..fd08681 100644 (file)
@@ -822,6 +822,18 @@ class Ingo_Storage_filters
     }
 
     /**
+     * Return the filter entry for a given ID.
+     *
+     * @return mixed  The rule hash entry, or false if not defined.
+     */
+    public function getFilter($id)
+    {
+        return isset($this->_filters[$id])
+            ? $this->_filters[$id]
+            : false;
+    }
+
+    /**
      * Returns a single rule hash.
      *
      * @param integer $id  A rule number.