setup.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. /**
  3. * setup.php
  4. *
  5. * Copyright (c) 1999-2004 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;
  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. } else {
  50. $url = "plugins/listcommands/mailout.php?action=$cmd&amp;";
  51. }
  52. $url .= 'send_to=' . strtr($act,'?','&');
  53. $output[] = makeComposeLink($url, $fieldsdescr[$cmd]);
  54. if ($cmd == 'post') {
  55. if (!isset($mailbox))
  56. $mailbox = 'INBOX';
  57. $url .= '&amp;passed_id='.$passed_id.
  58. '&amp;mailbox='.urlencode($mailbox).
  59. (isset($passed_ent_id)?'&amp;passed_ent_id='.$passed_ent_id:'');
  60. $url .= '&amp;smaction=reply';
  61. $output[] = makeComposeLink($url, $fieldsdescr['reply']);
  62. }
  63. } else if ($proto == 'href') {
  64. $output[] = '<a href="' . $act . '" target="_blank">'
  65. . $fieldsdescr[$cmd] . '</a>';
  66. }
  67. }
  68. if (count($output) > 0) {
  69. echo '<tr>';
  70. echo html_tag('td', '<b>' . _("Mailing List") . ':&nbsp;&nbsp;</b>',
  71. 'right', '', 'valign="middle" width="20%"') . "\n";
  72. echo html_tag('td', '<small>' . implode('&nbsp;|&nbsp;', $output) . '</small>',
  73. 'left', $color[0], 'valign="middle" width="80%"') . "\n";
  74. echo '</tr>';
  75. }
  76. }
  77. ?>