*/
require_once dirname(__FILE__) . '/lib/Application.php';
$shout = Horde_Registry::appInit('shout');
-$curaccount = $_SESSION['shout']['curaccount'];
-if (empty($curaccount)) {
+
+if (empty($_SESSION['shout']['curaccount'])) {
die("Permission denied.");
}
-$menus = $shout->storage->getMenus($curaccount);
+
+$curaccount = $_SESSION['shout']['curaccount'];
+$menus = $shout->storage->getMenus($curaccount['code']);
if (empty($menus)) {
- print_r($curaccount);
+ header('Location: ' . Horde::applicationUrl('wizard.php', true));
} else {
header('Location: ' . Horde::applicationUrl('dialplan.php', true));
exit;
return $recordings;
}
+ public function getRecordingByName($account, $filename)
+ {
+ $sql = 'SELECT id, filename FROM recordings ' .
+ 'WHERE account_id = (SELECT id FROM accounts WHERE code = ?) ' .
+ 'AND filename = ?;';
+ $args = array($account, $filename);
+ $msg = 'SQL query in Shout_Driver_Sql#getRecordingByName(): ' . $sql;
+ Horde::logMessage($msg, 'DEBUG');
+ $result = $this->_db->query($sql, $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);
+ }
+ if ($row === null) {
+ throw new Shout_Exception('No such recording found for this account.');
+ }
+ $result->free();
+ return $row;
+ }
+
public function addRecording($account, $name)
{
$sql = 'INSERT INTO recordings (filename, account_id) ' .
*/
class Shout
{
+ /**
+ * @var string default menu, used for creating initial menu
+ */
+ const MAIN_MENU = 'Main Menu';
+
+ /**
+ *
+ * @var string default recording, used for creating initial menu
+ */
+ const MAIN_RECORDING = 'main_menu';
+
var $applist = array();
var $_applist_curapp = '';
var $_applist_curfield = '';
--- /dev/null
+<div id="step1" class="step">
+ <h2>Step 1: Create your company greeting.</h2>
+ Here we record a company greeting.
+ Need: admin PIN, phone number
+ <?php print_r($curaccount); ?>
+</div>
+
+<div id="step2" class="step">
+ Here we create an extension.
+</div>
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Copyright 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');
+
+try {
+ // Only continue if there is no existing "Main Menu"
+ $curaccount = $_SESSION['shout']['curaccount'];
+ $menus = $shout->storage->getMenus($curaccount['code']);
+
+ if (!empty($menus) && !empty($menus[Shout::MAIN_MENU])) {
+ header('Location: ' . Horde::applicationUrl('dialplan.php', true));
+ exit;
+ }
+
+ // Create the default recording for the main menu
+ try {
+ $recording = $shout->storage->getRecordingByName($curaccount['code'],
+ Shout::MAIN_RECORDING);
+ } catch (Shout_Exception $e) {
+ $shout->storage->addRecording($curaccount['code'], Shout::MAIN_RECORDING);
+ $recording = $shout->storage->getRecordingByName($curaccount['code'],
+ Shout::MAIN_RECORDING);
+ }
+
+ // Create a default main menu
+ $details = array(
+ 'name' => Shout::MAIN_MENU,
+ 'description' => _("Main menu: what your callers will hear."),
+ 'recording_id' => $recording['id']
+ );
+ $shout->dialplan->saveMenuInfo($curaccount['code'], $details);
+ // Populate the default option, granting the ability to log into the admin
+ // section.
+ $shout->dialplan->saveMenuAction($curaccount['code'], Shout::MAIN_MENU,
+ '*', 'admin_login', array());
+
+
+} catch (Exception $e) {
+ $notification->push($e);
+}
+
+Horde::addScriptFile('prototype.js', 'horde');
+
+require SHOUT_TEMPLATES . '/common-header.inc';
+require SHOUT_TEMPLATES . '/menu.inc';
+
+$notification->notify();
+
+require SHOUT_TEMPLATES . '/wizard.inc';
+
+require $registry->get('templates', 'horde') . '/common-footer.inc';