$mail->setHeaderFromSource($head); $mail->setContentFromSource($pop->getFullBody($_mail, false, false, true)); $mail->date_read = CMbDT::dateTime(); $mail->user_id = $user->_id; //text plain if ($mail->_text_plain) { $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); } }
/** * get the html text from the mail structure * * @param int $source_object_id the user id * * @return mixed */ function getHtmlText($source_object_id) { if ($this->_text_html) { $textH = new CContentHTML(); //apicrypt if (CModule::getActive("apicrypt") && $this->_is_apicrypt == "html") { $this->_text_html = CApicrypt::uncryptBody($source_object_id, $this->_text_html); } $textH->content = CUserMail::purifyHTML($this->_text_html); //cleanup if (!($msg = $textH->store())) { $this->text_html_id = $textH->_id; } } return $this->text_html_id; }
$file->file_type = $attachment->getType($attachment->type, $attachment->subtype); $file->fillFields(); $file->putContent($file_pop); if ($str = $file->store()) { CAppUI::stepAjax($str, UI_MSG_ERROR); } else { $attachment->file_id = $file->_id; $attachment->store(); } } } //text link if ($text_html || $text_plain) { $content_type = "text/plain"; if ($text_html) { $text = new CContentHTML(); $text->load($text_html); $content_type = "text/html"; } else { $text = new CContentAny(); $text->load($text_plain); } $file = new CFile(); $file->setObject($object); $file->author_id = CAppUI::$user->_id; $file->file_name = "sans_titre"; $file->file_category_id = $category_id; if ($mail->subject) { $file->file_name = $mail->subject; } if ($rename_text) {
/** * @see parent::doStore() */ function doStore() { /** @var CUserMail $mail */ $mail = $this->_obj; $mail->date_inbox = CMbDT::dateTime(); $mail->date_read = $mail->date_inbox; $content_html = new CContentHTML(); $mail->_content = CUserMail::purifyHTML($mail->_content); $content_html->content = $mail->_content; if (!($msg = $content_html->store())) { $mail->text_html_id = $content_html->_id; $mail->_text_html = $content_html; } $content_plain = new CContentAny(); $content_plain->content = strip_tags($mail->_content); if (!($msg = $content_plain->store())) { $mail->text_plain_id = $content_plain->_id; } $hash = CMbSecurity::hash(CMbSecurity::SHA256, "==FROM==\n{$mail->from}\n==TO==\n{$mail->to}\n==SUBJECT==\n{$mail->subject}\n==CONTENT==\n{$mail->_content}"); if ($msg = $mail->store()) { CAppUI::setMsg($msg, UI_MSG_ERROR); return parent::doStore(); } $action = CValue::post('action'); switch ($action) { case 'draft': $mail->draft = '1'; CAppUI::setMsg('CUserMail-msg-drafted', UI_MSG_OK); break; case 'send': $mail->sent = '1'; $mail->draft = '0'; $account = $mail->loadAccount(); if ($mail->_is_apicrypt) { /** @var CSourceSMTP $smtp */ $smtp = CExchangeSource::get("mediuser-{$account->object_id}-apicrypt", 'smtp'); } else { /** @var CSourceSMTP $smtp */ $smtp = CExchangeSource::get("mediuser-{$account->object_id}", 'smtp'); } $smtp->init(); foreach (explode(',', $mail->to) as $_address) { $smtp->addTo($_address); } if ($mail->cc != '') { foreach (explode(',', $mail->cc) as $_address) { $smtp->addCc($_address); } } if ($mail->bcc != '') { foreach (explode(',', $mail->bcc) as $_address) { $smtp->addBcc($_address); } } $smtp->setSubject($mail->subject); if ($mail->_is_apicrypt) { $receiver = explode(',', $mail->to); $body = CApicrypt::encryptBody($account->object_id, $receiver[0], $mail->_content); $smtp->setBody($body); } else { $smtp->setBody($mail->_content); } /** @var CMailAttachments[] $attachments */ $attachments = $mail->loadAttachments(); foreach ($attachments as $_attachment) { $file = $_attachment->loadFiles(); $smtp->addAttachment($file->_file_path, $file->file_name); } try { $smtp->send(); CAppUI::setMsg('CUserMail-msg-sent', UI_MSG_OK); } catch (phpmailerException $e) { CAppUI::setMsg($e->errorMessage(), UI_MSG_ERROR); } catch (CMbException $e) { $e->stepAjax(); } break; default: } $mail->store(); if (CAppUI::isMsgOK() && $this->redirectStore) { $this->redirect =& $this->redirectStore; } if (!CAppUI::isMsgOK() && $this->redirectError) { $this->redirect =& $this->redirectError; } }
/** * Suppression de document / modèle * * @return string */ function delete() { $this->completeField("content_id"); $this->loadContent(false); $this->loadRefsFiles(); // Remove PDF preview foreach ($this->_ref_files as $_file) { $_file->delete(); } if ($msg = parent::delete()) { return $msg; } // Remove content return $this->_ref_content->delete(); }