Shout: Reduce information stored in the session
authorBen Klang <ben@alkaloid.net>
Wed, 31 Mar 2010 19:58:16 +0000 (15:58 -0400)
committerBen Klang <ben@alkaloid.net>
Wed, 31 Mar 2010 22:26:04 +0000 (18:26 -0400)
21 files changed:
shout/admin.php
shout/conferences.php
shout/devices.php
shout/dialplan.php
shout/extensions.php
shout/index.php
shout/lib/Ajax/Application.php
shout/lib/Application.php
shout/lib/Forms/AccountForm.php
shout/lib/Forms/ConferenceForm.php
shout/lib/Forms/DeviceForm.php
shout/lib/Forms/ExtensionForm.php
shout/lib/Forms/MenuForm.php
shout/lib/Forms/RecordingForm.php
shout/lib/Shout.php
shout/recordings.php
shout/templates/accounts/list.inc
shout/templates/conferences/list.inc
shout/templates/devices/list.inc
shout/templates/extensions/list.inc
shout/templates/recordings/list.inc

index 29002bd..74b73da 100644 (file)
@@ -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();
 
index 16152bc..ca99072 100644 (file)
@@ -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();
 
index e3562c8..5642b7d 100644 (file)
@@ -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();
 
index 1782815..b6c68a4 100644 (file)
@@ -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);
 
index ca72760..b70c092 100644 (file)
@@ -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();
 
index 1d9bc94..f814a83 100644 (file)
@@ -8,5 +8,17 @@
  *
  * @author  Ben Klang <ben@alkaloid.net>
  */
+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
index e2eba79..9fcf545 100644 (file)
@@ -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');
index a623bf0..cc5af4c 100644 (file)
@@ -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
index 74ba7da..0ddb09c 100644 (file)
@@ -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);
 
index 46d6b61..48a5207 100644 (file)
@@ -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);
index 7f4da65..0523f57 100644 (file)
@@ -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);
 
index ea110ec..0e0b72e 100644 (file)
@@ -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);
index 2bb810f..4b86005 100644 (file)
@@ -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")));
index 50b58e1..90b3e63 100644 (file)
@@ -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);
index 0356461..fcb705c 100644 (file)
@@ -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(
index 5607e4b..4ab4db9 100644 (file)
@@ -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) {
index 0a9047a..d155735 100644 (file)
@@ -1,5 +1,5 @@
 <div class="header">
-    Account: <?php echo $_SESSION['shout']['accounts'][$curaccount]['name']; ?>
+    Account: <?php echo $_SESSION['shout']['curaccount']['name']; ?>
 </div>
 
 <div id="extensionList">
index 7de64cc..c8b7eeb 100644 (file)
@@ -1,5 +1,5 @@
 <div class="header">
-    Account: <?php echo $_SESSION['shout']['accounts'][$curaccount]['name']; ?>
+    Account: <?php echo $_SESSION['shout']['curaccount']['name']; ?>
 </div>
 
 <div id="conferenceList">
index a56ec76..a9482ef 100644 (file)
@@ -1,5 +1,5 @@
 <div class="header">
-    Account: <?php echo $_SESSION['shout']['accounts'][$curaccount]['name']; ?>
+    Account: <?php echo $_SESSION['shout']['curaccount']['name']; ?>
 </div>
 
 <div id="extensionList">
index 885a03a..a0cc042 100644 (file)
@@ -1,5 +1,5 @@
 <div class="header">
-    Account: <?php echo $_SESSION['shout']['accounts'][$curaccount]['name']; ?>
+    Account: <?php echo $_SESSION['shout']['curaccount']['name']; ?>
 </div>
 
 <div id="extensionList">
index 82769e8..2154ee0 100644 (file)
@@ -1,5 +1,5 @@
 <div class="header">
-    Account: <?php echo $_SESSION['shout']['accounts'][$curaccount]['name']; ?>
+    Account: <?php echo $_SESSION['shout']['curaccount']['name']; ?>
 </div>
 
 <div id="extensionList">