Turba_Driver::deleteAll PHP Method

deleteAll() public method

Deletes all contacts from an address book.
public deleteAll ( string $sourceName = null )
$sourceName string The identifier of the address book to delete. If omitted, will clear the current user's 'default' address book for this source type.
    public function deleteAll($sourceName = null)
    {
        if (!$this->hasCapability('delete_all')) {
            throw new Turba_Exception('Not supported');
        }
        $ids = $this->_deleteAll($sourceName);
        // Update Horde_History and Tagger
        $history = $GLOBALS['injector']->getInstance('Horde_History');
        try {
            foreach ($ids as $uid) {
                // This is slightly hackish, but it saves us from having to
                // create and save an array of Turba_Objects before we delete
                // them, just to be able to calculate this using
                // Turba_Object#getGuid
                $guid = 'turba:' . $this->getName() . ':' . $uid;
                $history->log($guid, array('action' => 'delete'), true);
                // Remove tags.
                $GLOBALS['injector']->getInstance('Turba_Tagger')->replaceTags($uid, array(), $this->getContactOwner(), 'contact');
                /* Tell content we removed the object */
                $GLOBALS['injector']->getInstance('Content_Objects_Manager')->delete(array($uid), 'contact');
            }
        } catch (Exception $e) {
            Horde::log($e, 'ERR');
        }
    }