From ca281d00a2292b79dce6d6781211df9c07b56a00 Mon Sep 17 00:00:00 2001 From: Ben Klang Date: Fri, 2 Apr 2010 15:34:04 -0400 Subject: [PATCH] Shout: Get rid of actions in favor of AJAX --- shout/extensions.php | 75 +--------------------- .../{extensions/list.inc => extensions.inc.php} | 39 ++++++++--- shout/templates/extensions/delete.inc | 3 - shout/templates/extensions/edit.inc | 10 --- 4 files changed, 32 insertions(+), 95 deletions(-) rename shout/templates/{extensions/list.inc => extensions.inc.php} (94%) delete mode 100644 shout/templates/extensions/delete.inc delete mode 100644 shout/templates/extensions/edit.inc diff --git a/shout/extensions.php b/shout/extensions.php index 073ebe918..e9b3acf1e 100644 --- a/shout/extensions.php +++ b/shout/extensions.php @@ -14,7 +14,6 @@ $shout = Horde_Registry::appInit('shout'); require_once SHOUT_BASE . '/lib/Forms/ExtensionForm.php'; -$action = Horde_Util::getFormData('action'); $curaccount = $_SESSION['shout']['curaccount']; $RENDERER = new Horde_Form_Renderer(); @@ -22,77 +21,6 @@ $RENDERER = new Horde_Form_Renderer(); $section = 'extensions'; $title = _("Extensions: "); -switch ($action) { -case 'add': -case 'edit': - $vars = Horde_Variables::getDefaultVariables(); - $vars->set('account', $curaccount['code']); - $Form = new ExtensionDetailsForm($vars); - - if ($Form->isSubmitted() && $Form->validate($vars, true)) { - // Form is Valid and Submitted - try { - $Form->execute(); - $notification->push(_("Extension information updated."), - 'horde.success'); - $action = 'list'; - } catch (Exception $e) { - $notification->push($e); - } - break; - } elseif ($Form->isSubmitted()) { - $notification->push(_("Problem processing the form. Please check below and try again."), 'horde.warning'); - } - - // Create a new add/edit form - $extension = Horde_Util::getFormData('extension'); - $extensions = $shout->extensions->getExtensions($curaccount['code']); - $vars = new Horde_Variables($extensions[$extension]); - if ($action == 'edit') { - $vars->set('oldextension', $extension); - } - $vars->set('action', $action); - //$Form = new ExtensionDetailsForm($vars); - // Make sure we get the right template below. - $action = 'edit'; - - break; - -case 'delete': - $title .= sprintf(_("Delete Extension %s"), $extension); - $extension = Horde_Util::getFormData('extension'); - - $vars = Horde_Variables::getDefaultVariables(); - $vars->set('account', $curaccount['code']); - $Form = new ExtensionDeleteForm($vars); - - $FormValid = $Form->validate($vars, true); - - if ($Form->isSubmitted() && $FormValid) { - try { - $Form->execute(); - $notification->push(_("Extension Deleted.")); - $action = 'list'; - } catch (Exception $e) { - $notification->push($e); - } - } elseif ($Form->isSubmitted()) { - // Submitted but not valid - $notification->push(_("Problem processing the form. Please check below and try again."), 'horde.warning'); - } - - $vars = Horde_Variables::getDefaultVariables(array()); - $vars->set('account', $curaccount['code']); - $Form = new ExtensionDeleteForm($vars); - - break; - -case 'list': -default: - $action = 'list'; - $title .= _("List Users"); -} - // Fetch the (possibly updated) list of extensions try { @@ -104,12 +32,13 @@ try { Horde::addScriptFile('stripe.js', 'horde'); Horde::addScriptFile('prototype.js', 'horde'); +Horde::addScriptFile('scriptaculous.js', 'horde'); require SHOUT_TEMPLATES . '/common-header.inc'; require SHOUT_TEMPLATES . '/menu.inc'; $notification->notify(); -require SHOUT_TEMPLATES . '/extensions/' . $action . '.inc'; +require SHOUT_TEMPLATES . '/extensions.inc.php'; require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/shout/templates/extensions/list.inc b/shout/templates/extensions.inc.php similarity index 94% rename from shout/templates/extensions/list.inc rename to shout/templates/extensions.inc.php index 920713ee5..955827112 100644 --- a/shout/templates/extensions/list.inc +++ b/shout/templates/extensions.inc.php @@ -22,7 +22,10 @@ ?> - + '; + ?> +
-
Add Extension
+
+
Add Extension
+ @@ -85,9 +91,10 @@
* Full Name
-
- -
+
+ +
+
+ \ No newline at end of file diff --git a/shout/templates/extensions/delete.inc b/shout/templates/extensions/delete.inc deleted file mode 100644 index 217ef0607..000000000 --- a/shout/templates/extensions/delete.inc +++ /dev/null @@ -1,3 +0,0 @@ -Extension: get('extension'); ?>
-renderActive($RENDERER, $vars, Horde::applicationUrl('extensions.php'), 'post'); diff --git a/shout/templates/extensions/edit.inc b/shout/templates/extensions/edit.inc deleted file mode 100644 index ce74225d7..000000000 --- a/shout/templates/extensions/edit.inc +++ /dev/null @@ -1,10 +0,0 @@ -renderActive($RENDERER, $vars, Horde::applicationUrl('extensions.php'), 'post'); - -if ($vars->get('action') == 'edit') { - $deleteUrl = Horde::applicationUrl('extensions.php'); - $params = array ('action' => 'delete', - 'extension' => $extension); - $deleteUrl = Horde_Util::addParameter($deleteUrl, $params); - echo 'Delete Extension'; -} -- 2.11.0