menu_item_edit.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. <?php
  2. /*
  3. FusionPBX
  4. Version: MPL 1.1
  5. The contents of this file are subject to the Mozilla Public License Version
  6. 1.1 (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.mozilla.org/MPL/
  9. Software distributed under the License is distributed on an "AS IS" basis,
  10. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. for the specific language governing rights and limitations under the
  12. License.
  13. The Original Code is FusionPBX
  14. The Initial Developer of the Original Code is
  15. Mark J Crane <[email protected]>
  16. Portions created by the Initial Developer are Copyright (C) 2008-2022
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. //includes files
  22. require_once dirname(__DIR__, 2) . "/resources/require.php";
  23. require_once "resources/check_auth.php";
  24. //check permissions
  25. if (permission_exists('menu_add') || permission_exists('menu_edit')) {
  26. //access granted
  27. }
  28. else {
  29. echo "access denied";
  30. return;
  31. }
  32. //add multi-lingual support
  33. $language = new text;
  34. $text = $language->get();
  35. //define the variables
  36. $menu_uuid = null;
  37. $menu_item_uuid = null;
  38. $menu_item_title = '';
  39. $menu_item_link = '';
  40. $menu_item_category = '';
  41. $menu_item_icon = '';
  42. $menu_item_description = '';
  43. $menu_item_protected = '';
  44. $menu_item_parent_uuid = null;
  45. $menu_item_order = null;
  46. //get the menu_uuid
  47. if (!empty($_REQUEST)) {
  48. $menu_uuid = $_REQUEST["id"];
  49. $menu_item_uuid = $_REQUEST['menu_item_uuid'] ?? null;
  50. $group_uuid_name = $_REQUEST['group_uuid_name'] ?? null;
  51. $menu_item_group_uuid = $_REQUEST['menu_item_group_uuid'] ?? null;
  52. }
  53. //set the action
  54. $action = '';
  55. if (!empty($_REQUEST["a"])) {
  56. $action = $_REQUEST["a"];
  57. }
  58. //delete the group from the menu item
  59. if ($action == "delete" && permission_exists("menu_delete") && is_uuid($menu_item_group_uuid)) {
  60. //delete the group from the users
  61. $array['menu_item_groups'][0]['menu_item_group_uuid'] = $menu_item_group_uuid;
  62. $database = new database;
  63. $database->app_name = 'menu';
  64. $database->app_uuid = 'f4b3b3d2-6287-489c-2a00-64529e46f2d7';
  65. $database->delete($array);
  66. unset($array);
  67. //redirect the browser
  68. message::add($text['message-delete']);
  69. header("Location: menu_item_edit.php?id=".urlencode($menu_uuid)."&menu_item_uuid=".urlencode($menu_item_uuid)."&menu_uuid=".urlencode($menu_uuid));
  70. return;
  71. }
  72. //action add or update
  73. if (!empty($_REQUEST["menu_item_uuid"]) && is_uuid($_REQUEST["menu_item_uuid"])) {
  74. $action = "update";
  75. $menu_item_uuid = $_REQUEST["menu_item_uuid"];
  76. }
  77. else {
  78. $action = "add";
  79. }
  80. //get the HTTP POST variables and set them as PHP variables
  81. if (!empty($_POST)) {
  82. $menu_uuid = $_POST["menu_uuid"] ?? '';
  83. $menu_item_uuid = $_POST["menu_item_uuid"] ?? '';
  84. $menu_item_title = $_POST["menu_item_title"] ?? '';
  85. $menu_item_link = $_POST["menu_item_link"] ?? '';
  86. $menu_item_category = $_POST["menu_item_category"] ?? '';
  87. $menu_item_icon = $_POST["menu_item_icon"] ?? '';
  88. $menu_item_description = $_POST["menu_item_description"] ?? '';
  89. $menu_item_protected = $_POST["menu_item_protected"] ?? '';
  90. $menu_item_parent_uuid = $_POST["menu_item_parent_uuid"] ?? null;
  91. $menu_item_order = $_POST["menu_item_order"] ?? '';
  92. }
  93. //sanitize the menu link
  94. $menu_item_link = preg_replace('#[^a-zA-Z0-9_:\-\.\&\=\?\/]#', '', $menu_item_link);
  95. //when a HTTP POST is available then process it
  96. if (!empty($_POST) && empty($_POST["persistformvar"])) {
  97. if ($action == "update") {
  98. $menu_item_uuid = $_POST["menu_item_uuid"];
  99. }
  100. //validate the token
  101. $token = new token;
  102. if (!$token->validate($_SERVER['PHP_SELF'])) {
  103. message::add($text['message-invalid_token'],'negative');
  104. header('Location: menu.php');
  105. exit;
  106. }
  107. //check for all required data
  108. $msg = '';
  109. if (empty($menu_item_title)) { $msg .= $text['message-required'].$text['label-title']."<br>\n"; }
  110. if (empty($menu_item_category)) { $msg .= $text['message-required'].$text['label-category']."<br>\n"; }
  111. //if (empty($menu_item_link)) { $msg .= $text['message-required'].$text['label-link']."<br>\n"; }
  112. if (!empty($msg) && empty($_POST["persistformvar"])) {
  113. require_once "resources/header.php";
  114. require_once "resources/persist_form_var.php";
  115. echo "<div align='center'>\n";
  116. echo "<table><tr><td>\n";
  117. echo $msg."<br />";
  118. echo "</td></tr></table>\n";
  119. persistformvar($_POST);
  120. echo "</div>\n";
  121. require_once "resources/footer.php";
  122. return;
  123. }
  124. //add or update the database
  125. if (empty($_POST["persistformvar"])) {
  126. //get the language from the menu
  127. $sql = "select menu_language from v_menus ";
  128. $sql .= "where menu_uuid = :menu_uuid ";
  129. $parameters['menu_uuid'] = $menu_uuid;
  130. $database = new database;
  131. $menu_language = $database->select($sql, $parameters, 'column');
  132. unset($sql, $parameters);
  133. //get the highest menu item order
  134. if (!is_uuid($menu_item_parent_uuid)) {
  135. $sql = "select menu_item_order from v_menu_items ";
  136. $sql .= "where menu_uuid = :menu_uuid ";
  137. $sql .= "and menu_item_parent_uuid is null ";
  138. $sql .= "order by menu_item_order desc ";
  139. $sql .= "limit 1 ";
  140. $parameters['menu_uuid'] = $menu_uuid;
  141. $database = new database;
  142. $highest_menu_item_order = $database->select($sql, $parameters, 'column');
  143. unset($sql, $parameters);
  144. }
  145. //add a menu item
  146. if ($action == "add" && permission_exists('menu_add')) {
  147. $menu_item_uuid = uuid();
  148. $array['menu_items'][0]['menu_uuid'] = $menu_uuid;
  149. $array['menu_items'][0]['menu_item_title'] = $menu_item_title;
  150. $array['menu_items'][0]['menu_item_link'] = $menu_item_link;
  151. $array['menu_items'][0]['menu_item_category'] = $menu_item_category;
  152. $array['menu_items'][0]['menu_item_icon'] = $menu_item_icon;
  153. $array['menu_items'][0]['menu_item_description'] = $menu_item_description;
  154. $array['menu_items'][0]['menu_item_protected'] = $menu_item_protected;
  155. $array['menu_items'][0]['menu_item_uuid'] = $menu_item_uuid;
  156. if (!is_uuid($menu_item_parent_uuid)) {
  157. $array['menu_items'][0]['menu_item_parent_uuid'] = null;
  158. $array['menu_items'][0]['menu_item_order'] = ($highest_menu_item_order + 1);
  159. }
  160. else {
  161. $array['menu_items'][0]['menu_item_parent_uuid'] = $menu_item_parent_uuid;
  162. }
  163. $array['menu_items'][0]['menu_item_add_user'] = $_SESSION["username"];
  164. $array['menu_items'][0]['menu_item_add_date'] = 'now()';
  165. $database = new database;
  166. $database->app_name = 'menu';
  167. $database->app_uuid = 'f4b3b3d2-6287-489c-2a00-64529e46f2d7';
  168. $database->save($array);
  169. unset($array);
  170. }
  171. //update the menu item
  172. if ($action == "update" && permission_exists('menu_edit')) {
  173. $array['menu_items'][0]['menu_uuid'] = $menu_uuid;
  174. $array['menu_items'][0]['menu_item_title'] = $menu_item_title;
  175. $array['menu_items'][0]['menu_item_link'] = $menu_item_link;
  176. $array['menu_items'][0]['menu_item_category'] = $menu_item_category;
  177. $array['menu_items'][0]['menu_item_icon'] = $menu_item_icon;
  178. $array['menu_items'][0]['menu_item_description'] = $menu_item_description;
  179. $array['menu_items'][0]['menu_item_protected'] = $menu_item_protected;
  180. $array['menu_items'][0]['menu_item_uuid'] = $menu_item_uuid;
  181. if (!is_uuid($menu_item_parent_uuid)) {
  182. $array['menu_items'][0]['menu_item_parent_uuid'] = null;
  183. $array['menu_items'][0]['menu_item_order'] = is_numeric($menu_item_order) ? $menu_item_order : ($highest_menu_item_order + 1);
  184. }
  185. else {
  186. $array['menu_items'][0]['menu_item_parent_uuid'] = $menu_item_parent_uuid;
  187. }
  188. $array['menu_items'][0]['menu_item_add_user'] = $_SESSION["username"];
  189. $array['menu_items'][0]['menu_item_add_date'] = 'now()';
  190. $database = new database;
  191. $database->app_name = 'menu';
  192. $database->app_uuid = 'f4b3b3d2-6287-489c-2a00-64529e46f2d7';
  193. $database->save($array);
  194. unset($array);
  195. }
  196. //update child menu items to protected true or false
  197. $sql = "update v_menu_items ";
  198. $sql .= "set menu_item_protected = :menu_item_protected ";
  199. $sql .= "where menu_item_parent_uuid = :menu_item_parent_uuid ";
  200. $parameters['menu_item_parent_uuid'] = $menu_item_uuid;
  201. $parameters['menu_item_protected'] = $menu_item_protected;
  202. $database = new database;
  203. $database->execute($sql, $parameters);
  204. unset($parameters);
  205. //add a group to the menu
  206. if (!empty($group_uuid_name) && permission_exists('menu_add')) {
  207. $group_data = explode('|', $group_uuid_name);
  208. $group_uuid = $group_data[0];
  209. $group_name = $group_data[1];
  210. //add the group to the menu
  211. if (is_uuid($menu_item_uuid)) {
  212. $menu_item_group_uuid = uuid();
  213. $array['menu_item_groups'][0]['menu_item_group_uuid'] = $menu_item_group_uuid;
  214. $array['menu_item_groups'][0]['menu_uuid'] = $menu_uuid;
  215. $array['menu_item_groups'][0]['menu_item_uuid'] = $menu_item_uuid;
  216. $array['menu_item_groups'][0]['group_name'] = $group_name;
  217. $array['menu_item_groups'][0]['group_uuid'] = $group_uuid;
  218. $database = new database;
  219. $database->app_name = 'menu';
  220. $database->app_uuid = 'f4b3b3d2-6287-489c-2a00-64529e46f2d7';
  221. $database->save($array);
  222. unset($array);
  223. }
  224. }
  225. //add the menu item label
  226. if (!empty($menu_item_title) && permission_exists('menu_add')) {
  227. $sql = "select count(*) from v_menu_languages ";
  228. $sql .= "where menu_item_uuid = :menu_item_uuid ";
  229. $sql .= "and menu_language = :menu_language ";
  230. $parameters['menu_item_uuid'] = $menu_item_uuid;
  231. $parameters['menu_language'] = $menu_language;
  232. $database = new database;
  233. $num_rows = $database->select($sql, $parameters, 'column');
  234. if ($num_rows == 0) {
  235. $array['menu_languages'][0]['menu_language_uuid'] = uuid();
  236. $array['menu_languages'][0]['menu_uuid'] = $menu_uuid;
  237. $array['menu_languages'][0]['menu_item_uuid'] = $menu_item_uuid;
  238. $array['menu_languages'][0]['menu_language'] = $menu_language;
  239. $array['menu_languages'][0]['menu_item_title'] = $menu_item_title;
  240. $database = new database;
  241. $database->app_name = 'menu';
  242. $database->app_uuid = 'f4b3b3d2-6287-489c-2a00-64529e46f2d7';
  243. $database->save($array);
  244. unset($array);
  245. }
  246. else {
  247. $sql = "update v_menu_languages set ";
  248. $sql .= "menu_item_title = :menu_item_title ";
  249. $sql .= "where menu_uuid = :menu_uuid ";
  250. $sql .= "and menu_item_uuid = :menu_item_uuid ";
  251. $sql .= "and menu_language = :menu_language ";
  252. $parameters['menu_item_title'] = $menu_item_title;
  253. $parameters['menu_uuid'] = $menu_uuid;
  254. $parameters['menu_item_uuid'] = $menu_item_uuid;
  255. $parameters['menu_language'] = $menu_language;
  256. $database = new database;
  257. $database->execute($sql, $parameters);
  258. }
  259. unset($sql, $parameters, $num_rows);
  260. }
  261. //set response message
  262. if ($action == "add") {
  263. message::add($text['message-add']);
  264. }
  265. if ($action == "update") {
  266. message::add($text['message-update']);
  267. }
  268. //redirect the user
  269. if (!empty($_REQUEST['submit']) && $_REQUEST['submit'] == $text['button-add']) {
  270. header("Location: menu_item_edit.php?id=".urlencode($menu_uuid)."&menu_item_uuid=".urlencode($menu_item_uuid)."&menu_uuid=".urlencode($menu_uuid));
  271. }
  272. else {
  273. header("Location: menu_edit.php?id=".urlencode($menu_uuid));
  274. }
  275. return;
  276. }
  277. }
  278. //pre-populate the form
  279. if (!empty($_GET["menu_item_uuid"]) && empty($_POST["persistformvar"])) {
  280. $menu_item_uuid = $_GET["menu_item_uuid"];
  281. $sql = "select * from v_menu_items ";
  282. $sql .= "where menu_uuid = :menu_uuid ";
  283. $sql .= "and menu_item_uuid = :menu_item_uuid ";
  284. $parameters['menu_uuid'] = $menu_uuid;
  285. $parameters['menu_item_uuid'] = $menu_item_uuid;
  286. $database = new database;
  287. $row = $database->select($sql, $parameters, 'row');
  288. if (is_array($row) && sizeof($row) != 0) {
  289. $menu_item_title = $row["menu_item_title"];
  290. $menu_item_link = $row["menu_item_link"];
  291. $menu_item_category = $row["menu_item_category"];
  292. $menu_item_icon = $row["menu_item_icon"];
  293. $menu_item_description = $row["menu_item_description"];
  294. $menu_item_protected = $row["menu_item_protected"];
  295. $menu_item_parent_uuid = $row["menu_item_parent_uuid"];
  296. $menu_item_order = $row["menu_item_order"];
  297. $menu_item_add_user = $row["menu_item_add_user"];
  298. $menu_item_add_date = $row["menu_item_add_date"];
  299. //$menu_item_del_user = $row["menu_item_del_user"];
  300. //$menu_item_del_date = $row["menu_item_del_date"];
  301. $menu_item_mod_user = $row["menu_item_mod_user"];
  302. $menu_item_mod_date = $row["menu_item_mod_date"];
  303. }
  304. unset($sql, $parameters, $row);
  305. }
  306. //get the the menu items
  307. $sql = "select * from v_menu_items ";
  308. $sql .= "where menu_uuid = :menu_uuid ";
  309. $sql .= "order by menu_item_title asc ";
  310. $parameters['menu_uuid'] = $menu_uuid;
  311. $database = new database;
  312. $menu_items = $database->select($sql, $parameters, 'all');
  313. unset($sql, $parameters);
  314. //get the assigned groups
  315. $sql = "select ";
  316. $sql .= " mig.*, g.group_name, g.domain_uuid as group_domain_uuid ";
  317. $sql .= "from ";
  318. $sql .= " v_menu_item_groups as mig, ";
  319. $sql .= " v_groups as g ";
  320. $sql .= "where ";
  321. $sql .= " mig.group_uuid = g.group_uuid ";
  322. $sql .= " and mig.menu_uuid = :menu_uuid ";
  323. $sql .= " and mig.menu_item_uuid = :menu_item_uuid ";
  324. $sql .= "order by ";
  325. $sql .= " g.domain_uuid desc, ";
  326. $sql .= " g.group_name asc ";
  327. $parameters['menu_uuid'] = $menu_uuid;
  328. $parameters['menu_item_uuid'] = $menu_item_uuid;
  329. $database = new database;
  330. $menu_item_groups = $database->select($sql, $parameters, 'all');
  331. unset($sql, $parameters);
  332. //set the assigned_groups array
  333. $assigned_groups = array();
  334. if (!empty($menu_item_groups) && sizeof($menu_item_groups) != 0) {
  335. foreach ($menu_item_groups as $field) {
  336. if (!empty($field['group_name'])) {
  337. if (is_uuid($field['group_uuid'])) {
  338. $assigned_groups[] = $field['group_uuid'];
  339. }
  340. }
  341. }
  342. }
  343. //get the groups
  344. $sql = "select * from v_groups ";
  345. $sql .= "where (domain_uuid is null or domain_uuid = :domain_uuid) ";
  346. if (!empty($assigned_groups) && is_array($assigned_groups) && sizeof($assigned_groups) != 0) {
  347. $sql .= "and group_uuid not in ('".implode("','",$assigned_groups)."') ";
  348. }
  349. $sql .= "order by domain_uuid desc, group_name asc ";
  350. $database = new database;
  351. $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  352. $groups = $database->select($sql, $parameters, 'all');
  353. unset($sql, $sql_where, $parameters);
  354. //create token
  355. $object = new token;
  356. $token = $object->create($_SERVER['PHP_SELF']);
  357. //include the header
  358. $document['title'] = $text['title-menu_item'];
  359. require_once "resources/header.php";
  360. echo "<form name='frm' id='frm' method='post'>\n";
  361. echo "<div class='action_bar' id='action_bar'>\n";
  362. echo " <div class='heading'><b>".$text['header-menu_item']."</b></div>\n";
  363. echo " <div class='actions'>\n";
  364. echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'menu_edit.php?id='.urlencode($menu_uuid)]);
  365. echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save']);
  366. echo " </div>\n";
  367. echo " <div style='clear: both;'></div>\n";
  368. echo "</div>\n";
  369. echo "<table width='100%' cellpadding='0' cellspacing='0'>\n";
  370. echo " <tr>";
  371. echo " <td width='30%' class='vncellreq'>".$text['label-title']."</td>";
  372. echo " <td width='70%' class='vtable'><input type='text' class='formfld' name='menu_item_title' value='".escape($menu_item_title)."'></td>";
  373. echo " </tr>";
  374. echo " <tr>";
  375. echo " <td class='vncell'>".$text['label-link']."</td>";
  376. echo " <td class='vtable'><input type='text' class='formfld' name='menu_item_link' value='".escape($menu_item_link)."'></td>";
  377. echo " </tr>";
  378. echo " <tr>";
  379. echo " <td class='vncell'>".$text['label-category']."</td>";
  380. echo " <td class='vtable'>";
  381. echo " <select name=\"menu_item_category\" class='formfld'>\n";
  382. if ($menu_item_category == "internal") { echo "<option value=\"internal\" selected>".$text['option-internal']."</option>\n"; } else { echo "<option value=\"internal\">".$text['option-internal']."</option>\n"; }
  383. if ($menu_item_category == "external") { echo "<option value=\"external\" selected>".$text['option-external']."</option>\n"; } else { echo "<option value=\"external\">".$text['option-external']."</option>\n"; }
  384. if ($menu_item_category == "email") { echo "<option value=\"email\" selected>".$text['option-email']."</option>\n"; } else { echo "<option value=\"email\">".$text['option-email']."</option>\n"; }
  385. echo " </select>";
  386. echo " </td>";
  387. echo " </tr>";
  388. echo " <tr>";
  389. echo " <td class='vncell'>".$text['label-icon']."</td>";
  390. echo " <td class='vtable' style='vertical-align: bottom;'>";
  391. if (file_exists($_SERVER["PROJECT_ROOT"].'/resources/fontawesome/fas_icons.php')) {
  392. include 'resources/fontawesome/fas_icons.php';
  393. if (is_array($font_awesome_solid_icons) && @sizeof($font_awesome_solid_icons) != 0) {
  394. // rebuild and sort array
  395. foreach ($font_awesome_solid_icons as $i => $icon_class) {
  396. $icon_label = str_replace('fa-', '', $icon_class);
  397. $icon_label = str_replace('-', ' ', $icon_label);
  398. $icon_label = ucwords($icon_label);
  399. $icons[$icon_class] = $icon_label;
  400. }
  401. asort($icons, SORT_STRING);
  402. echo "<table cellpadding='0' cellspacing='0' border='0'>\n";
  403. echo " <tr>\n";
  404. echo " <td>\n";
  405. echo " <select class='formfld' name='menu_item_icon' id='menu_item_icon' onchange=\"$('#icons').slideUp(); $('#grid_icon').fadeIn();\">\n";
  406. echo " <option value=''></option>\n";
  407. foreach ($icons as $icon_class => $icon_label) {
  408. $selected = ($menu_item_icon == $icon_class) ? "selected" : null;
  409. echo " <option value='".escape($icon_class)."' ".$selected.">".escape($icon_label)."</option>\n";
  410. }
  411. echo " </select>\n";
  412. echo " </td>\n";
  413. echo " <td style='padding: 0 0 0 5px;'>\n";
  414. echo " <button id='grid_icon' type='button' class='btn btn-default list_control_icon' style='font-size: 15px; padding-top: 1px; padding-left: 3px;' onclick=\"$('#icons').fadeIn(); $(this).fadeOut();\"><span class='fas fa-th'></span></button>";
  415. echo " </td>\n";
  416. echo " </tr>\n";
  417. echo "</table>\n";
  418. echo "<div id='icons' style='clear: both; display: none; margin-top: 8px; padding-top: 10px; color: #000; max-height: 400px; overflow: auto;'>\n";
  419. foreach ($icons as $icon_class => $icon_label) {
  420. echo "<span class='fas ".escape($icon_class)." fa-fw' style='font-size: 24px; float: left; margin: 0 8px 8px 0; cursor: pointer; opacity: 0.3;' title='".escape($icon_label)."' onclick=\"$('#menu_item_icon').val('".escape($icon_class)."'); $('#icons').slideUp(); $('#grid_icon').fadeIn();\" onmouseover=\"this.style.opacity='1';\" onmouseout=\"this.style.opacity='0.3';\"></span>\n";
  421. }
  422. echo "</div>";
  423. }
  424. }
  425. else {
  426. echo " <input type='text' class='formfld' name='menu_item_icon' value='".escape($menu_item_icon)."'>";
  427. }
  428. echo " </td>";
  429. echo " </tr>";
  430. echo " <tr>";
  431. echo " <td class='vncell'>".$text['label-parent_menu']."</td>";
  432. echo " <td class='vtable'>";
  433. echo "<select name=\"menu_item_parent_uuid\" class='formfld'>\n";
  434. echo "<option value=\"\"></option>\n";
  435. foreach($menu_items as $field) {
  436. if ($menu_item_parent_uuid == $field['menu_item_uuid']) {
  437. echo "<option value='".escape($field['menu_item_uuid'])."' selected>".escape($field['menu_item_title'])."</option>\n";
  438. }
  439. else {
  440. echo "<option value='".escape($field['menu_item_uuid'])."'>".escape($field['menu_item_title'])."</option>\n";
  441. }
  442. }
  443. echo "</select>";
  444. unset($sql, $result);
  445. echo " </td>";
  446. echo " </tr>";
  447. echo " <tr>";
  448. echo " <td class='vncell' valign='top'>".$text['label-groups']."</td>";
  449. echo " <td class='vtable'>";
  450. if (!empty($menu_item_groups) && sizeof($menu_item_groups) != 0) {
  451. echo "<table cellpadding='0' cellspacing='0' border='0'>\n";
  452. foreach($menu_item_groups as $field) {
  453. if (!empty($field['group_name'])) {
  454. echo "<tr>\n";
  455. echo " <td class='vtable' style='white-space: nowrap; padding-right: 30px;' nowrap='nowrap'>";
  456. echo $field['group_name'].((!empty($field['group_domain_uuid'])) ? "@".$_SESSION['domains'][$field['group_domain_uuid']]['domain_name'] : null);
  457. echo " </td>\n";
  458. if (permission_exists('group_member_delete') || if_group("superadmin")) {
  459. echo " <td class='list_control_icons' style='width: 25px;'>";
  460. echo "<a href='menu_item_edit.php?id=".escape($field['menu_uuid'])."&menu_item_group_uuid=".escape($field['menu_item_group_uuid'])."&menu_item_uuid=".escape($menu_item_uuid)."&a=delete' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">".$v_link_label_delete."</a>";
  461. echo " </td>";
  462. }
  463. echo "</tr>\n";
  464. }
  465. }
  466. echo "</table>\n";
  467. echo "<br />\n";
  468. }
  469. if (!empty($groups)) {
  470. echo "<select name='group_uuid_name' class='formfld' style='width: auto; margin-right: 3px;'>\n";
  471. echo " <option value=''></option>\n";
  472. foreach($groups as $row) {
  473. if ($row['group_level'] <= $_SESSION['user']['group_level']) {
  474. if (!is_array($assigned_groups) || !in_array($row["group_uuid"], $assigned_groups)) {
  475. echo " <option value='".$row['group_uuid']."|".$row['group_name']."'>".$row['group_name'].((!empty($row['domain_uuid'])) ? "@".$_SESSION['domains'][$row['domain_uuid']]['domain_name'] : null)."</option>\n";
  476. }
  477. }
  478. }
  479. echo "</select>";
  480. echo button::create(['type'=>'submit','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'collapse'=>'never']);
  481. }
  482. echo " </td>";
  483. echo " </tr>";
  484. echo "<tr>\n";
  485. echo "<td class='vncell' valign='top' align='left' nowrap>\n";
  486. echo " ".$text['label-protected']."\n";
  487. echo "</td>\n";
  488. echo "<td class='vtable' align='left'>\n";
  489. echo " <select class='formfld' name='menu_item_protected'>\n";
  490. if ($menu_item_protected == "false") {
  491. echo " <option value='false' selected='selected' >".$text['label-false']."</option>\n";
  492. }
  493. else {
  494. echo " <option value='false'>".$text['label-false']."</option>\n";
  495. }
  496. if ($menu_item_protected == "true") {
  497. echo " <option value='true' selected='selected' >".$text['label-true']."</option>\n";
  498. }
  499. else {
  500. echo " <option value='true'>".$text['label-true']."</option>\n";
  501. }
  502. echo " </select><br />\n";
  503. echo $text['description-protected']."<br />\n";
  504. echo "\n";
  505. echo "</td>\n";
  506. echo "</tr>\n";
  507. if (!empty($action) && $action == "update") {
  508. if (empty($menu_item_parent_uuid)) {
  509. echo " <tr>";
  510. echo " <td class='vncell'>".$text['label-menu_order']."</td>";
  511. echo " <td class='vtable'><input type='text' class='formfld' name='menu_item_order' value='".escape($menu_item_order)."'></td>";
  512. echo " </tr>";
  513. }
  514. }
  515. echo " <tr>";
  516. echo " <td class='vncell'>".$text['label-description']."</td>";
  517. echo " <td class='vtable'><input type='text' class='formfld' name='menu_item_description' value='".escape($menu_item_description)."'></td>";
  518. echo " </tr>";
  519. echo "</table>";
  520. echo "<br><br>";
  521. if (permission_exists('menu_add') || permission_exists('menu_edit')) {
  522. if ($action == "update") {
  523. echo "<input type='hidden' name='menu_item_uuid' value='".escape($menu_item_uuid)."'>";
  524. }
  525. echo "<input type='hidden' name='menu_uuid' value='".escape($menu_uuid)."'>";
  526. echo "<input type='hidden' name='menu_item_uuid' value='".escape($menu_item_uuid)."'>";
  527. echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
  528. }
  529. echo "</form>";
  530. //include the footer
  531. require_once "resources/footer.php";
  532. ?>