Copy message attachments when creating a task from mail
This commit is contained in:
parent
754aa2a299
commit
bea7725725
2 changed files with 45 additions and 39 deletions
|
@ -844,7 +844,7 @@ function rcube_tasklist_ui(settings)
|
||||||
}
|
}
|
||||||
|
|
||||||
// show/hide tabs according to calendar's feature support
|
// show/hide tabs according to calendar's feature support
|
||||||
$('#taskedit-tab-attachments')[(list.attachments?'show':'hide')]();
|
$('#taskedit-tab-attachments')[(list.attachments||rec.attachments?'show':'hide')]();
|
||||||
|
|
||||||
// activate the first tab
|
// activate the first tab
|
||||||
$('#taskedit').tabs('select', 0);
|
$('#taskedit').tabs('select', 0);
|
||||||
|
@ -894,7 +894,7 @@ function rcube_tasklist_ui(settings)
|
||||||
$dialog.dialog('close');
|
$dialog.dialog('close');
|
||||||
};
|
};
|
||||||
|
|
||||||
if (rec.id) {
|
if (action != 'new') {
|
||||||
buttons[rcmail.gettext('delete', 'tasklist')] = function() {
|
buttons[rcmail.gettext('delete', 'tasklist')] = function() {
|
||||||
if (delete_task(rec.id))
|
if (delete_task(rec.id))
|
||||||
$dialog.dialog('close');
|
$dialog.dialog('close');
|
||||||
|
@ -930,6 +930,10 @@ function rcube_tasklist_ui(settings)
|
||||||
*/
|
*/
|
||||||
function load_attachment(rec, att)
|
function load_attachment(rec, att)
|
||||||
{
|
{
|
||||||
|
// can't open temp attachments
|
||||||
|
if (!rec.id || rec.id < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
var qstring = '_id='+urlencode(att.id)+'&_t='+urlencode(rec.recurrence_id||rec.id)+'&_list='+urlencode(rec.list);
|
var qstring = '_id='+urlencode(att.id)+'&_t='+urlencode(rec.recurrence_id||rec.id)+'&_list='+urlencode(rec.list);
|
||||||
|
|
||||||
// open attachment in frame if it's of a supported mimetype
|
// open attachment in frame if it's of a supported mimetype
|
||||||
|
|
|
@ -329,7 +329,6 @@ class tasklist extends rcube_plugin
|
||||||
private function cleanup_task(&$rec)
|
private function cleanup_task(&$rec)
|
||||||
{
|
{
|
||||||
// remove temp. attachment files
|
// remove temp. attachment files
|
||||||
$taskid = $rec['id'];
|
|
||||||
if (!empty($_SESSION['tasklist_session']) && ($taskid = $_SESSION['tasklist_session']['id'])) {
|
if (!empty($_SESSION['tasklist_session']) && ($taskid = $_SESSION['tasklist_session']['id'])) {
|
||||||
$this->rc->plugins->exec_hook('attachments_cleanup', array('group' => $taskid));
|
$this->rc->plugins->exec_hook('attachments_cleanup', array('group' => $taskid));
|
||||||
$this->rc->session->remove('tasklist_session');
|
$this->rc->session->remove('tasklist_session');
|
||||||
|
@ -650,7 +649,7 @@ class tasklist extends rcube_plugin
|
||||||
'size' => $_FILES['_attachments']['size'][$i],
|
'size' => $_FILES['_attachments']['size'][$i],
|
||||||
'name' => $_FILES['_attachments']['name'][$i],
|
'name' => $_FILES['_attachments']['name'][$i],
|
||||||
'mimetype' => rc_mime_content_type($filepath, $_FILES['_attachments']['name'][$i], $_FILES['_attachments']['type'][$i]),
|
'mimetype' => rc_mime_content_type($filepath, $_FILES['_attachments']['name'][$i], $_FILES['_attachments']['type'][$i]),
|
||||||
'group' => $eventid,
|
'group' => $taskid,
|
||||||
);
|
);
|
||||||
|
|
||||||
$attachment = $this->rc->plugins->exec_hook('attachment_upload', $attachment);
|
$attachment = $this->rc->plugins->exec_hook('attachment_upload', $attachment);
|
||||||
|
@ -852,14 +851,16 @@ class tasklist extends rcube_plugin
|
||||||
if ($message->headers) {
|
if ($message->headers) {
|
||||||
$task['title'] = trim($message->subject);
|
$task['title'] = trim($message->subject);
|
||||||
$task['description'] = trim($message->first_text_part());
|
$task['description'] = trim($message->first_text_part());
|
||||||
/*
|
$task['id'] = -$uid;
|
||||||
// copy mail attachments to event
|
|
||||||
if ($message->attachments) {
|
$this->load_driver();
|
||||||
$eventid = 'cal:';
|
|
||||||
if (!is_array($_SESSION['event_session']) || $_SESSION['event_session']['id'] != $eventid) {
|
// copy mail attachments to task
|
||||||
$_SESSION['event_session'] = array();
|
if ($message->attachments && $this->driver->attachments) {
|
||||||
$_SESSION['event_session']['id'] = $eventid;
|
if (!is_array($_SESSION['tasklist_session']) || $_SESSION['tasklist_session']['id'] != $task['id']) {
|
||||||
$_SESSION['event_session']['attachments'] = array();
|
$_SESSION['tasklist_session'] = array();
|
||||||
|
$_SESSION['tasklist_session']['id'] = $task['id'];
|
||||||
|
$_SESSION['tasklist_session']['attachments'] = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ((array)$message->attachments as $part) {
|
foreach ((array)$message->attachments as $part) {
|
||||||
|
@ -868,24 +869,25 @@ class tasklist extends rcube_plugin
|
||||||
'size' => $part->size,
|
'size' => $part->size,
|
||||||
'name' => $part->filename,
|
'name' => $part->filename,
|
||||||
'mimetype' => $part->mimetype,
|
'mimetype' => $part->mimetype,
|
||||||
'group' => $eventid,
|
'group' => $task['id'],
|
||||||
);
|
);
|
||||||
|
|
||||||
$attachment = $this->rc->plugins->exec_hook('attachment_save', $attachment);
|
$attachment = $this->rc->plugins->exec_hook('attachment_save', $attachment);
|
||||||
|
|
||||||
if ($attachment['status'] && !$attachment['abort']) {
|
if ($attachment['status'] && !$attachment['abort']) {
|
||||||
$id = $attachment['id'];
|
$id = $attachment['id'];
|
||||||
|
$attachment['classname'] = rcmail_filetype2classname($attachment['mimetype'], $attachment['name']);
|
||||||
|
|
||||||
// store new attachment in session
|
// store new attachment in session
|
||||||
unset($attachment['status'], $attachment['abort'], $attachment['data']);
|
unset($attachment['status'], $attachment['abort'], $attachment['data']);
|
||||||
$_SESSION['event_session']['attachments'][$id] = $attachment;
|
$_SESSION['tasklist_session']['attachments'][$id] = $attachment;
|
||||||
|
|
||||||
$attachment['id'] = 'rcmfile' . $attachment['id']; # add prefix to consider it 'new'
|
$attachment['id'] = 'rcmfile' . $attachment['id']; # add prefix to consider it 'new'
|
||||||
$event['attachments'][] = $attachment;
|
$task['attachments'][] = $attachment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
$this->rc->output->command('plugin.mail2taskdialog', $task);
|
$this->rc->output->command('plugin.mail2taskdialog', $task);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue