mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Menu: Include domain for non-global groups in list and select.
This commit is contained in:
@@ -41,15 +41,14 @@ else {
|
||||
//get the menu_uuid
|
||||
$menu_uuid = check_str($_REQUEST["id"]);
|
||||
$menu_item_uuid = check_str($_REQUEST['menu_item_uuid']);
|
||||
$group_name = check_str($_REQUEST['group_name']);
|
||||
$group_uuid_name = check_str($_REQUEST['group_uuid_name']);
|
||||
$menu_item_group_uuid = check_str($_REQUEST['menu_item_group_uuid']);
|
||||
|
||||
//delete the group from the user
|
||||
if ($_REQUEST["a"] == "delete" && permission_exists("menu_delete")) {
|
||||
//delete the group from the menu item
|
||||
if ($_REQUEST["a"] == "delete" && permission_exists("menu_delete") && $menu_item_group_uuid != '') {
|
||||
//delete the group from the users
|
||||
$sql = "delete from v_menu_item_groups ";
|
||||
$sql .= "where menu_uuid = '".$menu_uuid."' ";
|
||||
$sql .= "and menu_item_uuid = '".$menu_item_uuid."' ";
|
||||
$sql .= "and group_name = '".$group_name."' ";
|
||||
$sql .= "where menu_item_group_uuid = '".$menu_item_group_uuid."' ";
|
||||
$db->exec(check_sql($sql));
|
||||
//redirect the browser
|
||||
$_SESSION["message"] = $text['message-delete'];
|
||||
@@ -211,7 +210,10 @@ else {
|
||||
}
|
||||
|
||||
//add a group to the menu
|
||||
if ($_REQUEST["a"] != "delete" && strlen($group_name) > 0 && permission_exists('menu_add')) {
|
||||
if ($_REQUEST["a"] != "delete" && strlen($group_uuid_name) > 0 && permission_exists('menu_add')) {
|
||||
$group_data = explode('|', $group_uuid_name);
|
||||
$group_uuid = $group_data[0];
|
||||
$group_name = $group_data[1];
|
||||
//add the group to the menu
|
||||
if (strlen($menu_item_uuid) > 0) {
|
||||
$menu_item_group_uuid = uuid();
|
||||
@@ -220,14 +222,16 @@ else {
|
||||
$sql_insert .= "menu_item_group_uuid, ";
|
||||
$sql_insert .= "menu_uuid, ";
|
||||
$sql_insert .= "menu_item_uuid, ";
|
||||
$sql_insert .= "group_name ";
|
||||
$sql_insert .= "group_name, ";
|
||||
$sql_insert .= "group_uuid ";
|
||||
$sql_insert .= ")";
|
||||
$sql_insert .= "values ";
|
||||
$sql_insert .= "(";
|
||||
$sql_insert .= "'".$menu_item_group_uuid."', ";
|
||||
$sql_insert .= "'".$menu_uuid."', ";
|
||||
$sql_insert .= "'".$menu_item_uuid."', ";
|
||||
$sql_insert .= "'".$group_name."' ";
|
||||
$sql_insert .= "'".$group_name."', ";
|
||||
$sql_insert .= "'".$group_uuid."' ";
|
||||
$sql_insert .= ")";
|
||||
$db->exec($sql_insert);
|
||||
}
|
||||
@@ -270,14 +274,21 @@ else {
|
||||
}
|
||||
}
|
||||
|
||||
//redirect the user
|
||||
//set response message
|
||||
if ($action == "add") {
|
||||
$_SESSION["message"] = $text['message-add'];
|
||||
}
|
||||
if ($action == "update") {
|
||||
$_SESSION["message"] = $text['message-update'];
|
||||
}
|
||||
header("Location: menu_edit.php?id=".$menu_uuid);
|
||||
|
||||
//redirect the user
|
||||
if ($_REQUEST['submit'] == $text['button-add']) {
|
||||
header("Location: menu_item_edit.php?id=".$menu_uuid."&menu_item_uuid=".$menu_item_uuid."&menu_uuid=".$menu_uuid);
|
||||
}
|
||||
else {
|
||||
header("Location: menu_edit.php?id=".$menu_uuid);
|
||||
}
|
||||
return;
|
||||
} //if ($_POST["persistformvar"] != "true")
|
||||
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
|
||||
@@ -383,53 +394,78 @@ else {
|
||||
echo " <td class='vncell' valign='top'>".$text['label-groups']."</td>";
|
||||
echo " <td class='vtable'>";
|
||||
|
||||
echo "<table width='52%'>\n";
|
||||
$sql = "SELECT * FROM v_menu_item_groups ";
|
||||
$sql .= "where menu_uuid=:menu_uuid ";
|
||||
$sql .= "and menu_item_uuid=:menu_item_uuid ";
|
||||
//group list
|
||||
$sql = "select ";
|
||||
$sql .= " mig.*, g.domain_uuid as group_domain_uuid ";
|
||||
$sql .= "from ";
|
||||
$sql .= " v_menu_item_groups as mig, ";
|
||||
$sql .= " v_groups as g ";
|
||||
$sql .= "where ";
|
||||
$sql .= " mig.group_uuid = g.group_uuid ";
|
||||
$sql .= " and (";
|
||||
$sql .= " g.domain_uuid = :domain_uuid ";
|
||||
$sql .= " or g.domain_uuid is null ";
|
||||
$sql .= " ) ";
|
||||
$sql .= " and mig.menu_uuid = :menu_uuid ";
|
||||
$sql .= " and mig.menu_item_uuid = :menu_item_uuid ";
|
||||
$sql .= "order by ";
|
||||
$sql .= " g.domain_uuid desc, ";
|
||||
$sql .= " g.group_name asc ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->bindParam(':domain_uuid', $domain_uuid);
|
||||
$prep_statement->bindParam(':menu_uuid', $menu_uuid);
|
||||
$prep_statement->bindParam(':menu_item_uuid', $menu_item_uuid);
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
$result_count = count($result);
|
||||
foreach($result as $field) {
|
||||
if (strlen($field['group_name']) > 0) {
|
||||
echo "<tr>\n";
|
||||
echo " <td class='vtable'>".$field['group_name']."</td>\n";
|
||||
echo " <td>\n";
|
||||
if (permission_exists('group_member_delete') || if_group("superadmin")) {
|
||||
echo " <a href='menu_item_edit.php?id=".$field['menu_uuid']."&group_name=".$field['group_name']."&menu_item_uuid=".$menu_item_uuid."&menu_item_parent_uuid=".$menu_item_parent_uuid."&a=delete' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
|
||||
if ($result_count > 0) {
|
||||
echo "<table cellpadding='0' cellspacing='0' border='0'>\n";
|
||||
foreach($result as $field) {
|
||||
if (strlen($field['group_name']) > 0) {
|
||||
echo "<tr>\n";
|
||||
echo " <td class='vtable' style='white-space: nowrap; padding-right: 30px;' nowrap='nowrap'>";
|
||||
echo $field['group_name'].(($field['group_domain_uuid'] != '') ? "@".$_SESSION['domains'][$field['group_domain_uuid']]['domain_name'] : null);
|
||||
echo " </td>\n";
|
||||
if (permission_exists('group_member_delete') || if_group("superadmin")) {
|
||||
echo " <td class='list_control_icons' style='width: 25px;'>";
|
||||
echo "<a href='menu_item_edit.php?id=".$field['menu_uuid']."&menu_item_group_uuid=".$field['menu_item_group_uuid']."&menu_item_uuid=".$menu_item_uuid."&a=delete' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">".$v_link_label_delete."</a>";
|
||||
echo " </td>";
|
||||
}
|
||||
echo "</tr>\n";
|
||||
$assigned_groups[] = $field['group_uuid'];
|
||||
}
|
||||
echo " </td>\n";
|
||||
echo "</tr>\n";
|
||||
$assigned_groups[] = $field['group_name'];
|
||||
}
|
||||
echo "</table>\n";
|
||||
}
|
||||
echo "</table>\n";
|
||||
unset($sql, $prep_statement, $result, $result_count);
|
||||
|
||||
echo "<br />\n";
|
||||
$sql = "SELECT * FROM v_groups ";
|
||||
//group select
|
||||
$sql = "select * from v_groups ";
|
||||
$sql .= "where (domain_uuid = '".$domain_uuid."' or domain_uuid is null) ";
|
||||
$sql .= "order by group_name asc ";
|
||||
if (sizeof($assigned_groups) > 0) {
|
||||
$sql .= "and group_uuid not in ('".implode("','",$assigned_groups)."') ";
|
||||
}
|
||||
$sql .= "order by domain_uuid desc, group_name asc ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
echo "<select name=\"group_name\" class='formfld' style='width: auto; margin-right: 3px;'>\n";
|
||||
echo "<option value=\"\"></option>\n";
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach($result as $field) {
|
||||
if (!in_array($field['group_name'], $assigned_groups)) {
|
||||
if ($field['group_name'] == "superadmin" && if_group("superadmin")) {
|
||||
echo "<option value='".$field['group_name']."'>".$field['group_name']."</option>\n"; //only show the superadmin group to other users in the superadmin group
|
||||
}
|
||||
else {
|
||||
echo "<option value='".$field['group_name']."'>".$field['group_name']."</option>\n";
|
||||
$result_count = count($result);
|
||||
if ($result_count > 0) {
|
||||
echo "<br />\n";
|
||||
echo "<select name='group_uuid_name' class='formfld' style='width: auto; margin-right: 3px;'>\n";
|
||||
echo " <option value=''></option>\n";
|
||||
foreach($result as $field) {
|
||||
if ($field['group_name'] == "superadmin" && !if_group("superadmin")) { continue; } //only show the superadmin group to other superadmins
|
||||
if ($field['group_name'] == "admin" && (!if_group("superadmin") && !if_group("admin") )) { continue; } //only show the admin group to other admins
|
||||
if (!in_array($field["group_uuid"], $assigned_groups)) {
|
||||
echo " <option value='".$field['group_uuid']."|".$field['group_name']."'>".$field['group_name'].(($field['domain_uuid'] != '') ? "@".$_SESSION['domains'][$field['domain_uuid']]['domain_name'] : null)."</option>\n";
|
||||
}
|
||||
}
|
||||
echo "</select>";
|
||||
echo "<input type='submit' class='btn' name='submit' value=\"".$text['button-add']."\">\n";
|
||||
}
|
||||
echo "</select>";
|
||||
echo "<input type=\"submit\" class='btn' value=\"".$text['button-add']."\">\n";
|
||||
unset($sql, $result);
|
||||
unset($sql, $prep_statement, $result);
|
||||
|
||||
echo " </td>";
|
||||
echo " </tr>";
|
||||
|
||||
|
||||
@@ -65,24 +65,26 @@ function build_db_child_menu_list ($db, $menu_item_level, $menu_item_uuid, $c) {
|
||||
$menu_item_title = $row2[menu_item_title];
|
||||
$menu_item_link = $row2[menu_item_link];
|
||||
//get the groups that have been assigned to the menu
|
||||
$sql = "";
|
||||
$sql .= "select group_name from v_menu_item_groups ";
|
||||
$sql .= "where menu_uuid = '$menu_uuid' ";
|
||||
$sql .= "and menu_item_uuid = '".$menu_item_uuid."' ";
|
||||
$sql = "select ";
|
||||
$sql .= " g.group_name, g.domain_uuid as group_domain_uuid ";
|
||||
$sql .= "from ";
|
||||
$sql .= " v_menu_item_groups as mig, ";
|
||||
$sql .= " v_groups as g ";
|
||||
$sql .= "where ";
|
||||
$sql .= " mig.group_uuid = g.group_uuid ";
|
||||
$sql .= " and mig.menu_uuid = '".$menu_uuid."' ";
|
||||
$sql .= " and mig.menu_item_uuid = '".$menu_item_uuid."' ";
|
||||
$sql .= "order by ";
|
||||
$sql .= " g.domain_uuid desc, ";
|
||||
$sql .= " g.group_name asc ";
|
||||
$sub_prep_statement = $db->prepare(check_sql($sql));
|
||||
$sub_prep_statement->execute();
|
||||
$sub_result = $sub_prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
$group_list = "";
|
||||
$x = 0;
|
||||
unset($group_list);
|
||||
foreach ($sub_result as &$sub_row) {
|
||||
if ($x == 0) {
|
||||
$group_list = $sub_row["group_name"];
|
||||
}
|
||||
else {
|
||||
$group_list .= ", ".$sub_row["group_name"];
|
||||
}
|
||||
$x++;
|
||||
$group_list[] = $sub_row["group_name"].(($sub_row['group_domain_uuid'] != '') ? "@".$_SESSION['domains'][$sub_row['group_domain_uuid']]['domain_name'] : null);
|
||||
}
|
||||
$group_list = implode(', ', $group_list);
|
||||
unset ($sub_prep_statement);
|
||||
//display the main body of the list
|
||||
switch ($menu_item_category) {
|
||||
@@ -226,23 +228,26 @@ else {
|
||||
$menu_item_protected = $row['menu_item_protected'];
|
||||
|
||||
//get the groups that have been assigned to the menu
|
||||
$sql = "select group_name from v_menu_item_groups ";
|
||||
$sql .= "where menu_uuid = '$menu_uuid' ";
|
||||
$sql .= "and menu_item_uuid = '$menu_item_uuid' ";
|
||||
$sql = "select ";
|
||||
$sql .= " g.group_name, g.domain_uuid as group_domain_uuid ";
|
||||
$sql .= "from ";
|
||||
$sql .= " v_menu_item_groups as mig, ";
|
||||
$sql .= " v_groups as g ";
|
||||
$sql .= "where ";
|
||||
$sql .= " mig.group_uuid = g.group_uuid ";
|
||||
$sql .= " and mig.menu_uuid = '".$menu_uuid."' ";
|
||||
$sql .= " and mig.menu_item_uuid = '".$menu_item_uuid."' ";
|
||||
$sql .= "order by ";
|
||||
$sql .= " g.domain_uuid desc, ";
|
||||
$sql .= " g.group_name asc ";
|
||||
$sub_prep_statement = $db->prepare(check_sql($sql));
|
||||
$sub_prep_statement->execute();
|
||||
$sub_result = $sub_prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
$group_list = "";
|
||||
$x = 0;
|
||||
unset($group_list);
|
||||
foreach ($sub_result as &$sub_row) {
|
||||
if ($x == 0) {
|
||||
$group_list = $sub_row["group_name"];
|
||||
}
|
||||
else {
|
||||
$group_list .= ", ".$sub_row["group_name"];
|
||||
}
|
||||
$x++;
|
||||
$group_list[] = $sub_row["group_name"].(($sub_row['group_domain_uuid'] != '') ? "@".$_SESSION['domains'][$sub_row['group_domain_uuid']]['domain_name'] : null);
|
||||
}
|
||||
$group_list = implode(', ', $group_list);
|
||||
unset ($sub_prep_statement);
|
||||
|
||||
//add the type link based on the typd of the menu
|
||||
|
||||
Reference in New Issue
Block a user