diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php index a94a65cb..97ec1b13 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 e77bccca..11793c74 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(); - // load localizations - $this->add_texts('localization/', $this->rc->task == 'tasks' && (!$this->rc->action || $this->rc->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') { + // 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/', $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 + + 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')); }