From bb3b7fec0ee3b57a1ba690b113aff398e2c6d55f Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 3 Nov 2017 12:24:18 +0100 Subject: [PATCH] Make itip links optional and disabled by default This feature has ever had many limitations and inconsistent behaviour depending if the user is logged in or not. Also in meantime, PHP's mail() support has been removed from Roundcube Framework. Now to enable the feature you have to set calendar_itip_smtp_server option. --- plugins/calendar/config.inc.php.dist | 3 ++- .../lib/libcalendaring_itip.php | 20 ++++--------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/plugins/calendar/config.inc.php.dist b/plugins/calendar/config.inc.php.dist index 99da1edc..22705b86 100644 --- a/plugins/calendar/config.inc.php.dist +++ b/plugins/calendar/config.inc.php.dist @@ -138,8 +138,9 @@ $config['calendar_freebusy_trigger'] = false; $config['calendar_include_freebusy_data'] = 1; // SMTP server host used to send (anonymous) itip messages. -// Set to '' in order to use PHP's mail() function for email delivery. // To override the SMTP port or connection method, provide a full URL like 'tls://somehost:587' +// This will add a link to invitation messages to allow users from outside +// to reply when their mail clients do not support iTip format. $config['calendar_itip_smtp_server'] = null; // SMTP username used to send (anonymous) itip messages diff --git a/plugins/libcalendaring/lib/libcalendaring_itip.php b/plugins/libcalendaring/lib/libcalendaring_itip.php index b960e9a4..4a4e88d5 100644 --- a/plugins/libcalendaring/lib/libcalendaring_itip.php +++ b/plugins/libcalendaring/lib/libcalendaring_itip.php @@ -44,7 +44,6 @@ class libcalendaring_itip array('identity' => $this->rc->user->list_emails(true))); $this->sender = $hook['identity']; - $this->plugin->add_hook('message_before_send', array($this, 'before_send_hook')); $this->plugin->add_hook('smtp_connect', array($this, 'smtp_connect_hook')); } @@ -152,7 +151,10 @@ class libcalendaring_itip // } // append links for direct invitation replies - if ($method == 'REQUEST' && $rsvp && ($token = $this->store_invitation($event, $recipient['email']))) { + if ($method == 'REQUEST' && $rsvp + && $this->rc->config->get('calendar_itip_smtp_server') + && ($token = $this->store_invitation($event, $recipient['email'])) + ) { $mailbody .= "\n\n" . $this->gettext(array( 'name' => 'invitationattendlinks', 'vars' => array('url' => $this->plugin->get_url(array('action' => 'attend', 't' => $token))), @@ -177,20 +179,6 @@ class libcalendaring_itip return $sent; } - /** - * Plugin hook triggered by rcube::deliver_message() before delivering a message. - * Here we can set the 'smtp_server' config option to '' in order to use - * PHP's mail() function for unauthenticated email sending. - */ - public function before_send_hook($p) - { - if ($this->itip_send && !$this->rc->user->ID && $this->rc->config->get('calendar_itip_smtp_server', null) === '') { - $this->rc->config->set('smtp_server', ''); - } - - return $p; - } - /** * Plugin hook to alter SMTP authentication. * This is used if iTip messages are to be sent from an unauthenticated session