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:
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
The Initial Developer of the Original Code is
|
The Initial Developer of the Original Code is
|
||||||
Mark J Crane <markjcrane@fusionpbx.com>
|
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.
|
the Initial Developer. All Rights Reserved.
|
||||||
|
|
||||||
Contributor(s):
|
Contributor(s):
|
||||||
@@ -106,6 +106,14 @@ if (strlen($contact_uuid) > 0) {
|
|||||||
$prep_statement->execute();
|
$prep_statement->execute();
|
||||||
unset($prep_statement, $sql);
|
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
|
//delete contact groups
|
||||||
$sql = "delete from v_contact_groups ";
|
$sql = "delete from v_contact_groups ";
|
||||||
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
||||||
|
|||||||
+119
-127
@@ -117,141 +117,133 @@ else {
|
|||||||
//add or update the database
|
//add or update the database
|
||||||
if ($_POST["persistformvar"] != "true") {
|
if ($_POST["persistformvar"] != "true") {
|
||||||
|
|
||||||
//update last modified
|
//add the contact
|
||||||
$sql = "update v_contacts set ";
|
if ($action == "add") {
|
||||||
$sql .= "last_mod_date = now(), ";
|
$contact_uuid = uuid();
|
||||||
$sql .= "last_mod_user = '".$_SESSION['username']."' ";
|
$sql = "insert into v_contacts ";
|
||||||
$sql .= "where domain_uuid = '".$domain_uuid."' ";
|
$sql .= "( ";
|
||||||
$sql .= "and contact_uuid = '".$contact_uuid."' ";
|
$sql .= "domain_uuid, ";
|
||||||
$db->exec(check_sql($sql));
|
$sql .= "contact_uuid, ";
|
||||||
unset($sql);
|
$sql .= "contact_type, ";
|
||||||
|
$sql .= "contact_organization, ";
|
||||||
|
$sql .= "contact_name_prefix, ";
|
||||||
|
$sql .= "contact_name_given, ";
|
||||||
|
$sql .= "contact_name_middle, ";
|
||||||
|
$sql .= "contact_name_family, ";
|
||||||
|
$sql .= "contact_name_suffix, ";
|
||||||
|
$sql .= "contact_nickname, ";
|
||||||
|
$sql .= "contact_title, ";
|
||||||
|
$sql .= "contact_category, ";
|
||||||
|
$sql .= "contact_role, ";
|
||||||
|
$sql .= "contact_time_zone, ";
|
||||||
|
$sql .= "contact_note, ";
|
||||||
|
$sql .= "last_mod_date, ";
|
||||||
|
$sql .= "last_mod_user ";
|
||||||
|
$sql .= ") ";
|
||||||
|
$sql .= "values ";
|
||||||
|
$sql .= "( ";
|
||||||
|
$sql .= "'".$_SESSION['domain_uuid']."', ";
|
||||||
|
$sql .= "'".$contact_uuid."', ";
|
||||||
|
$sql .= "'".$contact_type."', ";
|
||||||
|
$sql .= "'".$contact_organization."', ";
|
||||||
|
$sql .= "'".$contact_name_prefix."', ";
|
||||||
|
$sql .= "'".$contact_name_given."', ";
|
||||||
|
$sql .= "'".$contact_name_middle."', ";
|
||||||
|
$sql .= "'".$contact_name_family."', ";
|
||||||
|
$sql .= "'".$contact_name_suffix."', ";
|
||||||
|
$sql .= "'".$contact_nickname."', ";
|
||||||
|
$sql .= "'".$contact_title."', ";
|
||||||
|
$sql .= "'".$contact_category."', ";
|
||||||
|
$sql .= "'".$contact_role."', ";
|
||||||
|
$sql .= "'".$contact_time_zone."', ";
|
||||||
|
$sql .= "'".$contact_note."', ";
|
||||||
|
$sql .= "now(), ";
|
||||||
|
$sql .= "'".$_SESSION['username']."' ";
|
||||||
|
$sql .= ")";
|
||||||
|
$db->exec(check_sql($sql));
|
||||||
|
unset($sql);
|
||||||
|
|
||||||
if ($action == "add") {
|
$_SESSION["message"] = $text['message-add'];
|
||||||
$contact_uuid = uuid();
|
$location = "contact_edit.php?id=".$contact_uuid;
|
||||||
$sql = "insert into v_contacts ";
|
} //if ($action == "add")
|
||||||
$sql .= "( ";
|
|
||||||
$sql .= "domain_uuid, ";
|
|
||||||
$sql .= "contact_uuid, ";
|
|
||||||
$sql .= "contact_type, ";
|
|
||||||
$sql .= "contact_organization, ";
|
|
||||||
$sql .= "contact_name_prefix, ";
|
|
||||||
$sql .= "contact_name_given, ";
|
|
||||||
$sql .= "contact_name_middle, ";
|
|
||||||
$sql .= "contact_name_family, ";
|
|
||||||
$sql .= "contact_name_suffix, ";
|
|
||||||
$sql .= "contact_nickname, ";
|
|
||||||
$sql .= "contact_title, ";
|
|
||||||
$sql .= "contact_category, ";
|
|
||||||
$sql .= "contact_role, ";
|
|
||||||
$sql .= "contact_time_zone, ";
|
|
||||||
$sql .= "contact_note, ";
|
|
||||||
$sql .= "last_mod_date, ";
|
|
||||||
$sql .= "last_mod_user ";
|
|
||||||
$sql .= ") ";
|
|
||||||
$sql .= "values ";
|
|
||||||
$sql .= "( ";
|
|
||||||
$sql .= "'".$_SESSION['domain_uuid']."', ";
|
|
||||||
$sql .= "'".$contact_uuid."', ";
|
|
||||||
$sql .= "'".$contact_type."', ";
|
|
||||||
$sql .= "'".$contact_organization."', ";
|
|
||||||
$sql .= "'".$contact_name_prefix."', ";
|
|
||||||
$sql .= "'".$contact_name_given."', ";
|
|
||||||
$sql .= "'".$contact_name_middle."', ";
|
|
||||||
$sql .= "'".$contact_name_family."', ";
|
|
||||||
$sql .= "'".$contact_name_suffix."', ";
|
|
||||||
$sql .= "'".$contact_nickname."', ";
|
|
||||||
$sql .= "'".$contact_title."', ";
|
|
||||||
$sql .= "'".$contact_category."', ";
|
|
||||||
$sql .= "'".$contact_role."', ";
|
|
||||||
$sql .= "'".$contact_time_zone."', ";
|
|
||||||
$sql .= "'".$contact_note."', ";
|
|
||||||
$sql .= "now(), ";
|
|
||||||
$sql .= "'".$_SESSION['username']."' ";
|
|
||||||
$sql .= ")";
|
|
||||||
$db->exec(check_sql($sql));
|
|
||||||
unset($sql);
|
|
||||||
|
|
||||||
$_SESSION["message"] = $text['message-add'];
|
//assign the contact to the user that added the contact
|
||||||
$location = "contact_edit.php?id=".$contact_uuid;
|
if ($action == "add") {
|
||||||
} //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);
|
||||||
|
}
|
||||||
|
|
||||||
//if contact is shared, remove contact group record containing user's uuid
|
//assign the contact to the group
|
||||||
if ($_POST['contact_shared'] == 'true') {
|
if ($group_uuid != '') {
|
||||||
$sql = "delete from v_contact_groups ";
|
$sql = "insert into v_contact_groups ";
|
||||||
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
$sql .= "( ";
|
||||||
$sql .= "and contact_uuid = '".$contact_uuid."' ";
|
$sql .= "contact_group_uuid, ";
|
||||||
$sql .= "and group_uuid = '".$_SESSION["user_uuid"]."' ";
|
$sql .= "domain_uuid, ";
|
||||||
$prep_statement = $db->prepare(check_sql($sql));
|
$sql .= "contact_uuid, ";
|
||||||
$prep_statement->execute();
|
$sql .= "group_uuid ";
|
||||||
unset($prep_statement, $sql);
|
$sql .= ") ";
|
||||||
$group_uuid = $_POST['group_uuid'];
|
$sql .= "values ";
|
||||||
}
|
$sql .= "( ";
|
||||||
//if private contact, delete any groups currently assigned, set group uuid to user's uuid
|
$sql .= "'".uuid()."', ";
|
||||||
else {
|
$sql .= "'".$domain_uuid."', ";
|
||||||
$sql = "delete from v_contact_groups ";
|
$sql .= "'".$contact_uuid."', ";
|
||||||
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
$sql .= "'".$group_uuid."' ";
|
||||||
$sql .= "and contact_uuid = '".$contact_uuid."' ";
|
$sql .= ") ";
|
||||||
$prep_statement = $db->prepare(check_sql($sql));
|
$db->exec(check_sql($sql));
|
||||||
$prep_statement->execute();
|
unset($sql);
|
||||||
unset($prep_statement, $sql);
|
}
|
||||||
$group_uuid = $_SESSION["user_uuid"];
|
|
||||||
}
|
|
||||||
|
|
||||||
//handle insertion of contact group (or private contact, if not shared)
|
//update the contact
|
||||||
if ($group_uuid != '') {
|
if ($action == "update") {
|
||||||
$sql = "insert into v_contact_groups ";
|
$sql = "update v_contacts set ";
|
||||||
$sql .= "( ";
|
$sql .= "contact_type = '".$contact_type."', ";
|
||||||
$sql .= "contact_group_uuid, ";
|
$sql .= "contact_organization = '".$contact_organization."', ";
|
||||||
$sql .= "domain_uuid, ";
|
$sql .= "contact_name_prefix = '".$contact_name_prefix."', ";
|
||||||
$sql .= "contact_uuid, ";
|
$sql .= "contact_name_given = '".$contact_name_given."', ";
|
||||||
$sql .= "group_uuid ";
|
$sql .= "contact_name_middle = '".$contact_name_middle."', ";
|
||||||
$sql .= ") ";
|
$sql .= "contact_name_family = '".$contact_name_family."', ";
|
||||||
$sql .= "values ";
|
$sql .= "contact_name_suffix = '".$contact_name_suffix."', ";
|
||||||
$sql .= "( ";
|
$sql .= "contact_nickname = '".$contact_nickname."', ";
|
||||||
$sql .= "'".uuid()."', ";
|
$sql .= "contact_title = '".$contact_title."', ";
|
||||||
$sql .= "'".$domain_uuid."', ";
|
$sql .= "contact_category = '".$contact_category."', ";
|
||||||
$sql .= "'".$contact_uuid."', ";
|
$sql .= "contact_role = '".$contact_role."', ";
|
||||||
$sql .= "'".$group_uuid."' ";
|
$sql .= "contact_time_zone = '".$contact_time_zone."', ";
|
||||||
$sql .= ") ";
|
$sql .= "contact_note = '".$contact_note."', ";
|
||||||
$db->exec(check_sql($sql));
|
$sql .= "last_mod_date = now(), ";
|
||||||
unset($sql);
|
$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);
|
||||||
|
|
||||||
if ($action == "update") {
|
$_SESSION["message"] = $text['message-update'];
|
||||||
$sql = "update v_contacts set ";
|
$location = "contact_edit.php?id=".$contact_uuid;
|
||||||
$sql .= "contact_type = '".$contact_type."', ";
|
} //if ($action == "update")
|
||||||
$sql .= "contact_organization = '".$contact_organization."', ";
|
|
||||||
$sql .= "contact_name_prefix = '".$contact_name_prefix."', ";
|
|
||||||
$sql .= "contact_name_given = '".$contact_name_given."', ";
|
|
||||||
$sql .= "contact_name_middle = '".$contact_name_middle."', ";
|
|
||||||
$sql .= "contact_name_family = '".$contact_name_family."', ";
|
|
||||||
$sql .= "contact_name_suffix = '".$contact_name_suffix."', ";
|
|
||||||
$sql .= "contact_nickname = '".$contact_nickname."', ";
|
|
||||||
$sql .= "contact_title = '".$contact_title."', ";
|
|
||||||
$sql .= "contact_category = '".$contact_category."', ";
|
|
||||||
$sql .= "contact_role = '".$contact_role."', ";
|
|
||||||
$sql .= "contact_time_zone = '".$contact_time_zone."', ";
|
|
||||||
$sql .= "contact_note = '".$contact_note."', ";
|
|
||||||
$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);
|
|
||||||
|
|
||||||
$_SESSION["message"] = $text['message-update'];
|
|
||||||
$location = "contact_edit.php?id=".$contact_uuid;
|
|
||||||
} //if ($action == "update")
|
|
||||||
|
|
||||||
//handle redirect
|
//handle redirect
|
||||||
if ($_POST['submit'] == $text['button-add']) {
|
if ($_POST['submit'] == $text['button-add']) {
|
||||||
$group_uuid = $_POST['group_uuid'];
|
$group_uuid = $_POST['group_uuid'];
|
||||||
//insert
|
//insert
|
||||||
$location = "contact_edit.php?id=".$contact_uuid;
|
$location = "contact_edit.php?id=".$contact_uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
header("Location: ".$location);
|
//redirect the browser
|
||||||
return;
|
header("Location: ".$location);
|
||||||
|
return;
|
||||||
|
|
||||||
} //if ($_POST["persistformvar"] != "true")
|
} //if ($_POST["persistformvar"] != "true")
|
||||||
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
|
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user