示例#1
0
文件: email.php 项目: nemein/openpsa
 /**
  * @todo This function does nothing (and would throw notices if it did)
  */
 private function _add_attachment($att)
 {
     return false;
     $attobj = $this->_article->create_attachment($att['name'], $att['name'], $att['mimetype']);
     if (!$attobj) {
         //Could not create attachment
         debug_add("Could not create attachment '{$att['name']}', errstr: " . midcom_connection::get_error_string(), MIDCOM_LOG_ERROR);
         continue;
     }
     $fp = @$attobj->open('w');
     if (!$fp) {
         //Could not open for writing, clean up and continue
         debug_add("Could not open attachment {$attobj->guid} for writing, errstr: " . midcom_connection::get_error_string(), MIDCOM_LOG_ERROR);
         $attobj->delete();
         continue;
     }
     if (!fwrite($fp, $att['content'], strlen($att['content']))) {
         //Could not write, clean up and continue
         debug_add("Error when writing attachment {$attobj->guid}, errstr: " . midcom_connection::get_error_string(), MIDCOM_LOG_ERROR);
         fclose($fp);
         $attobj->delete();
         continue;
     }
     fclose($fp);
     if (isset($att['part']) && isset($att['part']->headers) && isset($att['part']->headers['content-id'])) {
         //Attachment is embed, add tag to end of note
         if (!$embeds_added) {
             $this->_article->content .= "<p>";
             $embeds_added = true;
         }
         $this->_article->content .= "<a href=\"" . midcom_connection::get_url('self') . "midcom-serveattachmentguid-{$attobj->guid}/{$attobj->name}\">{$attobj->title}</a><br />";
     } else {
         //Add normal attachments as links to end of note
         if (!$attachments_added) {
             //We hope the client handles these so that embeds come first and attachments then so we can avoid double pass over this array
             $this->_article->content .= "\n\n";
             $attachments_added = true;
         }
         $this->_article->content .= "[{$attobj->title}](" . midcom_connection::get_url('self') . "midcom-serveattachmentguid-{$attobj->guid}/{$attobj->name}), ";
     }
 }