Shout: Dialplan support for conference rooms
authorBen Klang <ben@alkaloid.net>
Sun, 28 Mar 2010 21:39:07 +0000 (17:39 -0400)
committerBen Klang <ben@alkaloid.net>
Sun, 28 Mar 2010 21:39:47 +0000 (17:39 -0400)
shout/dialplan.php
shout/lib/Ajax/Application.php
shout/lib/Driver/Sql.php
shout/templates/dialplan/edit.inc
shout/themes/screen.css

index eaeebad..f5d7c6f 100644 (file)
@@ -53,6 +53,7 @@ default:
     $action = 'edit';
     try {
         $destinations = $shout->extensions->getExtensions($curaccount);
+        $conferences = $shout->storage->getConferences($curaccount);
         $soundfiles = $shout->getRecordings();
     } catch (Exception $e) {
         $notification->push(_("Problem getting destination information."));
index 3d42a16..bac80d1 100644 (file)
@@ -115,7 +115,19 @@ class Shout_Ajax_Application extends Horde_Ajax_Application_Base
             return $menus;
         } catch (Exception $e) {
             //FIXME: Create a way to notify the user of the failure.
-            die(var_dump($e));
+            Horde::logMessage($e, 'ERR');
+            return false;
+        }
+    }
+
+    public function getConferences()
+    {
+        try {
+            $shout = $GLOBALS['registry']->getApiInstance('shout', 'application');
+            $account = $_SESSION['shout']['curaccount'];
+            return $shout->storage->getConferences($account);
+        } catch (Exception $e) {
+            //FIXME: Create a way to notify the user of the failure.
             Horde::logMessage($e, 'ERR');
             return false;
         }
index 47c5680..c7af303 100644 (file)
@@ -425,6 +425,38 @@ class Shout_Driver_Sql extends Shout_Driver
         throw new Shout_Exception("Not implemented.");
     }
 
+    public function getConferences($account)
+    {
+        $sql = 'SELECT id, room_number, name, pin, options ' .
+               'FROM conferences ' .
+               'WHERE account_id = (SELECT id FROM accounts WHERE code = ?);';
+        $args = array($account);
+        $msg = 'SQL query in Shout_Driver_Sql#getConferences(): ' . $sql;
+        Horde::logMessage($msg, 'DEBUG');
+        $sth = $this->_db->prepare($sql);
+        $result = $this->_db->execute($sth, $args);
+        if ($result instanceof PEAR_Error) {
+            throw new Shout_Exception($result);
+        }
+
+        $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
+        if ($row instanceof PEAR_Error) {
+            throw new Shout_Exception($row);
+        }
+
+        $conferences = array();
+        while ($row && !($row instanceof PEAR_Error)) {
+            $roomno = $row['room_number'];
+            $conferences[$roomno] = $row;
+
+            /* Advance to the new row in the result set. */
+            $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
+        }
+
+        $result->free();
+        return $conferences;
+    }
+
     /**
      * Attempts to open a persistent connection to the SQL server.
      *
index ed1bfd3..85c7436 100644 (file)
@@ -88,6 +88,7 @@ var curmenu = null;
 var menuInfo = $H();
 var menuActions = $H(<?php echo Horde_Serialize::serialize(Shout::getMenuActions(), Horde_Serialize::JSON, Horde_Nls::getCharset()); ?>);
 var destinations = $H(<?php echo Horde_Serialize::serialize($destinations, Horde_Serialize::JSON, Horde_Nls::getCharset()); ?>);
+var conferences = $H(<?php echo Horde_Serialize::serialize($conferences, Horde_Serialize::JSON, Horde_Nls::getCharset()); ?>);
 var soundfiles = $H(<?php echo Horde_Serialize::serialize($soundfiles, Horde_Serialize::JSON, Horde_Nls::getCharset()); ?>);
 
 function empty(p)
@@ -194,12 +195,20 @@ function editAction(digit)
             var text = document.createTextNode(menuActions.get(action).args.roomno.name);
             div.appendChild(text);
 
-            var input = document.createElement('input');
-            input.name = 'roomno';
+            var select = document.createElement('select');
+            select.name = 'roomno';
+            conferences.each(function (item) {
+                var option = document.createElement('option');
+                option.value = item.key;
+                var text = document.createTextNode(item.value.name);
+                option.appendChild(text);
+                select.appendChild(option);
+            })
+
             if (menuInfo.get(curmenu).actions[digit] != null) {
-                input.value = menuInfo.get(curmenu).actions[digit].args.roomno;
+                select.value = menuInfo.get(curmenu).actions[digit].roomno;
             }
-            div.appendChild(input);
+            div.appendChild(select);
             break;
 
         case 'dial':
@@ -410,7 +419,7 @@ function refreshMenu()
         case 'conference':
             var roomno = pair.value.args['roomno'];
             if (roomno != null) {
-                text = document.createTextNode(roomno);
+                text = document.createTextNode(conferences.get(roomno).name);
             } else {
                 text = document.createTextNode('');
             }
index 226844d..4deceb2 100644 (file)
@@ -59,14 +59,10 @@ span.device:hover
     cursor: pointer;
 }
 
-ul {
-    list-style: none;
-    display: inline;
-}
-
 #controls {
     margin-left: auto;
     margin-right: auto;
+    list-style: none;
 }
 
 #controls li {
@@ -113,9 +109,6 @@ ul {
     background-image: url('graphics/digit-bg.png');
     -moz-border-radius: 10px;
     -webkit-border-radius: 10px;
-}
-
-.digit:hover {
     cursor: pointer;
 }
 
@@ -185,6 +178,7 @@ ul {
     float:left;
     margin: 3px;
     cursor: pointer;
+    padding: 2px 8px;
 }
 
 .button a {