summaryrefslogtreecommitdiff
path: root/plugins/hide_blockquote/hide_blockquote.php
diff options
context:
space:
mode:
authorThomas Bruederli <thomas@roundcube.net>2012-05-23 17:28:51 +0200
committerThomas Bruederli <thomas@roundcube.net>2012-05-23 17:28:51 +0200
commit2b1b8a079b28fa4a9de9a98c32486fa723507b8c (patch)
tree5548c7e0deafc138bd21719b5f2a596a25c91d62 /plugins/hide_blockquote/hide_blockquote.php
parentb97f21a18f9ffa5306bdccbb77c4b63a09a0e4e7 (diff)
parent85a6173879bb2486e394fb8e6b8a107a59167374 (diff)
Merge branch 'master' of github.com:roundcube/roundcubemail
Diffstat (limited to 'plugins/hide_blockquote/hide_blockquote.php')
-rw-r--r--plugins/hide_blockquote/hide_blockquote.php82
1 files changed, 82 insertions, 0 deletions
diff --git a/plugins/hide_blockquote/hide_blockquote.php b/plugins/hide_blockquote/hide_blockquote.php
new file mode 100644
index 000000000..ca0273a5d
--- /dev/null
+++ b/plugins/hide_blockquote/hide_blockquote.php
@@ -0,0 +1,82 @@
+<?php
+
+/**
+ * Quotation block hidding
+ *
+ * Plugin that adds a possibility to hide long blocks of cited text in messages.
+ *
+ * Configuration:
+ * // Minimum number of citation lines. Longer citation blocks will be hidden.
+ * // 0 - no limit (no hidding).
+ * $rcmail_config['hide_blockquote_limit'] = 0;
+ *
+ * @version @package_version@
+ * @license GNU GPLv3+
+ * @author Aleksander Machniak <alec@alec.pl>
+ */
+class hide_blockquote extends rcube_plugin
+{
+ public $task = 'mail|settings';
+
+ function init()
+ {
+ $rcmail = rcmail::get_instance();
+
+ if ($rcmail->task == 'mail'
+ && ($rcmail->action == 'preview' || $rcmail->action == 'show')
+ && ($limit = $rcmail->config->get('hide_blockquote_limit'))
+ ) {
+ // include styles
+ $skin = $rcmail->config->get('skin');
+ if (!file_exists($this->home."/skins/$skin/style.css")) {
+ $skin = 'default';
+ }
+ $this->include_stylesheet("skins/$skin/style.css");
+
+ // Script and localization
+ $this->include_script('hide_blockquote.js');
+ $this->add_texts('localization', true);
+
+ // set env variable for client
+ $rcmail->output->set_env('blockquote_limit', $limit);
+ }
+ else if ($rcmail->task == 'settings') {
+ $dont_override = $rcmail->config->get('dont_override', array());
+ if (!in_array('hide_blockquote_limit', $dont_override)) {
+ $this->add_hook('preferences_list', array($this, 'prefs_table'));
+ $this->add_hook('preferences_save', array($this, 'save_prefs'));
+ }
+ }
+ }
+
+ function prefs_table($args)
+ {
+ if ($args['section'] != 'mailview') {
+ return $args;
+ }
+
+ $this->add_texts('localization');
+
+ $rcmail = rcmail::get_instance();
+ $limit = (int) $rcmail->config->get('hide_blockquote_limit');
+ $field_id = 'hide_blockquote_limit';
+ $input = new html_inputfield(array('name' => '_'.$field_id, 'id' => $field_id, 'size' => 5));
+
+ $args['blocks']['main']['options']['hide_blockquote_limit'] = array(
+ 'title' => $this->gettext('quotelimit'),
+ 'content' => $input->show($limit ? $limit : '')
+ );
+
+ return $args;
+ }
+
+ function save_prefs($args)
+ {
+ if ($args['section'] == 'mailview') {
+ $args['prefs']['hide_blockquote_limit'] = (int) get_input_value('_hide_blockquote_limit', RCUBE_INPUT_POST);
+ }
+
+ return $args;
+ }
+
+}