From 01fe2cc321c3389c23fd347d599769a526b136cf Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 8 Nov 2010 22:03:06 -0700 Subject: [PATCH] Ingo: Convert to new Horde_Session API --- ingo/blacklist.php | 4 +- ingo/filters.php | 12 +++-- ingo/forward.php | 2 +- ingo/lib/Api.php | 4 +- ingo/lib/Application.php | 28 +++++----- ingo/lib/Block/overview.php | 14 ++--- ingo/lib/Ingo.php | 71 +++++++++++++------------- ingo/lib/Script/Imap.php | 4 +- ingo/lib/Script/Imap/Live.php | 20 +++----- ingo/lib/Storage.php | 6 +-- ingo/lib/Storage/Filters.php | 4 +- ingo/lib/Transport.php | 2 +- ingo/lib/Transport/Vfs.php | 2 +- ingo/lib/tests/ScriptTest.php | 2 +- ingo/rule.php | 2 +- ingo/script.php | 2 +- ingo/scripts/ingo-postfix-policyd | 4 +- ingo/scripts/upgrades/convert_prefs_to_sql.php | 2 +- ingo/spam.php | 4 +- ingo/vacation.php | 4 +- ingo/whitelist.php | 4 +- 21 files changed, 101 insertions(+), 96 deletions(-) diff --git a/ingo/blacklist.php b/ingo/blacklist.php index d83835eb6..b368329ba 100644 --- a/ingo/blacklist.php +++ b/ingo/blacklist.php @@ -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; diff --git a/ingo/filters.php b/ingo/filters.php index 2a8305c19..b6f318dd9 100644 --- a/ingo/filters.php +++ b/ingo/filters.php @@ -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; } diff --git a/ingo/forward.php b/ingo/forward.php index ed9881431..17946791a 100644 --- a/ingo/forward.php +++ b/ingo/forward.php @@ -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(); } diff --git a/ingo/lib/Api.php b/ingo/lib/Api.php index c47bf0b77..3f3d7b5d4 100644 --- a/ingo/lib/Api.php +++ b/ingo/lib/Api.php @@ -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) {} diff --git a/ingo/lib/Application.php b/ingo/lib/Application.php index cc670f203..1e7f00164 100644 --- a/ingo/lib/Application.php +++ b/ingo/lib/Application.php @@ -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'; } } diff --git a/ingo/lib/Block/overview.php b/ingo/lib/Block/overview.php index ae01dc8e3..69a38a5f1 100644 --- a/ingo/lib/Block/overview.php +++ b/ingo/lib/Block/overview.php @@ -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")) . '' . @@ -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")) . '' . 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")) . '' . @@ -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")) . '' . @@ -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")) . '' . diff --git a/ingo/lib/Ingo.php b/ingo/lib/Ingo.php index fdad944ec..ddf1ffb23 100644 --- a/ingo/lib/Ingo.php +++ b/ingo/lib/Ingo.php @@ -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) ); } diff --git a/ingo/lib/Script/Imap.php b/ingo/lib/Script/Imap.php index 5933f9258..6c7ad9397 100644 --- a/ingo/lib/Script/Imap.php +++ b/ingo/lib/Script/Imap.php @@ -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; } diff --git a/ingo/lib/Script/Imap/Live.php b/ingo/lib/Script/Imap/Live.php index abbf2064b..184933913 100644 --- a/ingo/lib/Script/Imap/Live.php +++ b/ingo/lib/Script/Imap/Live.php @@ -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 - ); + )); } /** diff --git a/ingo/lib/Storage.php b/ingo/lib/Storage.php index 968fbd5c7..2b8e159f3 100644 --- a/ingo/lib/Storage.php +++ b/ingo/lib/Storage.php @@ -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) diff --git a/ingo/lib/Storage/Filters.php b/ingo/lib/Storage/Filters.php index 4fdea7c83..ae03cda0a 100644 --- a/ingo/lib/Storage/Filters.php +++ b/ingo/lib/Storage/Filters.php @@ -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++; diff --git a/ingo/lib/Transport.php b/ingo/lib/Transport.php index a97ad93da..904bfdf95 100644 --- a/ingo/lib/Transport.php +++ b/ingo/lib/Transport.php @@ -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')); } } diff --git a/ingo/lib/Transport/Vfs.php b/ingo/lib/Transport/Vfs.php index c128bde11..f18767965 100644 --- a/ingo/lib/Transport/Vfs.php +++ b/ingo/lib/Transport/Vfs.php @@ -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); diff --git a/ingo/lib/tests/ScriptTest.php b/ingo/lib/tests/ScriptTest.php index 6006d61cf..3ddfe5773 100644 --- a/ingo/lib/tests/ScriptTest.php +++ b/ingo/lib/tests/ScriptTest.php @@ -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); diff --git a/ingo/rule.php b/ingo/rule.php index 75d15095e..3092b23e9 100644 --- a/ingo/rule.php +++ b/ingo/rule.php @@ -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) { diff --git a/ingo/script.php b/ingo/script.php index 14b1d1530..5aa2c96c5 100644 --- a/ingo/script.php +++ b/ingo/script.php @@ -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(); } diff --git a/ingo/scripts/ingo-postfix-policyd b/ingo/scripts/ingo-postfix-policyd index 3ad30f06b..2d0d883bc 100755 --- a/ingo/scripts/ingo-postfix-policyd +++ b/ingo/scripts/ingo-postfix-policyd @@ -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(); diff --git a/ingo/scripts/upgrades/convert_prefs_to_sql.php b/ingo/scripts/upgrades/convert_prefs_to_sql.php index d575e6c3f..d8ce4a694 100755 --- a/ingo/scripts/upgrades/convert_prefs_to_sql.php +++ b/ingo/scripts/upgrades/convert_prefs_to_sql.php @@ -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); diff --git a/ingo/spam.php b/ingo/spam.php index 14cdfdd3b..92d6cc1b7 100644 --- a/ingo/spam.php +++ b/ingo/spam.php @@ -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. */ diff --git a/ingo/vacation.php b/ingo/vacation.php index e3321d3da..b65080d54 100644 --- a/ingo/vacation.php +++ b/ingo/vacation.php @@ -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. */ diff --git a/ingo/whitelist.php b/ingo/whitelist.php index 0e4e5aede..fcd54eb39 100644 --- a/ingo/whitelist.php +++ b/ingo/whitelist.php @@ -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); } -- 2.11.0