functions.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. /**
  3. * functions.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. * @version $Id$
  14. * @package plugins
  15. * @subpackage listcommands
  16. */
  17. function plugin_listcommands_menu_do() {
  18. global $passed_id, $passed_ent_id, $color, $mailbox, $message, $startMessage;
  19. /**
  20. * Array of commands we can deal with from the header. The Reply option
  21. * is added later because we generate it using the Post information.
  22. */
  23. $fieldsdescr = listcommands_fieldsdescr();
  24. $output = array();
  25. foreach ($message->rfc822_header->mlist as $cmd => $actions) {
  26. /* I don't know this action... skip it */
  27. if ( !array_key_exists($cmd, $fieldsdescr) ) {
  28. continue;
  29. }
  30. /* proto = {mailto,href} */
  31. $proto = array_shift(array_keys($actions));
  32. $act = array_shift($actions);
  33. if ($proto == 'mailto') {
  34. if (($cmd == 'post') || ($cmd == 'owner')) {
  35. $url = 'src/compose.php?'.
  36. (isset($startMessage)?'startMessage='.$startMessage.'&amp;':'');
  37. } else {
  38. $url = "plugins/listcommands/mailout.php?action=$cmd&amp;";
  39. }
  40. $url .= 'send_to=' . str_replace('?','&amp;', $act);
  41. $output[] = makeComposeLink($url, $fieldsdescr[$cmd]);
  42. if ($cmd == 'post') {
  43. if (!isset($mailbox))
  44. $mailbox = 'INBOX';
  45. $url .= '&amp;passed_id='.$passed_id.
  46. '&amp;mailbox='.urlencode($mailbox).
  47. (isset($passed_ent_id)?'&amp;passed_ent_id='.$passed_ent_id:'');
  48. $url .= '&amp;smaction=reply';
  49. $output[] = makeComposeLink($url, $fieldsdescr['reply']);
  50. }
  51. } else if ($proto == 'href') {
  52. $output[] = '<a href="' . $act . '" target="_blank">'
  53. . $fieldsdescr[$cmd] . '</a>';
  54. }
  55. }
  56. if (count($output) > 0) {
  57. echo '<tr>' .
  58. html_tag('td', '<b>' . _("Mailing List") . ':&nbsp;&nbsp;</b>',
  59. 'right', '', 'valign="middle" width="20%"') . "\n" .
  60. html_tag('td', '<small>' . implode('&nbsp;|&nbsp;', $output) . '</small>',
  61. 'left', $color[0], 'valign="middle" width="80%"') . "\n" .
  62. '</tr>';
  63. }
  64. }
  65. /**
  66. * Returns an array with the actions as translated strings.
  67. * @return array action as key, translated string as value
  68. */
  69. function listcommands_fieldsdescr() {
  70. return array('post' => _("Post to List"),
  71. 'reply' => _("Reply to List"),
  72. 'subscribe' => _("Subscribe"),
  73. 'unsubscribe' => _("Unsubscribe"),
  74. 'archive' => _("List Archives"),
  75. 'owner' => _("Contact Listowner"),
  76. 'help' => _("Help"));
  77. }
  78. ?>