Ingo: Convert to new Horde_Session API
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 9 Nov 2010 05:03:06 +0000 (22:03 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 9 Nov 2010 05:21:59 +0000 (22:21 -0700)
21 files changed:
ingo/blacklist.php
ingo/filters.php
ingo/forward.php
ingo/lib/Api.php
ingo/lib/Application.php
ingo/lib/Block/overview.php
ingo/lib/Ingo.php
ingo/lib/Script/Imap.php
ingo/lib/Script/Imap/Live.php
ingo/lib/Storage.php
ingo/lib/Storage/Filters.php
ingo/lib/Transport.php
ingo/lib/Transport/Vfs.php
ingo/lib/tests/ScriptTest.php
ingo/rule.php
ingo/script.php
ingo/scripts/ingo-postfix-policyd
ingo/scripts/upgrades/convert_prefs_to_sql.php
ingo/spam.php
ingo/vacation.php
ingo/whitelist.php

index d83835e..b368329 100644 (file)
@@ -15,7 +15,7 @@ require_once dirname(__FILE__) . '/lib/Application.php';
 Horde_Registry::appInit('ingo');
 
 /* Redirect if blacklist is not available. */
-if (!in_array(Ingo_Storage::ACTION_BLACKLIST, $_SESSION['ingo']['script_categories'])) {
+if (!in_array(Ingo_Storage::ACTION_BLACKLIST, $session->get('ingo', 'script_categories'))) {
     $notification->push(_("Blacklist is not supported in the current filtering driver."), 'horde.error');
     Horde::url('filters.php', true)->redirect();
 }
@@ -78,7 +78,7 @@ case 'rule_update':
         }
 
         /* Update the timestamp for the rules. */
-        $_SESSION['ingo']['change'] = time();
+        $session->set('ingo', 'change', time());
     }
 
     break;
