You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

hide_blockquote.php 2.4KB

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