mirror of
https://github.com/owncloudarchive/contacts.git
synced 2024-12-01 13:24:10 +01:00
Move purging indexes to addressBookDeletion() hook
This commit is contained in:
parent
1ae88f66c6
commit
667a362fb3
@ -250,12 +250,6 @@ class Database extends AbstractBackend {
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteAddressBook($addressbookid) {
|
||||
\OC_Hook::emit('OCA\Contacts', 'pre_deleteAddressBook',
|
||||
array('id' => $addressbookid)
|
||||
);
|
||||
|
||||
// Clean up sharing
|
||||
\OCP\Share::unshareAll('addressbook', $addressbookid);
|
||||
|
||||
// Get all contact ids for this address book
|
||||
$ids = array();
|
||||
@ -281,22 +275,9 @@ class Database extends AbstractBackend {
|
||||
}
|
||||
}
|
||||
|
||||
// Purge contact property indexes
|
||||
if(count($ids)) {
|
||||
$stmt = \OCP\DB::prepare('DELETE FROM `' . $this->indexTableName
|
||||
.'` WHERE `contactid` IN ('.str_repeat('?,', count($ids)-1).'?)');
|
||||
try {
|
||||
$stmt->execute($ids);
|
||||
} catch(\Exception $e) {
|
||||
\OCP\Util::writeLog('contacts', __METHOD__.
|
||||
', exception: ' . $e->getMessage(), \OCP\Util::ERROR);
|
||||
}
|
||||
|
||||
// Purge categories
|
||||
$catctrl = new \OC_VCategories('contact');
|
||||
$catctrl->purgeObjects($ids);
|
||||
|
||||
}
|
||||
\OC_Hook::emit('OCA\Contacts', 'pre_deleteAddressBook',
|
||||
array('addressbookid' => $addressbookid, 'contactids' => $ids)
|
||||
);
|
||||
|
||||
// Delete contacts in address book.
|
||||
if(!isset(self::$preparedQueries['deleteaddressbookcontacts'])) {
|
||||
|
@ -66,6 +66,17 @@ class Hooks{
|
||||
* Delete any registred address books (Future)
|
||||
*/
|
||||
public static function addressBookDeletion($parameters) {
|
||||
// Clean up sharing
|
||||
\OCP\Share::unshareAll('addressbook', $parameters['addressbookid']);
|
||||
|
||||
if(count($parameters['contactids'])) {
|
||||
// Remove contacts from groups
|
||||
$catctrl = new \OC_VCategories('contact');
|
||||
$catctrl->purgeObjects($parameters['contactids']);
|
||||
|
||||
// Purge property indexes
|
||||
Utils\Properties::purgeIndexes($parameters['contactids']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user