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.

This commit is contained in:
Nate Jones
2014-10-18 06:49:34 +00:00
parent e89611f099
commit f2d643aecb
6 changed files with 172 additions and 103 deletions
+13 -7
View File
@@ -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);