Skip to content

Instantly share code, notes, and snippets.

@Takika
Last active April 20, 2017 20:32
Show Gist options
  • Save Takika/30909a17744ce75a0e31aed8bafe7d77 to your computer and use it in GitHub Desktop.
Save Takika/30909a17744ce75a0e31aed8bafe7d77 to your computer and use it in GitHub Desktop.
Roundcube default listing mode plugin
<?php
class listing_mode extends rcube_plugin
{
public $task = 'settings';
function init()
{
$this->add_hook('preferences_list', array($this, 'preferences_list_hook'));
$this->add_hook('preferences_save', array($this, 'preferences_save_hook'));
}
public function preferences_list_hook($args)
{
if ($args['section'] == 'mailbox') {
$config = rcmail::get_instance()->config;
$listview_select_order = new html_select(array('name' => '_default_list_mode', 'id' => '_default_list_mode'));
$listview_select_order->add(rcube_label('list'), 'list');
$listview_select_order->add(rcube_label('threads'), 'threads');
$listview_options = array(
'title' => $this->gettext('default_list_mode_label'),
'content' => $listview_select_order->show($config->get('default_list_mode', 'list')),
);
$args['blocks']['main']['options']['listview'] = $listview_options;
}
return $args;
}
public function preferences_save_hook($args)
{
if ($args['section'] == 'mailbox') {
$args['prefs']['default_list_mode'] = isset($_POST['_default_list_mode']) ? $_POST['_default_list_mode'] : 'list';
}
return $args;
}
}
@voidzero
Copy link

Seems convenient, thanks for sharing! But.. can you explain where I need to place this file, and how to use it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment