/** * delete accounts * * @param mixed $_accountIds array of account ids * @return array with success flag * @throws Tinebase_Exception_Record_NotAllowed */ public function delete($_accountIds) { $this->checkRight('MANAGE_ACCOUNTS'); $groupsController = Admin_Controller_Group::getInstance(); foreach ((array) $_accountIds as $accountId) { if ($accountId === Tinebase_Core::getUser()->getId()) { $message = 'You are not allowed to delete yourself!'; Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' ' . $message); throw new Tinebase_Exception_AccessDenied($message); } Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . " about to remove user with id: {$accountId}"); $oldUser = $this->get($accountId); $memberships = $groupsController->getGroupMemberships($accountId); if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " removing user from groups: " . print_r($memberships, true)); } foreach ((array) $memberships as $groupId) { $groupsController->removeGroupMember($groupId, $accountId); } if (Tinebase_Application::getInstance()->isInstalled('Addressbook') === true && !empty($oldUser->contact_id)) { $this->_deleteContact($oldUser->contact_id); } $this->_userBackend->deleteUser($accountId); } }
protected function _deleteDummyUsers() { foreach ($this->_objects as $object) { $this->_uit->deleteUser($object->getId()); } }