/** * @see parent::doStore() */ function doStore() { if (isset($_FILES['attachment'])) { $mail_id = CValue::post('mail_id'); $mail = new CUserMail(); $mail->load($mail_id); $files = array(); foreach ($_FILES['attachment']['error'] as $key => $file_error) { if (isset($_FILES['attachment']['name'][$key])) { $files[] = array('name' => $_FILES['attachment']['name'][$key], 'tmp_name' => $_FILES['attachment']['tmp_name'][$key], 'error' => $_FILES['attachment']['error'][$key], 'size' => $_FILES['attachment']['size'][$key]); } } foreach ($files as $_key => $_file) { if ($_file['error'] == UPLOAD_ERR_NO_FILE) { continue; } if ($_file['error'] != 0) { CAppUI::setMsg(CAppUI::tr("CFile-msg-upload-error-" . $_file["error"]), UI_MSG_ERROR); continue; } $attachment = new CMailAttachments(); $attachment->name = $_file['name']; $content_type = mime_content_type($_file['tmp_name']); $attachment->type = $attachment->getTypeInt($content_type); $attachment->bytes = $_file['size']; $attachment->mail_id = $mail_id; $content_type = explode('/', $content_type); $attachment->subtype = strtoupper($content_type[1]); $attachment->disposition = 'ATTACHMENT'; $attachment->extension = substr(strrchr($attachment->name, '.'), 1); $attachment->part = $mail->countBackRefs('mail_attachments') + 1; $attachment->store(); $file = new CFile(); $file->setObject($attachment); $file->author_id = CAppUI::$user->_id; $file->file_name = $attachment->name; $file->file_date = CMbDT::dateTime(); $file->fillFields(); $file->updateFormFields(); $file->doc_size = $attachment->bytes; $file->file_type = mime_content_type($_file['tmp_name']); $file->moveFile($_file, true); if ($msg = $file->store()) { CAppUI::setMsg(CAppUI::tr('CMailAttachments-error-upload-file') . ':' . CAppUI::tr($msg), UI_MSG_ERROR); CApp::rip(); } $attachment->file_id = $file->_id; if ($msg = $attachment->store()) { CAppUI::setMsg($msg, UI_MSG_ERROR); CApp::rip(); } } CAppUI::setMsg('CMailAttachments-msg-added', UI_MSG_OK); } else { parent::doStore(); } }
if ($mail->text_html_id) { $mail->loadContentHTML(); $mail->_content = $mail->_text_html->content; } elseif ($mail->text_plain_id) { $mail->loadContentPlain(); $mail->_content = $mail->_text_plain->content; } } 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";
<?php /** * $Id$ * * @package Mediboard * @subpackage messagerie * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ * @link http://www.mediboard.org */ $mail_id = CValue::get('mail_id'); $mail = new CUserMail(); $mail->load($mail_id); $mail->loadAttachments(); foreach ($mail->_attachments as $_attachment) { $_attachment->loadFiles(); } $smarty = new CSmartyDP(); $smarty->assign('attachments', $mail->_attachments); $smarty->display('inc_mail_attachments.tpl');
* @subpackage messagerie * @author SARL OpenXtrem <*****@*****.**> * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html * @version $Revision$ * @link http://www.mediboard.org */ CCanDo::checkRead(); $usermail_ids = json_decode(stripslashes(CValue::get('usermail_ids', '[]'))); $action = CValue::get('action'); if (empty($usermail_ids)) { CAppUI::stepAjax('CUserMail-msg-no_mail_selected', UI_MSG_WARNING); CApp::rip(); } foreach ($usermail_ids as $usermail_id) { $mail = new CUserMail(); $mail->load($usermail_id); switch ($action) { case 'unarchive': $mail->archived = 0; if (!$mail->date_read) { $mail->date_read = CMbDT::dateTime(); } break; case 'archive': $mail->archived = 1; if (!$mail->date_read) { $mail->date_read = CMbDT::dateTime(); } break; case 'unfavour': $mail->favorite = 0;