Changeset 2336 in subversion
- Timestamp:
- Mar 6, 2009 4:48:14 PM (4 years ago)
- Location:
- branches/devel-api
- Files:
-
- 4 added
- 5 edited
-
plugins/database_attachments (added)
-
plugins/database_attachments/database_attachments.php (added)
-
plugins/filesystem_attachments (added)
-
plugins/filesystem_attachments/filesystem_attachments.php (added)
-
program/include/rcube_plugin_api.php (modified) (3 diffs)
-
program/steps/mail/attachments.inc (modified) (4 diffs)
-
program/steps/mail/compose.inc (modified) (3 diffs)
-
program/steps/mail/func.inc (modified) (1 diff)
-
program/steps/mail/sendmail.inc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/devel-api/program/include/rcube_plugin_api.php
r2305 r2336 40 40 private $template_contents = array(); 41 41 42 private $required_plugins = array('filesystem_attachments'); 42 43 43 44 /** … … 93 94 $plugin->init(); 94 95 $this->plugins[] = $plugin; 96 97 // Remove required plugin class types from the required_plugins 98 // list as they are found 99 $key = array_search($plugin_name, $this->required_plugins); 100 if($key === FALSE){ 101 $parents = class_parents($plugin); 102 foreach($parents as $parent){ 103 $key = array_search($parent, $this->required_plugins); 104 if($key !== FALSE){ 105 break; 106 } 107 } 108 } 109 if($key !== FALSE){ 110 unset($this->required_plugins[$key]); 111 } 95 112 } 96 113 } … … 104 121 } 105 122 123 // Instantiate core plugins if not all required plugin types are satisfied 124 foreach($this->required_plugins as $plugin_name){ 125 $fn = $plugins_dir->path . DIRECTORY_SEPARATOR . $plugin_name . DIRECTORY_SEPARATOR . $plugin_name . '.php'; 126 if (file_exists($fn)) { 127 include($fn); 128 if (class_exists($plugin_name, false)) { 129 $plugin = new $plugin_name($this); 130 // check inheritance and task specification 131 if (is_subclass_of($plugin, 'rcube_plugin') && (!$plugin->task || $plugin->task == $rcmail->task)) { 132 $plugin->init(); 133 $this->plugins[] = $plugin; 134 } 135 } 136 } 137 } 138 106 139 // register an internal hook 107 140 $this->register_hook('template_container', array($this, 'template_container_hook')); -
branches/devel-api/program/steps/mail/attachments.inc
r2121 r2336 29 29 if ($RCMAIL->action=='remove-attachment') 30 30 { 31 if (preg_match('/^rcmfile([0-9]+)$/', $_POST['_file'], $regs)) 31 $plugin = rcmail::get_instance()->plugins->exec_hook('remove_attachment',array('id'=>substr($_POST['_file'],7))); 32 if ($plugin['status']) 32 33 { 33 $id = $ regs[1];34 $id = $plugin['id']; 34 35 if (is_array($_SESSION['compose']['attachments'][$id])) 35 36 { 36 @unlink($_SESSION['compose']['attachments'][$id]['path']);37 37 unset($_SESSION['compose']['attachments'][$id]); 38 38 $OUTPUT->command('remove_from_attachment_list', "rcmfile$id"); … … 45 45 if ($RCMAIL->action=='display-attachment') 46 46 { 47 if (preg_match('/^rcmfile([0-9]+)$/', $_GET['_file'], $regs)) 47 $plugin = rcmail::get_instance()->plugins->exec_hook('display_attachment',array('id'=>substr($_GET['_file'],7))); 48 if ($plugin['status']) 48 49 { 49 $id = $regs[1]; 50 if (is_array($_SESSION['compose']['attachments'][$id])) 51 { 52 $apath = $_SESSION['compose']['attachments'][$id]['path']; 53 header('Content-Type: ' . $_SESSION['compose']['attachments'][$id]['mimetype']); 54 header('Content-Length: ' . filesize($apath)); 55 readfile($apath); 50 $id = $plugin['id']; 51 $apath = $_SESSION['compose']['attachments'][$id]['path']; 52 header('Content-Type: ' . $_SESSION['compose']['attachments'][$id]['mimetype']); 53 header('Content-Length: ' . filesize($apath)); 54 readfile($apath); 55 // plugins that don't use disk storage will want this temp file removed after use 56 if($plugin['erase_after_send']){ 57 unlink($apath); 56 58 } 57 59 } … … 73 75 if (is_array($_FILES['_attachments']['tmp_name'])) { 74 76 foreach ($_FILES['_attachments']['tmp_name'] as $i => $filepath) { 75 $tmpfname = tempnam($temp_dir, 'rcmAttmnt'); 76 if (move_uploaded_file($filepath, $tmpfname)) { 77 $id = count($_SESSION['compose']['attachments']); 78 $_SESSION['compose']['attachments'][] = array( 79 'name' => $_FILES['_attachments']['name'][$i], 80 'mimetype' => rc_mime_content_type($tmpfname, $_FILES['_attachments']['type'][$i]), 81 'path' => $tmpfname, 82 ); 83 77 $plugin = rcmail::get_instance()->plugins->exec_hook('upload_attachment',array('filepath'=>$filepath,'index'=>$i)); 78 if ($plugin['status']) { 79 $id = $plugin['id']; 84 80 if (is_file($icon = $CONFIG['skin_path'] . '/images/icons/remove-attachment.png')) { 85 81 $button = html::img(array( … … 95 91 $content = html::a(array( 96 92 'href' => "#delete", 97 'onclick' => sprintf("return %s.command('remove-attachment','rcmfile% d', this)", JS_OBJECT_NAME, $id),93 'onclick' => sprintf("return %s.command('remove-attachment','rcmfile%s', this)", JS_OBJECT_NAME, $id), 98 94 'title' => rcube_label('delete'), 99 95 ), $button); -
branches/devel-api/program/steps/mail/compose.inc
r2161 r2336 589 589 || (empty($part->disposition) && $part->filename))) 590 590 { 591 if ($attachment = rcmail_save_attachment($message, $pid)) 592 $_SESSION['compose']['attachments'][] = $attachment; 591 if ($attachment = rcmail_save_attachment($message, $pid)){ 592 $_SESSION['compose']['attachments'][$attachment['id']] = $attachment; 593 } 593 594 } 594 595 } … … 605 606 { 606 607 if ($attachment = rcmail_save_attachment($message, $pid)) 607 $_SESSION['compose']['attachments'][ ] = $attachment;608 $_SESSION['compose']['attachments'][$attachment['id']] = $attachment; 608 609 } 609 610 } … … 614 615 global $RCMAIL; 615 616 616 $temp_dir = unslashify($RCMAIL->config->get('temp_dir'));617 $tmp_path = tempnam($temp_dir, 'rcmAttmnt');618 617 $part = $message->mime_parts[$pid]; 619 618 620 if ($fp = fopen($tmp_path, 'w')) 621 { 622 $message->get_part_content($pid, $fp); 623 fclose($fp); 624 619 $attachment = $message->get_part_content($pid); 620 $plugin = rcmail::get_instance()->plugins->exec_hook('save_attachment',array('attachment'=>$attachment,'filename'=>$part->filename)); 621 if ($plugin['status']) 622 { 625 623 return array( 626 624 'mimetype' => $part->ctype_primary . '/' . $part->ctype_secondary, 627 625 'name' => $part->filename, 628 'path' => $tmp_path, 629 'content_id' => $part->content_id 626 'path' => $plugin['tmp_path'], 627 'content_id' => $part->content_id, 628 'id' => $plugin['id'] 630 629 ); 630 } else { 631 return FALSE; 631 632 } 632 633 } -
branches/devel-api/program/steps/mail/func.inc
r2303 r2336 1215 1215 return; 1216 1216 1217 // remove attachment files from temp dir 1218 if (is_array($_SESSION['compose']['attachments'])) 1219 foreach ($_SESSION['compose']['attachments'] as $attachment) 1220 @unlink($attachment['path']); 1217 rcmail::get_instance()->plugins->exec_hook('cleanup_attachments',array()); 1221 1218 1222 1219 unset($_SESSION['compose']); -
branches/devel-api/program/steps/mail/sendmail.inc
r2303 r2336 299 299 foreach ($_SESSION['compose']['attachments'] as $id => $attachment) 300 300 { 301 // This hook gives attachment handlers a chance to place the file on disk 302 $plugin = rcmail::get_instance()->plugins->exec_hook('get_attachment', array('id' => $id,'attachment'=>$attachment)); 303 $attachment = $plugin['attachment']; 301 304 $dispurl = '/\ssrc\s*=\s*[\'"]?\S+display-attachment\S+file=rcmfile' . $id . '[\'"]?/'; 302 305 $match = preg_match($dispurl, $message_body); … … 322 325 ); 323 326 } 327 if($plugin['erase_after_send']){ 328 unlink($plugin['attachment']['path']); 329 } 324 330 } 325 331
Note: See TracChangeset
for help on using the changeset viewer.
