Esempio n. 1
0
 /**
  * create the CFiles attached to the mail
  *
  * @param CMailAttachments[] $attachList The list of CMailAttachment
  * @param CPop               $popClient  the CPop client
  *
  * @return void
  */
 function attachFiles($attachList, $popClient)
 {
     //size limit
     $size_required = CAppUI::pref("getAttachmentOnUpdate");
     if ($size_required == "") {
         $size_required = 0;
     }
     foreach ($attachList as $_attch) {
         $_attch->mail_id = $this->_id;
         $_attch->loadMatchingObject();
         if (!$_attch->_id) {
             $_attch->store();
         }
         //si preference taille ok OU que la piece jointe est incluse au texte => CFile
         if ($_attch->bytes <= $size_required || $_attch->disposition == "INLINE") {
             $file = new CFile();
             $file->setObject($_attch);
             $file->author_id = CAppUI::$user->_id;
             if (!$file->loadMatchingObject()) {
                 $file_pop = $popClient->decodeMail($_attch->encoding, $popClient->openPart($this->uid, $_attch->getpartDL()));
                 $file->file_name = $_attch->name;
                 //apicrypt attachment
                 if (strpos($_attch->name, ".apz") !== false) {
                     $file_pop = CApicrypt::uncryptAttachment($popClient->source->object_id, $file_pop);
                 }
                 //file type detection
                 $first = is_array($file_pop) ? reset($file_pop) : $file_pop;
                 $mime = $this->extensionDetection($first);
                 //file name
                 $infos = pathinfo($_attch->name);
                 $extension = $infos['extension'];
                 $mime_extension = strtolower(end(explode("/", $mime)));
                 if (strtolower($extension) != $mime_extension) {
                     $file->file_name = $infos['filename'] . "." . $mime_extension;
                 }
                 $file->file_type = $mime ? $mime : $_attch->getType($_attch->type, $_attch->subtype);
                 $file->fillFields();
                 $file->updateFormFields();
                 $file->putContent($file_pop);
                 $file->store();
             }
         }
     }
 }
 /**
  * LoadContent from pop content
  *
  * @param object $content content from pop
  *
  * @return bool
  */
 function loadContentFromPop($content)
 {
     switch ($this->subtype) {
         case 'SVG+XML':
             return $this->_content = CPop::decodeMail($this->encoding, $content);
             break;
         default:
             return $this->_content = base64_encode(CPop::decodeMail($this->encoding, $content));
             break;
     }
 }
            } else {
                CAppUI::stepAjax("CMailAttachments-msg-attachmentLinked-success", UI_MSG_OK);
            }
        }
    } else {
        // pop
        $account = new CSourcePOP();
        $account->load($mail->account_id);
        $pop = new CPop($account);
        $pop->open();
        $file = new CFile();
        $file->setObject($object);
        $file->author_id = CAppUI::$user->_id;
        $pop = new CPop($account);
        $pop->open();
        $file_pop = $pop->decodeMail($attachment->encoding, $pop->openPart($mail->uid, $attachment->getpartDL()));
        $pop->close();
        $file->file_name = $attachment->name;
        $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) {