|
|
@ -27,7 +27,7 @@
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
class swipe extends rcube_plugin
|
|
|
|
class swipe extends rcube_plugin
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public $task = 'mail|addressbook';
|
|
|
|
public $task = '^((?!login).)*$';
|
|
|
|
private $menu_file = null;
|
|
|
|
private $menu_file = null;
|
|
|
|
private $dont_override = array();
|
|
|
|
private $dont_override = array();
|
|
|
|
private $disabled_actions = array();
|
|
|
|
private $disabled_actions = array();
|
|
|
@ -35,6 +35,8 @@ class swipe extends rcube_plugin
|
|
|
|
private $config = array();
|
|
|
|
private $config = array();
|
|
|
|
private $actions = array(
|
|
|
|
private $actions = array(
|
|
|
|
'messagelist' => array(
|
|
|
|
'messagelist' => array(
|
|
|
|
|
|
|
|
'list_name' => 'message_list',
|
|
|
|
|
|
|
|
'selection_id' => 'uid',
|
|
|
|
'vertical' => array(
|
|
|
|
'vertical' => array(
|
|
|
|
'checkmail' => array('label' => 'checkmail')
|
|
|
|
'checkmail' => array('label' => 'checkmail')
|
|
|
|
),
|
|
|
|
),
|
|
|
@ -52,6 +54,8 @@ class swipe extends rcube_plugin
|
|
|
|
)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
),
|
|
|
|
'contactlist' => array(
|
|
|
|
'contactlist' => array(
|
|
|
|
|
|
|
|
'list_name' => 'contact_list',
|
|
|
|
|
|
|
|
'selection_id' => 'cid',
|
|
|
|
'vertical' => array(),
|
|
|
|
'vertical' => array(),
|
|
|
|
'horizontal' => array(
|
|
|
|
'horizontal' => array(
|
|
|
|
'vcard_attachments' => array('label' => 'vcard_attachments.forwardvcard', 'plugin' => true),
|
|
|
|
'vcard_attachments' => array('label' => 'vcard_attachments.forwardvcard', 'plugin' => true),
|
|
|
@ -59,7 +63,8 @@ class swipe extends rcube_plugin
|
|
|
|
'delete' => array('label' => 'delete'),
|
|
|
|
'delete' => array('label' => 'delete'),
|
|
|
|
'swipe-select' => array('label' => 'select')
|
|
|
|
'swipe-select' => array('label' => 'select')
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
),
|
|
|
|
|
|
|
|
'none' => null
|
|
|
|
);
|
|
|
|
);
|
|
|
|
private $rcube;
|
|
|
|
private $rcube;
|
|
|
|
private $list_type;
|
|
|
|
private $list_type;
|
|
|
@ -67,9 +72,19 @@ class swipe extends rcube_plugin
|
|
|
|
public function init()
|
|
|
|
public function init()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$this->rcube = rcube::get_instance();
|
|
|
|
$this->rcube = rcube::get_instance();
|
|
|
|
$this->list_type = $this->rcube->task == 'addressbook' ? 'contactlist' : 'messagelist';
|
|
|
|
|
|
|
|
$this->add_texts('localization/');
|
|
|
|
$this->add_texts('localization/');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch ($this->rcube->task) {
|
|
|
|
|
|
|
|
case 'addressbook':
|
|
|
|
|
|
|
|
$this->list_type = 'contactlist';
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'mail':
|
|
|
|
|
|
|
|
$this->list_type = 'messagelist';
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
$this->list_type = 'none';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$this->add_hook('ready', array($this, 'setup'));
|
|
|
|
$this->add_hook('ready', array($this, 'setup'));
|
|
|
|
$this->register_action('plugin.swipe.save_settings', array($this, 'save_settings'));
|
|
|
|
$this->register_action('plugin.swipe.save_settings', array($this, 'save_settings'));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -85,12 +100,24 @@ class swipe extends rcube_plugin
|
|
|
|
$this->menu_file = '/' . $this->local_skin_path() . '/includes/menu.html';
|
|
|
|
$this->menu_file = '/' . $this->local_skin_path() . '/includes/menu.html';
|
|
|
|
$filepath = slashify($this->home) . $this->menu_file;
|
|
|
|
$filepath = slashify($this->home) . $this->menu_file;
|
|
|
|
if (is_file($filepath) && is_readable($filepath)) {
|
|
|
|
if (is_file($filepath) && is_readable($filepath)) {
|
|
|
|
|
|
|
|
// Allow other plugins to interact with the actions list
|
|
|
|
|
|
|
|
$data = rcube::get_instance()->plugins->exec_hook('swipe_actions', array('list_type' => $this->list_type, 'actions' => $this->actions[$this->list_type]));
|
|
|
|
|
|
|
|
$this->list_type = $data['list_type'];
|
|
|
|
|
|
|
|
$this->actions[$this->list_type] = $data['actions'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sizeof($this->actions[$this->list_type]) == 0) {
|
|
|
|
|
|
|
|
// no swipe actions found, disable the plugin
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$config = $this->config[$this->list_type];
|
|
|
|
$config = $this->config[$this->list_type];
|
|
|
|
$this->rcube->output->set_env('swipe_actions', array(
|
|
|
|
$this->rcube->output->set_env('swipe_actions', array(
|
|
|
|
'left' => $config['left'],
|
|
|
|
'left' => $config['left'],
|
|
|
|
'right' => $config['right'],
|
|
|
|
'right' => $config['right'],
|
|
|
|
'down' => $config['down']
|
|
|
|
'down' => $config['down']
|
|
|
|
));
|
|
|
|
));
|
|
|
|
|
|
|
|
$this->rcube->output->set_env('swipe_list_name', $this->actions[$this->list_type]['list_name']);
|
|
|
|
|
|
|
|
$this->rcube->output->set_env('swipe_selection_id',$this->actions[$this->list_type]['selection_id']);
|
|
|
|
|
|
|
|
|
|
|
|
$this->include_stylesheet($this->local_skin_path() . '/swipe.css');
|
|
|
|
$this->include_stylesheet($this->local_skin_path() . '/swipe.css');
|
|
|
|
$this->include_script('swipe.js');
|
|
|
|
$this->include_script('swipe.js');
|
|
|
@ -124,11 +151,8 @@ class swipe extends rcube_plugin
|
|
|
|
$args['id'] = 'swipeoptions-' . $args['direction'];
|
|
|
|
$args['id'] = 'swipeoptions-' . $args['direction'];
|
|
|
|
$args['name'] = 'swipe_' . $args['direction'];
|
|
|
|
$args['name'] = 'swipe_' . $args['direction'];
|
|
|
|
|
|
|
|
|
|
|
|
// Allow other plugins to interact with the action list
|
|
|
|
|
|
|
|
$data = rcube::get_instance()->plugins->exec_hook('swipe_actions_list', array('actions' => $swipe_actions, 'direction' => $args['direction']));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$options = array();
|
|
|
|
$options = array();
|
|
|
|
foreach ($data['actions'] as $action => $info) {
|
|
|
|
foreach ($swipe_actions as $action => $info) {
|
|
|
|
if (!$this->_allowed_action($args['direction'], $action, $info)) {
|
|
|
|
if (!$this->_allowed_action($args['direction'], $action, $info)) {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -168,6 +192,10 @@ class swipe extends rcube_plugin
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$this->_load_config();
|
|
|
|
$this->_load_config();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Allow other plugins to interact with the actions list
|
|
|
|
|
|
|
|
$data = rcube::get_instance()->plugins->exec_hook('swipe_actions', array('list_type' => $this->list_type, 'actions' => $this->actions[$this->list_type]));
|
|
|
|
|
|
|
|
$this->list_type = $data['list_type'];
|
|
|
|
|
|
|
|
|
|
|
|
$save = false;
|
|
|
|
$save = false;
|
|
|
|
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)) && $this->_allowed_action($direction)) {
|
|
|
|
if (($prop = rcube_utils::get_input_value('swipe_' . $direction, rcube_utils::INPUT_POST)) && $this->_allowed_action($direction)) {
|
|
|
@ -189,7 +217,9 @@ class swipe extends rcube_plugin
|
|
|
|
|
|
|
|
|
|
|
|
// initialize internal config
|
|
|
|
// initialize internal config
|
|
|
|
foreach (array_keys($this->actions) as $list) {
|
|
|
|
foreach (array_keys($this->actions) as $list) {
|
|
|
|
$this->config[$list] = array('left' => 'none', 'right' => 'none', 'down' => 'none');
|
|
|
|
if ($list != 'none') {
|
|
|
|
|
|
|
|
$this->config[$list] = array('left' => 'none', 'right' => 'none', 'down' => 'none');
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// get user config
|
|
|
|
// get user config
|
|
|
|