Shout: Add conference list screen
authorBen Klang <ben@alkaloid.net>
Sun, 28 Mar 2010 21:46:44 +0000 (17:46 -0400)
committerBen Klang <ben@alkaloid.net>
Sun, 28 Mar 2010 21:46:44 +0000 (17:46 -0400)
shout/conferences.php [new file with mode: 0644]
shout/lib/Forms/ConferenceForm.php [new file with mode: 0644]
shout/lib/Shout.php
shout/templates/conferences/list.inc [new file with mode: 0644]
shout/themes/graphics/conference-add.png [new file with mode: 0755]

diff --git a/shout/conferences.php b/shout/conferences.php
new file mode 100644 (file)
index 0000000..afa57b1
--- /dev/null
@@ -0,0 +1,114 @@
+<?php
+/**
+ * Copyright 2009-2010 Alkaloid Networks LLC (http://projects.alkaloid.net)
+ *
+ * See the enclosed file COPYING for license information (BSD). If you
+ * did not receive this file, see
+ * http://www.opensource.org/licenses/bsd-license.php.
+ *
+ * @author  Ben Klang <ben@alkaloid.net>
+ */
+
+require_once dirname(__FILE__) . '/lib/Application.php';
+$shout = Horde_Registry::appInit('shout');
+
+require_once SHOUT_BASE . '/lib/Forms/ConferenceForm.php';
+
+$curaccount = $_SESSION['shout']['curaccount'];
+$action = Horde_Util::getFormData('action');
+$vars = Horde_Variables::getDefaultVariables();
+
+$RENDERER = new Horde_Form_Renderer();
+
+$title = _("Conferences: ");
+
+switch ($action) {
+case 'add':
+case 'edit':
+    $vars = Horde_Variables::getDefaultVariables();
+    $vars->set('account', $curaccount);
+    $Form = new ConferenceDetailsForm($vars);
+
+    // Show the list if the save was successful, otherwise back to edit.
+    if ($Form->isSubmitted() && $Form->isValid()) {
+        // Form is Valid and Submitted
+        try {
+            $devid = Horde_Util::getFormData('devid');
+
+            $Form->execute();
+            $notification->push(_("Conference information saved."),
+                                  'horde.success');
+            $action = 'list';
+            break;
+
+        } 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');
+    }
+
+    // Create a new add/edit form
+    $devid = Horde_Util::getFormData('devid');
+    $devices = $shout->devices->getDevices($curaccount);
+    $vars = new Horde_Variables($devices[$devid]);
+
+    $vars->set('action', $action);
+    $Form = new ConferenceDetailsForm($vars);
+
+    // Make sure we get the right template below.
+    $action = 'edit';
+
+    break;
+case 'delete':
+    $title .= sprintf(_("Delete Devices %s"), $extension);
+    $devid = Horde_Util::getFormData('devid');
+
+    $vars = Horde_Variables::getDefaultVariables();
+    $vars->set('account', $curaccount);
+    $Form = new DeviceDeleteForm($vars);
+
+    $FormValid = $Form->validate($vars, true);
+
+    if ($Form->isSubmitted() && $FormValid) {
+        try {
+            $Form->execute();
+            $notification->push(_("Device Deleted."));
+            $action = 'list';
+        } catch (Exception $e) {
+            $notification->push($e);
+        }
+    } elseif ($Form->isSubmitted()) {
+        $notification->push(_("Problem processing the form.  Please check below and try again."), 'horde.warning');
+    }
+
+    $vars = Horde_Variables::getDefaultVariables(array());
+    $vars->set('account', $curaccount);
+    $Form = new DeviceDeleteForm($vars);
+
+    break;
+
+case 'list':
+default:
+    $action = 'list';
+    $title .= _("List Conferences");
+}
+
+// Fetch the (possibly updated) list of extensions
+try {
+    $conferences = $shout->devices->getConferences($curaccount);
+} catch (Exception $e) {
+    $notification->push($e);
+    $devices = array();
+}
+
+Horde::addScriptFile('stripe.js', 'horde');
+require SHOUT_TEMPLATES . '/common-header.inc';
+require SHOUT_TEMPLATES . '/menu.inc';
+
+$notification->notify();
+
+require SHOUT_TEMPLATES . '/conferences/' . $action . '.inc';
+
+require $registry->get('templates', 'horde') . '/common-footer.inc';
diff --git a/shout/lib/Forms/ConferenceForm.php b/shout/lib/Forms/ConferenceForm.php
new file mode 100644 (file)
index 0000000..e69de29
index c30f770..55fe351 100644 (file)
@@ -30,7 +30,7 @@ class Shout
         $menu->add(Horde::applicationUrl('dialplan.php'), _("Incoming Calls"), "dialplan.png");
         $menu->add(Horde::applicationUrl('extensions.php'), _("Extensions"), "extension.png");
         $menu->add(Horde::applicationUrl('devices.php'), _("Devices"), "shout.png");
-        $menu->add(Horde::applicationUrl('conferences.png'), _("Conferences"), "conference.png");
+        $menu->add(Horde::applicationUrl('conferences.php'), _("Conferences"), "conference.png");
         //$menu->add(Horde::applicationUrl('recordings.php'), _("Recordings"), "recordings.png");
 
         /* Administration. */
diff --git a/shout/templates/conferences/list.inc b/shout/templates/conferences/list.inc
new file mode 100644 (file)
index 0000000..151a228
--- /dev/null
@@ -0,0 +1,54 @@
+<div class="header">
+    Account: <?php echo $_SESSION['shout']['accounts'][$curaccount]; ?>
+</div>
+
+<div id="conferenceList">
+    <table width="100%" cellspacing="0" class="striped">
+        <tr>
+            <td class="uheader">Name</td>
+            <td class="uheader">Room Number</td>
+            <td class="uheader">PIN</td>
+            <td class="uheader">Options</td>
+        </tr>
+        <?php
+            $editurl = Horde_Util::addParameter($url, 'action', 'edit');
+            $deleteurl = Horde_Util::addParameter($url, 'action', 'delete');
+            foreach ($conferences as $roomno => $info) {
+
+                $url = Horde::applicationUrl("conferences.php");
+                $url = Horde_Util::addParameter($url,
+                    array(
+                        'roomno' => $roomno,
+                    )
+                );
+
+        ?>
+        <tr class="item">
+            <td>
+                <?php echo Horde::link($editurl); echo $info['name']; ?></a>
+            </td>
+            <td>
+                <?php echo $roomno; ?>
+            </td>
+            <td>
+                <?php echo $info['pin']; ?>
+            </td>
+            <td>
+                <?php echo Horde::link($editurl); echo $info['options']; ?></a>
+            </td>
+        </tr>
+        <?php
+            }
+        ?>
+    </table>
+</div>
+<ul id="controls">
+    <?php
+    $addurl = Horde::applicationUrl('conferences.php');
+    $addurl = Horde_Util::addParameter($addurl, 'action', 'add');
+    ?>
+    <li><a class="button" href="<?php echo $addurl; ?>">
+        <?php echo Horde::img('conference-add.png'); ?>&nbsp;New Conference Room
+        </a>
+    </li>
+</ul>
diff --git a/shout/themes/graphics/conference-add.png b/shout/themes/graphics/conference-add.png
new file mode 100755 (executable)
index 0000000..06c5350
Binary files /dev/null and b/shout/themes/graphics/conference-add.png differ