From 5064e6fefd820728abde4a7a065e8a8d18d65919 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 2 Jun 2009 21:10:20 -0600 Subject: [PATCH] Various fixes to make ingo work in Git --- ingo/config/prefs.php.dist | 1 + ingo/forward.php | 3 ++- ingo/index.php | 13 ++++++++++++- ingo/lib/Ingo.php | 10 +++++----- ingo/lib/Session.php | 10 +++++----- ingo/lib/Storage.php | 24 ++++++++++++++---------- ingo/lib/tests/ProcmailTest.php | 2 +- ingo/lib/tests/SieveTest.php | 4 ++-- ingo/spam.php | 6 +++--- ingo/templates/rule/filter.inc | 2 +- ingo/templates/rule/footer.inc | 8 ++++---- ingo/templates/rule/header.inc | 4 ++-- ingo/vacation.php | 3 ++- 13 files changed, 54 insertions(+), 36 deletions(-) diff --git a/ingo/config/prefs.php.dist b/ingo/config/prefs.php.dist index dc388562e..d0264bb6c 100644 --- a/ingo/config/prefs.php.dist +++ b/ingo/config/prefs.php.dist @@ -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, diff --git a/ingo/forward.php b/ingo/forward.php index 029f458c5..80c0ed59e 100644 --- a/ingo/forward.php +++ b/ingo/forward.php @@ -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)); diff --git a/ingo/index.php b/ingo/index.php index bf9c3e0f6..40f9ee388 100644 --- a/ingo/index.php +++ b/ingo/index.php @@ -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.')); diff --git a/ingo/lib/Ingo.php b/ingo/lib/Ingo.php index 181f6d910..2e94c9a86 100644 --- a/ingo/lib/Ingo.php +++ b/ingo/lib/Ingo.php @@ -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'] && diff --git a/ingo/lib/Session.php b/ingo/lib/Session.php index e80b6aa0d..dd15471d5 100644 --- a/ingo/lib/Session.php +++ b/ingo/lib/Session.php @@ -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. */ diff --git a/ingo/lib/Storage.php b/ingo/lib/Storage.php index b9e7bf077..01e8ce2d5 100644 --- a/ingo/lib/Storage.php +++ b/ingo/lib/Storage.php @@ -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: *
@@ -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.
      */
diff --git a/ingo/lib/tests/ProcmailTest.php b/ingo/lib/tests/ProcmailTest.php
index 2915b0f89..e62d9886c 100644
--- a/ingo/lib/tests/ProcmailTest.php
+++ b/ingo/lib/tests/ProcmailTest.php
@@ -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
 {
diff --git a/ingo/lib/tests/SieveTest.php b/ingo/lib/tests/SieveTest.php
index 3e2701535..6abf7b1bb 100644
--- a/ingo/lib/tests/SieveTest.php
+++ b/ingo/lib/tests/SieveTest.php
@@ -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";
diff --git a/ingo/spam.php b/ingo/spam.php
index 2bfda0618..2a91c9f50 100644
--- a/ingo/spam.php
+++ b/ingo/spam.php
@@ -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();
diff --git a/ingo/templates/rule/filter.inc b/ingo/templates/rule/filter.inc
index 86a71b168..804d96238 100644
--- a/ingo/templates/rule/filter.inc
+++ b/ingo/templates/rule/filter.inc
@@ -1,7 +1,7 @@
  
  0): ?>
   
-   
+   
   
 
    
diff --git a/ingo/templates/rule/footer.inc b/ingo/templates/rule/footer.inc
index c22532206..e183f3a0b 100644
--- a/ingo/templates/rule/footer.inc
+++ b/ingo/templates/rule/footer.inc
@@ -27,13 +27,13 @@
       
- />  + />  - />  + />  - />  + />  - />  + /> 
diff --git a/ingo/templates/rule/header.inc b/ingo/templates/rule/header.inc index 2b570fcca..97a003d06 100644 --- a/ingo/templates/rule/header.inc +++ b/ingo/templates/rule/header.inc @@ -41,8 +41,8 @@ function delete_condition(num)
- />  - /> + />  + />   diff --git a/ingo/vacation.php b/ingo/vacation.php index c177e27c4..9c76851c2 100644 --- a/ingo/vacation.php +++ b/ingo/vacation.php @@ -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)); -- 2.11.0