Esempio n. 1
0
 function save_archival_image()
 {
     if ($this->do_not_save_archival) {
         return true;
     }
     $identifier = 'archival';
     return $this->add_attachment($identifier, "{$identifier}_{$this->_filename}", $this->title, midcom_helper_misc::get_mimetype($this->_original_tmpname), $this->_original_tmpname, false);
 }
Esempio n. 2
0
 /**
  * This is the actual code which filters and saves a derived image.
  *
  * @param string $identifier The derived image to construct.
  * @return boolean Indicating success
  */
 function _save_derived_image($identifier)
 {
     $this->_current_tmpname = $this->_filter->create_tmp_copy($this->_original_tmpname);
     if (!$this->_filter->set_file($this->_current_tmpname) || !$this->_filter->process_chain($this->derived_images[$identifier])) {
         return false;
     }
     if (isset($this->_identifier)) {
         // we come from the image*s* type
         $blob_identifier = "{$this->_identifier}{$identifier}";
         $title = $this->_title;
     } else {
         $blob_identifier = $identifier;
         $title = $this->title;
     }
     if (array_key_exists($identifier, $this->_pending_attachments)) {
         unset($this->_pending_attachments[$identifier]);
         return $this->update_attachment($blob_identifier, "{$identifier}_{$this->_filename}", $title, midcom_helper_misc::get_mimetype($this->_current_tmpname), $this->_current_tmpname, false);
     }
     if (isset($this->_attachment_map)) {
         $this->_attachment_map[$blob_identifier] = array($this->_identifier, $identifier);
     }
     return $this->add_attachment($blob_identifier, "{$identifier}_{$this->_filename}", $title, midcom_helper_misc::get_mimetype($this->_current_tmpname), $this->_current_tmpname, false);
 }
Esempio n. 3
0
 /**
  * Determine correct mimetype for file we have only content
  * (and perhaps filename) for.
  */
 private function _get_mimetype($content, $name = 'unknown')
 {
     $filename = tempnam($GLOBALS['midcom_config']['midcom_tempdir'], 'org_openpsa_mail_') . "_{$name}";
     $fp = fopen($filename, 'w');
     if (!$fp) {
         //Could not open file for writing
         unlink($filename);
         return false;
     }
     fwrite($fp, $content);
     fclose($fp);
     $mimetype = midcom_helper_misc::get_mimetype($filename);
     unlink($filename);
     return $mimetype;
 }