PageRenderTime 48ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/admin/ajax/menu_edit.php

https://github.com/anodyne/sms
PHP | 241 lines | 205 code | 31 blank | 5 comment | 45 complexity | 0e91e7b2dcae0c15698e97957134a962 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. /* need to connect to the database */
  3. require_once('../../framework/dbconnect.php');
  4. /* pulling a function from new library */
  5. require_once('../../framework/session.name.php');
  6. /* get system unique identifier */
  7. $sysuid = get_system_uid();
  8. /* rewrite master php.ini session.name */
  9. ini_set('session.name', $sysuid);
  10. session_start();
  11. if( !isset( $sessionAccess ) ) {
  12. $sessionAccess = FALSE;
  13. }
  14. if( !is_array( $sessionAccess ) ) {
  15. $sessionAccess = explode( ",", $_SESSION['sessionAccess'] );
  16. }
  17. if(in_array("x_menu", $sessionAccess))
  18. {
  19. include_once('../../framework/functionsGlobal.php');
  20. include_once('../../framework/functionsAdmin.php');
  21. include_once('../../framework/functionsUtility.php');
  22. if(isset($_GET['id']) && is_numeric($_GET['id']))
  23. {
  24. $id = $_GET['id'];
  25. }
  26. /* get the data */
  27. $get = "SELECT * FROM sms_menu_items WHERE menuid = $id LIMIT 1";
  28. $getR = mysql_query( $get );
  29. $pendingArray = mysql_fetch_assoc( $getR );
  30. switch($pendingArray['menuCat'])
  31. {
  32. case 'main':
  33. $action_tab = 1;
  34. $action_tab_sub = 1;
  35. $action_tab_sub_a = 1;
  36. break;
  37. case 'general':
  38. $action_tab = 2;
  39. $action_tab_sub_a = 1;
  40. switch($pendingArray['menuMainSec'])
  41. {
  42. case 'main':
  43. $action_tab_sub = 1;
  44. break;
  45. case 'personnel':
  46. $action_tab_sub = 2;
  47. break;
  48. case 'ship':
  49. $action_tab_sub = 4;
  50. break;
  51. case 'simm':
  52. $action_tab_sub = 3;
  53. break;
  54. }
  55. break;
  56. case 'admin':
  57. $action_tab = 3;
  58. $action_tab_sub = 1;
  59. switch($pendingArray['menuMainSec'])
  60. {
  61. case 'post':
  62. $action_tab_sub_a = 1;
  63. break;
  64. case 'manage':
  65. $action_tab_sub_a = 2;
  66. break;
  67. case 'reports':
  68. $action_tab_sub_a = 4;
  69. break;
  70. case 'user':
  71. $action_tab_sub_a = 3;
  72. break;
  73. }
  74. break;
  75. }
  76. ?>
  77. <script type="text/javascript">
  78. $(document).ready(function() {
  79. $('a#show_adv').click(function() {
  80. $('#advanced').toggle(75);
  81. return false;
  82. });
  83. });
  84. </script>
  85. <h2>Edit Menu Item</h2>
  86. <p>Use the fields below to edit the menu item. If you want more options (menu availability, section, category, authentication, or user access control), you can use the <strong>advanced options</strong> link below to show the remaining menu item options. <strong class='orange'>Use extreme caution when editing menu items. Incorrect modification can cause you to not be able to access the menu items any more!</strong></p>
  87. <hr size="1" width="100%" />
  88. <form method="post" action="">
  89. <table class="hud_guts">
  90. <tr>
  91. <td class="hudLabel">Title</td>
  92. <td></td>
  93. <td><input type="text" class="image" name="menuTitle" value="<?=$pendingArray['menuTitle'];?>" /></td>
  94. </tr>
  95. <tr>
  96. <td colspan="3" height="15"></td>
  97. </tr>
  98. <tr>
  99. <td class="hudLabel">Link URL</td>
  100. <td></td>
  101. <td><input type="text" class="image" name="menuLink" value="<?=$pendingArray['menuLink'];?>" /></td>
  102. </tr>
  103. <tr>
  104. <td class="hudLabel">Link Type</td>
  105. <td></td>
  106. <td>
  107. <select name="menuLinkType">
  108. <option value="onsite"<? if( $pendingArray['menuLinkType'] == "onsite" ) { echo " selected"; } ?>>Onsite</option>
  109. <option value="offsite"<? if( $pendingArray['menuLinkType'] == "offsite" ) { echo " selected"; } ?>>Offsite</option>
  110. </select>
  111. </td>
  112. </tr>
  113. <tr>
  114. <td colspan="3" height="15"></td>
  115. </tr>
  116. <tr>
  117. <td class="hudLabel">Group</td>
  118. <td></td>
  119. <td><input type="text" class="order" name="menuGroup" size="3" value="<?=$pendingArray['menuGroup'];?>" /></td>
  120. </tr>
  121. <tr>
  122. <td class="hudLabel">Order</td>
  123. <td></td>
  124. <td><input type="text" class="order" name="menuOrder" size="3" value="<?=$pendingArray['menuOrder'];?>" /></td>
  125. </tr>
  126. </table>
  127. <p><a href="#" id="show_adv" class="fontNormal"><strong>Advanced Options &raquo;</strong></a></p>
  128. <div id="advanced" style="display:none;">
  129. <table class="hud_guts">
  130. <tr>
  131. <td class="hudLabel">Status</td>
  132. <td></td>
  133. <td>
  134. <input type="radio" name="menuAvailability" id="maOn" value="on"<? if( $pendingArray['menuAvailability'] == "on" ) { echo " checked"; } ?>/><label for="maOn">On</label>
  135. <input type="radio" name="menuAvailability" id="maOff" value="off"<? if( $pendingArray['menuAvailability'] == "off" ) { echo " checked"; } ?>/><label for="maOff">Off</label>
  136. </td>
  137. </tr>
  138. <tr>
  139. <td colspan="3" height="15"></td>
  140. </tr>
  141. <tr>
  142. <td class="hudLabel">Category</td>
  143. <td></td>
  144. <td>
  145. <select name="menuCat">
  146. <option value="main"<? if( $pendingArray['menuCat'] == "main" ) { echo " selected"; } ?>>Main Navigation</option>
  147. <option value="general"<? if( $pendingArray['menuCat'] == "general" ) { echo " selected"; } ?>>General Menus</option>
  148. <option value="admin"<? if( $pendingArray['menuCat'] == "admin" ) { echo " selected"; } ?>>Admin Menus</option>
  149. </select>
  150. </td>
  151. </tr>
  152. <tr>
  153. <td class="hudLabel">Section</td>
  154. <td></td>
  155. <td>
  156. <select name="menuMainSec">
  157. <optgroup label="Main Navigation">
  158. <option value=""<? if( $pendingArray['menuMainSec'] == "" ) { echo " selected"; } ?>>Main Navigation</option>
  159. </optgroup>
  160. <optgroup label="General Menus">
  161. <option value="main"<? if( $pendingArray['menuMainSec'] == "main" ) { echo " selected"; } ?>>Main</option>
  162. <option value="personnel"<? if( $pendingArray['menuMainSec'] == "personnel" ) { echo " selected"; } ?>>Personnel</option>
  163. <option value="ship"<? if( $pendingArray['menuMainSec'] == "ship" ) { echo " selected"; } ?>><?=ucfirst( $simmType );?></option>
  164. <option value="simm"<? if( $pendingArray['menuMainSec'] == "simm" ) { echo " selected"; } ?>>Simm</option>
  165. </optgroup>
  166. <optgroup label="Admin Menus">
  167. <option value="post"<? if( $pendingArray['menuMainSec'] == "post" ) { echo " selected"; } ?>>Post</option>
  168. <option value="manage"<? if( $pendingArray['menuMainSec'] == "manage" ) { echo " selected"; } ?>>Manage</option>
  169. <option value="reports"<? if( $pendingArray['menuMainSec'] == "reports" ) { echo " selected"; } ?>>Reports</option>
  170. <option value="user"<? if( $pendingArray['menuMainSec'] == "user" ) { echo " selected"; } ?>>User</option>
  171. </optgroup>
  172. </select>
  173. </td>
  174. </tr>
  175. <tr>
  176. <td colspan="3" height="15"></td>
  177. </tr>
  178. <tr>
  179. <td class="hudLabel">Requires Login?</td>
  180. <td></td>
  181. <td>
  182. <input type="radio" id="menuLoginY" name="menuLogin" value="y" <? if( $pendingArray['menuLogin'] == "y" ) { echo "checked"; } ?>/><label for="menuLoginY">Yes</label>
  183. <input type="radio" id="menuLoginN" name="menuLogin" value="n" <? if( $pendingArray['menuLogin'] == "n" ) { echo "checked"; } ?>/><label for="menuLoginN">No</label>
  184. </td>
  185. </tr>
  186. <tr>
  187. <td colspan="3" height="15"></td>
  188. </tr>
  189. <?php if($pendingArray['menuCat'] == 'admin') {} else { ?>
  190. <tr>
  191. <td colspan="3" class="fontNormal yellow bold">Main navigation and general menus do not use the access control system. Changing this field for either category will not affect anything.</td>
  192. </tr>
  193. <?php } ?>
  194. <tr>
  195. <td class="hudLabel">Access Code</td>
  196. <td></td>
  197. <td><input type="text" class="title" name="menuAccess" value="<?=$pendingArray['menuAccess'];?>" /></td>
  198. </tr>
  199. </table><br /><br />
  200. </div>
  201. <div>
  202. <input type="hidden" name="action_id" value="<?=$pendingArray['menuid'];?>" />
  203. <input type="hidden" name="action_type" value="edit" />
  204. <input type="hidden" name="action_tab" value="<?=$action_tab;?>" />
  205. <input type="hidden" name="action_tab_sub" value="<?=$action_tab_sub;?>" />
  206. <input type="hidden" name="action_tab_sub_a" value="<?=$action_tab_sub_a;?>" />
  207. <input type="image" src="<?=$webLocation;?>images/hud_button_ok.png" name="activate" value="Activate" />
  208. </div>
  209. </form>
  210. <?php } /* close the referer check */ ?>