} else {
/* Cannot write. */
$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['_config'][$app] = $php;
+ $session['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');
$template->set('php', htmlspecialchars($php), true);
/* Create the link for the diff popup only if stored in session. */
$diff_link = '';
-if (!empty($_SESSION['_config'][$app])) {
+if (isset($session['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>';
}
*/
function _getDiff($app)
{
- global $renderer, $registry;
+ global $registry, $renderer, $session;
/* Read the existing configuration. */
$current_config = '';
/* Calculate the differences. */
$diff = new Text_Diff(explode("\n", $current_config),
- explode("\n", $_SESSION['_config'][$app]));
+ explode("\n", $session['horde:config/' . $app]));
$diff = $renderer->render($diff);
- if (!empty($diff)) {
- return $diff;
- } else {
- return _("No change.");
- }
+
+ return empty($diff)
+ ? _("No change.")
+ : $diff;
}
$diffs = array();
/* Only bother to do anything if there is any config. */
-if (!empty($_SESSION['_config'])) {
+if ($config = $session['horde:config/']) {
/* Set up the toggle button for inline/unified. */
$url = Horde::url('admin/config/diff.php')->add('render', ($render_type == 'inline') ? 'unified' : 'inline');
'toggle_renderer' => $toggle_renderer);
} else {
/* List all the apps with generated configuration. */
- ksort($_SESSION['_config']);
- foreach ($_SESSION['_config'] as $app => $config) {
+ ksort($config);
+ foreach ($config as $app => $config) {
$toggle_renderer = Horde::link($url . '#' . $app) . (($render_type == 'inline') ? _("unified") : _("inline")) . '</a>';
$diff = _getDiff($app);
if ($render_type != 'inline') {
/* Loop through the config and write to FTP. */
$no_errors = true;
- foreach ($_SESSION['_config'] as $app => $config) {
+ foreach ($session['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')) {
try {
$vfs->writeData($path, 'conf.php', $config);
$notification->push(sprintf(_("Successfully wrote %s"), Horde_Util::realPath($path . '/conf.php')), 'horde.success');
- unset($_SESSION['_config'][$app]);
+ unset($session['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');
/* Set up any actions that may be offered. */
$actions = array();
$ftpform = '';
-if (!empty($_SESSION['_config'])) {
+if ($session['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"'),
* to be run at the command prompt. */
$data = '#!/usr/bin/env php' . "\n";
$data .= '<?php' . "\n";
- foreach ($_SESSION['_config'] as $app => $php) {
+ foreach ($session['horde:config/'] as $app => $php) {
$path = $registry->get('fileroot', $app) . '/config';
/* Add code to save backup. */
$data .= 'if (file_exists(\'' . $path . '/conf.php\')) {' . "\n";