setup.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. * setup.php
  4. *
  5. * Copyright (c) 1999-2002 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. */
  15. function squirrelmail_plugin_init_listcommands () {
  16. global $squirrelmail_plugin_hooks;
  17. $squirrelmail_plugin_hooks['read_body_header']['listcommands'] = 'plugin_listcommands_menu';
  18. }
  19. function plugin_listcommands_menu() {
  20. global $passed_id, $passed_ent_id, $color, $mailbox,
  21. $message, $compose_new_win;
  22. /**
  23. * Array of commands we can deal with from the header. The Reply option
  24. * is added later because we generate it using the Post information.
  25. */
  26. $fieldsdescr = array('post' => _("Post to List"),
  27. 'reply' => _("Reply to List"),
  28. 'subscribe' => _("Subscribe"),
  29. 'unsubscribe' => _("Unsubscribe"),
  30. 'archive' => _("List Archives"),
  31. 'owner' => _("Contact Listowner"),
  32. 'help' => _("Help"));
  33. $output = array();
  34. foreach ($message->rfc822_header->mlist as $cmd => $actions) {
  35. /* I don't know this action... skip it */
  36. if(!array_key_exists($cmd, $fieldsdescr)) {
  37. continue;
  38. }
  39. /* proto = {mailto,href} */
  40. $proto = array_shift(array_keys($actions));
  41. $act = array_shift($actions);
  42. if ($proto == 'mailto') {
  43. if (($cmd == 'post') || ($cmd == 'owner')) {
  44. $url = 'compose.php?';
  45. } else {
  46. $url = "../plugins/listcommands/mailout.php?action=$cmd&amp;";
  47. }
  48. $url .= 'send_to=' . strtr($act,'?','&');
  49. if ($compose_new_win == '1') {
  50. $output[] = "<a href=\"javascript:void(0)\" onclick=\"comp_in_new('$url')\">" . $fieldsdescr[$cmd] . '</A>';
  51. }
  52. else {
  53. $output[] = '<A HREF="' . $url . '">' . $fieldsdescr[$cmd] . '</A>';
  54. }
  55. if ($cmd == 'post') {
  56. $url .= '&amp;passed_id='.$passed_id.
  57. '&amp;mailbox='.urlencode($mailbox).
  58. (isset($passed_ent_id)?'&amp;passed_ent_id='.$passed_ent_id:'');
  59. $url .= '&amp;action=reply';
  60. if ($compose_new_win == '1') {
  61. $output[] = "<A HREF=\"javascript:void(0)\" onClick=\"comp_in_new('$url')\">" . $fieldsdescr['reply'] . '</A>';
  62. } else {
  63. $output[] = '<A HREF="' . $url . '">' . $fieldsdescr['reply'] . '</A>';
  64. }
  65. }
  66. } else if ($proto == 'href') {
  67. $output[] = '<A HREF="' . $act . '" TARGET="_blank">'
  68. . $fieldsdescr[$cmd] . '</A>';
  69. }
  70. }
  71. if (count($output) > 0) {
  72. echo '<TR>';
  73. echo html_tag('TD', '<B>' . _("Mailing List") . ':&nbsp;&nbsp;</B>',
  74. 'right', '', 'VALIGN="MIDDLE" WIDTH="20%"') . "\n";
  75. echo html_tag('TD', '<SMALL>' . implode('&nbsp;|&nbsp;', $output) . '</small>',
  76. 'left', $color[0], 'VALIGN="MIDDLE" WIDTH="80%"') . "\n";
  77. echo "</TR>";
  78. }
  79. }
  80. ?>