Shout: One more round of tweaks to handling curaccount
authorBen Klang <ben@alkaloid.net>
Wed, 31 Mar 2010 22:02:11 +0000 (18:02 -0400)
committerBen Klang <ben@alkaloid.net>
Wed, 31 Mar 2010 22:26:04 +0000 (18:26 -0400)
12 files changed:
shout/admin.php
shout/conferences.php
shout/devices.php
shout/dialplan.php
shout/extensions.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/recordings.php
shout/templates/menu.inc

index 74b73da..023f36e 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']['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;
index ca99072..39daec3 100644 (file)
@@ -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();
index 5642b7d..fc6e0b5 100644 (file)
@@ -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();
index b6c68a4..c8b86e1 100644 (file)
@@ -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.
index b70c092..9d1aad8 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']['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();
index 48a5207..739c098 100644 (file)
@@ -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);
index 0523f57..ed568ca 100644 (file)
@@ -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);
index 0e0b72e..0fa6814 100644 (file)
@@ -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";
index 4b86005..d64c948 100644 (file)
@@ -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'];
index 90b3e63..984ad83 100644 (file)
@@ -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);
index 4ab4db9..a3516a0 100644 (file)
@@ -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);
index 5f948e4..5564d09 100644 (file)
@@ -35,7 +35,7 @@ function accountSubmit(clear)
      <?php
         foreach ($accounts as $account => $info) {
             print "<option value=\"$account\"";
-            if ($account == $curaccount) {
+            if ($account == $curaccount['code']) {
                 print " selected";
             }
             print ">${info['name']}</option>\n";