functions.php 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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, $oTemplate;
  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. $links = 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. $links[] = 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. $links[] = makeComposeLink($url, $fieldsdescr['reply']);
  53. }
  54. } else if ($proto == 'href') {
  55. $oTemplate->assign('uri', $act);
  56. $oTemplate->assign('target', '_blank');
  57. $oTemplate->assign('text', $fieldsdescr[$cmd]);
  58. $oTemplate->assign('class', '');
  59. $oTemplate->assign('onclick', '');
  60. $output = $oTemplate->fetch('hyperlink.tpl');
  61. $links[] = $output;
  62. }
  63. }
  64. if (count($links) > 0) {
  65. $oTemplate->assign('links', $links);
  66. $output = $oTemplate->fetch('plugins/listcommands/read_body_header.tpl');
  67. return array('read_body_header' => $output);
  68. }
  69. }
  70. /**
  71. * Returns an array with the actions as translated strings.
  72. * @return array action as key, translated string as value
  73. */
  74. function listcommands_fieldsdescr() {
  75. return array('post' => _("Post to List"),
  76. 'reply' => _("Reply to List"),
  77. 'subscribe' => _("Subscribe"),
  78. 'unsubscribe' => _("Unsubscribe"),
  79. 'archive' => _("List Archives"),
  80. 'owner' => _("Contact Listowner"),
  81. 'help' => _("Help"));
  82. }