functions.php 3.2 KB

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