Browse Source

Contacts: Private or Shared. User can create a private contact only visible to them, or can choose to share a contact with others by assigning it to group(s). Users can view only contacts assigned to their group(s) and contacts NOT assigned to any group.

Nate Jones 11 years ago
parent
commit
59066deb23
3 changed files with 22 additions and 9 deletions
  1. 13 7
      core/users/signup.php
  2. 8 1
      core/users/userdelete.php
  3. 1 1
      core/users/users.php

+ 13 - 7
core/users/signup.php

@@ -44,12 +44,17 @@ else {
 $username = check_str($_POST["username"]);
 $password = check_str($_POST["password"]);
 $confirmpassword = check_str($_POST["confirmpassword"]);
-$group_name = check_str($_POST["group_name"]);
+$group_uuid_name = check_str($_POST["group_uuid_name"]);
 $user_email = check_str($_POST["user_email"]);
 $contact_organization = check_str($_POST["contact_organization"]);
 $contact_name_given = check_str($_POST["contact_name_given"]);
 $contact_name_family = check_str($_POST["contact_name_family"]);
 
+if ($group_uuid_name != '') {
+	$group_data = explode('|', $group_uuid_name);
+	$group_uuid = $group_data[0];
+	$group_name = $group_data[1];
+}
 
 if (count($_POST)>0 && check_str($_POST["persistform"]) != "1") {
 
@@ -140,13 +145,14 @@ if (count($_POST)>0 && check_str($_POST["persistform"]) != "1") {
 	unset($sql);
 
 	//add the user to the group
-	if (strlen($group_name) > 0) {
+	if (strlen($group_uuid) > 0) {
 		if ( ($group_name == "superadmin" && if_group("superadmin")) || $group_name != "superadmin") {
 			$sql = "insert into v_group_users ";
 			$sql .= "( ";
 			$sql .= "group_user_uuid, ";
 			$sql .= "domain_uuid, ";
 			$sql .= "group_name, ";
+			$sql .= "group_uuid, ";
 			$sql .= "user_uuid ";
 			$sql .= ") ";
 			$sql .= "values ";
@@ -154,6 +160,7 @@ if (count($_POST)>0 && check_str($_POST["persistform"]) != "1") {
 			$sql .= "'".$group_user_uuid."', ";
 			$sql .= "'".$domain_uuid."', ";
 			$sql .= "'".$group_name."', ";
+			$sql .= "'".$group_uuid."', ";
 			$sql .= "'".$user_uuid."' ";
 			$sql .= ")";
 			$db->exec(check_sql($sql));
@@ -275,14 +282,13 @@ if (count($_POST)>0 && check_str($_POST["persistform"]) != "1") {
 	$sql .= "order by 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 "			<select name=\"group_uuid_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 ($field['group_name'] == "superadmin" && !if_group("superadmin")) { continue; }	//only show the superadmin group to other users in the superadmin group
-		if (!in_array($field["group_name"], $assigned_groups)) {
-			echo "		<option value='".$field['group_name']."'>".$field['group_name']."</option>\n";
-		}
+		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
+		echo "			<option value='".$field['group_uuid']."|".$field['group_name']."'>".$field['group_name']."</option>\n";
 	}
 	echo "			</select>";
 	unset($sql, $result);

+ 8 - 1
core/users/userdelete.php

@@ -34,6 +34,12 @@ else {
 	return;
 }
 
+//add multi-lingual support
+	require_once "app_languages.php";
+	foreach($text as $key => $value) {
+		$text[$key] = $value[$_SESSION['domain']['language']['code']];
+	}
+
 //get the id
 	$user_uuid = check_str($_GET["id"]);
 
@@ -54,7 +60,7 @@ else {
 //required to be a superadmin to delete a member of the superadmin group
 	$superadmin_list = superadmin_list($db);
 	if (if_superadmin($superadmin_list, $user_uuid)) {
-		if (!if_group("superadmin")) { 
+		if (!if_group("superadmin")) {
 			//access denied - do not delete the user
 			header("Location: index.php");
 			return;
@@ -84,6 +90,7 @@ else {
 	}
 
 //redirect the user
+	$_SESSION["message"] = $text['message-delete'];
 	header("Location: index.php");
 
 ?>

+ 1 - 1
core/users/users.php

@@ -187,7 +187,7 @@ echo "	<td align=\"center\">\n";
 					echo $text['option-false'];
 				}
 				echo "&nbsp;</td>\n";
-				echo "	<td valign='top' align='right'>";
+				echo "	<td valign='top' align='right' class='tr_link_void'>";
 				if (permission_exists('user_edit')) {
 					echo "<a href='usersupdate.php?id=".$row['user_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
 				}