forked from johndoh/roundcube-contextmenu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontextmenu.php
More file actions
100 lines (85 loc) · 4.89 KB
/
contextmenu.php
File metadata and controls
100 lines (85 loc) · 4.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
/**
* ContextMenu
*
* Plugin to add a context menu to various parts of the interface
*
* @author Philip Weir
*
* Copyright (C) 2009-2014 Philip Weir
*
* This program is a Roundcube (http://www.roundcube.net) plugin.
* For more information see README.md.
* See MANUAL.md for information about extending this plugin.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Roundcube. If not, see http://www.gnu.org/licenses/.
*/
class contextmenu extends rcube_plugin
{
public $task = 'mail|addressbook';
function init()
{
$rcmail = rcube::get_instance();
if ($rcmail->output->type == 'html') {
$this->include_script('contextmenu.js');
$this->include_stylesheet($this->local_skin_path() . '/contextmenu.css');
$this->include_script($this->local_skin_path() . '/functions.js');
$this->api->output->set_env('contextmenu', true);
}
if ($rcmail->task == 'mail') {
$this->register_action('plugin.contextmenu.messagecount', array($this, 'messagecount'));
// on the mailbox screen only add some additional options for the folder menu
if ($rcmail->action == '') {
$this->addition_folder_options();
}
}
elseif ($rcmail->task == 'addressbook' && $rcmail->action == '') {
// give other plugins a change to add address books before checking if they exist for the menu
$this->add_hook('render_page', array($this, 'addition_addressbook_options'));
}
}
public function addition_folder_options()
{
$this->add_texts('localization/');
$li = '';
$li .= html::tag('li', array('role' => 'menuitem'), $this->api->output->button(array('command' => 'plugin.contextmenu.collapseall', 'type' => 'link', 'class' => 'collapseall rcm_active', 'label' => 'contextmenu.collapseall', 'tabindex' => '-1', 'aria-disabled' => 'true')));
$li .= html::tag('li', array('role' => 'menuitem'), $this->api->output->button(array('command' => 'plugin.contextmenu.expandall', 'type' => 'link', 'class' => 'expandall rcm_active', 'label' => 'contextmenu.expandall', 'tabindex' => '-1', 'aria-disabled' => 'true')));
$li .= html::tag('li', array('role' => 'menuitem'), $this->api->output->button(array('command' => 'plugin.contextmenu.openfolder', 'type' => 'link', 'class' => 'openfolder rcm_active', 'label' => 'openinextwin', 'tabindex' => '-1', 'aria-disabled' => 'true')));
$out = html::tag('ul', array('id' => 'rcmFolderMenu', 'role' => 'menu'), $li);
$this->api->output->add_footer(html::div(array('style' => 'display: none;', 'aria-hidden' => 'true'), $out));
}
public function addition_addressbook_options()
{
$this->add_texts('localization/');
$li = '';
$li .= html::tag('li', array('role' => 'menuitem'), $this->api->output->button(array('command' => 'plugin.contextmenu.assigngroup', 'type' => 'link', 'class' => 'assigngroup disabled', 'classact' => 'assigngroup active', 'label' => 'contextmenu.assigngroup', 'tabindex' => '-1', 'aria-disabled' => 'true')));
if (count(rcube::get_instance()->get_address_sources(true)) > 1) {
// only show the move option if there are sources to move between
$li .= html::tag('li', array('role' => 'menuitem'), $this->api->output->button(array('command' => 'move', 'type' => 'link', 'class' => 'movecontact disabled', 'classact' => 'movecontact active', 'label' => 'moveto', 'tabindex' => '-1', 'aria-disabled' => 'true')));
$li .= html::tag('li', array('role' => 'menuitem'), $this->api->output->button(array('command' => 'copy', 'type' => 'link', 'class' => 'copycontact disabled', 'classact' => 'copycontact active', 'label' => 'copyto', 'tabindex' => '-1', 'aria-disabled' => 'true')));
}
$out = html::tag('ul', array('id' => 'rcmAddressBookMenu', 'role' => 'menu'), $li);
$this->api->output->add_footer(html::div(array('style' => 'display: none;', 'aria-hidden' => 'true'), $out));
}
public function messagecount()
{
$storage = rcube::get_instance()->storage;
$mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST);
// send output
header("Content-Type: application/json; charset=".RCUBE_CHARSET);
echo json_encode(array('messagecount' => $storage->count($mbox, 'EXISTS')));
exit;
}
}
?>