5.2.0-git
04/18/2014

[#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 04/28/2010 (1451 days ago)
Due
Updated 06/15/2010 (1403 days ago)
Assigned 06/15/2010 (1403 days ago)
Resolved
Milestone
Patch Yes

History
06/15/2010 03:28:12 PM Jan Schneider Patch ⇒ Yes
State ⇒ Assigned
Assigned to Jan Schneider
 
04/28/2010 03:08:08 PM 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.
04/28/2010 01:33:09 PM Jan Schneider Comment #2
State ⇒ Feedback
Reply to this comment
What's the rationale for that?
04/28/2010 09:38:23 AM 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