menu_item_protected deprecated

This protected feature has not been working correctly. At the moment commented out depending on feedback it maybe removed entirely.
This commit is contained in:
FusionPBX
2025-05-28 19:37:58 -06:00
committed by GitHub
parent ec613ab18d
commit b96b5f8c0f
5 changed files with 94 additions and 90 deletions

View File

@@ -193,10 +193,10 @@
$apps[$x]['db'][$y]['fields'][$z]['search'] = "true"; $apps[$x]['db'][$y]['fields'][$z]['search'] = "true";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++; $z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "menu_item_protected"; //$apps[$x]['db'][$y]['fields'][$z]['name'] = "menu_item_protected";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; //$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; //$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++; //$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "menu_item_order"; $apps[$x]['db'][$y]['fields'][$z]['name'] = "menu_item_order";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "numeric"; $apps[$x]['db'][$y]['fields'][$z]['type'] = "numeric";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = ""; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";

View File

@@ -53,7 +53,7 @@
$menu_item_icon = ''; $menu_item_icon = '';
$menu_item_icon_color = ''; $menu_item_icon_color = '';
$menu_item_description = ''; $menu_item_description = '';
$menu_item_protected = ''; //$menu_item_protected = '';
$menu_item_parent_uuid = null; $menu_item_parent_uuid = null;
$menu_item_order = null; $menu_item_order = null;
@@ -105,7 +105,7 @@
$menu_item_icon = $_POST["menu_item_icon"] ?? ''; $menu_item_icon = $_POST["menu_item_icon"] ?? '';
$menu_item_icon_color = $_POST["menu_item_icon_color"] ?? ''; $menu_item_icon_color = $_POST["menu_item_icon_color"] ?? '';
$menu_item_description = $_POST["menu_item_description"] ?? ''; $menu_item_description = $_POST["menu_item_description"] ?? '';
$menu_item_protected = $_POST["menu_item_protected"] ?? ''; //$menu_item_protected = $_POST["menu_item_protected"] ?? '';
$menu_item_parent_uuid = $_POST["menu_item_parent_uuid"] ?? null; $menu_item_parent_uuid = $_POST["menu_item_parent_uuid"] ?? null;
$menu_item_order = $_POST["menu_item_order"] ?? ''; $menu_item_order = $_POST["menu_item_order"] ?? '';
} }
@@ -177,7 +177,7 @@
$array['menu_items'][0]['menu_item_icon'] = $menu_item_icon; $array['menu_items'][0]['menu_item_icon'] = $menu_item_icon;
$array['menu_items'][0]['menu_item_icon_color'] = $menu_item_icon_color; $array['menu_items'][0]['menu_item_icon_color'] = $menu_item_icon_color;
$array['menu_items'][0]['menu_item_description'] = $menu_item_description; $array['menu_items'][0]['menu_item_description'] = $menu_item_description;
$array['menu_items'][0]['menu_item_protected'] = $menu_item_protected; //$array['menu_items'][0]['menu_item_protected'] = $menu_item_protected;
$array['menu_items'][0]['menu_item_uuid'] = $menu_item_uuid; $array['menu_items'][0]['menu_item_uuid'] = $menu_item_uuid;
if (!is_uuid($menu_item_parent_uuid)) { if (!is_uuid($menu_item_parent_uuid)) {
$array['menu_items'][0]['menu_item_parent_uuid'] = null; $array['menu_items'][0]['menu_item_parent_uuid'] = null;
@@ -203,7 +203,7 @@
$array['menu_items'][0]['menu_item_icon'] = $menu_item_icon; $array['menu_items'][0]['menu_item_icon'] = $menu_item_icon;
$array['menu_items'][0]['menu_item_icon_color'] = $menu_item_icon_color; $array['menu_items'][0]['menu_item_icon_color'] = $menu_item_icon_color;
$array['menu_items'][0]['menu_item_description'] = $menu_item_description; $array['menu_items'][0]['menu_item_description'] = $menu_item_description;
$array['menu_items'][0]['menu_item_protected'] = $menu_item_protected; //$array['menu_items'][0]['menu_item_protected'] = $menu_item_protected;
$array['menu_items'][0]['menu_item_uuid'] = $menu_item_uuid; $array['menu_items'][0]['menu_item_uuid'] = $menu_item_uuid;
if (!is_uuid($menu_item_parent_uuid)) { if (!is_uuid($menu_item_parent_uuid)) {
$array['menu_items'][0]['menu_item_parent_uuid'] = null; $array['menu_items'][0]['menu_item_parent_uuid'] = null;
@@ -221,13 +221,13 @@
} }
//update child menu items to protected true or false //update child menu items to protected true or false
$sql = "update v_menu_items "; //$sql = "update v_menu_items ";
$sql .= "set menu_item_protected = :menu_item_protected "; //$sql .= "set menu_item_protected = :menu_item_protected ";
$sql .= "where menu_item_parent_uuid = :menu_item_parent_uuid "; //$sql .= "where menu_item_parent_uuid = :menu_item_parent_uuid ";
$parameters['menu_item_parent_uuid'] = $menu_item_uuid; //$parameters['menu_item_parent_uuid'] = $menu_item_uuid;
$parameters['menu_item_protected'] = $menu_item_protected; //$parameters['menu_item_protected'] = $menu_item_protected;
$database->execute($sql, $parameters); //$database->execute($sql, $parameters);
unset($parameters); //unset($parameters);
//add a group to the menu //add a group to the menu
if (!empty($group_uuid_name) && permission_exists('menu_add')) { if (!empty($group_uuid_name) && permission_exists('menu_add')) {
@@ -319,7 +319,7 @@
$menu_item_icon = $row["menu_item_icon"]; $menu_item_icon = $row["menu_item_icon"];
$menu_item_icon_color = $row["menu_item_icon_color"]; $menu_item_icon_color = $row["menu_item_icon_color"];
$menu_item_description = $row["menu_item_description"]; $menu_item_description = $row["menu_item_description"];
$menu_item_protected = $row["menu_item_protected"]; //$menu_item_protected = $row["menu_item_protected"];
$menu_item_parent_uuid = $row["menu_item_parent_uuid"]; $menu_item_parent_uuid = $row["menu_item_parent_uuid"];
$menu_item_order = $row["menu_item_order"]; $menu_item_order = $row["menu_item_order"];
$menu_item_add_user = $row["menu_item_add_user"]; $menu_item_add_user = $row["menu_item_add_user"];
@@ -535,29 +535,29 @@
echo " </td>"; echo " </td>";
echo " </tr>"; echo " </tr>";
echo "<tr>\n"; //echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n"; //echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-protected']."\n"; //echo " ".$text['label-protected']."\n";
echo "</td>\n"; //echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; //echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='menu_item_protected'>\n"; //echo " <select class='formfld' name='menu_item_protected'>\n";
if ($menu_item_protected == "false") { //if ($menu_item_protected == "false") {
echo " <option value='false' selected='selected' >".$text['label-false']."</option>\n"; // echo " <option value='false' selected='selected' >".$text['label-false']."</option>\n";
} //}
else { //else {
echo " <option value='false'>".$text['label-false']."</option>\n"; // echo " <option value='false'>".$text['label-false']."</option>\n";
} //}
if ($menu_item_protected == "true") { //if ($menu_item_protected == "true") {
echo " <option value='true' selected='selected' >".$text['label-true']."</option>\n"; // echo " <option value='true' selected='selected' >".$text['label-true']."</option>\n";
} //}
else { //else {
echo " <option value='true'>".$text['label-true']."</option>\n"; // echo " <option value='true'>".$text['label-true']."</option>\n";
} //}
echo " </select><br />\n"; //echo " </select><br />\n";
echo $text['description-protected']."<br />\n"; //echo $text['description-protected']."<br />\n";
echo "\n"; //echo "\n";
echo "</td>\n"; //echo "</td>\n";
echo "</tr>\n"; //echo "</tr>\n";
if (!empty($action) && $action == "update") { if (!empty($action) && $action == "update") {
if (empty($menu_item_parent_uuid)) { if (empty($menu_item_parent_uuid)) {

View File

@@ -111,7 +111,7 @@
//set the db values as php variables //set the db values as php variables
$menu_item_uuid = $row2['menu_item_uuid']; $menu_item_uuid = $row2['menu_item_uuid'];
$menu_item_category = $row2['menu_item_category']; $menu_item_category = $row2['menu_item_category'];
$menu_item_protected = $row2['menu_item_protected']; //$menu_item_protected = $row2['menu_item_protected'];
$menu_item_parent_uuid = $row2['menu_item_parent_uuid']; $menu_item_parent_uuid = $row2['menu_item_parent_uuid'];
$menu_item_order = $row2['menu_item_order']; $menu_item_order = $row2['menu_item_order'];
$menu_item_title = $row2['menu_item_title']; $menu_item_title = $row2['menu_item_title'];
@@ -187,15 +187,15 @@
echo "<td class='no-wrap overflow no-link hide-sm-dn'>".$menu_item_link."&nbsp;</td>\n"; echo "<td class='no-wrap overflow no-link hide-sm-dn'>".$menu_item_link."&nbsp;</td>\n";
echo "<td class='no-wrap overflow hide-xs'>".$group_list."&nbsp;</td>"; echo "<td class='no-wrap overflow hide-xs'>".$group_list."&nbsp;</td>";
echo "<td class='center'>".$menu_item_category."&nbsp;</td>"; echo "<td class='center'>".$menu_item_category."&nbsp;</td>";
if (permission_exists('menu_item_edit')) { //if (permission_exists('menu_item_edit')) {
echo " <td class='no-link center'>\n"; // echo " <td class='no-link center'>\n";
echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.($menu_item_protected == 'true' ? 'true' : 'false')],'title'=>$text['button-toggle'],'onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('toggle'); list_form_submit('form_list')"]); // echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.($menu_item_protected == 'true' ? 'true' : 'false')],'title'=>$text['button-toggle'],'onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('toggle'); list_form_submit('form_list')"]);
} //}
else { //else {
echo " <td class='center'>\n"; // echo " <td class='center'>\n";
echo $text['label-'.($menu_item_protected == 'true' ? 'true' : 'false')]; // echo $text['label-'.($menu_item_protected == 'true' ? 'true' : 'false')];
} //}
echo " </td>\n"; //echo " </td>\n";
echo "<td class='center no-wrap'>&nbsp;</td>"; echo "<td class='center no-wrap'>&nbsp;</td>";
//echo "<td align='center'>"; //echo "<td align='center'>";
@@ -313,7 +313,7 @@
echo " <th class='no-wrap pct-35 hide-sm-dn'>".$text['label-link']."</th>"; echo " <th class='no-wrap pct-35 hide-sm-dn'>".$text['label-link']."</th>";
echo " <th class='no-wrap pct-35 hide-xs'>".$text['label-groups']."</th>"; echo " <th class='no-wrap pct-35 hide-xs'>".$text['label-groups']."</th>";
echo " <th class='no-wrap center shrink'>".$text['label-category']."</th>"; echo " <th class='no-wrap center shrink'>".$text['label-category']."</th>";
echo " <th class='no-wrap center shrink'>".$text['label-protected']."</th>"; //echo " <th class='no-wrap center shrink'>".$text['label-protected']."</th>";
echo " <th class='no-wrap center shrink'>".$text['label-menu_order']."</th>"; echo " <th class='no-wrap center shrink'>".$text['label-menu_order']."</th>";
if (permission_exists('menu_item_edit') && $list_row_edit_button) { if (permission_exists('menu_item_edit') && $list_row_edit_button) {
echo " <td class='action-button'>&nbsp;</td>\n"; echo " <td class='action-button'>&nbsp;</td>\n";
@@ -330,7 +330,7 @@
$menu_item_link = $row['menu_item_link']; $menu_item_link = $row['menu_item_link'];
$menu_item_icon = $row['menu_item_icon']; $menu_item_icon = $row['menu_item_icon'];
$menu_item_icon_color = $row['menu_item_icon_color']; $menu_item_icon_color = $row['menu_item_icon_color'];
$menu_item_protected = $row['menu_item_protected']; //$menu_item_protected = $row['menu_item_protected'];
//get the groups that have been assigned to the menu //get the groups that have been assigned to the menu
$sql = "select "; $sql = "select ";
@@ -399,15 +399,15 @@
echo "<td class='no-wrap overflow no-link hide-sm-dn'>".$menu_item_link."&nbsp;</td>\n"; echo "<td class='no-wrap overflow no-link hide-sm-dn'>".$menu_item_link."&nbsp;</td>\n";
echo "<td class='no-wrap overflow hide-xs'>".($group_list ?? '')."&nbsp;</td>\n"; echo "<td class='no-wrap overflow hide-xs'>".($group_list ?? '')."&nbsp;</td>\n";
echo "<td class='center'>".$menu_item_category."&nbsp;</td>\n"; echo "<td class='center'>".$menu_item_category."&nbsp;</td>\n";
if (permission_exists('menu_item_edit')) { //if (permission_exists('menu_item_edit')) {
echo "<td class='no-link center'>\n"; // echo "<td class='no-link center'>\n";
echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.($menu_item_protected == 'true' ? 'true' : 'false')],'title'=>$text['button-toggle'],'onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('toggle'); list_form_submit('form_list')"]); // echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.($menu_item_protected == 'true' ? 'true' : 'false')],'title'=>$text['button-toggle'],'onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('toggle'); list_form_submit('form_list')"]);
} //}
else { //else {
echo "<td class='center'>\n"; // echo "<td class='center'>\n";
echo $text['label-'.($menu_item_protected == 'true' ? 'true' : 'false')]; // echo $text['label-'.($menu_item_protected == 'true' ? 'true' : 'false')];
} //}
echo "</td>\n"; //echo "</td>\n";
echo "<td class='center'>".$row['menu_item_order']."&nbsp;</td>\n"; echo "<td class='center'>".$row['menu_item_order']."&nbsp;</td>\n";
//echo "<td align='center' nowrap>"; //echo "<td align='center' nowrap>";

View File

@@ -54,7 +54,7 @@
$menu = new menu; $menu = new menu;
$menu->menu_uuid = $menu_uuid; $menu->menu_uuid = $menu_uuid;
$menu->menu_language = $menu_language; $menu->menu_language = $menu_language;
$menu->delete_unprotected(); $menu->delete();
$menu->restore(); $menu->restore();
unset($menu); unset($menu);

View File

@@ -315,9 +315,9 @@
} }
/** /**
* delete items in the menu that are not protected * delete items in the menu
*/ */
public function delete_unprotected() { public function delete() {
//remove existing menu languages //remove existing menu languages
$sql = "delete from v_menu_languages "; $sql = "delete from v_menu_languages ";
$sql .= "where menu_uuid = :menu_uuid "; $sql .= "where menu_uuid = :menu_uuid ";
@@ -325,38 +325,38 @@
$sql .= " select menu_item_uuid "; $sql .= " select menu_item_uuid ";
$sql .= " from v_menu_items "; $sql .= " from v_menu_items ";
$sql .= " where menu_uuid = :menu_uuid "; $sql .= " where menu_uuid = :menu_uuid ";
$sql .= " and ( "; //$sql .= " and ( ";
$sql .= " menu_item_protected <> 'true' "; //$sql .= " menu_item_protected <> 'true' ";
$sql .= " or menu_item_protected is null "; //$sql .= " or menu_item_protected is null ";
$sql .= " ) "; //$sql .= " ) ";
$sql .= ") "; $sql .= ") ";
$parameters['menu_uuid'] = $this->menu_uuid; $parameters['menu_uuid'] = $this->menu_uuid;
$this->database->execute($sql, $parameters); $this->database->execute($sql, $parameters);
unset($sql, $parameters); unset($sql, $parameters);
//remove existing unprotected menu item groups //remove existing menu item groups
$sql = "delete from v_menu_item_groups "; $sql = "delete from v_menu_item_groups ";
$sql .= "where menu_uuid = :menu_uuid "; $sql .= "where menu_uuid = :menu_uuid ";
$sql .= "and menu_item_uuid in ( "; $sql .= "and menu_item_uuid in ( ";
$sql .= " select menu_item_uuid "; $sql .= " select menu_item_uuid ";
$sql .= " from v_menu_items "; $sql .= " from v_menu_items ";
$sql .= " where menu_uuid = :menu_uuid "; $sql .= " where menu_uuid = :menu_uuid ";
$sql .= " and ( "; //$sql .= " and ( ";
$sql .= " menu_item_protected <> 'true' "; //$sql .= " menu_item_protected <> 'true' ";
$sql .= " or menu_item_protected is null "; //$sql .= " or menu_item_protected is null ";
$sql .= " ) "; //$sql .= " ) ";
$sql .= ") "; $sql .= ") ";
$parameters['menu_uuid'] = $this->menu_uuid; $parameters['menu_uuid'] = $this->menu_uuid;
$this->database->execute($sql, $parameters); $this->database->execute($sql, $parameters);
unset($sql, $parameters); unset($sql, $parameters);
//remove existing unprotected menu items //remove existing menu items
$sql = "delete from v_menu_items "; $sql = "delete from v_menu_items ";
$sql .= "where menu_uuid = :menu_uuid "; $sql .= "where menu_uuid = :menu_uuid ";
$sql .= "and ( "; //$sql .= "and ( ";
$sql .= " menu_item_protected <> 'true' "; //$sql .= " menu_item_protected <> 'true' ";
$sql .= " or menu_item_protected is null "; //$sql .= " or menu_item_protected is null ";
$sql .= ") "; //$sql .= ") ";
$parameters['menu_uuid'] = $this->menu_uuid; $parameters['menu_uuid'] = $this->menu_uuid;
$this->database->execute($sql, $parameters); $this->database->execute($sql, $parameters);
unset($sql, $parameters); unset($sql, $parameters);
@@ -434,7 +434,7 @@
//execute save //execute save
$database = new database; $database = new database;
$database->app_name = $this->app_name; $database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid; $database->app_uuid = $this->app_uuid;
$database->save($array); $database->save($array);
unset($array); unset($array);
//set message //set message
@@ -786,7 +786,8 @@
$menu_items = $menu_field['menu_items']; $menu_items = $menu_field['menu_items'];
//prepare the protected menus //prepare the protected menus
$menu_item_title = ($menu_field['menu_item_protected'] == "true") ? $menu_field['menu_item_title'] : $menu_field['menu_language_title']; //$menu_item_title = ($menu_field['menu_item_protected'] == "true") ? $menu_field['menu_item_title'] : $menu_field['menu_language_title'];
$menu_item_title = $menu_field['menu_language_title'];
//prepare the menu_tags according to the category //prepare the menu_tags according to the category
$menu_tags = ''; $menu_tags = '';
@@ -867,7 +868,8 @@
$menu_items = $submenu_field['menu_items']; $menu_items = $submenu_field['menu_items'];
//prepare the protected menus //prepare the protected menus
$menu_item_title = ($submenu_field['menu_item_protected'] == "true") ? $submenu_field['menu_item_title'] : $submenu_field['menu_language_title']; //$menu_item_title = ($submenu_field['menu_item_protected'] == "true") ? $submenu_field['menu_item_title'] : $submenu_field['menu_language_title'];
$menu_item_title = $submenu_field['menu_language_title'];
//prepare the menu_tags according to the category //prepare the menu_tags according to the category
switch ($menu_item_category) { switch ($menu_item_category) {
@@ -922,8 +924,8 @@
//get the menu from the database //get the menu from the database
$sql = "select i.menu_item_link, l.menu_item_title as menu_language_title, "; $sql = "select i.menu_item_link, l.menu_item_title as menu_language_title, ";
$sql .= "i.menu_item_title, i.menu_item_protected, i.menu_item_category, "; $sql .= "i.menu_item_title, i.menu_item_category, i.menu_item_icon, ";
$sql .= "i.menu_item_icon, i.menu_item_icon_color, i.menu_item_uuid, i.menu_item_parent_uuid "; $sql .= "i.menu_item_icon_color, i.menu_item_uuid, i.menu_item_parent_uuid ";
$sql .= "from v_menu_items as i, v_menu_languages as l "; $sql .= "from v_menu_items as i, v_menu_languages as l ";
$sql .= "where i.menu_item_uuid = l.menu_item_uuid "; $sql .= "where i.menu_item_uuid = l.menu_item_uuid ";
$sql .= "and l.menu_language = :menu_language "; $sql .= "and l.menu_language = :menu_language ";
@@ -992,7 +994,9 @@
} }
//get the child menu from the database //get the child menu from the database
$sql = "select i.menu_item_link, l.menu_item_title as menu_language_title, i.menu_item_title, i.menu_item_protected, i.menu_item_category, i.menu_item_icon, i.menu_item_icon_color, i.menu_item_uuid, i.menu_item_parent_uuid "; $sql = "select i.menu_item_link, l.menu_item_title as menu_language_title, ";
$sql .= "i.menu_item_title, i.menu_item_category, i.menu_item_icon, ";
$sql .= "i.menu_item_icon_color, i.menu_item_uuid, i.menu_item_parent_uuid ";
$sql .= "from v_menu_items as i, v_menu_languages as l "; $sql .= "from v_menu_items as i, v_menu_languages as l ";
$sql .= "where i.menu_item_uuid = l.menu_item_uuid "; $sql .= "where i.menu_item_uuid = l.menu_item_uuid ";
$sql .= "and l.menu_language = :menu_language "; $sql .= "and l.menu_language = :menu_language ";
@@ -1039,13 +1043,13 @@
//add the row to the array //add the row to the array
$a[$x] = $row; $a[$x] = $row;
//prepare the protected menus //prepare the menus
if ($row['menu_item_protected'] == "true") { //if ($row['menu_item_protected'] == "true") {
$a[$x]['menu_item_title'] = $row['menu_item_title']; // $a[$x]['menu_item_title'] = $row['menu_item_title'];
} //}
else { //else {
$a[$x]['menu_item_title'] = $row['menu_language_title']; $a[$x]['menu_item_title'] = $row['menu_language_title'];
} //}
//get sub menu for children //get sub menu for children
if (!empty($menu_item_uuid)) { if (!empty($menu_item_uuid)) {