source: github/plugins/hide_blockquote/hide_blockquote.php @ 8e528fd

release-0.8
Last change on this file since 8e528fd was 8e528fd, checked in by Aleksander Machniak <alec@…>, 13 months ago

hide_blockquote - a new plugin for hiding citation blocks

  • Property mode set to 100644
File size: 2.5 KB
Line 
1<?php
2
3/**
4 * Quotation block hidding
5 *
6 * Plugin that adds a possibility to hide long blocks of cited text in messages.
7 *
8 * Configuration:
9 * // Minimum number of citation lines. Longer citation blocks will be hidden.
10 * // 0 - no limit (no hidding).
11 * $rcmail_config['hide_blockquote_limit'] = 0;
12 *
13 * @version @package_version@
14 * @license GNU GPLv3+
15 * @author Aleksander Machniak <alec@alec.pl>
16 */
17class hide_blockquote extends rcube_plugin
18{
19    public $task = 'mail|settings';
20
21    function init()
22    {
23        $rcmail = rcmail::get_instance();
24
25        if ($rcmail->task == 'mail'
26            && ($rcmail->action == 'preview' || $rcmail->action == 'show')
27            && ($limit = $rcmail->config->get('hide_blockquote_limit'))
28        ) {
29            // include styles
30            $skin = $rcmail->config->get('skin');
31            if (!file_exists($this->home."/skins/$skin/style.css")) {
32                $skin = 'default';
33            }
34            $this->include_stylesheet("skins/$skin/style.css");
35
36            // Script and localization
37            $this->include_script('hide_blockquote.js');
38            $this->add_texts('localization', true);
39
40            // set env variable for client
41            $rcmail->output->set_env('blockquote_limit', $limit);
42        }
43        else if ($rcmail->task == 'settings') {
44            $dont_override = $rcmail->config->get('dont_override', array());
45            if (!in_array('hide_blockquote_limit', $dont_override)) {
46                $this->add_hook('preferences_list', array($this, 'prefs_table'));
47                $this->add_hook('preferences_save', array($this, 'save_prefs'));
48            }
49        }
50    }
51
52    function prefs_table($args)
53    {
54        if ($args['section'] != 'mailview') {
55            return $args;
56        }
57
58        $this->add_texts('localization');
59
60        $rcmail   = rcmail::get_instance();
61        $limit    = (int) $rcmail->config->get('hide_blockquote_limit');
62        $field_id = 'hide_blockquote_limit';
63        $input    = new html_inputfield(array('name' => '_'.$field_id, 'id' => $field_id, 'size' => 5));
64
65        $args['blocks']['main']['options']['hide_blockquote_limit'] = array(
66            'title' => $this->gettext('quotelimit'),
67            'content' => $input->show($limit ? $limit : '')
68        );
69
70        return $args;
71    }
72
73    function save_prefs($args)
74    {
75        if ($args['section'] == 'mailview') {
76            $args['prefs']['hide_blockquote_limit'] = (int) get_input_value('_hide_blockquote_limit', RCUBE_INPUT_POST);
77        }
78
79        return $args;
80    }
81
82}
Note: See TracBrowser for help on using the repository browser.