rewrite config, add some future proofing

dev_contacts
PhilW 7 years ago
parent 8496ace616
commit 591af808e2

@ -36,10 +36,19 @@ Supported skins
Configuration Configuration
------------- -------------
To set the default actions add `$config['swipe_left']`, `$config['swipe_right']` To set the default actions add the following to your Roundcube config file:
and `$config['swipe_down']` to your Roundcube config file. For example: ```php
`$config['swipe_left'] = 'delete';`. Users can configure the actions, overriding $config['swipe_actions'] = array(
the defaults, from the List options menu. 'messagelist' => array(
'left' => '<action>',
'right' => '<action>',
'down' => '<action>'
)
);
```
Replace `<action>` with your desired action from the list below.
Users can configure the actions, overriding the defaults, from the
List Options menu.
Supported actions Supported actions
----------------- -----------------

@ -29,18 +29,19 @@ class swipe extends rcube_plugin
{ {
public $task = 'mail'; public $task = 'mail';
private $menu_file = ''; private $menu_file = '';
private $config = array('left' => 'none', 'right' => 'none', 'down' => 'none');
public function init() public function init()
{ {
$rcmail = rcube::get_instance(); $this->config = $this->_load_config();
$this->menu_file = '/' . $this->local_skin_path() . '/menu.html';
$this->menu_file = '/' . $this->local_skin_path() . '/menu.html';
if (is_file(slashify($this->home) . $this->menu_file)) { if (is_file(slashify($this->home) . $this->menu_file)) {
if ($rcmail->output->type == 'html') { if (rcube::get_instance()->output->type == 'html') {
$this->api->output->set_env('swipe_actions', array( $this->api->output->set_env('swipe_actions', array(
'left' => $rcmail->config->get('swipe_left', 'none'), 'left' => $this->config['left'],
'right' => $rcmail->config->get('swipe_right', 'none'), 'right' => $this->config['right'],
'down' => $rcmail->config->get('swipe_down', 'none') 'down' => $this->config['down']
)); ));
$this->add_texts('localization/', true); $this->add_texts('localization/', true);
$this->api->output->add_label('none', 'refresh', 'moveto', 'reply', 'replyall', 'forward', 'select'); $this->api->output->add_label('none', 'refresh', 'moveto', 'reply', 'replyall', 'forward', 'select');
@ -71,12 +72,20 @@ class swipe extends rcube_plugin
$config = array(); $config = array();
foreach (array('left', 'right', 'down') as $direction) { 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)) {
$config['swipe_' . $direction] = $prop; $config[$direction] = $prop;
} }
} }
if (count($config) > 0) { if (count($config) > 0) {
$config = array_merge($this->config, $config);
$config = array('swipe_actions' => array('messagelist' => $config));
rcube::get_instance()->user->save_prefs($config); rcube::get_instance()->user->save_prefs($config);
} }
} }
private function _load_config()
{
$config = rcube::get_instance()->config->get('swipe_actions', array());
return array_key_exists('messagelist', $config) ? $config['messagelist'] : $this->config;
}
} }

Loading…
Cancel
Save