index 2a8305c..b6f318d 100644 (file)
@@ -148,8 +148,14 @@ if (count($filter_list) == 0) {
     require INGO_TEMPLATES . '/filters/filter-none.inc';
 } else {
     $display = array();
-    $i = 0;
-    $rule_count = array_sum(array_map(create_function('$a', "return (in_array(\$a['action'], \$_SESSION['ingo']['script_categories'])) ? 1 : 0;"), $filter_list));
+    $i = $rule_count = 0;
+    $s_categories = $session->get('ingo', 'script_categories');
+
+    foreach ($filter_list as $val) {
+        if (in_array($val['action'], $s_categories)) {
+            ++$rule_count;
+        }
+    }
 
     /* Common graphics. */
     $down_img = Horde::img('nav/down.png', _("Move Rule Down"));
@@ -157,7 +163,7 @@ if (count($filter_list) == 0) {
 
     foreach ($filter_list as $rule_number => $filter) {
         /* Skip non-display categories. */
-        if (!in_array($filter['action'], $_SESSION['ingo']['script_categories'])) {
+        if (!in_array($filter['action'], $s_categories)) {
             continue;
         }
 
index ed98814..1794679 100644 (file)
@@ -14,7 +14,7 @@ require_once dirname(__FILE__) . '/lib/Application.php';
 Horde_Registry::appInit('ingo');
 
 /* Redirect if forward is not available. */
-if (!in_array(Ingo_Storage::ACTION_FORWARD, $_SESSION['ingo']['script_categories'])) {
+if (!in_array(Ingo_Storage::ACTION_FORWARD, $session->get('ingo', 'script_categories'))) {
     $notification->push(_("Forward is not supported in the current filtering driver."), 'horde.error');
     Horde::url('filters.php', true)->redirect();
 }
index c47bf0b..3f3d7b5 100644 (file)
@@ -169,7 +169,7 @@ class Ingo_Api extends Horde_Registry_Api
             }
 
             /* Update the timestamp for the rules. */
-            $_SESSION['ingo']['change'] = time();
+            $GLOBALS['session']->set('ingo', 'change', time());
 
             return true;
         } catch (Ingo_Exception $e) {}
@@ -198,7 +198,7 @@ class Ingo_Api extends Horde_Registry_Api
             }
 
             /* Update the timestamp for the rules. */
-            $_SESSION['ingo']['change'] = time();
+            $GLOBALS['session']->set('ingo', 'change', time());
 
             return true;
         } catch (Ingo_Exception $e) {}
index cc670f2..1e7f001 100644 (file)
@@ -68,7 +68,7 @@ class Ingo_Application extends Horde_Registry_Application
             $GLOBALS['all_rulesets'] = Ingo::listRulesets();
 
             /* If personal share doesn't exist then create it. */
-            $signature = $_SESSION['ingo']['backend']['id'] . ':' . $GLOBALS['registry']->getAuth();
+            $signature = $GLOBALS['session']->get('ingo', 'backend/id') . ':' . $GLOBALS['registry']->getAuth();
             if (!$GLOBALS['ingo_shares']->exists($signature)) {
                 $identity = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create();
                 $name = $identity->getValue('fullname');
@@ -82,11 +82,11 @@ class Ingo_Application extends Horde_Registry_Application
             }
 
             /* Select current share. */
-            $_SESSION['ingo']['current_share'] = Horde_Util::getFormData('ruleset', @$_SESSION['ingo']['current_share']);
-            if (empty($_SESSION['ingo']['current_share']) ||
-                empty($GLOBALS['all_rulesets'][$_SESSION['ingo']['current_share']]) ||
-                !$GLOBALS['all_rulesets'][$_SESSION['ingo']['current_share']]->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
-                $_SESSION['ingo']['current_share'] = $signature;
+            $GLOBALS['session']->set('ingo', 'current_share', Horde_Util::getFormData('ruleset', $GLOBALS['session']->get('ingo', 'current_share')));
+            if (!$GLOBALS['session']->get('ingo', 'current_share') ||
+                empty($GLOBALS['all_rulesets'][$GLOBALS['session']->get('ingo', 'current_share')]) ||
+                !$GLOBALS['all_rulesets'][$GLOBALS['session']->get('ingo', 'current_share')]->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
+                $GLOBALS['session']->set('ingo', 'current_share', $signature);
             }
         } else {
             $GLOBALS['ingo_shares'] = null;
@@ -127,26 +127,28 @@ class Ingo_Application extends Horde_Registry_Application
             Horde::logMessage($e->getMessage(), 'ERR');
         }
 
-        if (in_array(Ingo_Storage::ACTION_VACATION, $_SESSION['ingo']['script_categories'])) {
+        $s_categories = $GLOBALS['session']->get('ingo', 'script_categories');
+
+        if (in_array(Ingo_Storage::ACTION_VACATION, $s_categories)) {
             $menu->add(Horde::url('vacation.php'), _("_Vacation"), 'vacation.png');
         }
 
-        if (in_array(Ingo_Storage::ACTION_FORWARD, $_SESSION['ingo']['script_categories'])) {
+        if (in_array(Ingo_Storage::ACTION_FORWARD, $s_categories)) {
             $menu->add(Horde::url('forward.php'), _("_Forward"), 'forward.png');
         }
 
-        if (in_array(Ingo_Storage::ACTION_SPAM, $_SESSION['ingo']['script_categories'])) {
+        if (in_array(Ingo_Storage::ACTION_SPAM, $s_categories)) {
             $menu->add(Horde::url('spam.php'), _("S_pam"), 'spam.png');
         }
 
-        if ($_SESSION['ingo']['script_generate'] &&
+        if ($GLOBALS['session']->get('ingo', 'script_generate') &&
             (!$GLOBALS['prefs']->isLocked('auto_update') ||
              !$GLOBALS['prefs']->getValue('auto_update'))) {
             $menu->add(Horde::url('script.php'), _("_Script"), 'script.png');
         }
 
         if (!empty($GLOBALS['ingo_shares']) && empty($GLOBALS['conf']['share']['no_sharing'])) {
-            $menu->add('#', _("_Permissions"), 'perms.png', Horde_Themes::img(null, 'horde'), '', Horde::popupJs(Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/services/shares/edit.php', true), array('params' => array('app' => 'ingo', 'share' => $_SESSION['ingo']['backend']['id'] . ':' . $GLOBALS['registry']->getAuth()), 'urlencode' => true)) . 'return false;');
+            $menu->add('#', _("_Permissions"), 'perms.png', Horde_Themes::img(null, 'horde'), '', Horde::popupJs(Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/services/shares/edit.php', true), array('params' => array('app' => 'ingo', 'share' => $GLOBALS['session']->get('ingo', 'backend/id') . ':' . $GLOBALS['registry']->getAuth()), 'urlencode' => true)) . 'return false;');
         }
     }
 
@@ -236,8 +238,8 @@ class Ingo_Application extends Horde_Registry_Application
      */
     public function prefsInit($ui)
     {
-        if (!isset($_SESSION['ingo']['script_generate']) ||
-            $_SESSION['ingo']['script_generate']) {
+        if (!$GLOBALS['session']->exists('ingo', 'script_generate') ||
+            $GLOBALS['session']->get('ingo', 'script_generate')) {
             $ui->suppressGroups[] = 'script';
         }
     }
index ae01dc8..69a38a5 100644 (file)
@@ -45,9 +45,11 @@ class Horde_Block_ingo_overview extends Horde_Block
                 $active = _("active");
             }
 
-            switch($filter['name']) {
+            $s_categories = $GLOBALS['session']->get('ingo', 'script_categories');
+
+            switch ($filter['name']) {
             case 'Vacation':
-                if (in_array(Ingo_Storage::ACTION_VACATION, $_SESSION['ingo']['script_categories'])) {
+                if (in_array(Ingo_Storage::ACTION_VACATION, $s_categories)) {
                     $html .= $html_pre .
                         Horde::img('vacation.png', _("Vacation")) .
                         '</td><td>' .
@@ -57,7 +59,7 @@ class Horde_Block_ingo_overview extends Horde_Block
                 break;
 
             case 'Forward':
-                if (in_array(Ingo_Storage::ACTION_FORWARD, $_SESSION['ingo']['script_categories'])) {
+                if (in_array(Ingo_Storage::ACTION_FORWARD, $s_categories)) {
                     $html .= $html_pre .
                         Horde::img('forward.png', _("Forward")) . '</td><td>' .
                         Horde::url('forward.php')->link(array('title' => _("Edit"))) .
@@ -71,7 +73,7 @@ class Horde_Block_ingo_overview extends Horde_Block
                 break;
 
             case 'Whitelist':
-                if (in_array(Ingo_Storage::ACTION_WHITELIST, $_SESSION['ingo']['script_categories'])) {
+                if (in_array(Ingo_Storage::ACTION_WHITELIST, $s_categories)) {
                     $html .= $html_pre .
                         Horde::img('whitelist.png', _("Whitelist")) .
                         '</td><td>' .
@@ -81,7 +83,7 @@ class Horde_Block_ingo_overview extends Horde_Block
                 break;
 
             case 'Blacklist':
-                if (in_array(Ingo_Storage::ACTION_BLACKLIST, $_SESSION['ingo']['script_categories'])) {
+                if (in_array(Ingo_Storage::ACTION_BLACKLIST, $s_categories)) {
                     $html .= $html_pre .
                         Horde::img('blacklist.png', _("Blacklist")) .
                         '</td><td>' .
@@ -91,7 +93,7 @@ class Horde_Block_ingo_overview extends Horde_Block
                 break;
 
             case 'Spam Filter':
-                if (in_array(Ingo_Storage::ACTION_SPAM, $_SESSION['ingo']['script_categories'])) {
+                if (in_array(Ingo_Storage::ACTION_SPAM, $s_categories)) {
                     $html .= $html_pre .
                         Horde::img('spam.png', _("Spam Filter")) .
                         '</td><td>' .
index fdad944..ddf1ffb 100644 (file)
@@ -46,20 +46,23 @@ class Ingo
      */
     static public function createSession()
     {
-        if (isset($_SESSION['ingo'])) {
+        global $prefs, $session;
+
+        $session->remove('ingo');
+        if ($session->exists('ingo', 'change')) {
             return;
         }
 
-        global $prefs;
+        /* getBackend() and loadIngoScript() will both throw Exceptions, so
+         * do these first as errors are fatal. */
+        foreach (self::getBackend() as $key => $val) {
+            $session->set('ingo', 'backend/' . $key, $val);
+        }
 
-        $_SESSION['ingo'] = array(
-            'backend' => Ingo::getBackend(),
-            'change' => 0,
-            'storage' => array()
-        );
+        $ingo_script = self::loadIngoScript();
+        $session->set('ingo', 'script_generate', $ingo_script->generateAvailable());
 
-        $ingo_script = Ingo::loadIngoScript();
-        $_SESSION['ingo']['script_generate'] = $ingo_script->generateAvailable();
+        $session->set('ingo', 'change', 0);
 
         /* Disable categories as specified in preferences */
         $categories = array_merge($ingo_script->availableActions(), $ingo_script->availableCategories());
@@ -80,7 +83,7 @@ class Ingo
         }
 
         /* Set the list of categories this driver supports. */
-        $_SESSION['ingo']['script_categories'] = $categories;
+        $session->set('ingo', 'script_categories', $categories);
     }
 
     /**
@@ -168,11 +171,10 @@ class Ingo
     {
         if (empty($GLOBALS['ingo_shares'])) {
             $baseuser = ($full ||
-                        (isset($_SESSION['ingo']['backend']['hordeauth']) &&
-                         $_SESSION['ingo']['backend']['hordeauth'] === 'full'));
+                        ($GLOBALS['session']->get('ingo', 'backend/hordeauth') === 'full'));
             $user = $GLOBALS['registry']->getAuth($baseuser ? null : 'bare');
         } else {
-            list(, $user) = explode(':', $_SESSION['ingo']['current_share'], 2);
+            list(, $user) = explode(':', $GLOBALS['session']->get('ingo', 'current_share'), 2);
         }
 
         return $user;
@@ -244,7 +246,7 @@ class Ingo
      */
     static public function updateScript()
     {
-        if ($_SESSION['ingo']['script_generate']) {
+        if ($GLOBALS['session']->get('ingo', 'script_generate')) {
             try {
                 $ingo_script = self::loadIngoScript();
 
@@ -272,7 +274,7 @@ class Ingo
     {
         include INGO_BASE . '/config/backends.php';
         if (!isset($backends) || !is_array($backends)) {
-            throw new Horde_Exception(_("No backends configured in backends.php"));
+            throw new Ingo_Exception(_("No backends configured in backends.php"));
         }
 
         $backend = null;
@@ -302,10 +304,10 @@ class Ingo
         $backends[$backend]['id'] = $name;
         $backend = $backends[$backend];
 
-        if (empty($backend['script'])) {
-            throw new Ingo_Exception(sprintf(_("No \"%s\" element found in backend configuration."), 'script'));
-        } elseif (empty($backend['transport'])) {
-            throw new Ingo_Exception(sprintf(_("No \"%s\" element found in backend configuration."), 'transport'));
+        foreach (array('script', 'transport') as $val) {
+            if (empty($backend[$val])) {
+                throw new Ingo_Exception(sprintf(_("No \"%s\" element found in backend configuration."), $val));
+            }
         }
 
         /* Make sure the 'params' entry exists. */
@@ -324,8 +326,10 @@ class Ingo
      */
     static public function loadIngoScript()
     {
-        return Ingo_Script::factory($_SESSION['ingo']['backend']['script'],
-                                    isset($_SESSION['ingo']['backend']['scriptparams']) ? $_SESSION['ingo']['backend']['scriptparams'] : array());
+        return Ingo_Script::factory(
+            $GLOBALS['session']->get('ingo', 'backend/script'),
+            $GLOBALS['session']->get('ingo', 'backend/scriptparams', Horde_Session::TYPE_ARRAY)
+        );
     }
 
     /**
@@ -336,22 +340,19 @@ class Ingo
      */
     static public function getTransport()
     {
-        $params = $_SESSION['ingo']['backend']['params'];
+        global $registry, $session;
+
+        $params = $session->get('ingo', 'backend/params');
 
         // Set authentication parameters.
-        if (!empty($_SESSION['ingo']['backend']['hordeauth'])) {
-            $params['username'] = $GLOBALS['registry']->getAuth(($_SESSION['ingo']['backend']['hordeauth'] === 'full') ? null : 'bare');
-            $params['password'] = $GLOBALS['registry']->getAuthCredential('password');
-        } elseif (isset($_SESSION['ingo']['backend']['params']['username']) &&
-                  isset($_SESSION['ingo']['backend']['params']['password'])) {
-            $params['username'] = $_SESSION['ingo']['backend']['params']['username'];
-            $params['password'] = $_SESSION['ingo']['backend']['params']['password'];
-        } else {
-            $params['username'] = $GLOBALS['registry']->getAuth('bare');
-            $params['password'] = $GLOBALS['registry']->getAuthCredential('password');
+        if (($hordeauth = $session->get('ingo', 'backend/hordeauth')) ||
+            !isset($params['username']) ||
+            !isset($params['password'])) {
+            $params['username'] = $registry->getAuth(($hordeauth === 'full') ? null : 'bare');
+            $params['password'] = $registry->getAuthCredential('password');
         }
 
-        return Ingo_Transport::factory($_SESSION['ingo']['backend']['transport'], $params);
+        return Ingo_Transport::factory($GLOBALS['session']->get('ingo', 'backend/transport'), $params);
     }
 
     /**
@@ -390,7 +391,7 @@ class Ingo
         }
 
         if (is_null(self::$_shareCache)) {
-            self::$_shareCache = $GLOBALS['ingo_shares']->getPermissions($_SESSION['ingo']['current_share'], $GLOBALS['registry']->getAuth());
+            self::$_shareCache = $GLOBALS['ingo_shares']->getPermissions($GLOBALS['session']->get('ingo', 'current_share'), $GLOBALS['registry']->getAuth());
         }
 
         return self::$_shareCache & $mask;
@@ -426,7 +427,7 @@ class Ingo
             foreach (array_keys($GLOBALS['all_rulesets']) as $id) {
                 $options[] = array(
                     'name' => htmlspecialchars($GLOBALS['all_rulesets'][$id]->get('name')),
-                    'selected' => ($_SESSION['ingo']['current_share'] == $id),
+                    'selected' => ($GLOBALS['session']->get('ingo', 'current_share') == $id),
                     'val' => htmlspecialchars($id)
                 );
             }
index 5933f92..6c7ad93 100644 (file)
@@ -114,7 +114,7 @@ class Ingo_Script_Imap extends Ingo_Script
            2. The mailbox has changed -or-
            3. The rules have changed. */
         $cache = $this->_api->getCache();
-        if (($cache !== false) && ($cache == $_SESSION['ingo']['change'])) {
+        if (($cache !== false) && ($cache == $GLOBALS['session']->get('ingo', 'change'))) {
             return true;
         }
 
@@ -339,7 +339,7 @@ class Ingo_Script_Imap extends Ingo_Script
         }
 
         /* Set cache flag. */
-        $this->_api->storeCache($_SESSION['ingo']['change']);
+        $this->_api->storeCache($GLOBALS['session']->get('ingo', 'change'));
 
         return true;
     }
index abbf206..1849339 100644 (file)
@@ -79,31 +79,23 @@ class Ingo_Script_Imap_Live extends Ingo_Script_Imap_Api
      */
     public function getCache()
     {
-        if (empty($_SESSION['ingo']['imapcache'][$this->_params['mailbox']])) {
+        if ($cache = $GLOBALS['session']->get('ingo', 'imapcache/' . $this->_params['mailbox'])) {
             return false;
         }
-        $ptr = &$_SESSION['ingo']['imapcache'][$this->_params['mailbox']];
 
-        if ($this->_cacheId() != $ptr['id']) {
-            $ptr = array();
-            return false;
-        }
-
-        return $ptr['ts'];
+        return ($this->_cacheId() != $cache['id'])
+            ? false
+            : $cache['ts'];
     }
 
     /**
      */
     public function storeCache($timestamp)
     {
-        if (!isset($_SESSION['ingo']['imapcache'])) {
-            $_SESSION['ingo']['imapcache'] = array();
-        }
-
-        $_SESSION['ingo']['imapcache'][$this->_params['mailbox']] = array(
+        $GLOBALS['session']->set('ingo', 'imapcache/' . $this->_params['mailbox'], array(
             'id' => $this->_cacheId(),
             'ts' => $timestamp
-        );
+        ));
     }
 
     /**
index 968fbd5..2b8e159 100644 (file)
@@ -110,8 +110,8 @@ class Ingo_Storage
     {
         /* Store the current objects. */
         foreach ($this->_cache as $key => $val) {
-            if ($val['mod'] || !isset($_SESSION['ingo']['storage'][$key])) {
-                $_SESSION['ingo']['storage'][$key] = $GLOBALS['session']->store($val['ob'], false);
+            if ($val['mod'] || !$GLOBALS['session']->exists('ingo', 'storage/' . $key)) {
+                $GLOBALS['session']->set('ingo', 'storage/' . $key, $GLOBALS['session']->store($val['ob'], false));
             }
         }
     }
@@ -132,7 +132,7 @@ class Ingo_Storage
         /* Don't cache if using shares. */
         if ($cache && empty($GLOBALS['ingo_shares'])) {
             if (!isset($this->_cache[$field])) {
-                $cached = $GLOBALS['session']->retrieve($_SESSION['ingo']['storage'][$field]);
+                $cached = $GLOBALS['session']->retrieve($GLOBALS['session']->get('ingo', 'storage/' . $field));
                 $this->_cache[$field] = array(
                     'mod' => false,
                     'ob' => $cached ? $cached : $this->_retrieve($field, $readonly)
index 4fdea7c..ae03cda 100644 (file)
@@ -212,7 +212,7 @@ class Ingo_Storage_Filters
             $this->_filters[$id - 1] = $this->_filters[$id];
             $this->_filters[$id] = $temp;
             /* Continue to move up until we swap with a viewable category. */
-            if (in_array($temp['action'], $_SESSION['ingo']['script_categories'])) {
+            if (in_array($temp['action'], $GLOBALS['session']->get('ingo', 'script_categories'))) {
                 $i++;
             }
             $id--;
@@ -234,7 +234,7 @@ class Ingo_Storage_Filters
             $this->_filters[$id] = $temp;
             /* Continue to move down until we swap with a viewable
                category. */
-            if (in_array($temp['action'], $_SESSION['ingo']['script_categories'])) {
+            if (in_array($temp['action'], $GLOBALS['session']->get('ingo', 'script_categories'))) {
                 $i++;
             }
             $id++;
index a97ad93..904bfdf 100644 (file)
@@ -77,7 +77,7 @@ class Ingo_Transport
     public function supportShares()
     {
         return ($this->_support_shares &&
-                !empty($_SESSION['ingo']['backend']['shares']));
+                $GLOBALS['session']->get('ingo', 'backend/shares'));
     }
 
 }
index c128bde..f187679 100644 (file)
@@ -115,7 +115,7 @@ class Ingo_Transport_Vfs extends Ingo_Transport
         if (!empty($this->_params['vfs_path'])) {
             $user = Ingo::getUser();
             $domain = Ingo::getDomain();
-            if ($_SESSION['ingo']['backend']['hordeauth'] !== 'full') {
+            if ($GLOBALS['session']->get('ingo', 'backend/hordeauth') !== 'full') {
                 $pos = strpos($user, '@');
                 if ($pos !== false) {
                     $domain = substr($user, $pos + 1);
index 6006d61..3ddfe57 100644 (file)
@@ -128,7 +128,7 @@ class ScriptTester {
 
     function _setupStorage()
     {
-        $_SESSION['ingo']['change'] = 0;
+        $GLOBALS['session']->set('ingo', 'change', 0);
         $GLOBALS['ingo_storage'] = Ingo_Storage::factory('mock', array());
         foreach ($this->rules as $ob) {
             $GLOBALS['ingo_storage']->store($ob);
index 75d1509..3092b23 100644 (file)
@@ -118,7 +118,7 @@ case 'rule_delete':
     }
 
     /* Update the timestamp for the rules. */
-    $_SESSION['ingo']['change'] = time();
+    $session->set('ingo', 'change', time());
 
     /* Save the rule. */
     if ($vars->actionID == 'rule_save' && $valid) {
index 14b1d15..5aa2c96 100644 (file)
@@ -12,7 +12,7 @@ require_once dirname(__FILE__) . '/lib/Application.php';
 Horde_Registry::appInit('ingo');
 
 /* Redirect if script updating is not available. */
-if (!$_SESSION['ingo']['script_generate']) {
+if (!$session->get('ingo', 'script_generate')) {
     Horde::url('filters.php', true)->redirect();
 }
 
index 3ad30f0..2d0d883 100755 (executable)
@@ -63,6 +63,8 @@
 require_once dirname(__FILE__) . '/../../lib/Application.php';
 Horde_Registry::appInit('ingo', array('authentication' => 'none', 'cli' => true));
 
+exit('Not updated');
+
 // Initialize authentication manager.
 $auth = $injector->getInstance('Horde_Auth')->getAuth();
 
@@ -133,7 +135,7 @@ function smtpd_access_policy($query)
 
         // Retrieve the data.
         $GLOBALS['auth']->setAuth($user, array());
-        $_SESSION['ingo']['current_share'] = ':' . $user;
+        $GLOBALS['session']->set('ingo', 'current_share', ':' . $user);
 
         try {
             $whitelists[$user] = $GLOBALS['rules_storage']->retrieve(Ingo_Storage::ACTION_WHITELIST, false)->getWhitelist();
index d575e6c..d8ce4a6 100755 (executable)
@@ -51,7 +51,7 @@ while (!feof(STDIN)) {
     echo 'Converting filters for user: ' . $user;
 
     Horde_Auth::setAuth($user, array());
-    $_SESSION['ingo']['current_share'] = ':' . $user;
+    $session->set('ingo', 'current_share', ':' . $user);
 
     foreach ($rules as $rule) {
         $filter = $prefs_storage->retrieve($rule, false);
index 14cdfdd..92d6cc1 100644 (file)
@@ -41,7 +41,7 @@ class Horde_Form_Type_ingo_folders extends Horde_Form_Type {
 
 }
 
-if (!in_array(Ingo_Storage::ACTION_SPAM, $_SESSION['ingo']['script_categories'])) {
+if (!in_array(Ingo_Storage::ACTION_SPAM, $session->get('ingo', 'script_categories'))) {
     $notification->push(_("Simple spam filtering is not supported in the current filtering driver."), 'horde.error');
     Horde::url('filters.php', true)->redirect();
 }
@@ -118,7 +118,7 @@ if ($form->validate($vars)) {
     }
 
     /* Update the timestamp for the rules. */
-    $_SESSION['ingo']['change'] = time();
+    $session->set('ingo', 'change', time());
 }
 
 /* Add buttons depending on the above actions. */
index e3321d3..b65080d 100644 (file)
@@ -14,7 +14,7 @@ require_once dirname(__FILE__) . '/lib/Application.php';
 Horde_Registry::appInit('ingo');
 
 /* Redirect if vacation is not available. */
-if (!in_array(Ingo_Storage::ACTION_VACATION, $_SESSION['ingo']['script_categories'])) {
+if (!in_array(Ingo_Storage::ACTION_VACATION, $session->get('ingo', 'script_categories'))) {
     $notification->push(_("Vacation is not supported in the current filtering driver."), 'horde.error');
     Horde::url('filters.php', true)->redirect();
 }
@@ -90,7 +90,7 @@ if ($form->validate($vars)) {
     }
 
     /* Update the timestamp for the rules. */
-    $_SESSION['ingo']['change'] = time();
+    $session->set('ingo', 'change', time());
 }
 
 /* Add buttons depending on the above actions. */
index 0e4e5ae..fcd54eb 100644 (file)
@@ -16,7 +16,7 @@ require_once dirname(__FILE__) . '/lib/Application.php';
 Horde_Registry::appInit('ingo');
 
 /* Redirect if whitelist not available. */
-if (!in_array(Ingo_Storage::ACTION_WHITELIST, $_SESSION['ingo']['script_categories'])) {
+if (!in_array(Ingo_Storage::ACTION_WHITELIST, $session->get('ingo', 'script_categories'))) {
     $notification->push(_("Whitelist is not supported in the current filtering driver."), 'horde.error');
     Horde::url('filters.php', true)->redirect();
 }
@@ -40,7 +40,7 @@ case 'rule_update':
         }
 
         /* Update the timestamp for the rules. */
-        $_SESSION['ingo']['change'] = time();
+        $session->set('ingo', 'change', time());
     } catch (Ingo_Exception $e) {
         $notification->push($e);
     }