diff --git a/app/contacts/contact_edit.php b/app/contacts/contact_edit.php index 9e9196dcef..ac87911c1c 100644 --- a/app/contacts/contact_edit.php +++ b/app/contacts/contact_edit.php @@ -38,21 +38,6 @@ else { $language = new text; $text = $language->get(); -//handle removal of contact group - if ($_GET['a'] == 'delete') { - $contact_uuid = $_GET["id"]; - $contact_group_uuid = $_GET["cgid"]; - $sql = "delete from v_contact_groups "; - $sql .= "where contact_uuid = '".$contact_uuid."' "; - $sql .= "and contact_group_uuid = '".$contact_group_uuid."' "; - $db->exec(check_sql($sql)); - unset($sql); - - $_SESSION["message"] = $text['message-update']; - header("Location: contact_edit.php?id=".$contact_uuid); - exit; - } - //action add or update if (isset($_REQUEST["id"])) { $action = "update"; @@ -80,25 +65,6 @@ else { $contact_note = check_str($_POST["contact_note"]); } -//delete the user - if ($_GET["a"] == "delete" && permission_exists('contact_user_delete')) { - if (strlen($_REQUEST["contact_user_uuid"]) > 0) { - //set the variables - $contact_uuid = check_str($_REQUEST["contact_uuid"]); - $contact_user_uuid = check_str($_REQUEST["contact_user_uuid"]); - //delete the assigned user from the contact - $sql = "delete from v_contact_users "; - $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; - $sql .= "and contact_user_uuid = '$contact_user_uuid' "; - $db->exec(check_sql($sql)); - unset($sql); - } - - $_SESSION["message"] = $text['message-delete']; - header("Location: contact_edit.php?id=".$contact_uuid); - return; - } - //process the form data if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { @@ -682,7 +648,7 @@ else { echo " ".$field['username']."\n"; echo " \n"; if (permission_exists('contact_user_delete')) { - echo " $v_link_label_delete\n"; + echo " $v_link_label_delete\n"; } echo " \n"; echo " \n"; @@ -739,7 +705,7 @@ else { echo " ".$field['group_name']."\n"; echo " \n"; if (permission_exists('contact_group_delete') || if_group("superadmin")) { - echo " $v_link_label_delete\n"; + echo " $v_link_label_delete\n"; } echo " \n"; echo "\n"; diff --git a/app/contacts/contact_group_delete.php b/app/contacts/contact_group_delete.php new file mode 100644 index 0000000000..b1fe25208b --- /dev/null +++ b/app/contacts/contact_group_delete.php @@ -0,0 +1,65 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2015 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "resources/require.php"; +require_once "resources/check_auth.php"; +if (permission_exists('contact_group_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +// check if included in another file + if (!$included) { + //add multi-lingual support + $language = new text; + $text = $language->get(); + + if (count($_REQUEST) > 0) { + $contact_uuid = check_str($_REQUEST["contact_uuid"]); + $contact_group_uuid = $_REQUEST["id"]; + } + } + +//delete the group + if (is_uuid($contact_uuid) && is_uuid($contact_group_uuid)) { + $sql = "delete from v_contact_groups "; + $sql .= "where contact_uuid = '".$contact_uuid."' "; + $sql .= "and contact_group_uuid = '".$contact_group_uuid."' "; + $db->exec(check_sql($sql)); + unset($sql); + } + +//redirect the browser + if (!$included) { + $_SESSION["message"] = $text['message-delete']; + header("Location: contact_edit.php?id=".$contact_uuid); + return; + } + +?> \ No newline at end of file diff --git a/app/contacts/contact_user_delete.php b/app/contacts/contact_user_delete.php new file mode 100644 index 0000000000..d8112c3751 --- /dev/null +++ b/app/contacts/contact_user_delete.php @@ -0,0 +1,65 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2015 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "resources/require.php"; +require_once "resources/check_auth.php"; +if (permission_exists('contact_group_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +// check if included in another file + if (!$included) { + //add multi-lingual support + $language = new text; + $text = $language->get(); + + if (count($_REQUEST) > 0) { + $contact_user_uuid = check_str($_REQUEST["id"]); + $contact_uuid = check_str($_REQUEST["contact_uuid"]); + } + } + +//delete the user + if (is_uuid($contact_uuid) && is_uuid($contact_user_uuid)) { + $sql = "delete from v_contact_users "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and contact_user_uuid = '$contact_user_uuid' "; + $db->exec(check_sql($sql)); + unset($sql); + } + +//redirect the browser + if (!$included) { + $_SESSION["message"] = $text['message-delete']; + header("Location: contact_edit.php?id=".$contact_uuid); + return; + } + +?> \ No newline at end of file