Contacts - Import: Change Google import to use class delete() method to remove duplicates.

This commit is contained in:
Nate 2020-03-04 07:07:37 -07:00
parent afa3863c0c
commit 1bf11ef2d0
1 changed files with 35 additions and 18 deletions

View File

@ -17,25 +17,28 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2013
Portions created by the Initial Developer are Copyright (C) 2008-2020
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
require_once "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/functions/google_get_groups.php";
require_once "resources/functions/google_get_contacts.php";
if (permission_exists('contact_add')) {
//access granted
}
else {
echo "access denied";
exit;
}
//includes
require_once "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/functions/google_get_groups.php";
require_once "resources/functions/google_get_contacts.php";
//check permissions
if (permission_exists('contact_add')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
@ -99,11 +102,25 @@ if ($_POST['a'] == 'import') {
}
//replace contact (delete before inserts below)
else if ($duplicate_exists && $_POST['import_duplicates'] == 'replace') {
$contact_uuid = $duplicate_contact_uuid;
$included = true;
require_once "contact_delete.php";
unset($contact_uuid, $duplicate_contact_uuid);
$contacts_replaced++;
//build array
$array[0]['checked'] = 'true';
$array[0]['uuid'] = $duplicate_contact_uuid;
unset($duplicate_contact_uuid);
//grant temporary permissions
$p = new permissions;
$p->add('contact_delete', 'temp');
//delete duplicate contact
$obj = new contacts;
$obj->delete($array);
unset($array)
//revoke temporary permissions
$p->delete('contact_delete', 'temp');
//increase counter
$contacts_replaced++;
}
//extract contact record from array using contact id