|
|
@ -29,7 +29,9 @@ class swipe extends rcube_plugin
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public $task = 'mail';
|
|
|
|
public $task = 'mail';
|
|
|
|
private $menu_file = null;
|
|
|
|
private $menu_file = null;
|
|
|
|
private $config = array('left' => 'none', 'right' => 'none', 'down' => 'none');
|
|
|
|
private $config = array(
|
|
|
|
|
|
|
|
'messagelist' => array('left' => 'none', 'right' => 'none', 'down' => 'none')
|
|
|
|
|
|
|
|
);
|
|
|
|
private $actions = array(
|
|
|
|
private $actions = array(
|
|
|
|
'messagelist' => array(
|
|
|
|
'messagelist' => array(
|
|
|
|
'vertical' => array(
|
|
|
|
'vertical' => array(
|
|
|
@ -65,10 +67,11 @@ 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)) {
|
|
|
|
|
|
|
|
$config = $this->config[$this->list_type];
|
|
|
|
$this->rcube->output->set_env('swipe_actions', array(
|
|
|
|
$this->rcube->output->set_env('swipe_actions', array(
|
|
|
|
'left' => $this->config['left'],
|
|
|
|
'left' => $config['left'],
|
|
|
|
'right' => $this->config['right'],
|
|
|
|
'right' => $config['right'],
|
|
|
|
'down' => $this->config['down']
|
|
|
|
'down' => $config['down']
|
|
|
|
));
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
$this->add_hook('template_container', array($this, 'options_menu'));
|
|
|
|
$this->add_hook('template_container', array($this, 'options_menu'));
|
|
|
@ -117,12 +120,13 @@ class swipe extends rcube_plugin
|
|
|
|
$options = array('none' => $this->gettext('none')) + $options;
|
|
|
|
$options = array('none' => $this->gettext('none')) + $options;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$config = $this->config[$this->list_type];
|
|
|
|
switch ($args['type']) {
|
|
|
|
switch ($args['type']) {
|
|
|
|
case 'radio':
|
|
|
|
case 'radio':
|
|
|
|
foreach ($options as $val => $text) {
|
|
|
|
foreach ($options as $val => $text) {
|
|
|
|
$fieldid = $args['id'] . '-' . $val;
|
|
|
|
$fieldid = $args['id'] . '-' . $val;
|
|
|
|
$radio = new html_radiobutton(array('name' => $args['name'], 'id' => $fieldid, 'class' => $val, 'value' => $val));
|
|
|
|
$radio = new html_radiobutton(array('name' => $args['name'], 'id' => $fieldid, 'class' => $val, 'value' => $val));
|
|
|
|
$radio = $radio->show($this->config[$args['direction']]);
|
|
|
|
$radio = $radio->show($config[$args['direction']]);
|
|
|
|
$field = $radio . html::label($fieldid, $text);
|
|
|
|
$field = $radio . html::label($fieldid, $text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -130,7 +134,7 @@ class swipe extends rcube_plugin
|
|
|
|
case 'select':
|
|
|
|
case 'select':
|
|
|
|
$select = new html_select($args);
|
|
|
|
$select = new html_select($args);
|
|
|
|
$select->add(array_values($options), array_keys($options));
|
|
|
|
$select->add(array_values($options), array_keys($options));
|
|
|
|
$field = $select->show($this->config[$args['direction']]);
|
|
|
|
$field = $select->show($config[$args['direction']]);
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -140,32 +144,29 @@ class swipe extends rcube_plugin
|
|
|
|
|
|
|
|
|
|
|
|
public function save_settings()
|
|
|
|
public function save_settings()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$config = array();
|
|
|
|
$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)) {
|
|
|
|
$config[$direction] = $prop;
|
|
|
|
$this->config[$this->list_type][$direction] = $prop;
|
|
|
|
|
|
|
|
$save = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (count($config) > 0) {
|
|
|
|
if ($save) {
|
|
|
|
$config = array_merge($this->config, $config);
|
|
|
|
rcube::get_instance()->user->save_prefs(array('swipe_actions' => $this->config));
|
|
|
|
$config = array('swipe_actions' => array($this->list_type => $config));
|
|
|
|
|
|
|
|
rcube::get_instance()->user->save_prefs($config);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private function _load_config()
|
|
|
|
private function _load_config()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$config = $this->rcube->config->get('swipe_actions', array());
|
|
|
|
$config = $this->rcube->config->get('swipe_actions', array());
|
|
|
|
$config = array_key_exists($this->list_type, $config) ? $config[$this->list_type] : array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// add user config
|
|
|
|
// remove disabled actions
|
|
|
|
foreach ($config as $dirction => $action) {
|
|
|
|
foreach ($config as $list => $opts) {
|
|
|
|
if ($this->_allowed_action($dirction, $action)) {
|
|
|
|
foreach ($opts as $dirction => $action) {
|
|
|
|
$this->config[$dirction] = $action;
|
|
|
|
if ($this->_allowed_action($dirction, $action)) {
|
|
|
|
}
|
|
|
|
$this->config[$list][$dirction] = $action;
|
|
|
|
else {
|
|
|
|
}
|
|
|
|
$this->config[$dirction] = "none";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|