Page MenuHomePhorge

D5724.1775204244.diff
No OneTemporary

Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None

D5724.1775204244.diff

diff --git a/plugins/kolab/Kolab/CockpitLink.php b/plugins/kolab/Kolab/CockpitLink.php
new file mode 100644
--- /dev/null
+++ b/plugins/kolab/Kolab/CockpitLink.php
@@ -0,0 +1,51 @@
+<?php
+
+namespace Kolab;
+
+/**
+ * Adds a link to the Kolab Cockpit in the task menu
+ */
+class CockpitLink extends Feature
+{
+ /**
+ * Feature initialization.
+ */
+ public function init()
+ {
+ $this->plugin->add_hook('ready', [$this, 'readyHook']);
+ }
+
+ /**
+ * Ready hook handler
+ */
+ public function readyHook($args): array
+ {
+ if ($this->rc->output->type !== 'html' || !empty($this->rc->output->env['framed'])) {
+ return $args;
+ }
+
+ $url = $this->rc->config->get('kolab_cockpit_url');
+
+ if (empty($url)) {
+ return $args;
+ }
+
+ // Add the button
+ $this->plugin->add_button([
+ 'command' => 'cockpit',
+ 'class' => 'button-cockpit',
+ 'classsel' => 'button-cockpit button-selected',
+ 'innerclass' => 'button-inner',
+ 'label' => 'kolab.account',
+ 'type' => 'link',
+ ], 'taskbar');
+
+ // Register button image and action
+ $this->rc->output->add_footer(
+ "<style>#taskmenu a.button-cockpit:before { content: \"\\f007\"; }</style>"
+ . "<script>rcmail.register_command('cockpit', () => location.href = '$url', true)</script>"
+ );
+
+ return $args;
+ }
+}
diff --git a/plugins/kolab/Kolab/Helpdesk.php b/plugins/kolab/Kolab/Helpdesk.php
--- a/plugins/kolab/Kolab/Helpdesk.php
+++ b/plugins/kolab/Kolab/Helpdesk.php
@@ -102,9 +102,16 @@
if (!empty($this->allowed_tasks)) {
$json = json_encode($this->allowed_tasks);
$script = <<<END
- \$('a').filter(function() {
- var ev = \$(this).attr('onclick');
- return ev && ev.match(/'switch-task','([a-z]+)'/) && !{$json}.includes(RegExp.\$1);
+ \$('#taskmenu > a, #taskmenu .action-buttons > a').filter(function() {
+ var task = 'notask', ev = \$(this).attr('onclick');
+ if (ev && ev.match(/'switch-task','([a-z]+)'/)) {
+ // built-in commands
+ task = RegExp.\$1;
+ } else if (ev && ev.match(/rcmail.command\('([a-z]+)'/)) {
+ // plugin commands
+ task = RegExp.\$1;
+ }
+ return !{$json}.includes(task);
}).remove();
END;
diff --git a/plugins/kolab/config.inc.php.dist b/plugins/kolab/config.inc.php.dist
--- a/plugins/kolab/config.inc.php.dist
+++ b/plugins/kolab/config.inc.php.dist
@@ -15,3 +15,6 @@
// Lifetime of cache entries. Possible units: s, m, h, d, w
$config['kolab_client_cache_ttl'] = '10m';
+
+// Kolab Cockpit URL - for a button in the task menu
+$config['kolab_cockpit_url'] = null;
diff --git a/plugins/kolab/kolab.php b/plugins/kolab/kolab.php
--- a/plugins/kolab/kolab.php
+++ b/plugins/kolab/kolab.php
@@ -25,6 +25,7 @@
{
private $features = [
'Kolab\Addresses',
+ 'Kolab\CockpitLink',
'Kolab\Configuration',
'Kolab\Contacts',
'Kolab\Delegation',
@@ -76,6 +77,9 @@
// Read the plugin config, we try to not do this in init()
$this->load_config();
+ // Load localization
+ $this->add_texts('localization/', false);
+
return $args;
}
diff --git a/plugins/kolab/localization/en_US.inc b/plugins/kolab/localization/en_US.inc
new file mode 100644
--- /dev/null
+++ b/plugins/kolab/localization/en_US.inc
@@ -0,0 +1,8 @@
+<?php
+
+/**
+ * Localization for the Kolab plugin
+ */
+
+$labels = [];
+$labels['account'] = 'Account';

File Metadata

Mime Type
text/plain
Expires
Fri, Apr 3, 8:17 AM (19 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18823160
Default Alt Text
D5724.1775204244.diff (3 KB)

Event Timeline