diff --git a/plugins/kolab_chat/kolab_chat.php b/plugins/kolab_chat/kolab_chat.php index e988e105..03f5e35d 100644 --- a/plugins/kolab_chat/kolab_chat.php +++ b/plugins/kolab_chat/kolab_chat.php @@ -1,218 +1,219 @@ * * Copyright (C) 2014-2018, Kolab Systems AG * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ class kolab_chat extends rcube_plugin { public $task = '^(?!login|logout).*$'; private $rc; private $driver; public function init() { $this->rc = rcube::get_instance(); $this->add_hook('startup', array($this, 'startup')); } /** * Startup hook handler, initializes/enables Chat */ public function startup($args) { // the files module can be enabled/disabled by the kolab_auth plugin if ($this->rc->config->get('kolab_chat_disabled') || !$this->rc->config->get('kolab_chat_enabled', true)) { return; } $this->add_texts('localization/'); $this->load_config(); $extwin = $this->rc->config->get('kolab_chat_extwin'); $driver = $this->rc->config->get('kolab_chat_driver', 'mattermost'); if (!$driver || !file_exists(__DIR__ . "/drivers/$driver.php")) { return; } // Load the driver require_once __DIR__ . "/drivers/$driver.php"; $class_name = "kolab_chat_$driver"; $this->driver = new $class_name($this); // Register UI end-points $this->register_task('kolab-chat'); $this->register_action('index', array($this, 'ui')); $this->register_action('action', array($this, 'action')); if ($this->rc->output->type == 'html' && !$this->rc->output->get_env('framed')) { + $this->include_stylesheet($this->local_skin_path() . '/kolab_chat.css'); $this->rc->output->set_env('kolab_chat_extwin', (bool) $extwin); $this->rc->output->add_script( "rcmail.addEventListener('beforeswitch-task', function(p) { if (p == 'kolab-chat' && rcmail.env.kolab_chat_extwin) { rcmail.open_window('?_task=kolab-chat&redirect=1', false, false, true); return false; } });", 'foot' ); $this->add_button(array( 'command' => 'kolab-chat', 'class' => 'button-chat', 'classsel' => 'button-chat button-selected', 'innerclass' => 'button-inner', 'label' => 'kolab_chat.chat', 'type' => 'link', ), 'taskbar'); $this->driver->ui(); } if ($this->rc->output->type == 'html' && $args['task'] == 'settings') { // add hooks for Chat 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')); } } /** * Display chat iframe wrapped by Roundcube interface elements (taskmenu) * or a dummy page with redirect to the chat app. */ function ui() { if ($this->driver) { $this->driver->ui(); $url = rcube::JQ($this->driver->url()); if (!empty($_GET['redirect'])) { echo '' . '' . ''; exit; } else { $this->rc->output->add_script( "rcmail.addEventListener('init', function() {" . "rcmail.location_href('$url', rcmail.get_frame_window(rcmail.env.contentframe));" . "});", 'foot' ); $this->rc->output->send('kolab_chat.chat'); } } } /** * Handler for driver specific actions */ function action() { if ($this->driver) { $this->driver->action(); } } /** * Handler for preferences_sections_list hook. * Adds Chat settings section into preferences sections list. * * @param array Original parameters * * @return array Modified parameters */ function preferences_sections_list($p) { $p['list']['kolab-chat'] = array( 'id' => 'kolab-chat', 'section' => $this->gettext('chat'), 'class' => 'chat' ); return $p; } /** * Handler for preferences_list hook. * Adds options blocks into Chat settings sections in Preferences. * * @param array Original parameters * * @return array Modified parameters */ function preferences_list($p) { if ($p['section'] != 'kolab-chat') { return $p; } $no_override = array_flip((array) $this->rc->config->get('dont_override')); $p['blocks']['main']['name'] = $this->gettext('mainoptions'); if (!isset($no_override['kolab_chat_extwin'])) { if (!$p['current']) { $p['blocks']['main']['content'] = true; return $p; } $field_id = 'rcmfd_kolab_chat_extwin'; $input = new html_checkbox(array('name' => '_kolab_chat_extwin', 'id' => $field_id, 'value' => 1)); $p['blocks']['main']['options']['kolab_chat_extwin'] = array( 'title' => html::label($field_id, rcube::Q($this->gettext('showinextwin'))), 'content' => $input->show($this->rc->config->get('kolab_chat_extwin') ? 1 : 0), ); } if ($p['current']) { // update env flag in the parent window $this->rc->output->command('parent.set_env', array('kolab_chat_extwin' => (bool) $this->rc->config->get('kolab_chat_extwin'))); } return $p; } /** * Handler for preferences_save hook. * Executed on Chat settings form submit. * * @param array Original parameters * * @return array Modified parameters */ function preferences_save($p) { if ($p['section'] == 'kolab-chat') { $p['prefs'] = array( 'kolab_chat_extwin' => isset($_POST['_kolab_chat_extwin']), ); } return $p; } } diff --git a/plugins/kolab_chat/skins/larry/images/buttons.png b/plugins/kolab_chat/skins/larry/images/buttons.png new file mode 100644 index 00000000..4a57bdfe Binary files /dev/null and b/plugins/kolab_chat/skins/larry/images/buttons.png differ diff --git a/plugins/kolab_chat/skins/larry/kolab_chat.css b/plugins/kolab_chat/skins/larry/kolab_chat.css new file mode 100644 index 00000000..2d40a9fc --- /dev/null +++ b/plugins/kolab_chat/skins/larry/kolab_chat.css @@ -0,0 +1,16 @@ +#taskbar a.button-chat span.button-inner { + background: url(images/buttons.png) 0 -4px no-repeat; +} + +#taskbar a.button-chat:hover span.button-inner, +#taskbar a.button-chat.button-selected span.button-inner { + background-position: 0 -36px; +} + +#sections-table #rcmrowkolab-chat .section { + background: url(images/buttons.png) 0 -98px no-repeat; +} + +#sections-table #rcmrowkolab-chat.selected .section { + background-position: -1px -69px; +}