5.3.0-git
2014-09-20

[#8991] Check for active rules
Summary Check for active rules
Queue Ingo
Queue Version 1.2.3
Type Enhancement
State Assigned
Priority 1. Low
Owners jan (at) horde (dot) org
Requester rene.plattner (at) uibk (dot) ac (dot) at
Created 2010-04-28 (1606 days ago)
Due
Updated 2010-06-15 (1558 days ago)
Assigned 2010-06-15 (1558 days ago)
Resolved
Milestone
Patch Yes

History
2010-06-15 15:28:12 Jan Schneider Patch ⇒ Yes
State ⇒ Assigned
Assigned to Jan Schneider
 
2010-04-28 15:08:08 rene (dot) plattner (at) uibk (dot) ac (dot) at Comment #3 Reply to this comment
At our installation by default all ingo rules are disabled.
So we are interrested in to disable the local user procmail script, if 
no user rule is aktive.
If no local procmail script is active then the global procmail script is used.
This is easier for us for debugging.
2010-04-28 13:33:09 Jan Schneider Comment #2
State ⇒ Feedback
Reply to this comment
What's the rationale for that?
2010-04-28 09:38:23 rene (dot) plattner (at) uibk (dot) ac (dot) at Comment #1
State ⇒ New
Patch ⇒ No
Milestone ⇒
Queue ⇒ Ingo
Summary ⇒ Check for active rules
Type ⇒ Enhancement
Priority ⇒ 1. Low
Reply to this comment
We added some code to check if any rules are active:

--- ingo-h3-1.2.3/lib/Storage.php       2009-07-24 10:57:03.000000000 +0200
+++ /var/www/html/horde/ingo/lib/Storage.php    2010-03-09 
11:30:49.000000000 +0100
@@ -896,6 +896,21 @@
      }

      /**
+     * Checks, if all rules are disabled.
+     *
+     * @return boolean  True on success.
+     */
+    function allRulesDisabled()
+    {
+        foreach ($this->_filters as $id => $rule) {
+            if ($rule['disable'] == false) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
       * Searches for the first rule of a certain action type and returns its
       * number.
       *

If all rules are disabled then we remove the script on the backend:

--- ingo-h3-1.2.3/lib/Ingo.php  2008-12-15 03:33:08.000000000 +0100
+++ /var/www/html/horde/ingo/lib/Ingo.php       2010-03-09 
11:34:17.000000000 +0100
@@ -153,6 +153,11 @@
          global $notification;

          $driver = Ingo::getDriver();
+        $filters = 
&$GLOBALS['ingo_storage']->retrieve(INGO_STORAGE_ACTION_FILTERS);
+        if ($filters->allRulesDisabled()) {
+            $script = '';
+            $deactivate = true;
+        }
          $res = $driver->setScriptActive($script);
          if (is_a($res, 'PEAR_Error')) {
              $msg = ($deactivate)

I appreciate your comment.

Kind regards,

René Plattner