diff --git a/README.md b/README.md
index 54c34fe..8cea816 100644
--- a/README.md
+++ b/README.md
@@ -57,6 +57,7 @@ List Options menu.
Supported actions
-----------------
+*Mesasge List:*
The following actions are available for left/right swipe:
* `archive` - Archive the message (Requires the Roundcube Archive plugin)
@@ -76,6 +77,15 @@ The following actions are available for down swipe:
* `checkmail` - Check for new messages in the current folder
* `none` - Swipe disabled
+disabled_actions and dont_override
+----------------------------------
+This plugin respects the disabled_actions config option for Roundcube commands.
+To prevent users from overriding swipe config you can add any of the following
+to dont_override:
+* `swipe_actions` - Prevent overriding all swipe config
+* `swipe_actions.list` - e.g. `swipe_actions.mesasgelist` Prevent overriding of the swipe actions on a specific list, e.g. mesasgelist
+* `swipe_actions.list.direction` - e.g. `swipe_actions.mesasgelist.left` Prevent overriding of the swipe actions on a specific list and direction
+
Interaction with other plugins
------------------------------
The `swipe_actions_list` hook is triggered when listing the available actions
diff --git a/skins/elastic/includes/menu.html b/skins/elastic/includes/menu.html
index f8aba6f..e45b705 100644
--- a/skins/elastic/includes/menu.html
+++ b/skins/elastic/includes/menu.html
@@ -2,28 +2,22 @@
\ No newline at end of file
diff --git a/swipe.js b/swipe.js
index f2f4d8e..e22c992 100644
--- a/swipe.js
+++ b/swipe.js
@@ -435,7 +435,7 @@ $(document).ready(function() {
rcmail.addEventListener('beforemenu-open', function(name) {
if (name == rcmail.env.swipe_menuname) {
var menu_obj = $('.swipe-menu');
- if (!rcmail.env.swipe_list.draggable && menu_obj.find('select,input').length > 0) {
+ if (!rcmail.env.swipe_list.draggable && menu_obj.find('select > option,input').length > 0) {
if (bw.edge)
menu_obj.find('.swipeoptions-down').hide();
diff --git a/swipe.php b/swipe.php
index 2a972f7..9febd02 100644
--- a/swipe.php
+++ b/swipe.php
@@ -36,16 +36,16 @@ class swipe extends rcube_plugin
'checkmail' => 'checkmail'
),
'horizontal' => array(
- 'swipe-read' => 'swipe.markasread',
- 'swipe-flagged' => 'swipe.markasflagged',
+ 'archive' => 'archive.buttontext',
'delete' => 'delete',
'forward' => 'forward',
+ 'markasjunk' => 'markasjunk.markasjunk',
+ 'move' => 'moveto',
'reply' => 'reply',
'reply-all' => 'replyall',
- 'move' => 'moveto',
- 'swipe-select' => 'select',
- 'archive' => 'archive.buttontext',
- 'markasjunk' => 'markasjunk.markasjunk'
+ 'swipe-flagged' => 'swipe.markasflagged',
+ 'swipe-read' => 'swipe.markasread',
+ 'swipe-select' => 'select'
)
)
);
@@ -56,9 +56,10 @@ class swipe extends rcube_plugin
{
$this->rcube = rcube::get_instance();
$this->list_type = 'messagelist';
- $this->config = $this->_load_config();
$this->register_action('plugin.swipe.save_settings', array($this, 'save_settings'));
+ $this->_load_config();
+
if ($this->rcube->output->type == 'html' && $this->rcube->action == '') {
$this->menu_file = '/' . $this->local_skin_path() . '/includes/menu.html';
$filepath = slashify($this->home) . $this->menu_file;
@@ -93,8 +94,6 @@ class swipe extends rcube_plugin
public function options_list($args)
{
- $disabled_actions = (array) rcube::get_instance()->config->get('disabled_actions');
- $laoded_plugins = $this->api->loaded_plugins();
$swipe_actions = $this->actions[$args['source']][$args['axis']];
$args['id'] = 'swipeoptions-' . $args['direction'];
$args['name'] = 'swipe_' . $args['direction'];
@@ -104,11 +103,7 @@ class swipe extends rcube_plugin
$options = array();
foreach ($data['actions'] as $action => $text) {
- // Skip the action if it is in disabled_actions config option
- // Also skip actions from disabled/not configured plugins
- if (in_array($action, $disabled_actions) || in_array('mail.' . $action, $disabled_actions) ||
- ($action == 'archive' && !$this->rcube->output->env['archive_folder']) ||
- ($action == 'markasjunk' && !in_array('markasjunk', $laoded_plugins))) {
+ if (!$this->_allowed_action($args['direction'], $action)) {
continue;
}
@@ -166,7 +161,7 @@ class swipe extends rcube_plugin
{
$config = array();
foreach (array('left', 'right', 'down') as $direction) {
- if ($prop = rcube_utils::get_input_value('swipe_' . $direction, rcube_utils::INPUT_POST)) {
+ if (($prop = rcube_utils::get_input_value('swipe_' . $direction, rcube_utils::INPUT_POST)) && $this->_allowed_action($direction)) {
$config[$direction] = $prop;
}
}
@@ -181,7 +176,48 @@ class swipe extends rcube_plugin
private function _load_config()
{
$config = $this->rcube->config->get('swipe_actions', array());
+ $config = array_key_exists($this->list_type, $config) ? $config[$this->list_type] : array();
+
+ // add user config
+ foreach ($config as $dirction => $action) {
+ if ($this->_allowed_action($dirction, $action)) {
+ $this->config[$dirction] = $action;
+ }
+ else {
+ $this->config[$dirction] = "none";
+ }
+ }
+ }
+
+ private function _allowed_action($direction, $action = '')
+ {
+ $dont_override = (array) $this->rcube->config->get('dont_override');
+ $disabled_actions = (array) $this->rcube->config->get('disabled_actions');
+ $laoded_plugins = $this->api->loaded_plugins();
+ $result = true;
+
+ // Skip the action if it is in disabled_actions config option
+ // Also skip actions from disabled/not configured plugins
+ if (in_array('swipe_actions', $dont_override) || in_array('swipe_actions.' . $this->list_type, $dont_override) ||
+ in_array('swipe_actions.' . $this->list_type . '.' . $direction, $dont_override)) {
+ $result = false;
+ }
+ else if (in_array($action, $disabled_actions) || in_array($this->rcube->task . $action, $disabled_actions)) {
+ $result = false;
+ }
+ else if ($action == 'archive' && !$this->rcube->output->env['archive_folder']) {
+ // archive plugin
+ $result = false;
+ }
+ else if ($action == 'markasjunk' && !in_array('markasjunk', $laoded_plugins)) {
+ // markasjunk plugin
+ $result = false;
+ }
+ else if ($action == 'attvcard' && !in_array('vcard_attachments', $laoded_plugins)) {
+ // vcard_attachments plugin
+ $result = false;
+ }
- return array_key_exists($this->list_type, $config) ? $config[$this->list_type] : $this->config;
+ return $result;
}
}