Horde: Convert to new Horde_Session API
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 3 Nov 2010 06:52:31 +0000 (00:52 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 4 Nov 2010 19:43:01 +0000 (13:43 -0600)
horde/admin/config/config.php
horde/admin/config/diff.php
horde/admin/config/index.php
horde/admin/config/scripts.php
horde/config/hooks.php.dist
horde/login.php
horde/services/language.php

index 7bc9535..382564e 100644 (file)
@@ -65,7 +65,7 @@ if (Horde_Util::getFormData('submitbutton') == _("Revert Configuration")) {
         $notification->push(sprintf(_("Could not save the configuration file %s. You can either use one of the options to save the code back on %s or copy manually the code below to %s."), Horde_Util::realPath($path . '/conf.php'), Horde::link(Horde::url('admin/config/index.php') . '#update', _("Configuration")) . _("Configuration") . '</a>', Horde_Util::realPath($path . '/conf.php')), 'horde.warning', array('content.raw'));
 
         /* Save to session. */
-        $session['horde:config/' . $app] = $php;
+        $session->set('horde', 'config/' . $app, $php);
     }
 } elseif ($form->isSubmitted()) {
     $notification->push(_("There was an error in the configuration form. Perhaps you left out a required field."), 'horde.error');
@@ -76,7 +76,7 @@ $template = $injector->createInstance('Horde_Template');
 $template->set('php', htmlspecialchars($php), true);
 /* Create the link for the diff popup only if stored in session. */
 $diff_link = '';
-if (isset($session['horde:config/' . $app])) {
+if ($session->exists('horde', 'config/' . $app)) {
     $url = Horde::url('admin/config/diff.php', true)->add('app', $app);
     $diff_link = Horde::link('#', '', '', '', Horde::popupJs($url, array('height' => 480, 'width' => 640, 'urlencode' => true)) . 'return false;') . _("show differences") . '</a>';
 }
index af54ed4..4cfd2d4 100644 (file)
@@ -31,7 +31,7 @@ function _getDiff($app)
 
     /* Calculate the differences. */
     $diff = new Text_Diff(explode("\n", $current_config),
-                          explode("\n", $session['horde:config/' . $app]));
+                          explode("\n", $session->get('horde', 'config/' . $app)));
     $diff = $renderer->render($diff);
 
     return empty($diff)
@@ -41,7 +41,7 @@ function _getDiff($app)
 
 $diffs = array();
 /* Only bother to do anything if there is any config. */
-if ($config = $session['horde:config/']) {
+if ($config = $session->get('horde', 'config/')) {
     /* Set up the toggle button for inline/unified. */
     $url = Horde::url('admin/config/diff.php')->add('render', ($render_type == 'inline') ? 'unified' : 'inline');
 
index 0d1234e..01ac685 100644 (file)
@@ -30,7 +30,7 @@ function _uploadFTP($params)
 
     /* Loop through the config and write to FTP. */
     $no_errors = true;
-    foreach ($session['horde:config/'] as $app => $config) {
+    foreach ($session->get('horde', 'config/') as $app => $config) {
         $path = $registry->get('fileroot', $app) . '/config';
         /* Try to back up the current conf.php. */
         if ($vfs->exists($path, 'conf.php')) {
@@ -45,7 +45,7 @@ function _uploadFTP($params)
         try {
             $vfs->writeData($path, 'conf.php', $config);
             $notification->push(sprintf(_("Successfully wrote %s"), Horde_Util::realPath($path . '/conf.php')), 'horde.success');
-            unset($session['horde:config/' . $app]);
+            $session->remove('horde', 'config/' . $app);
         } catch (VFS_Exception $e) {
             $no_errors = false;
             $notification->push(sprintf(_("Could not write configuration for \"%s\": %s"), $app, $e->getMessage()), 'horde.error');
@@ -168,7 +168,7 @@ Horde_Array::arraySort($apps, 'sort');
 /* Set up any actions that may be offered. */
 $actions = array();
 $ftpform = '';
-if ($session['horde:config/']) {
+if ($session->get('horde', 'config/')) {
     $url = Horde::url('admin/config/diff.php');
     $action = _("Show differences between currently saved and the newly generated configuration.");
     $actions[] = array('icon' => Horde::img('search.png', '', 'align="middle"'),
index 2234f2e..1cad990 100644 (file)
@@ -44,7 +44,7 @@ if ($setup == 'conf' && $type == 'php') {
      * to be run at the command prompt. */
     $data = '#!/usr/bin/env php' . "\n";
     $data .= '<?php' . "\n";
-    foreach ($session['horde:config/'] as $app => $php) {
+    foreach ($session->get('horde', 'config/') as $app => $php) {
         $path = $registry->get('fileroot', $app) . '/config';
         /* Add code to save backup. */
         $data .= 'if (file_exists(\'' . $path . '/conf.php\')) {' . "\n";
index 17f1c67..fb63006 100644 (file)
@@ -685,13 +685,13 @@ class Horde_Hooks
 //            (!empty($cfgSources['imsp']['use_shares']))) {
 //            // Only do this once per session or when this session variable
 //            // is purposely unset.
-//            if ($session['horde:imsp_synched']) {
+//            if ($session->get('horde', 'imsp_synched')) {
 //                return;
 //            }
 //
 //            $results = Net_IMSP_Utils::synchShares($share_obj, $cfgSources['imsp']);
 //            if (!$results instanceof PEAR_Error) {
-//                $session['horde:imsp_synched'] = true;
+//                $session->set('horde', 'imsp_synched') = true;
 //
 //                // Now deal with adding or removing address books from prefs.
 //                // FIXME: Updating prefs seems to hang the server. Narrowed
@@ -730,7 +730,7 @@ class Horde_Hooks
 //                // We have to save the connection info for the imsp server
 //                // since the share_modify hook will not occur from within
 //                // turba's context.
-//                $session['horde:imsp_config'] = $cfgSources['imsp']['params'];
+//                $session->set('horde', 'imsp_config', $cfgSources['imsp']['params']);
 //            }
 //        }
 //    }
@@ -749,7 +749,7 @@ class Horde_Hooks
 //        if (is_array($params) &&
 //            !empty($params['source']) &&
 //            ($params['source'] == 'imsp') &&
-//            $session['horde:imsp_config']) {
+//            ($config = $session->get('horde', 'imsp_config'))) {
 //            // Ensure we don't try to change ownership.
 //            $params = @unserialize($share->get('params'));
 //            $bookName = $params['name'];
@@ -762,7 +762,7 @@ class Horde_Hooks
 //            $users = $injector->getInstance('Horde_Perms')->getUserPermissions();
 //            foreach ($users as $user => $perm) {
 //                $acl = Net_IMSP_Utils::permsToACL($perm);
-//                $result = Net_IMSP_Utils::setACL($session['horde:imsp_config'], $bookName, $user, $acl);
+//                $result = Net_IMSP_Utils::setACL($config, $bookName, $user, $acl);
 //            }
 //        }
 //    }
index 5034cb5..4ad719e 100644 (file)
@@ -245,12 +245,12 @@ if (!empty($conf['auth']['alternate_login'])) {
 
 /* Build the <select> widget containing the available languages. */
 if (!$is_auth && !$prefs->isLocked('language')) {
-    $session['horde:language'] = $registry->preferredLang($vars->new_lang);
+    $session->set('horde', 'language', $registry->preferredLang($vars->new_lang));
     $langs = array();
 
     foreach ($registry->nlsconfig['languages'] as $key => $val) {
         $langs[] = array(
-            'sel' => ($key == $session['horde:language']),
+            'sel' => ($key == $session->get('horde', 'language')),
             'val' => $key,
             // Language names are already encoded.
             'name' => $val
index 32b46bc..b9269e0 100644 (file)
@@ -14,8 +14,8 @@ require_once dirname(__FILE__) . '/../lib/Application.php';
 Horde_Registry::appInit('horde');
 
 /* Set the language. */
-$session['horde:language'] = $registry->preferredLanguage(Horde_Util::getForm('new_lang'));
-$prefs->setValue('language', $sessoin['horde:language']);
+$session->set('horde', 'language', $registry->preferredLanguage(Horde_Util::getForm('new_lang')));
+$prefs->setValue('language', $session->get('horde', 'language'));
 
 /* Update apps language */
 foreach ($registry->listApps() as $app) {