Source for file voice_menu.php

Documentation is available at voice_menu.php

  1. <?php
  2. /**
  3. * Main menu of the voice application
  4. *
  5. * Allows user to navigate between menus and choose commands.
  6. * @package Phone2Dev
  7. * @author Stanislav Miroshnikov
  8. */
  9.  
  10. // start the session
  11. session_start();
  12.  
  13. print "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
  14.  
  15. /**
  16. * Requires custom error handler
  17. */
  18. require_once("voice_error.php");
  19. //trigger_error('This is an information log message.', E_USER_NOTICE);
  20. //NOTE: default values are for debuging purposes only
  21. /*
  22. if(!isset($_SESSION['intUserId'])) {
  23. $_SESSION['intUserId'] = 1;
  24. }
  25.  
  26. if(!isset($_SESSION['intMainMenuId'])) {
  27. $_SESSION['intMainMenuId'] = 1;
  28. }
  29. */
  30.  
  31. /**
  32. * Requires PHP VoiceXML Library
  33. */
  34. require_once ("phpvoice/vxml.class.php");
  35.  
  36. // check that the require parameters are set
  37. if(isset($_SESSION['intUserId']) && isset($_SESSION['intMainMenuId'])) {
  38. // user is logged in, show the menu
  39. /**
  40. * Requires Phone2Dev class for database access
  41. */
  42. require_once ("phone2dev.php");
  43. $objP2D =& new Phone2Dev();
  44.  
  45. // connect to the database
  46. $objP2D->dbConnect();
  47.  
  48. //if the menuId is not supplied display the user's main menu
  49. $intMenuId = -1;
  50. if(!isset($_GET['menuId'])) {
  51. $intMenuId = $_SESSION['intMainMenuId'];
  52. } else {
  53. $intMenuId = $_GET['menuId'];
  54. }
  55.  
  56. $app =& new gonx_vxml();
  57. $app->start_vxml("", "", "", "", "", "2.0"); {
  58. // catch the disconnect event
  59. $app->start_catch("connection.disconnect"); {
  60. $app->start_exit_c();
  61. }$app->end_catch();
  62. // show the menu
  63. $app->start_menu("main_menu"); {
  64. $app->start_prompt(); {
  65. $app->write("Select one of the following menu choices:");
  66. $app->start_enumerate_c();
  67. }$app->end_prompt();
  68. // display the menus' sub menus
  69. $arrSubMenus = &$objP2D->getSubMenus($intMenuId, $_SESSION['intUserId']);
  70. reset($arrSubMenus);
  71. while (list($intSubMenuId, $strSubMenuName) = each($arrSubMenus)) {
  72. if($intSubMenuId != $intMenuId) {
  73. $app->start_choice("", "", "",
  74. "voice_menu.php?menuId="
  75. .$intSubMenuId);{
  76. $app->write($strSubMenuName);
  77. }$app->end_choice();
  78. }
  79. }
  80. // display the menus' commands
  81. $arrCommands = &$objP2D->getCommands($intMenuId, $_SESSION['intUserId']);
  82. while (list($intComId, $arrComInfo) = each($arrCommands)) {
  83. $app->start_choice("", "", "",
  84. "voice_command.php?menuId=".$intMenuId
  85. ."&amp;commandId=".$intComId
  86. ."&amp;deviceId=".$arrComInfo['intDeviceId']);{
  87. $app->write($arrComInfo['strDeviceName']." "
  88. .$arrComInfo['strComName']);
  89. }$app->end_choice();
  90. }
  91. // if this is not the main menu give option to return to main menu
  92. if($intMenuId != $_SESSION['intMainMenuId']) {
  93. $app->start_choice("", "", "",
  94. "voice_menu.php?menuId="
  95. .$_SESSION['intMainMenuId']);{
  96. $app->write("Return to main menu.");
  97. }$app->end_choice();
  98. }
  99. if($intMenuId != $_SESSION['intMainMenuId']) {
  100. // this command has a parent menu if it is not located
  101. // in the main menu
  102. $app->start_choice("", "", "",
  103. "voice_menu.php?menuId="
  104. .$intMenuId);{
  105. $app->write("Return to previous menu.");
  106. }$app->end_choice();
  107. }
  108. }$app->end_menu();
  109. }$app->end_vxml();
  110.  
  111. // generate the document
  112. $app->generate();
  113.  
  114. // disconnect from the database
  115. $objP2D->dbDisconnect();
  116. } else {
  117. // user is not logged in correctly
  118. $app =& new gonx_vxml();
  119. $app->start_vxml("", "", "", "", "", "2.0"); {
  120. // catch the disconnect event
  121. $app->start_catch("connection.disconnect"); {
  122. $app->start_exit_c();
  123. }$app->end_catch();
  124. $app->start_form("login_failure",""); {
  125. $app->start_block(); {
  126. $app->start_prompt(); {
  127. $app->write("Error. Your session have expired or");
  128. $app->write("you have not logged in.");
  129. }$app->end_prompt();
  130. }$app->end_block();
  131. $app->start_exit_c();
  132. }$app->end_form();
  133. // end of the vxml document
  134. }$app->end_vxml();
  135.  
  136. // generate the document
  137. $app->generate();
  138. }
  139.  
  140. ?>

Documentation generated on Tue, 4 Jan 2005 13:48:14 -0500 by phpDocumentor 1.3.0RC3