/** * migrate from SQL account storage to another one (for example LDAP) * - deletes all users, groups and roles because they will be * imported from new accounts storage backend */ protected function _migrateFromSqlAccountsStorage() { Setup_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Deleting all user accounts, groups, roles and rights'); Tinebase_User::factory(Tinebase_User::SQL)->deleteAllUsers(); $contactSQLBackend = new Addressbook_Backend_Sql(); $allUserContactIds = $contactSQLBackend->search(new Addressbook_Model_ContactFilter(array('type' => 'user')), null, true); if (count($allUserContactIds) > 0) { $contactSQLBackend->delete($allUserContactIds); } Tinebase_Group::factory(Tinebase_Group::SQL)->deleteAllGroups(); $listsSQLBackend = new Addressbook_Backend_List(); $allGroupListIds = $listsSQLBackend->search(new Addressbook_Model_ListFilter(array('type' => 'group')), null, true); if (count($allGroupListIds) > 0) { $listsSQLBackend->delete($allGroupListIds); } $roles = Tinebase_Acl_Roles::getInstance(); $roles->deleteAllRoles(); // import users (from new backend) / create initial users (SQL) Tinebase_User::syncUsers(array('syncContactData' => TRUE)); $roles->createInitialRoles(); $applications = Tinebase_Application::getInstance()->getApplications(NULL, 'id'); foreach ($applications as $application) { Setup_Initialize::initializeApplicationRights($application); } }
/** * delete multiple groups * * @param array $_groupIds * @return void */ public function delete($_groupIds) { $this->checkRight('MANAGE_ACCOUNTS'); // check default user group / can't delete this group $defaultUserGroup = Tinebase_Group::getInstance()->getDefaultGroup(); if (in_array($defaultUserGroup->getId(), $_groupIds)) { Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Can\'t delete default group: ' . $defaultUserGroup->name); foreach ($_groupIds as $key => $value) { if ($value == $defaultUserGroup->getId()) { unset($_groupIds[$key]); } } } if (empty($_groupIds)) { return; } $eventBefore = new Admin_Event_BeforeDeleteGroup(); $eventBefore->groupIds = $_groupIds; Tinebase_Event::fireEvent($eventBefore); if (Tinebase_Application::getInstance()->isInstalled('Addressbook') === true) { $listIds = array(); foreach ($_groupIds as $groupId) { $group = $this->get($groupId); if (!empty($group->list_id)) { $listIds[] = $group->list_id; } } if (!empty($listIds)) { $listBackend = new Addressbook_Backend_List(); $listBackend->delete($listIds); } } Tinebase_Group::getInstance()->deleteGroups($_groupIds); $event = new Admin_Event_DeleteGroup(); $event->groupIds = $_groupIds; Tinebase_Event::fireEvent($event); }