function moveImapMessage($id, $target_folders_id)
 {
     $message = toC_Email_Accounts_Admin::getCachedMessage($id);
     $src_folder = toC_Email_Accounts_Admin::getFolderData($message['folders_id']);
     $target_folder = toC_Email_Accounts_Admin::getFolderData($target_folders_id);
     if ($this->connectMailServer($src_folder['folders_name'])) {
         if ($this->_inbox->move(imap::utf7_imap_encode($target_folder['folders_name']), array($message['uid']))) {
             $this->closeMailServer();
             return $this->moveCachedMessage($id, $target_folders_id);
         }
     }
     $this->closeMailServer();
     return false;
 }
Exemplo n.º 2
0
 function saveAccount()
 {
     global $toC_Json, $osC_Language;
     $error = false;
     $feedback = '';
     $accounts_id = isset($_REQUEST['accounts_id']) && !empty($_REQUEST['accounts_id']) ? $_REQUEST['accounts_id'] : null;
     $data['user_id'] = $_SESSION['admin']['id'];
     $data['accounts_name'] = isset($_REQUEST['accounts_name']) ? $_REQUEST['accounts_name'] : '';
     $data['accounts_email'] = isset($_REQUEST['accounts_email']) ? $_REQUEST['accounts_email'] : '';
     $data['signature'] = isset($_REQUEST['signature']) ? $_REQUEST['signature'] : '';
     $data['type'] = $_REQUEST['type'];
     $data['host'] = $_REQUEST['host'];
     $data['port'] = $_REQUEST['port'];
     $data['username'] = $_REQUEST['username'];
     $data['password'] = $_REQUEST['password'];
     $data['sent'] = $_REQUEST['sent'];
     $data['drafts'] = $_REQUEST['drafts'];
     $data['trash'] = $_REQUEST['trash'];
     $data['save_copy_on_server'] = isset($_REQUEST['save_copy_on_server']) && $_REQUEST['save_copy_on_server'] == 'on' ? 1 : 0;
     $data['mbroot'] = isset($_REQUEST['mbroot']) ? imap::utf7_imap_encode($_REQUEST['mbroot']) : 'INBOX';
     $data['use_ssl'] = isset($_REQUEST['use_ssl']) && $_REQUEST['use_ssl'] == 'on' ? 1 : 0;
     $data['novalidate_cert'] = isset($_REQUEST['novalidate_cert']) && $_REQUEST['novalidate_cert'] == 'on' ? 1 : 0;
     $data['examine_headers'] = isset($_REQUEST['examine_headers']) && $_REQUEST['examine_headers'] == 'on' ? 1 : 0;
     $data['use_system_mailer'] = isset($_REQUEST['use_system_mailer']) && $_REQUEST['use_system_mailer'] == 'on' ? 1 : 0;
     $data['smtp_host'] = isset($_REQUEST['smtp_host']) ? $_REQUEST['smtp_host'] : '';
     $data['smtp_port'] = isset($_REQUEST['smtp_port']) ? $_REQUEST['smtp_port'] : 25;
     $data['smtp_encryption'] = isset($_REQUEST['smtp_encryption']) ? $_REQUEST['smtp_encryption'] : '';
     $data['smtp_username'] = isset($_REQUEST['smtp_username']) ? $_REQUEST['smtp_username'] : '';
     $data['smtp_password'] = isset($_REQUEST['smtp_password']) ? $_REQUEST['smtp_password'] : '';
     if (toC_Email_Accounts_Admin::checkEmailAccount($data['username'], $accounts_id)) {
         $response = array('success' => false, 'feedback' => $osC_Language->get('ms_error_email_account_already_exist'));
     } else {
         if ($accounts_id == null) {
             $error_info = null;
             if (toC_Email_Accounts_Admin::checkEmailAccountOnSever($data, $error_info) === false) {
                 $error = true;
                 $response = array('success' => false, 'feedback' => sprintf($osC_Language->get('ms_error_connect_server_failed'), $error_info));
             }
         }
         if ($error === false) {
             $accounts_id = toC_Email_Accounts_Admin::saveAccount($accounts_id, $data);
             $node = array('id' => $accounts_id, 'text' => $data['accounts_email'], 'iconCls' => 'icon-folder-account-record', 'expanded' => true, 'type' => 'account', 'children' => toC_Email_Accounts_Admin::getMailBoxNodes($accounts_id, 0), 'protocol' => $data['type']);
             $response = array('success' => true, 'feedback' => $osC_Language->get('ms_success_action_performed'), 'accounts_node' => $node);
         }
     }
     echo $toC_Json->encode($response);
 }