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.

markasjunk.php 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /**
  3. * Mark as Junk
  4. *
  5. * Sample plugin that adds a new button to the mailbox toolbar
  6. * to mark the selected messages as Junk and move them to the Junk folder
  7. *
  8. * @license GNU GPLv3+
  9. * @author Thomas Bruederli
  10. */
  11. class markasjunk extends rcube_plugin
  12. {
  13. public $task = 'mail';
  14. function init()
  15. {
  16. $rcmail = rcmail::get_instance();
  17. $this->register_action('plugin.markasjunk', array($this, 'request_action'));
  18. $this->add_hook('storage_init', array($this, 'storage_init'));
  19. if ($rcmail->action == '' || $rcmail->action == 'show') {
  20. $skin_path = $this->local_skin_path();
  21. $this->add_texts('localization', true);
  22. $this->include_script('markasjunk.js');
  23. if (is_file($this->home . "/$skin_path/markasjunk.css")) {
  24. $this->include_stylesheet("$skin_path/markasjunk.css");
  25. }
  26. $this->add_button(array(
  27. 'type' => 'link',
  28. 'label' => 'buttontext',
  29. 'command' => 'plugin.markasjunk',
  30. 'class' => 'button buttonPas junk disabled',
  31. 'classact' => 'button junk',
  32. 'title' => 'buttontitle',
  33. 'domain' => 'markasjunk'
  34. ),'toolbar');
  35. }
  36. }
  37. function storage_init($args)
  38. {
  39. $flags = array(
  40. 'JUNK' => 'Junk',
  41. 'NONJUNK' => 'NonJunk',
  42. );
  43. // register message flags
  44. $args['message_flags'] = array_merge((array)$args['message_flags'], $flags);
  45. return $args;
  46. }
  47. function request_action()
  48. {
  49. $this->add_texts('localization');
  50. $rcmail = rcmail::get_instance();
  51. $storage = $rcmail->get_storage();
  52. foreach (rcmail::get_uids(null, null, $multifolder, rcube_utils::INPUT_POST) as $mbox => $uids) {
  53. $storage->unset_flag($uids, 'NONJUNK', $mbox);
  54. $storage->set_flag($uids, 'JUNK', $mbox);
  55. }
  56. if (($junk_mbox = $rcmail->config->get('junk_mbox'))) {
  57. $rcmail->output->command('move_messages', $junk_mbox);
  58. }
  59. $rcmail->output->command('display_message', $this->gettext('reportedasjunk'), 'confirmation');
  60. $rcmail->output->send();
  61. }
  62. }