public static function _clean($destination, $source, $syncTaskId = 0, $whitelist = array()) { $service = ServicesModel::first(array('library' => 'Contacts'))->toArray(); $task = TasksServicesModel::first(array('task_id' => $syncTaskId, 'service_id' => $service['id']))->toArray(); $task['stats'] = json_decode($task['stats'], true); // Contacts $contacts = BackupsModel::all(array('user_id' => $source['username']['id'], 'sync_task_id' => $syncTaskId, 'entity_type' => static::$kind['contact']))->toArray(); if ($contacts && ($task['stats']['contacts'] || $destination['username']['id'] == $source['username']['id'])) { foreach ($contacts as $contact) { // $whitelist - shared or clean data if ($whitelist) { if (isset($whitelist['contacts']) && in_array($contact['entity_id'], $whitelist['contacts'])) { \Rest::deleteXML('https://www.google.com/m8/feeds/contacts/default/full/' . $contact['entity_id'], array(), $destination); } } else { if ($destination['username']['id'] == $source['username']['id']) { \Rest::deleteXML('https://www.google.com/m8/feeds/contacts/default/full/' . $contact['entity_id'], array(), $destination); } else { if ($contact['entity_new_id']) { \Rest::deleteXML('https://www.google.com/m8/feeds/contacts/default/full/' . $contact['entity_new_id'], array(), $destination); } } } } } }