From: Ben Klang Date: Sun, 28 Mar 2010 21:39:07 +0000 (-0400) Subject: Shout: Dialplan support for conference rooms X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=250d1e14fe84ba711a38cb9e04cbd2142acc55b1;p=horde.git Shout: Dialplan support for conference rooms --- diff --git a/shout/dialplan.php b/shout/dialplan.php index eaeebade0..f5d7c6f81 100644 --- a/shout/dialplan.php +++ b/shout/dialplan.php @@ -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.")); diff --git a/shout/lib/Ajax/Application.php b/shout/lib/Ajax/Application.php index 3d42a16e1..bac80d140 100644 --- a/shout/lib/Ajax/Application.php +++ b/shout/lib/Ajax/Application.php @@ -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; } diff --git a/shout/lib/Driver/Sql.php b/shout/lib/Driver/Sql.php index 47c5680f2..c7af303db 100644 --- a/shout/lib/Driver/Sql.php +++ b/shout/lib/Driver/Sql.php @@ -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. * diff --git a/shout/templates/dialplan/edit.inc b/shout/templates/dialplan/edit.inc index ed1bfd376..85c743633 100644 --- a/shout/templates/dialplan/edit.inc +++ b/shout/templates/dialplan/edit.inc @@ -88,6 +88,7 @@ var curmenu = null; var menuInfo = $H(); var menuActions = $H(); var destinations = $H(); +var conferences = $H(); var soundfiles = $H(); 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(''); } diff --git a/shout/themes/screen.css b/shout/themes/screen.css index 226844d3a..4deceb294 100644 --- a/shout/themes/screen.css +++ b/shout/themes/screen.css @@ -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 {