--- /dev/null
+<?php
+/**
+ * ContextForm Class
+ *
+ * $Horde: shout/lib/System.php,v 1.0 2005/07/07 23:48:11 ben Exp $
+ *
+ * Copyright 2005 Ben Klang <ben@alkaloid.net>
+ *
+ * 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 <ben@alkaloid.net>
+ * @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));
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * $Horde: shout/system.php,v 1.0 2005/07/07 11:36:01 ben Exp $
+ *
+ * Copyright 2005 Ben Klang <ben@alkaloid.net>
+ *
+ * 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 '<br />';
+
+ // 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);
+}