01171: Recent notify posts for the PITS group should include Summary

Summary: Recent notify posts for the PITS group should include Summary
Created: 2010-02-12 17:15
Status: Closed - added
Category: Other
From: Rogutės?
Assigned:
Priority: 3

Currently, notification mails like this one are sent for changes in the PITS group:

Recent PmWiki posts:
  http://www.pmwiki.org/wiki/Site/AllRecentChanges

  * http://pmwiki.org/wiki/PITS/00962
       February 04, 2010, at 07:00 AM by Petko

Wouldn't it be nice to get something like this instead:

Recent PmWiki posts:
  http://www.pmwiki.org/wiki/Site/AllRecentChanges

  * http://pmwiki.org/wiki/PITS/00962
       "Make [=>><<=] behave identically with other block formatting ..."
       February 04, 2010, at 07:00 AM by Petko 

Usually, I am only interested in a handful of PITS entries, and having to look up the summary of every changed one gets cumbersome (is everyone else memorizing the numbers of the PITS entries they want to follow?).

To achieve this, local/pits.php could include something along the lines:

$FmtPV['$Summary']='FormatPITSummary($pn)';
function FormatPITSummary($pn) {
  $s=PageTextVar($pn, "Summary");
  $s=str_replace(array('$', "\n"), array('#',' '), $s);
  if (strlen($s)>74) $s=substr($s, 0, 70).'...';
  return $s;
}

and "\"{\$Summary}\"" could be added to $NotifyItemFmt...

Added -- for testing period. Thanks! --Petko February 13, 2010, at 05:40 AM

Unfortunately, the $NotifyItemFmt is sent through the FmtPageName() function which expands too many global variables. FmtPageName() was not intended to convert user-input and this raises security concerns. Modifying FmtPageName() is difficult as too many things depend on it (including recipes). So, until we find a way to deal with this, I reverted the changes to the previous state. --Petko February 13, 2010, at 10:53 AM


The two e-mails I got with this enabled looked really nice!

Now I see that with my proposal, GLOBAL variables could be exposed. Sorry I wasn't careful enough. Suggestions:

  1. Looking at FmtPageName(), it is clear that the function only cares about strings with '$' characters. So a safe way to deal with this would be to strip '$' off user input in FormatPITSummary() (I've changed the above example accordingly) – not very clean, but perhaps still more useful than mere PITS numbers.
  2. A more complex but, in my opinion, correct way would be to use $FmtV (which is a simple search & replace at the very end of FmtPageName()):
$FmtPV['$DirtySummary']='FormatPITSummary($pn)';
function FormatPITSummary($pn) {
  global $FmtV;
  $s=PageTextVar($pn, "Summary");
  $s=str_replace("\n", ' ', $s);
  if (strlen($s)>74) $s=substr($s, 0, 70).'...';
  $FmtV['$CleanSummary']=$s;
  return '$CleanSummary';
}

-- Rogutės, 2010-02-13