diff --git a/core/groups/app_defaults.php b/core/groups/app_defaults.php
index ac6da67793..aa4b737e7a 100644
--- a/core/groups/app_defaults.php
+++ b/core/groups/app_defaults.php
@@ -116,6 +116,7 @@ if ($domains_processed == 1) {
//add or update the view
$sql = "CREATE VIEW view_groups AS (";
$sql .= " select domain_uuid, group_uuid, group_name, ";
+ $sql .= " (select domain_name from v_domains where domain_uuid = g.domain_uuid) as domain_name, ";
$sql .= " (select count(*) from v_group_permissions where group_uuid = g.group_uuid) as group_permissions, ";
$sql .= " (select count(*) from v_user_groups where group_uuid = g.group_uuid) as group_members, ";
$sql .= " group_level, group_protected, group_description ";
diff --git a/core/groups/group_edit.php b/core/groups/group_edit.php
index 9070b17caa..2bc5fa4b7a 100644
--- a/core/groups/group_edit.php
+++ b/core/groups/group_edit.php
@@ -46,31 +46,36 @@
$text = $language->get();
//action add or update
- if (is_uuid($_REQUEST["id"])) {
+ if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
$action = "update";
$group_uuid = $_REQUEST["id"];
- $id = $_REQUEST["id"];
}
else {
$action = "add";
+ $group_uuid = '';
}
+//set default values
+ $group_name = '';
+ $group_level = '10';
+ $group_description = '';
+
//get http post variables and set them to php variables
- if (is_array($_POST)) {
- $group_uuid = $_POST["group_uuid"];
- $group_name = $_POST["group_name"];
+ if (!empty($_POST)) {
+ $group_uuid = $_POST["group_uuid"] ?? '';
+ $group_name = $_POST["group_name"] ?? '';
$group_name_previous = $_POST["group_name_previous"];
$domain_uuid = $_POST["domain_uuid"];
- $group_level = $_POST["group_level"];
- $group_protected = $_POST["group_protected"];
- $group_description = $_POST["group_description"];
+ $group_level = $_POST["group_level"] ?? '10';
+ $group_protected = $_POST["group_protected"] ?? '';
+ $group_description = $_POST["group_description"] ?? '';
}
//process the user data and save it to the database
- if (count($_POST) > 0 && empty($_POST["persistformvar"])) {
+ if (!empty($_POST) && empty($_POST["persistformvar"])) {
//process the http post data by submitted action
- if ($_POST['action'] != '' && is_uuid($group_uuid)) {
+ if (!empty($_POST['action']) && is_uuid($group_uuid)) {
$array[0]['checked'] = 'true';
$array[0]['uuid'] = $group_uuid;
@@ -122,7 +127,7 @@
}
//add the group_uuid
- if (!is_uuid($_POST["group_uuid"])) {
+ if (empty($_POST["group_uuid"])) {
$group_uuid = uuid();
}
@@ -170,8 +175,7 @@
}
//pre-populate the form
- if (is_array($_GET) && $_POST["persistformvar"] != "true") {
- $group_uuid = $_GET["id"];
+ if (!empty($group_uuid) && empty($_POST["persistformvar"])) {
$sql = "select * from v_groups ";
$sql .= "where group_uuid = :group_uuid ";
//$sql .= "and domain_uuid = :domain_uuid ";
@@ -179,11 +183,11 @@
$parameters['group_uuid'] = $group_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
- if (is_array($row) && @sizeof($row) != 0) {
+ if (!empty($row)) {
$group_name = $row["group_name"];
$domain_uuid = $row["domain_uuid"];
- $group_permissions = $row["group_permissions"];
- $group_members = $row["group_members"];
+ $group_permissions = $row["group_permissions"] ?? '';
+ $group_members = $row["group_members"] ?? '';
$group_level = $row["group_level"];
$group_protected = $row["group_protected"];
$group_description = $row["group_description"];
@@ -206,23 +210,21 @@
echo "
".$text['title-group']."
\n";
echo " \n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'id'=>'btn_back','link'=>'groups.php']);
- $button_margin = 'margin-left: 15px;';
if (permission_exists('group_permission_view')) {
- echo button::create(['type'=>'button','label'=>$text['button-permissions'],'icon'=>'key','style'=>$button_margin,'link'=>'group_permissions.php?group_uuid='.urlencode($group_uuid)]);
- unset($button_margin);
+ $button_margin = 'margin-left: 15px;';
+ echo button::create(['type'=>'button','label'=>$text['button-permissions'],'icon'=>'key','style'=>$button_margin,'link'=>'group_permissions.php?group_uuid='.urlencode($group_uuid ?? '')]);
}
if (permission_exists('group_member_view')) {
- echo button::create(['type'=>'button','label'=>$text['button-members'],'icon'=>'users','style'=>$button_margin,'link'=>'group_members.php?group_uuid='.urlencode($group_uuid)]);
- unset($button_margin);
+ $button_margin = 'margin-left: 0px;';
+ echo button::create(['type'=>'button','label'=>$text['button-members'],'icon'=>'users','style'=>$button_margin,'link'=>'group_members.php?group_uuid='.urlencode($group_uuid ?? '')]);
}
- $button_margin = 'margin-left: 15px;';
if ($action == 'update' && permission_exists('group_add')) {
+ $button_margin = 'margin-left: 15px;';
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'name'=>'btn_copy','style'=>$button_margin,'onclick'=>"modal_open('modal-copy','btn_copy');"]);
- unset($button_margin);
}
if ($action == 'update' && permission_exists('group_delete')) {
+ $button_margin = 'margin-left: 0px;';
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'name'=>'btn_delete','style'=>$button_margin,'onclick'=>"modal_open('modal-delete','btn_delete');"]);
- unset($button_margin);
}
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'id'=>'btn_save','style'=>'margin-left: 15px;']);
echo "
\n";
@@ -249,7 +251,7 @@
echo " \n";
echo " \n";
echo "
\n";
- echo $text['description-group_name']."\n";
+ //echo $text['description-group_name']."\n";
echo "\n";
echo "\n";
@@ -275,7 +277,7 @@
}
echo " \n";
echo "
\n";
- echo $text['description-domain_uuid']."\n";
+ //echo $text['description-domain_uuid']."\n";
echo "\n";
echo "\n";
@@ -292,7 +294,7 @@
}
echo " \n";
echo "
\n";
- echo $text['description-group_level']."\n";
+ //echo $text['description-group_level']."\n";
echo "\n";
echo "\n";
@@ -306,7 +308,7 @@
echo " \n";
echo " \n";
echo "
\n";
- echo $text['description-group_protected']."\n";
+ //echo $text['description-group_protected']."\n";
echo "\n";
echo "\n";
@@ -317,7 +319,7 @@
echo "\n";
echo " \n";
echo " \n";
- echo $text['description-group_description']."\n";
+ //echo $text['description-group_description']."\n";
echo " | \n";
echo "\n";
diff --git a/core/groups/groupmemberadd.php b/core/groups/group_member_add.php
similarity index 100%
rename from core/groups/groupmemberadd.php
rename to core/groups/group_member_add.php
diff --git a/core/groups/group_members.php b/core/groups/group_members.php
index e7ac7b5a54..8df988db23 100644
--- a/core/groups/group_members.php
+++ b/core/groups/group_members.php
@@ -51,15 +51,18 @@
$language = new text;
$text = $language->get();
-//get the http post data
- if (is_array($_POST['group_members'])) {
- $action = $_POST['action'];
- $group_uuid = $_POST['group_uuid'];
- $group_members = $_POST['group_members'];
- }
+//get the http data
+ $action = $_REQUEST['action'] ?? '';
+ $group_uuid = $_REQUEST['group_uuid'] ?? '';
+ $group_members = $_REQUEST['group_members'] ?? '';
+
+//set default values
+ $group_name = '';
+ $domain_uuid = '';
+ $list_row_url = '';
//process the http post data by action
- if ($action != '' && is_array($group_members) && @sizeof($group_members) != 0) {
+ if (!empty($action) && !empty($group_members)) {
switch ($action) {
case 'delete':
if (permission_exists('group_member_delete') && is_uuid($group_uuid)) {
@@ -75,7 +78,6 @@
}
//get the group uuid, lookup domain uuid (if any) and name
- $group_uuid = $_REQUEST['group_uuid'];
$sql = "select domain_uuid, group_name from v_groups ";
$sql .= "where group_uuid = :group_uuid ";
$parameters['group_uuid'] = $group_uuid;
@@ -120,12 +122,16 @@
unset($sql, $parameters);
//add group_member to the users array
- foreach ($users as &$field) {
- $field['group_member'] = 'false';
- foreach($user_groups as $row) {
- if ($row['user_uuid'] == $field['user_uuid']) {
- $field['group_member'] = 'true';
- break;
+ if (!empty($users)) {
+ foreach ($users as &$field) {
+ $field['group_member'] = 'false';
+ if (!empty($user_groups)) {
+ foreach($user_groups as $row) {
+ if ($row['user_uuid'] == $field['user_uuid']) {
+ $field['group_member'] = 'true';
+ break;
+ }
+ }
}
}
}
@@ -148,7 +154,7 @@
}
if (permission_exists('group_member_add')) {
- echo "