/**
  * try to delete a contact and its id
  *
  */
 public function testDeleteContact()
 {
     $contact = $this->testCreateContact();
     $this->_backend->delete($contact->getId());
     $this->setExpectedException('Tinebase_Exception_NotFound');
     $contact = $this->_backend->get($contact->getId());
 }
 /**
  * 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);
     }
 }
 /**
  * remove autogenerated contacts
  *
  * @param Zend_Console_Getopt $opts
  *
  * @throws Addressbook_Exception
  * @throws Tinebase_Exception_InvalidArgument
  * @todo use OR filter for different locales
  */
 public function removeAutogeneratedContacts($opts)
 {
     if (!Tinebase_Application::getInstance()->isInstalled('Calendar')) {
         throw new Addressbook_Exception('Calendar application not installed');
     }
     $params = $this->_parseArgs($opts);
     $languages = isset($params['languages']) ? $params['languages'] : array('en', 'de');
     $contactBackend = new Addressbook_Backend_Sql();
     foreach ($languages as $language) {
         $locale = new Zend_Locale($language);
         $translation = Tinebase_Translation::getTranslation('Calendar', $locale);
         // search all contacts with note "This contact has been automatically added by the system as an event attender"
         $noteFilter = new Addressbook_Model_ContactFilter(array(array('field' => 'note', 'operator' => 'equals', 'value' => $translation->_('This contact has been automatically added by the system as an event attender'))));
         $contactIdsToDelete = $contactBackend->search($noteFilter, null, Tinebase_Backend_Sql_Abstract::IDCOL);
         if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
             Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . " About to delete " . count($contactIdsToDelete) . ' contacts ...');
         }
         $number = $contactBackend->delete($contactIdsToDelete);
         if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
             Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . " Deleted " . $number . ' autogenerated contacts for language ' . $language);
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * try to delete a contact
  *
  */
 public function testDeleteContact()
 {
     $this->_backend->delete($GLOBALS['Addressbook_ControllerTest']['contactId']);
     $this->setExpectedException('Tinebase_Exception_NotFound');
     $contact = $this->_backend->get($GLOBALS['Addressbook_ControllerTest']['contactId']);
 }