From cb4ccee883013b0202c042dd356e18da1fe64483 Mon Sep 17 00:00:00 2001 From: Ben Klang Date: Wed, 31 Mar 2010 18:02:11 -0400 Subject: [PATCH] Shout: One more round of tweaks to handling curaccount --- shout/admin.php | 8 ++++---- shout/conferences.php | 12 ++++++------ shout/devices.php | 12 ++++++------ shout/dialplan.php | 14 +++++++------- shout/extensions.php | 10 +++++----- shout/lib/Forms/ConferenceForm.php | 9 ++++----- shout/lib/Forms/DeviceForm.php | 1 - shout/lib/Forms/ExtensionForm.php | 1 - shout/lib/Forms/MenuForm.php | 3 +-- shout/lib/Forms/RecordingForm.php | 1 - shout/recordings.php | 8 ++++---- shout/templates/menu.inc | 2 +- 12 files changed, 38 insertions(+), 43 deletions(-) diff --git a/shout/admin.php b/shout/admin.php index 74b73dafb..023f36ed3 100644 --- a/shout/admin.php +++ b/shout/admin.php @@ -15,7 +15,7 @@ $shout = Horde_Registry::appInit('shout'); require_once SHOUT_BASE . '/lib/Forms/AccountForm.php'; $action = Horde_Util::getFormData('action'); -$curaccount = $_SESSION['shout']['curaccount']['code']; +$curaccount = $_SESSION['shout']['curaccount']; $RENDERER = new Horde_Form_Renderer(); @@ -25,7 +25,7 @@ switch ($action) { case 'add': case 'edit': $vars = Horde_Variables::getDefaultVariables(); - $vars->set('account', $curaccount); + $vars->set('account', $curaccount['code']); $Form = new AccountDetailsForm($vars); if ($Form->isSubmitted() && $Form->validate($vars, true)) { @@ -58,7 +58,7 @@ case 'delete': $extension = Horde_Util::getFormData('extension'); $vars = Horde_Variables::getDefaultVariables(); - $vars->set('account', $curaccount); + $vars->set('account', $curaccount['code']); $Form = new ExtensionDeleteForm($vars); $FormValid = $Form->validate($vars, true); @@ -77,7 +77,7 @@ case 'delete': } $vars = Horde_Variables::getDefaultVariables(array()); - $vars->set('account', $curaccount); + $vars->set('account', $curaccount['code']); $Form = new ExtensionDeleteForm($vars); break; diff --git a/shout/conferences.php b/shout/conferences.php index ca99072b2..39daec33f 100644 --- a/shout/conferences.php +++ b/shout/conferences.php @@ -14,7 +14,7 @@ $shout = Horde_Registry::appInit('shout'); require_once SHOUT_BASE . '/lib/Forms/ConferenceForm.php'; -$curaccount = $_SESSION['shout']['curaccount']['code']; +$curaccount = $_SESSION['shout']['curaccount']; $action = Horde_Util::getFormData('action'); $vars = Horde_Variables::getDefaultVariables(); @@ -26,7 +26,7 @@ switch ($action) { case 'add': case 'edit': $vars = Horde_Variables::getDefaultVariables(); - $vars->set('account', $curaccount); + $vars->set('account', $curaccount['code']); $Form = new ConferenceDetailsForm($vars); // Show the list if the save was successful, otherwise back to edit. @@ -49,7 +49,7 @@ case 'edit': // Create a new add/edit form $roomno = Horde_Util::getFormData('roomno'); - $conferences = $shout->storage->getConferences($curaccount); + $conferences = $shout->storage->getConferences($curaccount['code']); $vars = new Horde_Variables($conferences[$roomno]); $vars->set('action', $action); @@ -65,7 +65,7 @@ case 'delete': $devid = Horde_Util::getFormData('devid'); $vars = Horde_Variables::getDefaultVariables(); - $vars->set('account', $curaccount); + $vars->set('account', $curaccount['code']); $Form = new DeviceDeleteForm($vars); $FormValid = $Form->validate($vars, true); @@ -83,7 +83,7 @@ case 'delete': } $vars = Horde_Variables::getDefaultVariables(array()); - $vars->set('account', $curaccount); + $vars->set('account', $curaccount['code']); $Form = new DeviceDeleteForm($vars); break; @@ -95,7 +95,7 @@ default: // Fetch the (possibly updated) list of extensions try { - $conferences = $shout->devices->getConferences($curaccount); + $conferences = $shout->devices->getConferences($curaccount['code']); } catch (Exception $e) { $notification->push($e); $devices = array(); diff --git a/shout/devices.php b/shout/devices.php index 5642b7ddc..fc6e0b54c 100644 --- a/shout/devices.php +++ b/shout/devices.php @@ -14,7 +14,7 @@ $shout = Horde_Registry::appInit('shout'); require_once SHOUT_BASE . '/lib/Forms/DeviceForm.php'; -$curaccount = $_SESSION['shout']['curaccount']['code']; +$curaccount = $_SESSION['shout']['curaccount']; $action = Horde_Util::getFormData('action'); $vars = Horde_Variables::getDefaultVariables(); @@ -26,7 +26,7 @@ switch ($action) { case 'add': case 'edit': $vars = Horde_Variables::getDefaultVariables(); - $vars->set('account', $curaccount); + $vars->set('account', $curaccount['code']); $Form = new DeviceDetailsForm($vars); // Show the list if the save was successful, otherwise back to edit. @@ -51,7 +51,7 @@ case 'edit': // Create a new add/edit form $devid = Horde_Util::getFormData('devid'); - $devices = $shout->devices->getDevices($curaccount); + $devices = $shout->devices->getDevices($curaccount['code']); $vars = new Horde_Variables($devices[$devid]); $vars->set('action', $action); @@ -66,7 +66,7 @@ case 'delete': $devid = Horde_Util::getFormData('devid'); $vars = Horde_Variables::getDefaultVariables(); - $vars->set('account', $curaccount); + $vars->set('account', $curaccount['code']); $Form = new DeviceDeleteForm($vars); $FormValid = $Form->validate($vars, true); @@ -84,7 +84,7 @@ case 'delete': } $vars = Horde_Variables::getDefaultVariables(array()); - $vars->set('account', $curaccount); + $vars->set('account', $curaccount['code']); $Form = new DeviceDeleteForm($vars); break; @@ -97,7 +97,7 @@ default: // Fetch the (possibly updated) list of extensions try { - $devices = $shout->devices->getDevices($curaccount); + $devices = $shout->devices->getDevices($curaccount['code']); } catch (Exception $e) { $notification->push($e); $devices = array(); diff --git a/shout/dialplan.php b/shout/dialplan.php index b6c68a40d..c8b86e1d3 100644 --- a/shout/dialplan.php +++ b/shout/dialplan.php @@ -16,14 +16,14 @@ require_once SHOUT_BASE . '/lib/Forms/MenuForm.php'; $action = Horde_Util::getFormData('action'); $menu = Horde_Util::getFormData('menu'); -$curaccount = $_SESSION['shout']['curaccount']['code']; +$curaccount = $_SESSION['shout']['curaccount']; -$menus = $shout->storage->getMenus($curaccount); +$menus = $shout->storage->getMenus($curaccount['code']); switch($action) { case 'add': $vars = Horde_Variables::getDefaultVariables(); - $vars->set('account', $curaccount); + $vars->set('account', $curaccount['code']); $Form = new MenuForm($vars); if ($Form->isSubmitted() && $Form->validate($vars, true)) { @@ -32,7 +32,7 @@ case 'add': $Form->execute(); $notification->push(_("Menu added."), 'horde.success'); - $menus = $shout->storage->getMenus($curaccount); + $menus = $shout->storage->getMenus($curaccount['code']); $action = 'edit'; } catch (Exception $e) { @@ -59,9 +59,9 @@ default: // after a successful add. if ($action == 'edit') { try { - $destinations = $shout->extensions->getExtensions($curaccount); - $conferences = $shout->storage->getConferences($curaccount); - $recordings = $shout->storage->getRecordings($curaccount); + $destinations = $shout->extensions->getExtensions($curaccount['code']); + $conferences = $shout->storage->getConferences($curaccount['code']); + $recordings = $shout->storage->getRecordings($curaccount['code']); // If any of these are empty, we need to coerce them to null. // Otherwise we end up with a Prototype.js $H([]) (Hash of an empty // Array) which causes confusion inside the library. diff --git a/shout/extensions.php b/shout/extensions.php index b70c092e2..9d1aad81d 100644 --- a/shout/extensions.php +++ b/shout/extensions.php @@ -15,7 +15,7 @@ $shout = Horde_Registry::appInit('shout'); require_once SHOUT_BASE . '/lib/Forms/ExtensionForm.php'; $action = Horde_Util::getFormData('action'); -$curaccount = $_SESSION['shout']['curaccount']['code']; +$curaccount = $_SESSION['shout']['curaccount']; $RENDERER = new Horde_Form_Renderer(); @@ -26,7 +26,7 @@ switch ($action) { case 'add': case 'edit': $vars = Horde_Variables::getDefaultVariables(); - $vars->set('account', $curaccount); + $vars->set('account', $curaccount['code']); $Form = new ExtensionDetailsForm($vars); if ($Form->isSubmitted() && $Form->validate($vars, true)) { @@ -63,7 +63,7 @@ case 'delete': $extension = Horde_Util::getFormData('extension'); $vars = Horde_Variables::getDefaultVariables(); - $vars->set('account', $curaccount); + $vars->set('account', $curaccount['code']); $Form = new ExtensionDeleteForm($vars); $FormValid = $Form->validate($vars, true); @@ -82,7 +82,7 @@ case 'delete': } $vars = Horde_Variables::getDefaultVariables(array()); - $vars->set('account', $curaccount); + $vars->set('account', $curaccount['code']); $Form = new ExtensionDeleteForm($vars); break; @@ -96,7 +96,7 @@ default: // Fetch the (possibly updated) list of extensions try { - $extensions = $shout->extensions->getExtensions($curaccount); + $extensions = $shout->extensions->getExtensions($curaccount['code']); } catch (Exception $e) { $notification->push($e); $extensions = array(); diff --git a/shout/lib/Forms/ConferenceForm.php b/shout/lib/Forms/ConferenceForm.php index 48a520753..739c09808 100644 --- a/shout/lib/Forms/ConferenceForm.php +++ b/shout/lib/Forms/ConferenceForm.php @@ -13,20 +13,19 @@ class ConferenceDetailsForm extends Horde_Form { function __construct(&$vars) { + $accountname = $_SESSION['shout']['curaccount']['name']; if ($vars->exists('roomno')) { - $formtitle = "Edit Conference Room"; + $title = sprintf(_("Edit Conference Room - Account: %s"), $accountname); $roomno = $vars->get('roomno'); $this->addHidden('', 'oldroomno', 'text', true); $vars->set('oldroomno', $roomno); $edit = true; } else { - $formtitle = "Create Conference Room"; + $title = sprintf(_("Create Conference Room - Account: %s"), $accountname); $edit = false; } - $curaccount = $_SESSION['shout']['curaccount']['code']; - $accountname = $vars->account; - $title = sprintf(_("$formtitle")); + ; parent::__construct($vars, $title); $this->addHidden('', 'action', 'text', true); diff --git a/shout/lib/Forms/DeviceForm.php b/shout/lib/Forms/DeviceForm.php index 0523f575d..ed568ca8c 100644 --- a/shout/lib/Forms/DeviceForm.php +++ b/shout/lib/Forms/DeviceForm.php @@ -22,7 +22,6 @@ class DeviceDetailsForm extends Horde_Form { $edit = false; } - $curaccount = $_SESSION['shout']['curaccount']['code']; $accountname = $_SESSION['shout']['curaccount']['name']; $title = sprintf(_("$formtitle - Account: %s"), $accountname); parent::__construct($vars, $title); diff --git a/shout/lib/Forms/ExtensionForm.php b/shout/lib/Forms/ExtensionForm.php index 0e0b72e29..0fa681495 100644 --- a/shout/lib/Forms/ExtensionForm.php +++ b/shout/lib/Forms/ExtensionForm.php @@ -21,7 +21,6 @@ class ExtensionDetailsForm extends Horde_Form { */ function __construct(&$vars) { - $curaccount = $_SESSION['shout']['curaccount']['code']; $action = $vars->get('action'); if ($action == 'edit') { $formtitle = "Edit User"; diff --git a/shout/lib/Forms/MenuForm.php b/shout/lib/Forms/MenuForm.php index 4b860052e..d64c948a2 100644 --- a/shout/lib/Forms/MenuForm.php +++ b/shout/lib/Forms/MenuForm.php @@ -22,7 +22,6 @@ class MenuForm extends Horde_Form { $edit = false; } - $curaccount = $_SESSION['shout']['curaccount']['code']; $accountname = $_SESSION['shout']['curaccount']['name']; $title = sprintf(_("%s - Account: %s"), $formtitle, $accountname); parent::__construct($vars, $title); @@ -37,7 +36,7 @@ class MenuForm extends Horde_Form { $this->addVariable(_("Description"), 'description', 'text', false); $shout = $GLOBALS['registry']->getApiInstance('shout', 'application'); - $recordings = $shout->storage->getRecordings($curaccount); + $recordings = $shout->storage->getRecordings($_SESSION['shout']['curaccount']['code']); $list = array(); foreach ($recordings as $id => $info) { $list[$id] = $info['filename']; diff --git a/shout/lib/Forms/RecordingForm.php b/shout/lib/Forms/RecordingForm.php index 90b3e63cc..984ad83d9 100644 --- a/shout/lib/Forms/RecordingForm.php +++ b/shout/lib/Forms/RecordingForm.php @@ -16,7 +16,6 @@ class RecordingDetailsForm extends Horde_Form { $formtitle = "Create Recording"; - $curaccount = $_SESSION['shout']['curaccount']['code']; $accountname = $vars->account; $title = sprintf(_("$formtitle")); parent::__construct($vars, $title); diff --git a/shout/recordings.php b/shout/recordings.php index 4ab4db920..a3516a0f7 100644 --- a/shout/recordings.php +++ b/shout/recordings.php @@ -15,13 +15,13 @@ $shout = Horde_Registry::appInit('shout'); require_once SHOUT_BASE . '/lib/Forms/RecordingForm.php'; $action = Horde_Util::getFormData('action'); -$curaccount = $_SESSION['shout']['curaccount']['code']; -$recordings = $shout->storage->getRecordings($curaccount); +$curaccount = $_SESSION['shout']['curaccount']; +$recordings = $shout->storage->getRecordings($curaccount['code']); switch($action) { case 'add': $vars = Horde_Variables::getDefaultVariables(); - $vars->set('account', $curaccount); + $vars->set('account', $curaccount['code']); $Form = new RecordingDetailsForm($vars); if ($Form->isSubmitted() && $Form->validate($vars, true)) { @@ -30,7 +30,7 @@ case 'add': $Form->execute(); $notification->push(_("Recording added."), 'horde.success'); - $recordings = $shout->storage->getRecordings($curaccount); + $recordings = $shout->storage->getRecordings($curaccount['code']); $action = 'list'; } catch (Exception $e) { $notification->push($e); diff --git a/shout/templates/menu.inc b/shout/templates/menu.inc index 5f948e431..5564d095c 100644 --- a/shout/templates/menu.inc +++ b/shout/templates/menu.inc @@ -35,7 +35,7 @@ function accountSubmit(clear) $info) { print "\n"; -- 2.11.0