Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

markasjunk.php 2.2KB

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