From 523f670cd67e3ca454b97b14a70724bcd2e78d9a Mon Sep 17 00:00:00 2001 From: Ben Klang Date: Wed, 31 Mar 2010 15:58:16 -0400 Subject: [PATCH] Shout: Reduce information stored in the session --- shout/admin.php | 2 +- shout/conferences.php | 2 +- shout/devices.php | 2 +- shout/dialplan.php | 2 +- shout/extensions.php | 2 +- shout/index.php | 14 +++++++++++++- shout/lib/Ajax/Application.php | 18 +++++++++--------- shout/lib/Application.php | 7 +++---- shout/lib/Forms/AccountForm.php | 4 ++-- shout/lib/Forms/ConferenceForm.php | 2 +- shout/lib/Forms/DeviceForm.php | 4 ++-- shout/lib/Forms/ExtensionForm.php | 6 +++--- shout/lib/Forms/MenuForm.php | 8 ++++---- shout/lib/Forms/RecordingForm.php | 4 ++-- shout/lib/Shout.php | 2 +- shout/recordings.php | 2 +- shout/templates/accounts/list.inc | 2 +- shout/templates/conferences/list.inc | 2 +- shout/templates/devices/list.inc | 2 +- shout/templates/extensions/list.inc | 2 +- shout/templates/recordings/list.inc | 2 +- 21 files changed, 51 insertions(+), 40 deletions(-) diff --git a/shout/admin.php b/shout/admin.php index 29002bd0f..74b73dafb 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']; +$curaccount = $_SESSION['shout']['curaccount']['code']; $RENDERER = new Horde_Form_Renderer(); diff --git a/shout/conferences.php b/shout/conferences.php index 16152bccd..ca99072b2 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']; +$curaccount = $_SESSION['shout']['curaccount']['code']; $action = Horde_Util::getFormData('action'); $vars = Horde_Variables::getDefaultVariables(); diff --git a/shout/devices.php b/shout/devices.php index e3562c81f..5642b7ddc 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']; +$curaccount = $_SESSION['shout']['curaccount']['code']; $action = Horde_Util::getFormData('action'); $vars = Horde_Variables::getDefaultVariables(); diff --git a/shout/dialplan.php b/shout/dialplan.php index 17828158a..b6c68a40d 100644 --- a/shout/dialplan.php +++ b/shout/dialplan.php @@ -16,7 +16,7 @@ require_once SHOUT_BASE . '/lib/Forms/MenuForm.php'; $action = Horde_Util::getFormData('action'); $menu = Horde_Util::getFormData('menu'); -$curaccount = $_SESSION['shout']['curaccount']; +$curaccount = $_SESSION['shout']['curaccount']['code']; $menus = $shout->storage->getMenus($curaccount); diff --git a/shout/extensions.php b/shout/extensions.php index ca72760c1..b70c092e2 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']; +$curaccount = $_SESSION['shout']['curaccount']['code']; $RENDERER = new Horde_Form_Renderer(); diff --git a/shout/index.php b/shout/index.php index 1d9bc94f3..f814a8302 100644 --- a/shout/index.php +++ b/shout/index.php @@ -8,5 +8,17 @@ * * @author Ben Klang */ +require_once dirname(__FILE__) . '/lib/Application.php'; +$shout = Horde_Registry::appInit('shout'); +$curaccount = $_SESSION['shout']['curaccount']; +if (empty($curaccount)) { + die("Permission denied."); +} +$menus = $shout->storage->getMenus($curaccount); -require dirname(__FILE__) . '/dialplan.php'; +if (empty($menus)) { + print_r($curaccount); +} else { + header('Location: ' . Horde::applicationUrl('dialplan.php', true)); + exit; +} \ No newline at end of file diff --git a/shout/lib/Ajax/Application.php b/shout/lib/Ajax/Application.php index e2eba7926..9fcf545fd 100644 --- a/shout/lib/Ajax/Application.php +++ b/shout/lib/Ajax/Application.php @@ -34,7 +34,7 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base { $vars = $this->_vars; $shout = $GLOBALS['registry']->getApiInstance('shout', 'application'); - $account = $_SESSION['shout']['curaccount']; + $account = $_SESSION['shout']['curaccount']['code']; try { $shout = $GLOBALS['registry']->getApiInstance('shout', 'application'); $shout->extensions->addDestination($account, $vars->extension, $vars->type, $vars->destination); @@ -54,7 +54,7 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base { $vars = $this->_vars; $shout = $GLOBALS['registry']->getApiInstance('shout', 'application'); - $account = $_SESSION['shout']['curaccount']; + $account = $_SESSION['shout']['curaccount']['code']; try { // FIXME: Use Form? $shout = $GLOBALS['registry']->getApiInstance('shout', 'application'); @@ -76,7 +76,7 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base try { $vars = $this->_vars; $shout = $GLOBALS['registry']->getApiInstance('shout', 'application'); - $account = $_SESSION['shout']['curaccount']; + $account = $_SESSION['shout']['curaccount']['code']; return $shout->extensions->getExtensions($account); } catch (Exception $e) { //FIXME: Create a way to notify the user of the failure. @@ -90,7 +90,7 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base try { $vars = $this->_vars; $shout = $GLOBALS['registry']->getApiInstance('shout', 'application'); - $account = $_SESSION['shout']['curaccount']; + $account = $_SESSION['shout']['curaccount']['code']; return $shout->devices->getDevices($account); } catch (Exception $e) { //FIXME: Create a way to notify the user of the failure. @@ -106,7 +106,7 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base { try { $shout = $GLOBALS['registry']->getApiInstance('shout', 'application'); - $account = $_SESSION['shout']['curaccount']; + $account = $_SESSION['shout']['curaccount']['code']; $menus = $shout->storage->getMenus($account); if (empty($menus)) { return false; @@ -127,7 +127,7 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base { try { $shout = $GLOBALS['registry']->getApiInstance('shout', 'application'); - $account = $_SESSION['shout']['curaccount']; + $account = $_SESSION['shout']['curaccount']['code']; $menu = $this->_vars->get('menu'); if (empty($menu)) { throw new Shout_Exception('Must specify a menu to delete.'); @@ -145,7 +145,7 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base { try { $shout = $GLOBALS['registry']->getApiInstance('shout', 'application'); - $account = $_SESSION['shout']['curaccount']; + $account = $_SESSION['shout']['curaccount']['code']; return $shout->storage->getConferences($account); } catch (Exception $e) { //FIXME: Create a way to notify the user of the failure. @@ -158,7 +158,7 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base { try { $shout = $GLOBALS['registry']->getApiInstance('shout', 'application'); - $account = $_SESSION['shout']['curaccount']; + $account = $_SESSION['shout']['curaccount']['code']; $vars = &$this->_vars; $info = array( 'name' => $vars->get('name'), @@ -182,7 +182,7 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base if (!($action = $vars->get('action'))) { throw new Shout_Exception("Invalid action requested."); } - $account = $_SESSION['shout']['curaccount']; + $account = $_SESSION['shout']['curaccount']['code']; $digit = $vars->get('digit'); $menu = $vars->get('menu'); $action = $vars->get('action'); diff --git a/shout/lib/Application.php b/shout/lib/Application.php index a623bf0dd..cc5af4c87 100644 --- a/shout/lib/Application.php +++ b/shout/lib/Application.php @@ -96,7 +96,7 @@ class Shout_Application extends Horde_Registry_Application $account = Horde_Util::getFormData('account'); if (empty($account) && !empty($_SESSION['shout']['curaccount'])) { - $account = $_SESSION['shout']['curaccount']; + $account = $_SESSION['shout']['curaccount']['code']; } if (!empty($account) && !in_array($account, array_keys($accounts))) { @@ -116,8 +116,7 @@ class Shout_Application extends Horde_Registry_Application } } - $_SESSION['shout']['accounts'] = $accounts; - $_SESSION['shout']['curaccount'] = $account; + $_SESSION['shout']['curaccount'] = $accounts[$account]; } /** @@ -160,7 +159,7 @@ class Shout_Application extends Horde_Registry_Application public function getRecordings() { - $account = $_SESSION['shout']['curaccount']; + $account = $_SESSION['shout']['curaccount']['code']; $rlist = $this->vfs->listFolder($account); // In Asterisk, filenames the same basename and different extension are diff --git a/shout/lib/Forms/AccountForm.php b/shout/lib/Forms/AccountForm.php index 74ba7dadb..0ddb09c33 100644 --- a/shout/lib/Forms/AccountForm.php +++ b/shout/lib/Forms/AccountForm.php @@ -22,7 +22,7 @@ class AccountDetailsForm extends Horde_Form { */ function __construct(&$vars) { - $account = $_SESSION['shout']['curaccount']; + $account = $_SESSION['shout']['curaccount']['code']; $action = $vars->get('action'); if ($action == 'edit') { $formtitle = "Edit Account"; @@ -31,7 +31,7 @@ class AccountDetailsForm extends Horde_Form { $formtitle = "Add Account"; } - $accountname = $_SESSION['shout']['accounts'][$curaccount]['name']; + $accountname = $_SESSION['shout']['curaccount']['name']; $title = sprintf(_("$formtitle %s"), $accountname); parent::__construct($vars, $title); diff --git a/shout/lib/Forms/ConferenceForm.php b/shout/lib/Forms/ConferenceForm.php index 46d6b61cc..48a520753 100644 --- a/shout/lib/Forms/ConferenceForm.php +++ b/shout/lib/Forms/ConferenceForm.php @@ -24,7 +24,7 @@ class ConferenceDetailsForm extends Horde_Form { $edit = false; } - $curaccount = $_SESSION['shout']['curaccount']; + $curaccount = $_SESSION['shout']['curaccount']['code']; $accountname = $vars->account; $title = sprintf(_("$formtitle")); parent::__construct($vars, $title); diff --git a/shout/lib/Forms/DeviceForm.php b/shout/lib/Forms/DeviceForm.php index 7f4da6504..0523f575d 100644 --- a/shout/lib/Forms/DeviceForm.php +++ b/shout/lib/Forms/DeviceForm.php @@ -22,8 +22,8 @@ class DeviceDetailsForm extends Horde_Form { $edit = false; } - $curaccount = $_SESSION['shout']['curaccount']; - $accountname = $_SESSION['shout']['accounts'][$curaccount]['name']; + $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 ea110ec0d..0e0b72e29 100644 --- a/shout/lib/Forms/ExtensionForm.php +++ b/shout/lib/Forms/ExtensionForm.php @@ -21,7 +21,7 @@ class ExtensionDetailsForm extends Horde_Form { */ function __construct(&$vars) { - $curaccount = $_SESSION['shout']['curaccount']; + $curaccount = $_SESSION['shout']['curaccount']['code']; $action = $vars->get('action'); if ($action == 'edit') { $formtitle = "Edit User"; @@ -29,7 +29,7 @@ class ExtensionDetailsForm extends Horde_Form { $formtitle = "Add User"; } - $accountname = $_SESSION['shout']['accounts'][$curaccount]['name']; + $accountname = $_SESSION['shout']['curaccount']['name']; $title = sprintf(_("$formtitle - Account: %s"), $accountname); parent::__construct($vars, $title); @@ -82,7 +82,7 @@ class ExtensionDeleteForm extends Horde_Form $account = $vars->get('account'); $title = _("Delete Extension %s - Account: %s"); - $title = sprintf($title, $extension, $_SESSION['shout']['accounts'][$account]['name']); + $title = sprintf($title, $extension, $_SESSION['shout']['curaccount']['name']); parent::__construct($vars, $title); $this->addHidden('', 'account', 'text', true); diff --git a/shout/lib/Forms/MenuForm.php b/shout/lib/Forms/MenuForm.php index 2bb810f9d..4b860052e 100644 --- a/shout/lib/Forms/MenuForm.php +++ b/shout/lib/Forms/MenuForm.php @@ -22,8 +22,8 @@ class MenuForm extends Horde_Form { $edit = false; } - $curaccount = $_SESSION['shout']['curaccount']; - $accountname = $_SESSION['shout']['accounts'][$curaccount]['name']; + $curaccount = $_SESSION['shout']['curaccount']['code']; + $accountname = $_SESSION['shout']['curaccount']['name']; $title = sprintf(_("%s - Account: %s"), $formtitle, $accountname); parent::__construct($vars, $title); @@ -52,7 +52,7 @@ class MenuForm extends Horde_Form { { $shout = $GLOBALS['registry']->getApiInstance('shout', 'application'); - $account = $_SESSION['shout']['curaccount']; + $account = $_SESSION['shout']['curaccount']['code']; $details = array( 'name' => $this->_vars->get('name'), @@ -77,7 +77,7 @@ class DeviceMenuForm extends Horde_Form $account = $vars->get('account'); $title = _("Delete Menu %s - Account: %s"); - $title = sprintf($title, $menu, $_SESSION['shout']['accounts'][$account]['name']); + $title = sprintf($title, $menu, $_SESSION['shout']['curaccount']['name']); parent::__construct($vars, $title); $this->setButtons(array(_("Delete"), _("Cancel"))); diff --git a/shout/lib/Forms/RecordingForm.php b/shout/lib/Forms/RecordingForm.php index 50b58e162..90b3e63cc 100644 --- a/shout/lib/Forms/RecordingForm.php +++ b/shout/lib/Forms/RecordingForm.php @@ -16,7 +16,7 @@ class RecordingDetailsForm extends Horde_Form { $formtitle = "Create Recording"; - $curaccount = $_SESSION['shout']['curaccount']; + $curaccount = $_SESSION['shout']['curaccount']['code']; $accountname = $vars->account; $title = sprintf(_("$formtitle")); parent::__construct($vars, $title); @@ -49,7 +49,7 @@ class ConferenceDeleteForm extends Horde_Form $account = $vars->get('account'); $title = _("FIXME Delete Recording %s - Account: %s"); - $title = sprintf($title, $devid, $_SESSION['shout']['accounts'][$account]['name']); + $title = sprintf($title, $devid, $_SESSION['shout']['curaccount']['name']); parent::__construct($vars, $title); $this->addHidden('', 'account', 'text', true); diff --git a/shout/lib/Shout.php b/shout/lib/Shout.php index 03564617c..fcb705cb7 100644 --- a/shout/lib/Shout.php +++ b/shout/lib/Shout.php @@ -143,7 +143,7 @@ class Shout static public function getMenuActions() { $shout = $GLOBALS['registry']->getApiInstance('shout', 'application'); - $account = $_SESSION['shout']['curaccount']; + $account = $_SESSION['shout']['curaccount']['code']; return array( 'jump' => array( diff --git a/shout/recordings.php b/shout/recordings.php index 5607e4b0c..4ab4db920 100644 --- a/shout/recordings.php +++ b/shout/recordings.php @@ -15,7 +15,7 @@ $shout = Horde_Registry::appInit('shout'); require_once SHOUT_BASE . '/lib/Forms/RecordingForm.php'; $action = Horde_Util::getFormData('action'); -$curaccount = $_SESSION['shout']['curaccount']; +$curaccount = $_SESSION['shout']['curaccount']['code']; $recordings = $shout->storage->getRecordings($curaccount); switch($action) { diff --git a/shout/templates/accounts/list.inc b/shout/templates/accounts/list.inc index 0a9047a80..d15573505 100644 --- a/shout/templates/accounts/list.inc +++ b/shout/templates/accounts/list.inc @@ -1,5 +1,5 @@
- Account: + Account:
diff --git a/shout/templates/conferences/list.inc b/shout/templates/conferences/list.inc index 7de64cc03..c8b7eebd1 100644 --- a/shout/templates/conferences/list.inc +++ b/shout/templates/conferences/list.inc @@ -1,5 +1,5 @@
- Account: + Account:
diff --git a/shout/templates/devices/list.inc b/shout/templates/devices/list.inc index a56ec7654..a9482ef14 100644 --- a/shout/templates/devices/list.inc +++ b/shout/templates/devices/list.inc @@ -1,5 +1,5 @@
- Account: + Account:
diff --git a/shout/templates/extensions/list.inc b/shout/templates/extensions/list.inc index 885a03a4f..a0cc0424b 100644 --- a/shout/templates/extensions/list.inc +++ b/shout/templates/extensions/list.inc @@ -1,5 +1,5 @@
- Account: + Account:
diff --git a/shout/templates/recordings/list.inc b/shout/templates/recordings/list.inc index 82769e811..2154ee0ba 100644 --- a/shout/templates/recordings/list.inc +++ b/shout/templates/recordings/list.inc @@ -1,5 +1,5 @@
- Account: + Account:
-- 2.11.0