/** * add system account with tine user credentials (from config.inc.php or config db) * * @param Tinebase_Record_RecordSet $_accounts of Expressomail_Model_Account */ protected function _addSystemAccount(Tinebase_Record_RecordSet $_accounts) { $userId = Tinebase_Core::getUser()->getId(); $fullUser = Tinebase_User::getInstance()->getFullUserById($userId); $email = $this->_getAccountEmail($fullUser); // only create account if email address is set if ($email) { $systemAccount = new Expressomail_Model_Account(NULL, TRUE); $this->_addSystemAccountConfigValues($systemAccount); $systemAccount->type = Expressomail_Model_Account::TYPE_SYSTEM; $systemAccount->user_id = $userId; $this->_addUserValues($systemAccount, $fullUser, $email); // create new account and update capabilities Tinebase_Timemachine_ModificationLog::setRecordMetaData($systemAccount, 'create'); if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . print_r($systemAccount->toArray(), TRUE)); } $systemAccount = $this->_backend->create($systemAccount); $_accounts->addRecord($systemAccount); $cap = $this->updateCapabilities($systemAccount); $this->_addFolderDefaults($systemAccount, TRUE); $this->_backend->update($systemAccount); $this->_addedDefaultAccount = TRUE; // set as default account preference Tinebase_Core::getPreference($this->_applicationName)->{Expressomail_Preference::DEFAULTACCOUNT} = $systemAccount->getId(); Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Created new system account "' . $systemAccount->name . '".'); } else { Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' Could not create system account for user ' . $fullUser->accountLoginName . '. No email address given.'); } }
/** * test create trash on the fly */ public function testCreateTrashOnTheFly() { // make sure that the delimiter is correct / fetched from server $capabilities = $this->_controller->updateCapabilities($this->_account); // set another trash folder $this->_account->trash_folder = 'newtrash'; $this->_foldersToDelete[] = 'newtrash'; $accountBackend = new Expressomail_Backend_Account(); $account = $accountBackend->update($this->_account); $newtrash = $this->_controller->getSystemFolder($account, Expressomail_Model_Folder::FOLDER_TRASH); }