From: Michael M Slusarz Date: Wed, 3 Nov 2010 07:23:38 +0000 (-0600) Subject: Turba: Convert to new Horde_Session API X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=5d76464fe72eca0fcee6227d3650c94d08f497f7;p=horde.git Turba: Convert to new Horde_Session API --- diff --git a/turba/addressbooks/create.php b/turba/addressbooks/create.php index 4b3cc4b35..1ecaa5e6d 100644 --- a/turba/addressbooks/create.php +++ b/turba/addressbooks/create.php @@ -13,7 +13,7 @@ Horde_Registry::appInit('turba'); // Exit if this isn't an authenticated user, or if there's no source // configured for shares. -if (!$GLOBALS['registry']->getAuth() || !$session['turba:has_share']) { +if (!$GLOBALS['registry']->getAuth() || !$session->get('turba', 'has_share')) { require TURBA_BASE . '/' . ($browse_source_count ? basename($prefs->getValue('initial_page')) : 'search.php'); exit; diff --git a/turba/addressbooks/delete.php b/turba/addressbooks/delete.php index 47bc01eb3..d70346dd3 100644 --- a/turba/addressbooks/delete.php +++ b/turba/addressbooks/delete.php @@ -13,7 +13,7 @@ Horde_Registry::appInit('turba'); // Exit if this isn't an authenticated user, or if there's no source // configured for shares. -if (!$GLOBALS['registry']->getAuth() || !$session['turba:has_share']) { +if (!$GLOBALS['registry']->getAuth() || !$session->get('turba', 'has_share')) { require TURBA_BASE . '/' . ($browse_source_count ? basename($prefs->getValue('initial_page')) : 'search.php'); exit; diff --git a/turba/addressbooks/edit.php b/turba/addressbooks/edit.php index 15fc5c00f..60245ff32 100644 --- a/turba/addressbooks/edit.php +++ b/turba/addressbooks/edit.php @@ -13,7 +13,7 @@ Horde_Registry::appInit('turba'); // Exit if this isn't an authenticated user, or if there's no source // configured for shares. -if (!$GLOBALS['registry']->getAuth() || !$session['turba:has_share']) { +if (!$GLOBALS['registry']->getAuth() || !$session->get('turba', 'has_share')) { require TURBA_BASE . '/' . ($browse_source_count ? basename($prefs->getValue('initial_page')) : 'search.php'); exit; diff --git a/turba/addressbooks/index.php b/turba/addressbooks/index.php index 620f4b88d..c0c21db87 100644 --- a/turba/addressbooks/index.php +++ b/turba/addressbooks/index.php @@ -13,7 +13,7 @@ Horde_Registry::appInit('turba'); // Exit if this isn't an authenticated user, or if there's no source // configured for shares. -if (!$GLOBALS['registry']->getAuth() || !$session['turba:has_share']) { +if (!$GLOBALS['registry']->getAuth() || !$session->get('turba', 'has_share')) { require TURBA_BASE . '/' . ($browse_source_count ? basename($prefs->getValue('initial_page')) : 'search.php'); exit; diff --git a/turba/config/hooks.php.dist b/turba/config/hooks.php.dist index 4ad0a0cf3..f374a1f44 100644 --- a/turba/config/hooks.php.dist +++ b/turba/config/hooks.php.dist @@ -25,7 +25,7 @@ class Turba_Hooks */ // public function default_dir($username = null) // { -// if (!$username || !$GLOBALS['session']['turba:has_share']) { +// if (!$username || !$GLOBALS['session']->get('turba', 'has_share')) { // return; // } // diff --git a/turba/lib/Api.php b/turba/lib/Api.php index 4cc527f7c..5067ad96f 100644 --- a/turba/lib/Api.php +++ b/turba/lib/Api.php @@ -125,7 +125,7 @@ class Turba_Api extends Horde_Registry_Api // Bring in a clean copy of sources. require TURBA_BASE . '/config/backends.php'; - if ($session['turba:has_share']) { + if ($session->get('turba', 'has_share')) { $shares = Turba::listShares(true); foreach ($shares as $uid => $share) { $params = @unserialize($share->get('params')); @@ -257,7 +257,7 @@ class Turba_Api extends Horde_Registry_Api } else { // Assume $parts[0] is a valid username and we need to list their // shared addressbooks. - if (!$session['turba:has_share']) { + if (!$session->get('turba', 'has_share')) { // No backends are configured to provide shares return array(); } diff --git a/turba/lib/Application.php b/turba/lib/Application.php index fefcf3fbf..5a13ac624 100644 --- a/turba/lib/Application.php +++ b/turba/lib/Application.php @@ -80,7 +80,7 @@ class Turba_Application extends Horde_Registry_Application foreach ($cfgSources as $key => $cfg) { if (!empty($cfg['use_shares'])) { // Create a share instance. - $GLOBALS['session']['turba:has_share'] = true; + $GLOBALS['session']->set('turba', 'has_share', true); $GLOBALS['turba_shares'] = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Share')->create(); $cfgSources = Turba::getConfigFromShares($cfgSources); break; @@ -93,7 +93,7 @@ class Turba_Application extends Horde_Registry_Application // Build the directory sources select widget. $default_source = Horde_Util::nonInputVar('source'); if (empty($default_source)) { - if (!($default_source = $GLOBALS['session']['turba:source'])) { + if (!($default_source = $GLOBALS['session']->get('turba', 'source'))) { $default_source = Turba::getDefaultAddressBook(); } $default_source = Horde_Util::getFormData('source', $default_source); @@ -119,7 +119,7 @@ class Turba_Application extends Horde_Registry_Application if (empty($cfgSources[$default_source]['browse'])) { $default_source = Turba::getDefaultAddressBook(); } - $GLOBALS['session']['turba:source'] = $default_source; + $GLOBALS['session']->set('turba', 'source', $default_source); $GLOBALS['default_source'] = $default_source; /* Only set $add_source_options if there is at least one editable @@ -176,7 +176,7 @@ class Turba_Application extends Horde_Registry_Application */ public function menu($menu) { - if ($GLOBALS['session']['turba:has_share']) { + if ($GLOBALS['session']->get('turba', 'has_share')) { $menu->add(Horde::url('addressbooks/index.php'), _("_My Address Books"), 'turba.png'); } @@ -429,7 +429,7 @@ class Turba_Application extends Horde_Registry_Application } /* Only attempt share removal if we have shares configured */ - if (!$GLOBALS['session']['turba:has_share']) { + if (!$GLOBALS['session']->get('turba', 'has_share')) { return; } diff --git a/turba/lib/Form/DeleteAddressBook.php b/turba/lib/Form/DeleteAddressBook.php index f8b93e77b..21b09e9ff 100644 --- a/turba/lib/Form/DeleteAddressBook.php +++ b/turba/lib/Form/DeleteAddressBook.php @@ -64,8 +64,8 @@ class Turba_Form_DeleteAddressBook extends Horde_Form throw new Turba_Exception($e); } - if ($GLOBALS['session']['turba:source'] == Horde_Util::getFormData('deleteshare')) { - unset($GLOBALS['session']['turba:source']); + if ($GLOBALS['session']->get('turba', 'source') == Horde_Util::getFormData('deleteshare')) { + $GLOBALS['session']->remove('turba', 'source'); } $abooks = json_decode($GLOBALS['prefs']->getValue('addressbooks')); diff --git a/turba/lib/LoginTasks/SystemTask/UpgradeLists.php b/turba/lib/LoginTasks/SystemTask/UpgradeLists.php index c93d7a9b5..bba646d01 100644 --- a/turba/lib/LoginTasks/SystemTask/UpgradeLists.php +++ b/turba/lib/LoginTasks/SystemTask/UpgradeLists.php @@ -35,7 +35,7 @@ class Turba_LoginTasks_SystemTask_UpgradeLists extends Horde_LoginTasks_SystemTa */ public function execute() { - if ($GLOBALS['session']['turba:has_share']) { + if ($GLOBALS['session']->get('turba', 'has_share')) { $criteria = array('__type' => 'Group'); $sources = array_keys($GLOBALS['cfgSources']); foreach ($sources as $sourcekey) { diff --git a/turba/lib/LoginTasks/SystemTask/UpgradePrefs.php b/turba/lib/LoginTasks/SystemTask/UpgradePrefs.php index a10a4e5ab..b7246b172 100644 --- a/turba/lib/LoginTasks/SystemTask/UpgradePrefs.php +++ b/turba/lib/LoginTasks/SystemTask/UpgradePrefs.php @@ -37,7 +37,7 @@ class Turba_LoginTasks_SystemTask_UpgradePrefs extends Horde_LoginTasks_SystemTa { global $registry; - if ($GLOBALS['session']['turba:has_share']) { + if ($GLOBALS['session']->get('turba', 'has_share')) { $this->_doAddressbooks(); $this->_doColumns(); $this->_doAddSource(); diff --git a/turba/lib/Turba.php b/turba/lib/Turba.php index 9a400ba42..4e6b4c48f 100644 --- a/turba/lib/Turba.php +++ b/turba/lib/Turba.php @@ -527,7 +527,7 @@ class Turba { */ function listShares($owneronly = false, $permission = Horde_Perms::READ) { - if (!$GLOBALS['session']['turba:has_share']) { + if (!$GLOBALS['session']->get('turba', 'has_share')) { // No backends are configured to provide shares return array(); } diff --git a/turba/lib/View/List.php b/turba/lib/View/List.php index efa04f16d..75fc1b47a 100644 --- a/turba/lib/View/List.php +++ b/turba/lib/View/List.php @@ -177,7 +177,7 @@ class Turba_View_List implements Countable $listHtml = $this->getPage($numDisplayed, $min, $max); $crit = array(); - if ($session['turba:search_mode'] == 'advanced') { + if ($session->get('turba', 'search_mode') == 'advanced') { $map = $driver->getCriteria(); foreach ($map as $key => $value) { if ($key != '__key') { diff --git a/turba/search.php b/turba/search.php index fc5f08089..3f8949fd7 100644 --- a/turba/search.php +++ b/turba/search.php @@ -51,17 +51,18 @@ Horde_Registry::appInit('turba'); /* Verify if the search mode variable is passed in form or is registered in * the session. Always use basic search by default. */ if (Horde_Util::getFormData('search_mode')) { - $session['turba:search_mode'] = Horde_Util::getFormData('search_mode'); + $session->set('turba', 'search_mode', Horde_Util::getFormData('search_mode')); } -if (!in_array($session['turba:search_mode'], array('basic', 'advanced', 'duplicate'))) { - $session['turba:search_mode'] = 'basic'; +if (!in_array($session->get('turba', 'search_mode'), array('basic', 'advanced', 'duplicate'))) { + $session->set('turba', 'search_mode', 'basic'); } +$search_mode = $session->get('turba', 'search_mode'); /* Get the current source. */ $addressBooks = Turba::getAddressBooks(); $editableAddressBooks = Turba::getAddressBooks(Horde_Perms::EDIT & Horde_Perms::DELETE, array('require_add' => true)); -if ($session['turba:search_mode'] == 'duplicate') { +if ($search_mode == 'duplicate') { $addressBooks = $editableAddressBooks; } $source = Horde_Util::getFormData('source', $default_source); @@ -93,7 +94,7 @@ try { if ($driver) { $map = $driver->getCriteria(); - if ($session['turba:search_mode'] == 'advanced') { + if ($search_mode == 'advanced') { $criteria = array(); foreach (array_keys($map) as $key) { if ($key != '__key') { @@ -111,7 +112,7 @@ if ($driver) { /* Only try to perform a search if we actually have search criteria. */ if ((is_array($criteria) && count($criteria)) || !empty($val) || - ($session['turba:search_mode'] == 'duplicate' && + ($search_mode == 'duplicate' && (Horde_Util::getFormData('search') || Horde_Util::getFormData('dupe') || count($addressBooks) == 1))) { @@ -131,7 +132,7 @@ if ($driver) { 'params' => serialize(array( 'type' => 'vbook', 'source' => $source, - 'criteria' => $session['turba:search_mode'] == 'basic' ? array($criteria => $val) : $criteria + 'criteria' => $search_mode == 'basic' ? array($criteria => $val) : $criteria )) ); @@ -151,7 +152,7 @@ if ($driver) { } /* Perform a search. */ - if ($session['turba:search_mode'] == 'duplicate') { + if ($search_mode == 'duplicate') { try { $duplicates = $driver->searchDuplicates(); $dupe = Horde_Util::getFormData('dupe'); @@ -163,9 +164,9 @@ if ($driver) { } } else { try { - if ((($session['turba:search_mode'] == 'basic') && + if ((($search_mode == 'basic') && ($results = $driver->search(array($criteria => $val)))) || - (($session['turba:search_mode'] == 'advanced') && + (($search_mode == 'advanced') && ($results = $driver->search($criteria)))) { /* Read the columns to display from the preferences. */ $sources = Turba::getColumns(); @@ -227,14 +228,14 @@ $searchView->criteria = $criteria; $searchView->value = $val; /* The form footer and vbook section. */ -if ($session['turba:search_mode'] != 'duplicate') { +if ($search_mode != 'duplicate') { $vbookView = new Horde_View(array('templatePath' => TURBA_TEMPLATES . '/search')); - $vbookView->hasShare = isset($session['turba:has_share']); + $vbookView->hasShare = $session->get('turba', 'has_share'); $vbookView->shareSources = $shareSources; $vbookView->source = $source; } -switch ($session['turba:search_mode']) { +switch ($search_mode) { case 'basic': $title = _("Basic Search"); Horde::addInlineScript(array( @@ -264,10 +265,10 @@ if (isset($view) && is_object($view)) { require TURBA_TEMPLATES . '/common-header.inc'; require TURBA_TEMPLATES . '/menu.inc'; -echo $tabs->render($session['turba:search_mode']); +echo $tabs->render($search_mode); echo $headerView->render('header'); -echo $searchView->render($session['turba:search_mode']); -if ($session['turba:search_mode'] != 'duplicate') { +echo $searchView->render($search_mode); +if ($search_mode != 'duplicate') { echo $vbookView->render('vbook'); } if (isset($view) && is_object($view)) {