mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-06 11:43:50 +00:00
new changes to group_permissions/menu logic
This commit is contained in:
@@ -225,6 +225,12 @@
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'groupdesc';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
|
||||
$z++;
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'group_unchanged';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = 'groupdesc';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = '';
|
||||
|
||||
|
||||
$y = 2; //table array index
|
||||
$z = 0; //field array index
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
$text['label-time_zone']['en-us'] = 'Time Zone';
|
||||
$text['label-enabled']['en-us'] = 'Enabled';
|
||||
$text['label-group_name']['en-us'] = 'Name';
|
||||
$text['label-group_check']['en-us'] = 'Protected';
|
||||
$text['label-group_description']['en-us'] = 'Description';
|
||||
$text['label-group_permissions']['en-us'] = 'Permissions';
|
||||
$text['label-group_members']['en-us'] = 'Members';
|
||||
@@ -68,7 +69,13 @@
|
||||
$text['button-back']['en-us'] = 'Back';
|
||||
$text['button-save']['en-us'] = 'Save';
|
||||
$text['button-restore']['en-us'] = 'Restore Default';
|
||||
$text['button-copy']['en-us'] = 'Copy';
|
||||
$text['button-add_member']['en-us'] = 'Add Member';
|
||||
|
||||
$text['message-copy']['en-us'] = 'Copy Completed';
|
||||
$text['message-copy']['pt-pt'] = '';
|
||||
$text['message-message']['en-us'] = 'Message';
|
||||
$text['message-message']['pt-pt'] = '';
|
||||
|
||||
$text['confirm-delete']['en-us'] = 'Do you really want to delete this?';
|
||||
|
||||
|
||||
@@ -26,6 +26,13 @@
|
||||
require_once "root.php";
|
||||
require_once "resources/require.php";
|
||||
require_once "resources/check_auth.php";
|
||||
require_once "resources/classes/logging.php";
|
||||
// Logging class initialization
|
||||
$log = new Logging();
|
||||
|
||||
// set path and name of log file (optional)
|
||||
$log->lfile('/tmp/mylog.txt');
|
||||
|
||||
if (permission_exists('group_permissions') || if_group("superadmin")) {
|
||||
//access granted
|
||||
}
|
||||
@@ -106,6 +113,7 @@ require_once "resources/paging.php";
|
||||
$permission_name = $row["permission_name"];
|
||||
$permissions_db[$permission_name] = "true";
|
||||
}
|
||||
|
||||
//show the db checklist
|
||||
//echo "<pre>";
|
||||
//print_r($permissions_db);
|
||||
@@ -121,7 +129,8 @@ require_once "resources/paging.php";
|
||||
$permissions_db_checklist[$row['name']] = "false";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//show the db checklist
|
||||
//echo "<pre>";
|
||||
//print_r($permissions_db_checklist);
|
||||
@@ -167,6 +176,58 @@ require_once "resources/paging.php";
|
||||
$sql .= "and permission_name = '$permission' ";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
|
||||
foreach($apps as $app) {
|
||||
foreach ($app['permissions'] as $row) {
|
||||
if ($row['name'] == $permission) {
|
||||
|
||||
$log->lwrite("2");
|
||||
$log->lwrite($row['menu']['uuid']);
|
||||
|
||||
$sql = "delete from v_menu_item_groups ";
|
||||
$sql .= "where menu_item_uuid = '".$row['menu']['uuid']."' ";
|
||||
$sql .= "and group_name = '$group_name' ";
|
||||
$sql .= "and menu_uuid = 'b4750c3f-2a86-b00d-b7d0-345c14eca286' ";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
|
||||
$sql = "";
|
||||
$sql .= " select menu_item_parent_uuid from v_menu_items ";
|
||||
$sql .= "where menu_item_uuid = '".$row['menu']['uuid']."' ";
|
||||
$sql .= "and menu_uuid = 'b4750c3f-2a86-b00d-b7d0-345c14eca286' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as &$row) {
|
||||
$menu_item_parent_uuid = $row["menu_item_parent_uuid"];
|
||||
}
|
||||
unset ($prep_statement);
|
||||
|
||||
$sql = "";
|
||||
$sql .= " select * from v_menu_items as i, v_menu_item_groups as g ";
|
||||
$sql .= "where i.menu_item_uuid = g.menu_item_uuid ";
|
||||
$sql .= "and i.menu_uuid = 'b4750c3f-2a86-b00d-b7d0-345c14eca286' ";
|
||||
$sql .= "and i.menu_item_parent_uuid = '$menu_item_parent_uuid' ";
|
||||
$sql .= "and g.group_name = '$group_name' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
$result_count = count($result);
|
||||
if ($result_count == 0) {
|
||||
$sql = "delete from v_menu_item_groups ";
|
||||
$sql .= "where menu_item_uuid = '$menu_item_parent_uuid' ";
|
||||
$sql .= "and group_name = '$group_name' ";
|
||||
$sql .= "and menu_uuid = 'b4750c3f-2a86-b00d-b7d0-345c14eca286' ";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
}
|
||||
unset ($prep_statement);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
//set the permission to false in the permissions_db_checklist
|
||||
$permissions_db_checklist[$permission] = "false";
|
||||
}
|
||||
@@ -188,6 +249,71 @@ require_once "resources/paging.php";
|
||||
$sql .= ")";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
|
||||
foreach($apps as $app) {
|
||||
foreach ($app['permissions'] as $row) {
|
||||
if ($row['name'] == $permission) {
|
||||
|
||||
$log->lwrite("1");
|
||||
$log->lwrite($row['menu']['uuid']);
|
||||
$log->lwrite($row['menu']['parent_uuid']);
|
||||
|
||||
$sql = "insert into v_menu_item_groups ";
|
||||
$sql .= "(";
|
||||
$sql .= "menu_uuid, ";
|
||||
$sql .= "menu_item_uuid, ";
|
||||
$sql .= "group_name ";
|
||||
$sql .= ")";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'b4750c3f-2a86-b00d-b7d0-345c14eca286', ";
|
||||
$sql .= "'".$row['menu']['uuid']."', ";
|
||||
$sql .= "'$group_name' ";
|
||||
$sql .= ")";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
|
||||
$sql = "";
|
||||
$sql .= " select menu_item_parent_uuid from v_menu_items ";
|
||||
$sql .= "where menu_item_uuid = '".$row['menu']['uuid']."' ";
|
||||
$sql .= "and menu_uuid = 'b4750c3f-2a86-b00d-b7d0-345c14eca286' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as &$row) {
|
||||
$menu_item_parent_uuid = $row["menu_item_parent_uuid"];
|
||||
}
|
||||
unset ($prep_statement);
|
||||
|
||||
$sql = "";
|
||||
$sql .= " select * from v_menu_item_groups ";
|
||||
$sql .= "where menu_item_uuid = '$menu_item_parent_uuid' ";
|
||||
$sql .= "and group_name = '$group_name' ";
|
||||
$sql .= "and menu_uuid = 'b4750c3f-2a86-b00d-b7d0-345c14eca286' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
$result_count = count($result);
|
||||
if ($result_count == 0) {
|
||||
$sql = "insert into v_menu_item_groups ";
|
||||
$sql .= "(";
|
||||
$sql .= "menu_uuid, ";
|
||||
$sql .= "menu_item_uuid, ";
|
||||
$sql .= "group_name ";
|
||||
$sql .= ")";
|
||||
$sql .= "values ";
|
||||
$sql .= "(";
|
||||
$sql .= "'b4750c3f-2a86-b00d-b7d0-345c14eca286', ";
|
||||
$sql .= "'$menu_item_parent_uuid', ";
|
||||
$sql .= "'$group_name' ";
|
||||
$sql .= ")";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
}
|
||||
unset ($prep_statement);
|
||||
}
|
||||
}
|
||||
}
|
||||
//set the permission to true in the permissions_db_checklist
|
||||
$permissions_db_checklist[$permission] = "true";
|
||||
}
|
||||
@@ -233,8 +359,19 @@ require_once "resources/paging.php";
|
||||
$app_name = $app['name'];
|
||||
$description = $app['description']['en-us'];
|
||||
|
||||
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
||||
echo "<tr>\n";
|
||||
echo " <td valign='top' style='width:80%' nowrap='nowrap'>\n";
|
||||
echo "<strong>".$app_name."</strong><br />\n";
|
||||
echo " </td>\n";
|
||||
echo "</tr>\n";
|
||||
echo "<tr>\n";
|
||||
echo " <td valign='top'>\n";
|
||||
echo "".$description."<br /><br />";
|
||||
echo " </td>\n";
|
||||
echo "</tr>\n";
|
||||
echo "</table>";
|
||||
|
||||
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
||||
echo "<tr>\n";
|
||||
echo "<th>".$text['label-permission_permissions']."</th>\n";
|
||||
|
||||
@@ -45,6 +45,21 @@ else {
|
||||
//show the header
|
||||
require_once "resources/header.php";
|
||||
$page["title"] = $text['title-group_manager'];
|
||||
|
||||
if (isset($_REQUEST["change"])) {
|
||||
//get the values from the HTTP POST and save them as PHP variables
|
||||
$change = check_str($_REQUEST["change"]);
|
||||
$group_name = check_str($_REQUEST["group_name"]);
|
||||
|
||||
$sql = "update v_groups set ";
|
||||
$sql .= "group_unchanged = '$change' ";
|
||||
$sql .= "where domain_uuid = '$domain_uuid' ";
|
||||
$sql .= "and group_name = '$group_name' ";
|
||||
$db->exec(check_sql($sql));
|
||||
unset($sql);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//show the content
|
||||
echo "<div class='' style='padding:0px;'>\n";
|
||||
@@ -72,6 +87,7 @@ else {
|
||||
$strlist = "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
||||
$strlist .= "<tr class='border'>\n";
|
||||
$strlist .= " <th align=\"left\" nowrap> ".$text['label-group_name']." </th>\n";
|
||||
$strlist .= " <th align=\"left\" nowrap> ".$text['label-group_check']." </th>\n";
|
||||
$strlist .= " <th align=\"left\" nowrap> ".$text['label-group_description']." </th>\n";
|
||||
$strlist .= " <th align=\"center\" nowrap> </th>\n";
|
||||
|
||||
@@ -86,6 +102,7 @@ else {
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as &$row) {
|
||||
$group_name = $row["group_name"];
|
||||
$group_unchanged= $row["group_unchanged"];
|
||||
$group_uuid = $row["group_uuid"];
|
||||
$group_description = $row["group_description"];
|
||||
if (strlen($group_name) == 0) { $group_name = " "; }
|
||||
@@ -98,6 +115,15 @@ else {
|
||||
else {
|
||||
$strlist .= "<tr>";
|
||||
$strlist .= "<td class='".$row_style[$c]."' align=\"left\" class='' nowrap> $group_name </td>\n";
|
||||
//$strlist .= "<td class='".$row_style[$c]."' align=\"left\" class='' nowrap> $group_unchanged </td>\n";
|
||||
$strlist .= " <td class='".$row_style[$c]."' align=\"left\" nowrap='nowrap' nowrap>\n";
|
||||
if ($group_unchanged == "true") {
|
||||
$strlist .= " <input type='checkbox' name='group_unchanged' checked='checked' value='true' onchange=\"window.location='".PROJECT_PATH."/core/users/groups.php?change=false&group_name=".$group_name."';\">\n";
|
||||
}
|
||||
else {
|
||||
$strlist .= " <input type='checkbox' name='group_unchanged' value='false' onchange=\"window.location='".PROJECT_PATH."/core/users/groups.php?change=true&group_name=".$group_name."';\">\n";
|
||||
}
|
||||
$strlist .= " </td>\n";
|
||||
$strlist .= "<td class='".$row_style[$c]."' align=\"left\" class='' nowrap> $group_description </td>\n";
|
||||
|
||||
$strlist .= "<td class='".$row_style[$c]."' align=\"center\" nowrap>\n";
|
||||
@@ -120,7 +146,7 @@ else {
|
||||
}
|
||||
|
||||
$strlist .= "<tr>\n";
|
||||
$strlist .= "<td colspan='4' align='right' height='20'>\n";
|
||||
$strlist .= "<td colspan='5' align='right' height='20'>\n";
|
||||
if (permission_exists('group_add')) {
|
||||
$strlist .= " <a href='groupadd.php' alt='".$text['button-add']."'>$v_link_label_add</a>\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user