1
0
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:
Thomas Tanghus 2013-05-27 01:46:02 +02:00
parent 1ae88f66c6
commit 667a362fb3
2 changed files with 14 additions and 22 deletions

View File

@ -250,12 +250,6 @@ class Database extends AbstractBackend {
* @return bool * @return bool
*/ */
public function deleteAddressBook($addressbookid) { 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 // Get all contact ids for this address book
$ids = array(); $ids = array();
@ -281,22 +275,9 @@ class Database extends AbstractBackend {
} }
} }
// Purge contact property indexes \OC_Hook::emit('OCA\Contacts', 'pre_deleteAddressBook',
if(count($ids)) { array('addressbookid' => $addressbookid, 'contactids' => $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);
}
// Delete contacts in address book. // Delete contacts in address book.
if(!isset(self::$preparedQueries['deleteaddressbookcontacts'])) { if(!isset(self::$preparedQueries['deleteaddressbookcontacts'])) {

View File

@ -66,6 +66,17 @@ class Hooks{
* Delete any registred address books (Future) * Delete any registred address books (Future)
*/ */
public static function addressBookDeletion($parameters) { 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']);
}
} }
/** /**