Documentation is available at voice_menu.php
- <?php
- /**
- * Main menu of the voice application
- *
- * Allows user to navigate between menus and choose commands.
- * @package Phone2Dev
- * @author Stanislav Miroshnikov
- */
- // start the session
- session_start();
- print "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
- /**
- * Requires custom error handler
- */
- require_once("voice_error.php");
- //trigger_error('This is an information log message.', E_USER_NOTICE);
- //NOTE: default values are for debuging purposes only
- /*
- if(!isset($_SESSION['intUserId'])) {
- $_SESSION['intUserId'] = 1;
- }
- if(!isset($_SESSION['intMainMenuId'])) {
- $_SESSION['intMainMenuId'] = 1;
- }
- */
- /**
- * Requires PHP VoiceXML Library
- */
- require_once ("phpvoice/vxml.class.php");
- // check that the require parameters are set
- if(isset($_SESSION['intUserId']) && isset($_SESSION['intMainMenuId'])) {
- // user is logged in, show the menu
- /**
- * Requires Phone2Dev class for database access
- */
- require_once ("phone2dev.php");
- $objP2D =& new Phone2Dev();
- // connect to the database
- $objP2D->dbConnect();
- //if the menuId is not supplied display the user's main menu
- $intMenuId = -1;
- if(!isset($_GET['menuId'])) {
- $intMenuId = $_SESSION['intMainMenuId'];
- } else {
- $intMenuId = $_GET['menuId'];
- }
- $app =& new gonx_vxml();
- $app->start_vxml("", "", "", "", "", "2.0"); {
- // catch the disconnect event
- $app->start_catch("connection.disconnect"); {
- $app->start_exit_c();
- }$app->end_catch();
- // show the menu
- $app->start_menu("main_menu"); {
- $app->start_prompt(); {
- $app->write("Select one of the following menu choices:");
- $app->start_enumerate_c();
- }$app->end_prompt();
- // display the menus' sub menus
- $arrSubMenus = &$objP2D->getSubMenus($intMenuId, $_SESSION['intUserId']);
- reset($arrSubMenus);
- while (list($intSubMenuId, $strSubMenuName) = each($arrSubMenus)) {
- if($intSubMenuId != $intMenuId) {
- $app->start_choice("", "", "",
- "voice_menu.php?menuId="
- .$intSubMenuId);{
- $app->write($strSubMenuName);
- }$app->end_choice();
- }
- }
- // display the menus' commands
- $arrCommands = &$objP2D->getCommands($intMenuId, $_SESSION['intUserId']);
- while (list($intComId, $arrComInfo) = each($arrCommands)) {
- $app->start_choice("", "", "",
- "voice_command.php?menuId=".$intMenuId
- ."&commandId=".$intComId
- ."&deviceId=".$arrComInfo['intDeviceId']);{
- $app->write($arrComInfo['strDeviceName']." "
- .$arrComInfo['strComName']);
- }$app->end_choice();
- }
- // if this is not the main menu give option to return to main menu
- if($intMenuId != $_SESSION['intMainMenuId']) {
- $app->start_choice("", "", "",
- "voice_menu.php?menuId="
- .$_SESSION['intMainMenuId']);{
- $app->write("Return to main menu.");
- }$app->end_choice();
- }
- if($intMenuId != $_SESSION['intMainMenuId']) {
- // this command has a parent menu if it is not located
- // in the main menu
- $app->start_choice("", "", "",
- "voice_menu.php?menuId="
- .$intMenuId);{
- $app->write("Return to previous menu.");
- }$app->end_choice();
- }
- }$app->end_menu();
- }$app->end_vxml();
- // generate the document
- $app->generate();
- // disconnect from the database
- $objP2D->dbDisconnect();
- } else {
- // user is not logged in correctly
- $app =& new gonx_vxml();
- $app->start_vxml("", "", "", "", "", "2.0"); {
- // catch the disconnect event
- $app->start_catch("connection.disconnect"); {
- $app->start_exit_c();
- }$app->end_catch();
- $app->start_form("login_failure",""); {
- $app->start_block(); {
- $app->start_prompt(); {
- $app->write("Error. Your session have expired or");
- $app->write("you have not logged in.");
- }$app->end_prompt();
- }$app->end_block();
- $app->start_exit_c();
- }$app->end_form();
- // end of the vxml document
- }$app->end_vxml();
- // generate the document
- $app->generate();
- }
- ?>
Documentation generated on Tue, 4 Jan 2005 13:48:14 -0500 by phpDocumentor 1.3.0RC3