$textP = new CContentAny();
        $textP->content = $mail->_text_plain;
        if ($msg = $textP->store()) {
            CAppUI::setMsg($msg, UI_MSG_ERROR);
        }
        $mail->text_plain_id = $textP->_id;
    }
    //text html
    if ($mail->_text_html) {
        $textH = new CContentHTML();
        $text = new CMbXMLDocument();
        $text = $text->sanitizeHTML($mail->_text_html);
        //cleanup
        $textH->content = $text;
        if ($msg = $textH->store()) {
            CAppUI::setMsg($msg, UI_MSG_ERROR);
        } else {
            $mail->text_html_id = $textH->_id;
        }
    }
    $msg = $mail->store();
    if ($msg) {
        CAppUI::setMsg($msg, UI_MSG_ERROR);
    }
}
$mail->loadRefsFwd();
$pop->close();
//Smarty
$smarty = new CSmartyDP();
$smarty->assign("mail", $mail);
$smarty->display("ajax_open_pop_email.tpl");
    }
} else {
    $mail->from = $account->user;
    $mail->account_class = $account->_class;
    $mail->account_id = $account->_id;
    $mail->draft = '1';
    if ($reply_to_id) {
        $mail->in_reply_to_id = $reply_to_id;
        $reply_to = new CUserMail();
        $reply_to->load($reply_to_id);
        $mail->to = $reply_to->from;
        strpos($reply_to->subject, 'Re:') === false ? $mail->subject = "Re: {$reply_to->subject}" : ($mail->subject = $reply_to->subject);
        if ($answer_to_all) {
            $mail->cc = $reply_to->cc;
        }
    }
    $mail->store();
}
$mail->loadAttachments();
foreach ($mail->_attachments as $_attachment) {
    $_attachment->loadFiles();
}
// Initialisation de CKEditor
$templateManager = new CTemplateManager();
$templateManager->editor = "ckeditor";
$templateManager->messageMode = true;
$templateManager->initHTMLArea();
$smarty = new CSmartyDP();
$smarty->assign('mail', $mail);
$smarty->assign('account', $account);
$smarty->display('inc_edit_usermail.tpl');
 function createUserMail($user_id, $object = null, $apicrypt = false)
 {
     if (CModule::getActive('messagerie')) {
         $mail = new CUserMail();
         $mail->account_id = $this->_id;
         $mail->account_class = $this->_class;
         $mail->sent = 1;
         $mail->subject = $this->_mail->Subject;
         $mail->from = $this->_mail->From;
         $mail->to = $this->_to['address'];
         $mail->date_inbox = CMbDT::dateTime();
         if ($this->_mail->ContentType == 'text/html') {
             $mail->_text_html = $this->_mail->Body;
             if ($apicrypt) {
                 $mail->_is_apicrypt = 'html';
             }
             $mail->getHtmlText($user_id);
         } else {
             $mail->_text_plain = $this->_mail->Body;
             if ($apicrypt) {
                 $mail->_is_apicrypt = 'plain';
             }
             $mail->getPlainText($user_id);
         }
         $mail->store();
         if ($object) {
             $file = null;
             switch ($object->_class) {
                 case "CCompteRendu":
                     $file = $object->_ref_file;
                     break;
                 case "CFile":
                     $file = $object;
                     break;
             }
             if ($file && $file->_id) {
                 $attachment = new CMailAttachments();
                 $attachment->mail_id = $mail->_id;
                 list($type, $subtype) = explode('/', $file->file_type);
                 $attachment->type = $attachment->getTypeInt($type);
                 $attachment->part = 1;
                 $attachment->subtype = $subtype;
                 $attachment->bytes = $file->doc_size;
                 list($file_name, $extension) = explode('.', $file->file_name);
                 $attachment->name = $file_name;
                 $attachment->extension = $extension;
                 $attachment->file_id = $file->_id;
                 $attachment->store();
             }
         }
     }
 }
Beispiel #4
0
         //text html
         $mail_unseen->getHtmlText($_source->object_id);
         //sent ?
         if (strpos($mail_unseen->from, $_source->user) !== false) {
             $mail_unseen->sent = 1;
         }
         //unread increment
         if (!$mail_unseen->date_read) {
             $unread++;
         }
         //read on server + pref + not sent => archived !
         if ($mail_unseen->date_read && $archivedOnReception && !$mail_unseen->sent) {
             $mail_unseen->archived = 1;
         }
         //store the usermail
         if (!($msg = $mail_unseen->store())) {
             $created++;
         }
         //attachments list
         $pop->cleanTemp();
         $attachs = $pop->getListAttachments($_mail);
         $mail_unseen->attachFiles($attachs, $pop);
     } else {
         // si le mail est lu sur MB mais non lu sur IMAP => on le flag
         if ($mail_unseen->date_read) {
             $pop->setflag($_mail, "\\Seen");
         }
     }
     $loop++;
 }
 //foreach
        case 'unfavour':
            $mail->favorite = 0;
            break;
        case 'favour':
            $mail->favorite = 1;
            break;
        case 'delete':
            if ($msg = $mail->delete()) {
                CAppUI::stepAjax($msg, UI_MSG_ERROR);
            }
            break;
        case 'mark_read':
            $mail->date_read = CMbDT::dateTime();
            break;
        case 'mark_unread':
            $mail->date_read = '';
            break;
        default:
            break;
    }
    if ($action != 'delete') {
        if ($msg = $mail->store()) {
            CAppUI::stepAjax($msg, UI_MSG_ERROR);
        }
    }
}
$msg = "CUserMail-msg-{$action}";
if (count($usermail_ids) > 1) {
    $msg .= '-pl';
}
CAppUI::stepAjax($msg, UI_MSG_OK);