Shout: re-active the wizard. It works!
authorBen Klang <ben@alkaloid.net>
Sat, 3 Apr 2010 01:51:56 +0000 (21:51 -0400)
committerBen Klang <ben@alkaloid.net>
Sat, 3 Apr 2010 01:52:20 +0000 (21:52 -0400)
shout/lib/Forms/NumberForm.php
shout/lib/Shout.php
shout/templates/wizard.inc
shout/wizard.php

index e6c5d4f..fbd3198 100644 (file)
@@ -50,7 +50,7 @@ class NumberDetailsForm extends Horde_Form {
         $accountcode = $vars->get('accountcode');
         if (!empty($accountcode)) {
             $menus = $shout->storage->getMenus($accountcode);
-            $list = array();
+            $list = array('' => '-- None --');
             foreach ($menus as $id => $info) {
                 $list[$id] = $info['name'];
             }
index 27796cb..e9d6ab1 100644 (file)
@@ -242,19 +242,19 @@ class Shout
 
     static public function getAdminTabs()
     {
-        $tabname = Horde_Util::getFormData('tabname');
+        $tabname = Horde_Util::getFormData('view');
         $tabs = new Horde_Ui_Tabs('view', Horde_Variables::getDefaultVariables());
         $tabs->addTab(_("Telephone Numbers"),
                       Horde::applicationUrl('admin/numbers.php'),
-                      array('tabname' => 'numbers', id => 'tabnumbers'));
+                      array('view' => 'numbers', id => 'tabnumbers'));
         $tabs->addTab(_("Accounts"),
                       Horde::applicationUrl('admin/accounts.php'),
-                      array('tabname' => 'accounts', id => 'tabaccounts'));
-        if ($tabname === null) {
-            $tabname = 'numbers';
+                      array('view' => 'accounts', id => 'tabaccounts'));
+        if ($view === null) {
+            $view = 'numbers';
         }
 
-        echo $tabs->render($tabname);
+        echo $tabs->render($view);
     }
 
 }
index f1daff7..d5ef4fe 100644 (file)
@@ -11,7 +11,7 @@
     <h3 onclick="showstep('step1')">Step 1: Create your company greeting</h3>
     <div id="step1">
         <ol>
-            <li>Call your new number: FIXME</li>
+            <li>Call your new number: <?php echo $number; ?></li>
             <li>When you hear the default greeting, press the star key, "<span class="attention">*</span>".</li>
             <li>When prompted, enter your admin PIN: <span class="attention"><?php echo $curaccount['adminpin']; ?></span>.</li>
             <li>Press <span class="attention">1</span> to manage recordings.</li>
index 4f5250e..6f7f6e2 100644 (file)
@@ -14,38 +14,54 @@ $shout = Horde_Registry::appInit('shout');
 require_once SHOUT_BASE . '/lib/Forms/ExtensionForm.php';
 
 try {
-    // Only continue if there is no existing "Main Menu"
     $curaccount = $_SESSION['shout']['curaccount'];
+
+    // Only continue if there is an assigned phone number
+    $numbers = $shout->storage->getNumbers($curaccount['code']);
+    if (empty($numbers)) {
+        throw new Shout_Exception("No valid numbers on this account.");
+    }
+    // Grab the first available number
+    $number = reset($numbers);
+    $number = $number['number'];
+
+    // Only continue if there is no existing "Main Menu"
     $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,
-//                                     'star', 'admin_login', array());
+    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);
+
+    // Associate this menu with the first number.
+    // FIXME: This could be disruptive.
+    $shout->storage->saveNumber($number, $curaccount['code'], Shout::MAIN_MENU);
+
+    // Populate the default option, granting the ability to log into the admin
+    // section.
+    $shout->dialplan->saveMenuAction($curaccount['code'], Shout::MAIN_MENU,
+                                     'star', 'admin_login', array());
     $extensions = $shout->extensions->getExtensions($curaccount['code']);
 } catch (Exception $e) {
+    print_r($e);
     $notification->push($e);
 }