From 5985ab23688c190fb1348e43c435ae886bee4d07 Mon Sep 17 00:00:00 2001 From: Ben Klang Date: Fri, 8 Jul 2005 09:40:15 +0000 Subject: [PATCH] Added System tab for system contexts git-svn-id: https://svn.alkaloid.net/gpl/shout/trunk@51 06cd67b6-e706-0410-b29e-9de616bca6e9 --- lib/System.php | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ system.php | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+) create mode 100644 lib/System.php create mode 100644 system.php diff --git a/lib/System.php b/lib/System.php new file mode 100644 index 000000000..d6622c315 --- /dev/null +++ b/lib/System.php @@ -0,0 +1,65 @@ + + * + * See the enclosed file LICENSE for license information (BSD). If you + * did not receive this file, see http://www.horde.org/licenses/bsdl.php. + * + * @author Ben Klang + * @package Shout + */ +class ContextForm extends Horde_Form { + + var $_useFormToken = false; + + function ContextForm(&$vars) + { + global $shout; + + parent::Horde_Form($vars, _("Select System Context")); + + $contextfilter = SHOUT_CONTEXT_CUSTOMERS | SHOUT_CONTEXT_EXTENSIONS| + SHOUT_CONTEXT_MOH | SHOUT_CONTEXT_CONFERENCE; + $contexts = $shout->getContexts($contextfilter); + foreach ($contexts as $context) { + $tmpcontexts[$context] = $context; + } + if (count($contexts)) { + $contexts = &$this->addVariable(_("System Context: "), 'syscontext', + 'enum', true, false, null, array($tmpcontexts, _("Choose:"))); + + require_once 'Horde/Form/Action.php'; + $contexts->setAction(Horde_Form_Action::factory('submit')); + } else { + $this->addVariable(_("System Context: "), 'syscontext', 'invalid', + true, false, null, + array(_("There are no system contexts which you can view."))); + } + } +} + +class SettingsForm extends Horde_Form { + + var $_useFormToken = false; + + function SettingsForm(&$vars) + { + global $shout, $syscontext; + + parent::Horde_Form($vars, _("Edit System Settings")); + + $cols = Shout::getContextTypes(); + $rows = array($syscontext); + $matrix = array(); + $matrix[0] = + Shout::integerToArray($shout->getContextProperties($syscontext)); + + $this->addVariable(_("Context Properties"), 'properties', 'matrix', + false, false, null, array($cols, $rows, $matrix, false)); + } + +} diff --git a/system.php b/system.php new file mode 100644 index 000000000..6d5eff42d --- /dev/null +++ b/system.php @@ -0,0 +1,68 @@ + + * + * See the enclosed file LICENSE for license information (GPL). If you + * did not receive this file, see http://www.horde.org/licenses/gpl.php. + */ +@define('SHOUT_BASE', dirname(__FILE__) . '/..'); +require_once SHOUT_BASE . '/lib/System.php'; +require_once 'Horde/Variables.php'; + +$RENDERER = &new Horde_Form_Renderer(); + +$empty = ''; +$beendone = 0; +$wereerrors = 0; + +$vars = &Variables::getDefaultVariables($empty); +$syscontext = Util::getFormData("syscontext"); +$formname = $vars->get('formname'); + +$title = _("System Settings"); + +$ContextForm = &Horde_Form::singleton('ContextForm', $vars); +$ContextFormValid = $ContextForm->validate($vars, true); + +// print_r($vars); +if ($ContextFormValid) { + $SettingsForm = &Horde_Form::singleton('SettingsForm', $vars); + + $SettingsForm->open($RENDERER, $vars, 'index.php', 'post'); + $SettingsFormValid = $SettingsForm->validate($vars, true); + // Render the original form readonly. + $ContextForm->preserve($vars); + $RENDERER->beginInactive($ContextForm->getTitle()); + $RENDERER->renderFormInactive($ContextForm, $vars); + $RENDERER->end(); + echo '
'; + + // Render the second stage form. + if ($formname != 'SettingsForm') { + $SettingsForm->clearValidation(); + } + $RENDERER->beginActive($SettingsForm->getTitle()); + $ContextForm->preserveVarByPost($vars, "section"); + $SettingsForm->preserve($vars); + $RENDERER->renderFormActive($SettingsForm, $vars); + $RENDERER->submit(); + $RENDERER->end(); + + $SettingsForm->close($RENDERER); + + $beendone = 1; +} else { + if ($formname != 'ContextForm') { + $ContextForm->clearValidation(); + } + $ContextForm->open($RENDERER, $vars, 'index.php', 'post'); + $ContextForm->preserveVarByPost($vars, "section"); + $ContextForm->preserve($vars); + $RENDERER->beginActive($ContextForm->getTitle()); + $RENDERER->renderFormActive($ContextForm, $vars); + $RENDERER->submit(); + $RENDERER->end(); + $ContextForm->close($RENDERER); +} -- 2.11.0