Beispiel #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');
 }
Beispiel #2
0
 /**
  * set vacation active field for account
  * 
  * @param string|Felamimail_Model_Account $_account
  * @param boolean $_vacationEnabled
  * @return Felamimail_Model_Account
  */
 public function setVacationActive(Felamimail_Model_Account $_account, $_vacationEnabled)
 {
     $account = $this->get($_account->getId());
     if ($account->sieve_vacation_active != $_vacationEnabled) {
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Updating sieve_vacation_active = ' . $_vacationEnabled . ' for account: ' . $account->name);
         }
         $account->sieve_vacation_active = (bool) $_vacationEnabled;
         // skip all special update handling
         $account = $this->_backend->update($account);
     }
     return $account;
 }
 /**
  * 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);
 }
 /**
  * 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);
 }