Various fixes to make ingo work in Git
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 3 Jun 2009 03:10:20 +0000 (21:10 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 3 Jun 2009 03:21:27 +0000 (21:21 -0600)
13 files changed:
ingo/config/prefs.php.dist
ingo/forward.php
ingo/index.php
ingo/lib/Ingo.php
ingo/lib/Session.php
ingo/lib/Storage.php
ingo/lib/tests/ProcmailTest.php
ingo/lib/tests/SieveTest.php
ingo/spam.php
ingo/templates/rule/filter.inc
ingo/templates/rule/footer.inc
ingo/templates/rule/header.inc
ingo/vacation.php

index dc38856..d0264bb 100644 (file)
@@ -57,6 +57,7 @@ $_prefs['filter_seen'] = array(
 // the below entries.
 
 // Filter rules.
+require_once dirname(__FILE__) . '/../lib/Storage.php';
 $_prefs['rules'] = array(
     'value' => 'a:5:{i:0;a:2:{s:4:"name";s:9:"Whitelist";s:6:"action";i:' . Ingo_Storage::ACTION_WHITELIST . ';}i:1;a:3:{s:4:"name";s:8:"Vacation";s:6:"action";i:' . Ingo_Storage::ACTION_VACATION . ';s:7:"disable";b:1;}i:2;a:2:{s:4:"name";s:9:"Blacklist";s:6:"action";i:' . Ingo_Storage::ACTION_BLACKLIST . ';}i:3;a:3:{s:4:"name";s:11:"Spam Filter";s:6:"action";i:' . Ingo_Storage::ACTION_SPAM . ';s:7:"disable";b:1;}i:4;a:2:{s:4:"name";s:7:"Forward";s:6:"action";i:' . Ingo_Storage::ACTION_FORWARD . ';}}',
     'locked' => false,
index 029f458..80c0ed5 100644 (file)
@@ -11,6 +11,8 @@
  */
 
 require_once dirname(__FILE__) . '/lib/base.php';
+require_once 'Horde/Help.php';
+require_once 'Horde/Variables.php';
 
 /* Redirect if forward is not available. */
 if (!in_array(Ingo_Storage::ACTION_FORWARD, $_SESSION['ingo']['script_categories'])) {
@@ -26,7 +28,6 @@ $fwd_id = $filters->findRuleId(Ingo_Storage::ACTION_FORWARD);
 $fwd_rule = $filters->getRule($fwd_id);
 
 /* Load libraries. */
-require_once 'Horde/Variables.php';
 $vars = &Variables::getDefaultVariables();
 if ($vars->get('submitbutton') == _("Return to Rules List")) {
     header('Location: ' . Horde::applicationUrl('filters.php', true));
index bf9c3e0..40f9ee3 100644 (file)
@@ -17,7 +17,18 @@ $ingo_configured = (is_readable(INGO_BASE . '/config/conf.php') &&
                     is_readable(INGO_BASE . '/config/fields.php'));
 
 if (!$ingo_configured) {
-    require INGO_BASE . '/../lib/Test.php';
+    if (!defined('HORDE_BASE')) {
+        /* Temporary fix - if horde does not live directly under the imp
+         * directory, the HORDE_BASE constant should be defined in
+         * imp/lib/base.local.php. */
+        if (file_exists(INGO_BASE . '/lib/base.local.php')) {
+            include INGO_BASE . '/lib/base.local.php';
+        } else {
+            define('HORDE_BASE', INGO_BASE . '/..');
+        }
+    }
+
+    require HORDE_BASE . '/lib/Test.php';
     Horde_Test::configFilesMissing('Ingo', INGO_BASE,
         array('conf.php', 'prefs.php', 'backends.php'),
         array('fields.php' => 'This file defines types of credentials that a backend might request.'));
index 181f6d9..2e94c9a 100644 (file)
@@ -375,10 +375,10 @@ class Ingo
      *
      * @return boolean  True if the address is not empty.
      */
-    static protected function _filterEmptyAddress($address)
+    static public function filterEmptyAddress($address)
     {
         $address = trim($address);
-        return !empty($address) && $address != '@';
+        return !empty($address) && ($address != '@');
     }
 
     /**
@@ -396,13 +396,13 @@ class Ingo
         if (!is_a($blacklist_url = $GLOBALS['registry']->link('mail/showBlacklist'), 'PEAR_Error')) {
             $menu->add(Horde::url($blacklist_url), _("_Blacklist"), 'blacklist.png');
         }
-        if (in_array(INGO_STORAGE_ACTION_VACATION, $_SESSION['ingo']['script_categories'])) {
+        if (in_array(Ingo_Storage::ACTION_VACATION, $_SESSION['ingo']['script_categories'])) {
             $menu->add(Horde::applicationUrl('vacation.php'), _("_Vacation"), 'vacation.png');
         }
-        if (in_array(INGO_STORAGE_ACTION_FORWARD, $_SESSION['ingo']['script_categories'])) {
+        if (in_array(Ingo_Storage::ACTION_FORWARD, $_SESSION['ingo']['script_categories'])) {
             $menu->add(Horde::applicationUrl('forward.php'), _("_Forward"), 'forward.png');
         }
-        if (in_array(INGO_STORAGE_ACTION_SPAM, $_SESSION['ingo']['script_categories'])) {
+        if (in_array(Ingo_Storage::ACTION_SPAM, $_SESSION['ingo']['script_categories'])) {
             $menu->add(Horde::applicationUrl('spam.php'), _("S_pam"), 'spam.png');
         }
         if ($_SESSION['ingo']['script_generate'] &&
index e80b6aa..dd15471 100644 (file)
@@ -46,19 +46,19 @@ class Ingo_Session
         /* Disable categories as specified in preferences */
         $disabled = array();
         if ($prefs->isLocked('blacklist')) {
-            $disabled[] = INGO_STORAGE_ACTION_BLACKLIST;
+            $disabled[] = Ingo_Storage::ACTION_BLACKLIST;
         }
         if ($prefs->isLocked('whitelist')) {
-            $disabled[] = INGO_STORAGE_ACTION_WHITELIST;
+            $disabled[] = Ingo_Storage::ACTION_WHITELIST;
         }
         if ($prefs->isLocked('vacation')) {
-            $disabled[] = INGO_STORAGE_ACTION_VACATION;
+            $disabled[] = Ingo_Storage::ACTION_VACATION;
         }
         if ($prefs->isLocked('forward')) {
-            $disabled[] = INGO_STORAGE_ACTION_FORWARD;
+            $disabled[] = Ingo_Storage::ACTION_FORWARD;
         }
         if ($prefs->isLocked('spam')) {
-            $disabled[] = INGO_STORAGE_ACTION_SPAM;
+            $disabled[] = Ingo_Storage::ACTION_SPAM;
         }
 
         /* Set the list of categories this driver supports. */
index b9e7bf0..01e8ce2 100644 (file)
@@ -98,7 +98,7 @@ class Ingo_Storage
     /**
      * Destructor.
      */
-    protected function __destruct()
+    public function __destruct()
     {
         $cache = &Horde_SessionObjects::singleton();
 
@@ -118,7 +118,7 @@ class Ingo_Storage
      * Retrieves the specified data.
      *
      * @param integer $field     The field name of the desired data
-     *                           (INGO_STORAGE_ACTION_* constants).
+     *                           (ACTION_* constants).
      * @param boolean $cache     Use the cached object?
      * @param boolean $readonly  Whether to disable any write operations.
      *
@@ -233,7 +233,7 @@ class Ingo_Storage
     /**
      * Returns information on a given action constant.
      *
-     * @param integer $action  The INGO_STORAGE_ACTION_* value.
+     * @param integer $action  The ACTION_* value.
      *
      * @return stdClass  Object with the following values:
      * <pre>
@@ -489,7 +489,9 @@ class Ingo_Storage_blacklist extends Ingo_Storage_rule
 
     public function getBlacklist()
     {
-        return array_filter($this->_addr, array('Ingo', '_filterEmptyAddress'));
+        return empty($this->_addr)
+            ? array()
+            : array_filter($this->_addr, array('Ingo', 'filterEmptyAddress'));
     }
 
     public function getBlacklistFolder()
@@ -522,7 +524,7 @@ class Ingo_Storage_whitelist extends Ingo_Storage_rule
     public function setWhitelist($data, $sort = true)
     {
         $addr = &$this->_addressList($data, $sort);
-        $addr = array_filter($addr, array('Ingo', '_filterEmptyAddress'));
+        $addr = array_filter($addr, array('Ingo', 'filterEmptyAddress'));
         if (!empty($GLOBALS['conf']['storage']['maxwhitelist'])) {
             $addr_count = count($addr);
             if ($addr_count > $GLOBALS['conf']['storage']['maxwhitelist']) {
@@ -536,7 +538,9 @@ class Ingo_Storage_whitelist extends Ingo_Storage_rule
 
     public function getWhitelist()
     {
-        return array_filter($this->_addr, array('Ingo', '_filterEmptyAddress'));
+        return empty($this->_addr)
+            ? array()
+            : array_filter($this->_addr, array('Ingo', 'filterEmptyAddress'));
     }
 
 }
@@ -838,9 +842,9 @@ class Ingo_Storage_filters
     {
         return array(
             'name' => _("New Rule"),
-            'combine' => INGO_STORAGE_COMBINE_ALL,
+            'combine' => self::COMBINE_ALL,
             'conditions' => array(),
-            'action' => INGO_STORAGE_ACTION_KEEP,
+            'action' => self::ACTION_KEEP,
             'action-value' => '',
             'stop' => true,
             'flags' => 0,
@@ -853,7 +857,7 @@ class Ingo_Storage_filters
      * number.
      *
      * @param integer $action  The field type of the searched rule
-     *                         (INGO_STORAGE_ACTION_* constants).
+     *                         (ACTION_* constants).
      *
      * @return integer  The number of the first matching rule or null.
      */
@@ -870,7 +874,7 @@ class Ingo_Storage_filters
      * Searches for and returns the first rule of a certain action type.
      *
      * @param integer $action  The field type of the searched rule
-     *                         (INGO_STORAGE_ACTION_* constants).
+     *                         (ACTION_* constants).
      *
      * @return array  The first matching rule hash or null.
      */
index 2915b0f..e62d988 100644 (file)
@@ -161,7 +161,7 @@ $DEFAULT');
         $vacation->setVacationReason("Because I don't like working!");
 
         $this->store($vacation);
-        $this->_enableRule(INGO_STORAGE_ACTION_VACATION);
+        $this->_enableRule(Ingo_Storage::ACTION_VACATION);
 
         $this->assertScript(':0
 {
index 3e27015..6abf7b1 100644 (file)
@@ -102,7 +102,7 @@ stop;
         $vacation->setVacationReason("Because I don't like working!");
 
         $this->store($vacation);
-        $this->_enableRule(INGO_STORAGE_ACTION_VACATION);
+        $this->_enableRule(Ingo_Storage::ACTION_VACATION);
 
         $this->assertScript('require "vacation";
 if allof ( not exists ["list-help", "list-unsubscribe", "list-subscribe", "list-owner", "list-post", "list-archive", "list-id"], not header :comparator "i;ascii-casemap" :is "Precedence" "list,bulk" ) {
@@ -127,7 +127,7 @@ vacation :days 7 :addresses "from@example.com" :subject "Subject" "Because I don
         $spam->setSpamFolder("Junk");
 
         $this->store($spam);
-        $this->_enableRule(INGO_STORAGE_ACTION_SPAM);
+        $this->_enableRule(Ingo_Storage::ACTION_SPAM);
         $this->assertScript('require "fileinto";
 if header :comparator "i;ascii-casemap" :contains "X-Spam-Level" "*******"  {
 fileinto "Junk";
index 2bfda06..2a91c9f 100644 (file)
@@ -51,9 +51,9 @@ if (!in_array(Ingo_Storage::ACTION_SPAM, $_SESSION['ingo']['script_categories'])
 require_once 'Horde/Variables.php';
 
 /* Get the spam object and rule. */
-$spam = &$ingo_storage->retrieve(INGO_STORAGE_ACTION_SPAM);
-$filters = &$ingo_storage->retrieve(INGO_STORAGE_ACTION_FILTERS);
-$spam_id = $filters->findRuleId(INGO_STORAGE_ACTION_SPAM);
+$spam = &$ingo_storage->retrieve(Ingo_Storage::ACTION_SPAM);
+$filters = &$ingo_storage->retrieve(Ingo_Storage::ACTION_FILTERS);
+$spam_id = $filters->findRuleId(Ingo_Storage::ACTION_SPAM);
 $spam_rule = $filters->getRule($spam_id);
 
 $vars = &Variables::getDefaultVariables();
index 86a71b1..804d962 100644 (file)
@@ -1,7 +1,7 @@
  <tr style="vertical-align:top">
 <?php if ($cond_num > 0): ?>
   <td>
-   <strong><?php echo ($rule['combine'] == INGO_STORAGE_COMBINE_ALL) ? _("and") : _("or") ?></strong>
+   <strong><?php echo ($rule['combine'] == Ingo_Storage::COMBINE_ALL) ? _("and") : _("or") ?></strong>
   </td>
 <?php elseif (($cond_num == 0) && !$lastfield): ?>
   <td>&nbsp;</td>
index c225322..e183f3a 100644 (file)
       <table cellspacing="0">
         <tr>
           <td>
-            <input type="checkbox" id="seen" name="flags[]" value="<?php echo INGO_STORAGE_FLAG_SEEN ?>"<?php echo (INGO_STORAGE_FLAG_SEEN & $rule['flags']) ? ' checked="checked" ' : '' ?>/><?php echo Horde::label('seen', _("Seen")) ?>&nbsp;
+            <input type="checkbox" id="seen" name="flags[]" value="<?php echo Ingo_Storage::FLAG_SEEN ?>"<?php echo (Ingo_Storage::FLAG_SEEN & $rule['flags']) ? ' checked="checked" ' : '' ?>/><?php echo Horde::label('seen', _("Seen")) ?>&nbsp;
           </td><td>
-            <input type="checkbox" id="flagged" name="flags[]" value="<?php echo INGO_STORAGE_FLAG_FLAGGED ?>"<?php echo (INGO_STORAGE_FLAG_FLAGGED & $rule['flags']) ? ' checked="checked" ' : '' ?>/><?php echo Horde::label('flagged', _("Flagged For Followup")) ?>&nbsp;
+            <input type="checkbox" id="flagged" name="flags[]" value="<?php echo Ingo_Storage::FLAG_FLAGGED ?>"<?php echo (Ingo_Storage::FLAG_FLAGGED & $rule['flags']) ? ' checked="checked" ' : '' ?>/><?php echo Horde::label('flagged', _("Flagged For Followup")) ?>&nbsp;
           </td><td>
-            <input type="checkbox" id="answered" name="flags[]" value="<?php echo INGO_STORAGE_FLAG_ANSWERED ?>"<?php echo (INGO_STORAGE_FLAG_ANSWERED & $rule['flags']) ? ' checked="checked" ' : '' ?>/><?php echo Horde::label('answered', _("Answered")) ?>&nbsp;
+            <input type="checkbox" id="answered" name="flags[]" value="<?php echo Ingo_Storage::FLAG_ANSWERED ?>"<?php echo (Ingo_Storage::FLAG_ANSWERED & $rule['flags']) ? ' checked="checked" ' : '' ?>/><?php echo Horde::label('answered', _("Answered")) ?>&nbsp;
           </td><td>
-            <input type="checkbox" id="deleted" name="flags[]" value="<?php echo INGO_STORAGE_FLAG_DELETED ?>"<?php echo (INGO_STORAGE_FLAG_DELETED & $rule['flags']) ? ' checked="checked" ' : '' ?>/><?php echo Horde::label('deleted', _("Deleted")) ?>&nbsp;
+            <input type="checkbox" id="deleted" name="flags[]" value="<?php echo Ingo_Storage::FLAG_DELETED ?>"<?php echo (Ingo_Storage::FLAG_DELETED & $rule['flags']) ? ' checked="checked" ' : '' ?>/><?php echo Horde::label('deleted', _("Deleted")) ?>&nbsp;
           </td>
         </tr>
       </table>
index 2b570fc..97a003d 100644 (file)
@@ -41,8 +41,8 @@ function delete_condition(num)
     <td>
       <em><?php echo _("For an incoming message that matches:") ?></em>
       <br />
-      <input id="all" onclick="document.rule.submit(); return true;" type="radio" name="combine" value="<?php echo INGO_STORAGE_COMBINE_ALL ?>"<?php echo ($rule['combine'] == INGO_STORAGE_COMBINE_ALL) ? ' checked="checked"' : '' ?> /><?php echo Horde::label('all', _("All of the following")) ?>&nbsp;
-      <input id="any" onclick="document.rule.submit(); return true;" type="radio" name="combine" value="<?php echo INGO_STORAGE_COMBINE_ANY ?>"<?php echo ($rule['combine'] == INGO_STORAGE_COMBINE_ANY) ? ' checked="checked"' : '' ?> /><?php echo Horde::label('any', _("Any of the following")) ?>
+      <input id="all" onclick="document.rule.submit(); return true;" type="radio" name="combine" value="<?php echo Ingo_Storage::COMBINE_ALL ?>"<?php echo ($rule['combine'] == Ingo_Storage::COMBINE_ALL) ? ' checked="checked"' : '' ?> /><?php echo Horde::label('all', _("All of the following")) ?>&nbsp;
+      <input id="any" onclick="document.rule.submit(); return true;" type="radio" name="combine" value="<?php echo Ingo_Storage::COMBINE_ANY ?>"<?php echo ($rule['combine'] == Ingo_Storage::COMBINE_ANY) ? ' checked="checked"' : '' ?> /><?php echo Horde::label('any', _("Any of the following")) ?>
     </td>
     <td width="40" class="rightAlign">
       <?php echo Help::link('ingo', 'rule-combine') ?>&nbsp;
index c177e27..9c76851 100644 (file)
@@ -11,6 +11,8 @@
  */
 
 require_once dirname(__FILE__) . '/lib/base.php';
+require_once 'Horde/Help.php';
+require_once 'Horde/Variables.php';
 
 /* Redirect if vacation is not available. */
 if (!in_array(Ingo_Storage::ACTION_VACATION, $_SESSION['ingo']['script_categories'])) {
@@ -26,7 +28,6 @@ $vac_id = $filters->findRuleId(Ingo_Storage::ACTION_VACATION);
 $vac_rule = $filters->getRule($vac_id);
 
 /* Load libraries. */
-require_once 'Horde/Variables.php';
 $vars = Variables::getDefaultVariables();
 if ($vars->get('submitbutton') == _("Return to Rules List")) {
     header('Location: ' . Horde::applicationUrl('filters.php', true));