示例#1
0
 /**
  * update function (-> 3.2)
  * - check all users with 'userEmailAccount' and update their accounts / preferences
  */
 public function update_1()
 {
     // update account types for users with userEmailAccount preference
     $imapConfig = Tinebase_Config::getInstance()->getConfigAsArray(Tinebase_Config::IMAP);
     if (array_key_exists('host', $imapConfig)) {
         $accounts = Felamimail_Controller_Account::getInstance()->getAll();
         $accountBackend = new Felamimail_Backend_Account();
         foreach ($accounts as $account) {
             try {
                 if (Tinebase_Core::getPreference('Felamimail')->getValueForUser('userEmailAccount', $account->user_id)) {
                     $user = Tinebase_User::getInstance()->getFullUserById($account->user_id);
                     // account email == user->emailAddress && account->host == system account host -> type = system
                     if ($account->email == $user->accountEmailAddress && $account->host == $imapConfig['host']) {
                         $account->type = Felamimail_Model_Account::TYPE_SYSTEM;
                         Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Switching to system account: ' . $account->name);
                         $accountBackend->update($account);
                     }
                 }
             } catch (Exception $e) {
                 // do nothing
             }
         }
     }
     // rename preference
     $this->_db->query('UPDATE ' . SQL_TABLE_PREFIX . "preferences SET name = 'useSystemAccount' WHERE name = 'userEmailAccount'");
     $this->setApplicationVersion('Felamimail', '3.2');
 }
示例#2
0
 /**
  * add system account with tine user credentials (from config.inc.php or config db) 
  *
  * @param Tinebase_Record_RecordSet $_accounts of Felamimail_Model_Account
  */
 protected function _addSystemAccount(Tinebase_Record_RecordSet $_accounts)
 {
     $userId = $this->_currentAccount->getId();
     $fullUser = Tinebase_User::getInstance()->getFullUserById($userId);
     $email = $this->_getAccountEmail($fullUser);
     // only create account if email address is set
     if ($email) {
         $systemAccount = new Felamimail_Model_Account(NULL, TRUE);
         $this->_addSystemAccountConfigValues($systemAccount);
         $systemAccount->type = Felamimail_Model_Account::TYPE_SYSTEM;
         $systemAccount->user_id = $userId;
         $this->_addUserValues($systemAccount, $fullUser, $email);
         $this->_addFolderDefaults($systemAccount, TRUE);
         // 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);
         $this->_addedDefaultAccount = TRUE;
         // set as default account preference
         Tinebase_Core::getPreference($this->_applicationName)->{Felamimail_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.');
     }
 }
 /**
  * try to get a message as plain/text
  */
 public function testGetPlainTextMessage()
 {
     $accountBackend = new Felamimail_Backend_Account();
     $message = $this->_sendMessage();
     // get complete message
     $this->_account->display_format = Felamimail_Model_Account::DISPLAY_PLAIN;
     $accountBackend->update($this->_account);
     $message = $this->_json->getMessage($message['id']);
     $this->_account->display_format = Felamimail_Model_Account::DISPLAY_HTML;
     $accountBackend->update($this->_account);
     // check
     $this->assertEquals("aaaaaä \n\r\n", $message['body']);
 }
 /**
  * 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 Felamimail_Backend_Account();
     $account = $accountBackend->update($this->_account);
     $newtrash = $this->_controller->getSystemFolder($account, Felamimail_Model_Folder::FOLDER_TRASH);
 }
示例#5
0
 /**
  * test create trash on the fly
  */
 public function testCreateTrashOnTheFly()
 {
     // set another trash folder
     $this->_account->trash_folder = 'newtrash';
     $this->_foldersToDelete[] = 'newtrash';
     $accountBackend = new Felamimail_Backend_Account();
     $account = $accountBackend->update($this->_account);
     $newtrash = $this->_controller->getSystemFolder($account, Felamimail_Model_Folder::FOLDER_TRASH);
 }