setup.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. * setup.php
  4. *
  5. * Copyright (c) 1999-2005 The SquirrelMail Project Team
  6. * Licensed under the GNU GPL. For full terms see the file COPYING.
  7. *
  8. * Implementation of RFC 2369 for SquirrelMail.
  9. * When viewing a message from a mailinglist complying with this RFC,
  10. * this plugin displays a menu which gives the user a choice of mailinglist
  11. * commands such as (un)subscribe, help and list archives.
  12. *
  13. * $Id$
  14. * @package plugins
  15. * @subpackage listcommands
  16. */
  17. /**
  18. * Initialize the listcommands plugin
  19. */
  20. function squirrelmail_plugin_init_listcommands () {
  21. global $squirrelmail_plugin_hooks;
  22. $squirrelmail_plugin_hooks['read_body_header']['listcommands'] = 'plugin_listcommands_menu';
  23. }
  24. function plugin_listcommands_menu() {
  25. global $passed_id, $passed_ent_id, $color, $mailbox, $message, $startMessage;
  26. /**
  27. * Array of commands we can deal with from the header. The Reply option
  28. * is added later because we generate it using the Post information.
  29. */
  30. $fieldsdescr = array('post' => _("Post to List"),
  31. 'reply' => _("Reply to List"),
  32. 'subscribe' => _("Subscribe"),
  33. 'unsubscribe' => _("Unsubscribe"),
  34. 'archive' => _("List Archives"),
  35. 'owner' => _("Contact Listowner"),
  36. 'help' => _("Help"));
  37. $output = array();
  38. foreach ($message->rfc822_header->mlist as $cmd => $actions) {
  39. /* I don't know this action... skip it */
  40. if ( !array_key_exists($cmd, $fieldsdescr) ) {
  41. continue;
  42. }
  43. /* proto = {mailto,href} */
  44. $proto = array_shift(array_keys($actions));
  45. $act = array_shift($actions);
  46. if ($proto == 'mailto') {
  47. if (($cmd == 'post') || ($cmd == 'owner')) {
  48. $url = 'src/compose.php?'.
  49. (isset($startMessage)?'startMessage='.$startMessage.'&amp;':'');
  50. } else {
  51. $url = "plugins/listcommands/mailout.php?action=$cmd&amp;";
  52. }
  53. $url .= 'send_to=' . strtr($act,'?','&');
  54. $output[] = makeComposeLink($url, $fieldsdescr[$cmd]);
  55. if ($cmd == 'post') {
  56. if (!isset($mailbox))
  57. $mailbox = 'INBOX';
  58. $url .= '&amp;passed_id='.$passed_id.
  59. '&amp;mailbox='.urlencode($mailbox).
  60. (isset($passed_ent_id)?'&amp;passed_ent_id='.$passed_ent_id:'');
  61. $url .= '&amp;smaction=reply';
  62. $output[] = makeComposeLink($url, $fieldsdescr['reply']);
  63. }
  64. } else if ($proto == 'href') {
  65. $output[] = '<a href="' . $act . '" target="_blank">'
  66. . $fieldsdescr[$cmd] . '</a>';
  67. }
  68. }
  69. if (count($output) > 0) {
  70. echo '<tr>';
  71. echo html_tag('td', '<b>' . _("Mailing List") . ':&nbsp;&nbsp;</b>',
  72. 'right', '', 'valign="middle" width="20%"') . "\n";
  73. echo html_tag('td', '<small>' . implode('&nbsp;|&nbsp;', $output) . '</small>',
  74. 'left', $color[0], 'valign="middle" width="80%"') . "\n";
  75. echo '</tr>';
  76. }
  77. }
  78. ?>