summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2013-11-06 10:59:47 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2013-11-25 08:40:34 (GMT)
commitca501beaa67c501de0a9071b801efbfa0ad3caa2 (patch)
tree3974ba8b555c9b9f4688301840473ad39d7746f7
parent7b74234b73eebb10981952360d9026620257814f (diff)
downloadroundcubemail-plugins-kolab-roundcubemail-plugins-kolab-3.1.8.tar.gz
Initialize calendar and tasklist plugins in 'startup' hook and allow other plugins (e.g. kolab:auth) to disabled them (#2476)roundcubemail-plugins-kolab-3.1.8
-rw-r--r--plugins/calendar/calendar.php47
-rw-r--r--plugins/tasklist/tasklist.php25
2 files changed, 50 insertions, 22 deletions
diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php
index f71109e..ccbc75a 100644
--- a/plugins/calendar/calendar.php
+++ b/plugins/calendar/calendar.php
@@ -88,15 +88,6 @@ class calendar extends rcube_plugin
require($this->home . '/lib/calendar_ui.php');
$this->ui = new calendar_ui($this);
- // load Calendar user interface which includes jquery-ui
- if (!$this->rc->output->ajax_call && !$this->rc->output->env['framed']) {
- $this->ui->init();
-
- // settings are required in (almost) every GUI step
- if ($this->rc->action != 'attend')
- $this->rc->output->set_env('calendar_settings', $this->load_settings());
- }
-
// catch iTIP confirmation requests that don're require a valid session
if ($this->rc->action == 'attend' && !empty($_REQUEST['_t'])) {
$this->add_hook('startup', array($this, 'itip_attend_response'));
@@ -104,8 +95,32 @@ class calendar extends rcube_plugin
else if ($this->rc->action == 'feed' && !empty($_REQUEST['_cal'])) {
$this->add_hook('startup', array($this, 'ical_feed_export'));
}
- else if ($this->rc->task == 'calendar' && $this->rc->action != 'save-pref') {
- if ($this->rc->action != 'upload') {
+ else {
+ // default startup routine
+ $this->add_hook('startup', array($this, 'startup'));
+ }
+ }
+
+ /**
+ * Startup hook
+ */
+ public function startup($args)
+ {
+ // the calendar module can be enabled/disabled by the kolab_auth plugin
+ if ($this->rc->config->get('calendar_disabled', false) || !$this->rc->config->get('calendar_enabled', true))
+ return;
+
+ // load Calendar user interface
+ if (!$this->rc->output->ajax_call && !$this->rc->output->env['framed']) {
+ $this->ui->init();
+
+ // settings are required in (almost) every GUI step
+ if ($args['action'] != 'attend')
+ $this->rc->output->set_env('calendar_settings', $this->load_settings());
+ }
+
+ if ($args['task'] == 'calendar' && $args['action'] != 'save-pref') {
+ if ($args['action'] != 'upload') {
$this->load_driver();
}
@@ -138,19 +153,19 @@ class calendar extends rcube_plugin
}
}
}
- else if ($this->rc->task == 'settings') {
+ else if ($args['task'] == 'settings') {
// add hooks for Calendar settings
$this->add_hook('preferences_sections_list', array($this, 'preferences_sections_list'));
$this->add_hook('preferences_list', array($this, 'preferences_list'));
$this->add_hook('preferences_save', array($this, 'preferences_save'));
}
- else if ($this->rc->task == 'mail') {
+ else if ($args['task'] == 'mail') {
// hooks to catch event invitations on incoming mails
- if ($this->rc->action == 'show' || $this->rc->action == 'preview') {
+ if ($args['action'] == 'show' || $args['action'] == 'preview') {
$this->add_hook('message_load', array($this, 'mail_message_load'));
$this->add_hook('template_object_messagebody', array($this, 'mail_messagebody_html'));
}
-
+
// add 'Create event' item to message menu
if ($this->api->output->type == 'html') {
$this->api->add_content(html::tag('li', null,
@@ -167,7 +182,7 @@ class calendar extends rcube_plugin
$this->api->output->add_label('calendar.createfrommail');
}
}
-
+
// add hooks to display alarms
$this->add_hook('pending_alarms', array($this, 'pending_alarms'));
$this->add_hook('dismiss_alarms', array($this, 'dismiss_alarms'));
diff --git a/plugins/tasklist/tasklist.php b/plugins/tasklist/tasklist.php
index 94cf4bb..840ee2e 100644
--- a/plugins/tasklist/tasklist.php
+++ b/plugins/tasklist/tasklist.php
@@ -71,13 +71,26 @@ class tasklist extends rcube_plugin
// load plugin configuration
$this->load_config();
+ $this->timezone = $this->lib->timezone;
+
+ // proceed initialization in startup hook
+ $this->add_hook('startup', array($this, 'startup'));
+ }
+
+ /**
+ * Startup hook
+ */
+ public function startup($args)
+ {
+ // the tasks module can be enabled/disabled by the kolab_auth plugin
+ if ($this->rc->config->get('tasklist_disabled', false) || !$this->rc->config->get('tasklist_enabled', true))
+ return;
+
// load localizations
- $this->add_texts('localization/', $this->rc->task == 'tasks' && (!$this->rc->action || $this->rc->action == 'print'));
+ $this->add_texts('localization/', $args['task'] == 'tasks' && (!$args['action'] || $args['action'] == 'print'));
$this->rc->load_language($_SESSION['language'], array('tasks.tasks' => $this->gettext('navtitle'))); // add label for task title
- $this->timezone = $this->lib->timezone;
-
- if ($this->rc->task == 'tasks' && $this->rc->action != 'save-pref') {
+ if ($args['task'] == 'tasks' && $args['action'] != 'save-pref') {
$this->load_driver();
// register calendar actions
@@ -94,9 +107,9 @@ class tasklist extends rcube_plugin
$this->collapsed_tasks = array_filter(explode(',', $this->rc->config->get('tasklist_collapsed_tasks', '')));
}
- else if ($this->rc->task == 'mail') {
+ else if ($args['task'] == 'mail') {
// TODO: register hooks to catch ical/vtodo email attachments
- if ($this->rc->action == 'show' || $this->rc->action == 'preview') {
+ if ($args['action'] == 'show' || $args['action'] == 'preview') {
// $this->add_hook('message_load', array($this, 'mail_message_load'));
// $this->add_hook('template_object_messagebody', array($this, 'mail_messagebody_html'));
}