Portions created by the Initial Developer are Copyright (C) 2008-2014 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ include "root.php"; require_once "resources/require.php"; //check the permissions require_once "resources/check_auth.php"; if (if_group("admin") || if_group("superadmin")) { //access allowed } else { echo "access denied"; return; } //add multi-lingual support $language = new text; $text = $language->get(); //show the header require_once "resources/header.php"; $document['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_uuid = check_str($_REQUEST["group_uuid"]); $group_name = check_str($_REQUEST["group_name"]); $sql = "update v_groups set group_protected = '".$change."' "; $sql .= "where group_uuid = '".$group_uuid."' "; if (!permission_exists('group_domain')) { $sql .= "and ("; $sql .= " domain_uuid = '".$domain_uuid."' "; $sql .= " or domain_uuid is null "; $sql .= ") "; } $db->exec(check_sql($sql)); unset($sql); $_SESSION["message"] = $text['message-update']; } //get the groups $sql = "select * from v_groups "; if (!(permission_exists('group_all') && $_GET['showall'] == 'true')) { $sql .= "where domain_uuid = '".$domain_uuid."' "; $sql .= "or domain_uuid is null "; } $sql .= "order by domain_uuid desc, group_name asc "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $groups = $prep_statement->fetchAll(PDO::FETCH_NAMED); unset($sql, $prep_statement); $system_groups = array('superadmin','admin','user','public','agent'); //get group counts $sql = "select group_uuid, count(user_uuid) as group_count from v_group_users "; if (!permission_exists('user_all')) { $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; } $sql .= "group by group_uuid "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); foreach ($result as $row) { $group_counts[$row['group_uuid']] = $row['group_count']; } unset($sql, $prep_statement, $result, $row); //show the content echo ""; echo ""; echo ""; echo "\n"; echo ""; echo "
"; echo " ".$text['header-group_manager'].""; echo "

"; echo "
"; if (permission_exists('group_all')) { if ($_GET['showall'] != 'true') { echo "\n"; } } if (permission_exists('user_view')) { echo " "; } if (permission_exists('group_edit')) { echo " "; } echo "
"; echo "
"; $c = 0; $row_style["0"] = "row_style0"; $row_style["1"] = "row_style1"; $echo = "\n"; $echo .= "\n"; if (permission_exists('group_all') && $_GET['showall'] == 'true') { $echo .= " \n"; } $echo .= " \n"; $echo .= " \n"; $echo .= " \n"; $echo .= " \n"; $echo .= " \n"; $echo .= "\n"; $count = 0; foreach ($groups as &$row) { $domain_uuid = $row['domain_uuid']; $group_uuid = $row["group_uuid"]; $group_name = $row["group_name"]; $group_protected = $row["group_protected"]; $group_description = $row["group_description"]; if (strlen($group_name) == 0) { $group_name = " "; } if (strlen($group_description) == 0) { $group_description = " "; } $group_description = wordwrap($group_description, 50, "
\n"); if (!if_group("superadmin") && $group_name == "superadmin") { //hide the superadmin group from non superadmin's } else { if (permission_exists('group_edit') && !($domain_uuid == '' && in_array($group_name, $system_groups))) { $tr_link = (permission_exists('group_edit')) ? "href='groupedit.php?id=".$group_uuid."'" : null; } else { unset($tr_link); } $echo .= "\n"; if (permission_exists('group_all') && $_GET['showall'] == 'true') { $echo .= "\n"; } $echo .= "\n"; $echo .= "\n"; $echo .= "\n"; $echo .= "\n"; $echo .= "\n"; $echo .= "\n"; } $c = ($c) ? 0 : 1; $count++; } $echo .= "\n"; $echo .= ""; $echo .= "\n"; $echo .= "\n"; $echo .= "
".$text['label-domain']."".$text['label-group_name']."".$text['label-group_tools']."".$text['label-group_protected']."".$text['label-group_description'].""; if (permission_exists('group_add')) { $echo .= "".$v_link_label_add.""; } $echo .= "
"; $echo .= ($domain_uuid != '') ? $_SESSION['domains'][$domain_uuid]['domain_name'] : "".$text['label-global'].""; $echo .= ""; if (permission_exists('group_edit') && !($domain_uuid == '' && in_array($group_name, $system_groups))) { $echo .= "".(($domain_uuid == '' && $_GET['showall'] != 'true') ? "".$group_name."" : $group_name).""; } else { $echo .= ($domain_uuid == '' && $_GET['showall'] != 'true') ? "".$group_name."" : $group_name; } $echo .= "".$group_description.""; if (permission_exists('group_edit')) { if (!($domain_uuid == '' && in_array($group_name, $system_groups))) { $echo .= "".$v_link_label_edit.""; } else { $echo .= "".str_replace("list_control_icon", "list_control_icon_disabled", $v_link_label_edit).""; } } if (permission_exists('group_delete')) { if (!($domain_uuid == '' && in_array($group_name, $system_groups))) { $echo .= "".$v_link_label_delete.""; } else { $echo .= "".str_replace("list_control_icon", "list_control_icon_disabled", $v_link_label_delete).""; } } $echo .= "
 "; if (permission_exists('group_add')) { $echo .= "".$v_link_label_add.""; } $echo .= "
\n"; $echo .= "
"; if ($count > 0) { echo $echo; } //show the footer require_once "resources/footer.php"; ?>