Assign the user that created the contact to the user that created it. When deleting a contact delete the user assigned to it.

This commit is contained in:
markjcrane 2016-01-17 16:16:51 -07:00
parent e9ff3523ec
commit 505c1e6276
2 changed files with 128 additions and 128 deletions

View File

@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2012
Portions created by the Initial Developer are Copyright (C) 2008-2015
the Initial Developer. All Rights Reserved.
Contributor(s):
@ -106,6 +106,14 @@ if (strlen($contact_uuid) > 0) {
$prep_statement->execute();
unset($prep_statement, $sql);
//delete contact users
$sql = "delete from v_contact_users ";
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
$sql .= "and contact_uuid = '".$contact_uuid."' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
unset($prep_statement, $sql);
//delete contact groups
$sql = "delete from v_contact_groups ";
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";

View File

@ -117,15 +117,7 @@ else {
//add or update the database
if ($_POST["persistformvar"] != "true") {
//update last modified
$sql = "update v_contacts set ";
$sql .= "last_mod_date = now(), ";
$sql .= "last_mod_user = '".$_SESSION['username']."' ";
$sql .= "where domain_uuid = '".$domain_uuid."' ";
$sql .= "and contact_uuid = '".$contact_uuid."' ";
$db->exec(check_sql($sql));
unset($sql);
//add the contact
if ($action == "add") {
$contact_uuid = uuid();
$sql = "insert into v_contacts ";
@ -175,29 +167,27 @@ else {
$location = "contact_edit.php?id=".$contact_uuid;
} //if ($action == "add")
//if contact is shared, remove contact group record containing user's uuid
if ($_POST['contact_shared'] == 'true') {
$sql = "delete from v_contact_groups ";
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
$sql .= "and contact_uuid = '".$contact_uuid."' ";
$sql .= "and group_uuid = '".$_SESSION["user_uuid"]."' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
unset($prep_statement, $sql);
$group_uuid = $_POST['group_uuid'];
}
//if private contact, delete any groups currently assigned, set group uuid to user's uuid
else {
$sql = "delete from v_contact_groups ";
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
$sql .= "and contact_uuid = '".$contact_uuid."' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
unset($prep_statement, $sql);
$group_uuid = $_SESSION["user_uuid"];
//assign the contact to the user that added the contact
if ($action == "add") {
$sql = "insert into v_contact_users ";
$sql .= "( ";
$sql .= "contact_user_uuid, ";
$sql .= "domain_uuid, ";
$sql .= "contact_uuid, ";
$sql .= "user_uuid ";
$sql .= ") ";
$sql .= "values ";
$sql .= "( ";
$sql .= "'".uuid()."', ";
$sql .= "'".$domain_uuid."', ";
$sql .= "'".$contact_uuid."', ";
$sql .= "'".$_SESSION["user_uuid"]."' ";
$sql .= ") ";
$db->exec(check_sql($sql));
unset($sql);
}
//handle insertion of contact group (or private contact, if not shared)
//assign the contact to the group
if ($group_uuid != '') {
$sql = "insert into v_contact_groups ";
$sql .= "( ";
@ -217,6 +207,7 @@ else {
unset($sql);
}
//update the contact
if ($action == "update") {
$sql = "update v_contacts set ";
$sql .= "contact_type = '".$contact_type."', ";
@ -250,6 +241,7 @@ else {
$location = "contact_edit.php?id=".$contact_uuid;
}
//redirect the browser
header("Location: ".$location);
return;