Changeset 5143 in subversion


Ignore:
Timestamp:
Aug 29, 2011 1:06:29 PM (21 months ago)
Author:
thomasb
Message:

Add plugin hook message_part_get for message part downloads

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/steps/mail/get.inc

    r4410 r5143  
    8080    $mimetype = sprintf('%s/%s', $ctype_primary, $ctype_secondary); 
    8181 
     82    // allow post-processing of the message body 
     83    $plugin = $RCMAIL->plugins->exec_hook('message_part_get', 
     84      array('id' => $part->mime_id, 'mimetype' => $mimetype, 'part' => $part, 'download' => !empty($_GET['_download']))); 
     85 
     86    if ($plugin['abort']) 
     87      exit; 
     88 
     89    // overwrite modified vars from plugin 
     90    $mimetype = $plugin['mimetype']; 
     91    list($ctype_primary, $ctype_secondary) = explode('/', $mimetype); 
     92    if ($plugin['body']) 
     93      $part->body = $plugin['body']; 
     94 
    8295    $browser = $RCMAIL->output->browser; 
    8396 
    8497    // send download headers 
    85     if ($_GET['_download']) { 
     98    if ($plugin['download']) { 
    8699      header("Content-Type: application/octet-stream"); 
    87100      if ($browser->ie) 
     
    98111 
    99112    // deliver part content 
    100     if ($ctype_primary == 'text' && $ctype_secondary == 'html' && empty($_GET['_download'])) { 
     113    if ($ctype_primary == 'text' && $ctype_secondary == 'html' && empty($plugin['download'])) { 
    101114      // get part body if not available 
    102115      if (!$part->body) 
     
    120133        $filename = addcslashes($filename, '"'); 
    121134 
    122       $disposition = !empty($_GET['_download']) ? 'attachment' : 'inline'; 
     135      $disposition = !empty($plugin['download']) ? 'attachment' : 'inline'; 
    123136 
    124137      header("Content-Disposition: $disposition; filename=\"$filename\""); 
Note: See TracChangeset for help on using the changeset viewer.