functions.php 3.2 KB

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