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
+22 -5
View File
@@ -17,18 +17,21 @@
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-2013 Portions created by the Initial Developer are Copyright (C) 2008-2020
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
*/ */
//includes
require_once "root.php"; require_once "root.php";
require_once "resources/require.php"; require_once "resources/require.php";
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
require_once "resources/functions/google_get_groups.php"; require_once "resources/functions/google_get_groups.php";
require_once "resources/functions/google_get_contacts.php"; require_once "resources/functions/google_get_contacts.php";
//check permissions
if (permission_exists('contact_add')) { if (permission_exists('contact_add')) {
//access granted //access granted
} }
@@ -99,10 +102,24 @@ if ($_POST['a'] == 'import') {
} }
//replace contact (delete before inserts below) //replace contact (delete before inserts below)
else if ($duplicate_exists && $_POST['import_duplicates'] == 'replace') { else if ($duplicate_exists && $_POST['import_duplicates'] == 'replace') {
$contact_uuid = $duplicate_contact_uuid; //build array
$included = true; $array[0]['checked'] = 'true';
require_once "contact_delete.php"; $array[0]['uuid'] = $duplicate_contact_uuid;
unset($contact_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++; $contacts_replaced++;
} }