Hide 'Save to calendar' option for VTODO attachments (#3227)

This commit is contained in:
Thomas Bruederli 2014-07-30 17:51:54 +02:00
parent b3c5acd66a
commit 228a1b2438
2 changed files with 32 additions and 20 deletions

View file

@ -2240,6 +2240,7 @@ class calendar extends rcube_plugin
} }
$html = ''; $html = '';
$has_events = false;
foreach ($this->ics_parts as $mime_id) { foreach ($this->ics_parts as $mime_id) {
$part = $this->message->mime_parts[$mime_id]; $part = $this->message->mime_parts[$mime_id];
$charset = $part->ctype_parameters['charset'] ? $part->ctype_parameters['charset'] : RCMAIL_CHARSET; $charset = $part->ctype_parameters['charset'] ? $part->ctype_parameters['charset'] : RCMAIL_CHARSET;
@ -2255,16 +2256,20 @@ class calendar extends rcube_plugin
if ($event['_type'] != 'event') // skip non-event objects (#2928) if ($event['_type'] != 'event') // skip non-event objects (#2928)
continue; continue;
$has_events = true;
// get prepared inline UI for this event object // get prepared inline UI for this event object
$html .= html::div('calendar-invitebox', if ($this->ical->method) {
$this->itip->mail_itip_inline_ui( $html .= html::div('calendar-invitebox',
$event, $this->itip->mail_itip_inline_ui(
$this->ical->method, $event,
$mime_id.':'.$idx, $this->ical->method,
'calendar', $mime_id.':'.$idx,
rcube_utils::anytodatetime($this->message->headers->date) 'calendar',
) rcube_utils::anytodatetime($this->message->headers->date)
); )
);
}
// limit listing // limit listing
if ($idx >= 3) if ($idx >= 3)
@ -2280,7 +2285,7 @@ class calendar extends rcube_plugin
} }
// add "Save to calendar" button into attachment menu // add "Save to calendar" button into attachment menu
if (!empty($this->ics_parts)) { if ($has_events) {
$this->add_button(array( $this->add_button(array(
'id' => 'attachmentsavecal', 'id' => 'attachmentsavecal',
'name' => 'attachmentsavecal', 'name' => 'attachmentsavecal',

View file

@ -1305,6 +1305,7 @@ class tasklist extends rcube_plugin
// @todo: Calendar plugin does the same, which means the // @todo: Calendar plugin does the same, which means the
// attachment body is fetched twice, this is not optimal // attachment body is fetched twice, this is not optimal
$html = ''; $html = '';
$has_tasks = false;
foreach ($this->ics_parts as $mime_id) { foreach ($this->ics_parts as $mime_id) {
$part = $this->message->mime_parts[$mime_id]; $part = $this->message->mime_parts[$mime_id];
$charset = $part->ctype_parameters['charset'] ? $part->ctype_parameters['charset'] : RCMAIL_CHARSET; $charset = $part->ctype_parameters['charset'] ? $part->ctype_parameters['charset'] : RCMAIL_CHARSET;
@ -1322,16 +1323,20 @@ class tasklist extends rcube_plugin
continue; continue;
} }
$has_tasks = true;
// get prepared inline UI for this event object // get prepared inline UI for this event object
$html .= html::div('tasklist-invitebox', if ($this->ical->method) {
$this->itip->mail_itip_inline_ui( $html .= html::div('tasklist-invitebox',
$task, $this->itip->mail_itip_inline_ui(
$this->ical->method, $task,
$mime_id . ':' . $idx, $this->ical->method,
'tasks', $mime_id . ':' . $idx,
rcube_utils::anytodatetime($this->message->headers->date) 'tasks',
) rcube_utils::anytodatetime($this->message->headers->date)
); )
);
}
// limit listing // limit listing
if ($idx >= 3) { if ($idx >= 3) {
@ -1348,8 +1353,10 @@ class tasklist extends rcube_plugin
$p['content'] = $html . $p['content']; $p['content'] = $html . $p['content'];
$this->rc->output->add_label('tasklist.savingdata','tasklist.deletetaskconfirm','tasklist.declinedeleteconfirm'); $this->rc->output->add_label('tasklist.savingdata','tasklist.deletetaskconfirm','tasklist.declinedeleteconfirm');
}
// add "Save to calendar" button into attachment menu // add "Save to tasks" button into attachment menu
if ($has_tasks) {
$this->add_button(array( $this->add_button(array(
'id' => 'attachmentsavetask', 'id' => 'attachmentsavetask',
'name' => 'attachmentsavetask', 'name' => 'attachmentsavetask',