01179: Configurable redirect from PmForm
Description: In PmForm HandlePmForm(), a Redirect() is performed at the end of processing. This prohibits additional cookbook processing after PmForm. Specifically it means that any Ajax oriented PmForm requests are not possible.
Goal is to permit processing post-HandlePmForm().
Proposal
- Change last line of HandlePmForm() in PmForm from:
Redirect($pagename, '{$PageUrl}?pmform=success');
To:
SDV($PmFormRedirectFunction,'Redirect'); $PmFormRedirectFunction($pagename, '{$PageUrl}?pmform=success');
- Add PmFormRedirectFunction to the list of global variables in HandlePmForm().
I'm not too concerned with redirects on error handling, since PmForm performs a HandleBrowse, providing a post-PmForm hook point where it's possible to check $MessageFmt.
I've bumped into the same issue, and something like this would be very helpful. However, a slightly larger scope might be more useful: how about introducing a new function PmFormExit that would by default wrap lines 153..162 of pmform.php but be overwritable with a variable like $PmFormExitFunction: —Eemeli Aro April 27, 2010, at 05:22 AM
--- pmform.php 2009-08-13 15:46:05.000000000 +0300 +++ pmform-mod.php 2010-04-27 13:17:18.000000000 +0300 @@ -123,7 +123,7 @@ function HandlePmForm($pagename, $auth = 'read') { - global $PmFormPostPatterns, $PmFormTemplatesFmt, $MessagesFmt; + global $PmFormPostPatterns, $PmFormTemplatesFmt, $PmFormExitFunction; $post_opt = RequestArgs($_POST); $pat = array_keys($PmFormPostPatterns); $rep = array_values($PmFormPostPatterns); @@ -150,16 +150,8 @@ if (!$errors && @$safe_opt['mailto']) $errors = PmFormMail($pagename, $msgtmpl, $opt, $safe_opt); - if ($errors) { - foreach ((array)$errors as $errmsg) { - $errmsg = htmlspecialchars($errmsg, ENT_NOQUOTES); - $MessagesFmt[] = "<div class='wikimessage'>$errmsg</div>"; - } - return HandleDispatch($pagename, 'browse'); - } - # $GLOBALS['EnableRedirect'] = 0; - if (@$opt['successpage']) Redirect(MakePageName($pagename, $opt['successpage'])); - Redirect($pagename, '{$PageUrl}?pmform=success'); + SDV($PmFormExitFunction, 'PmFormExit'); + $PmFormExitFunction($pagename, $errors, $opt, $safe_opt); } @@ -272,3 +264,18 @@ if (!$tf) return '$[An error has occurred]'; return NULL; } + + +function PmFormExit($pagename, $errors, $opt, $safe_opt) { + global $MessagesFmt; + if ($errors) { + foreach ((array)$errors as $errmsg) { + $errmsg = htmlspecialchars($errmsg, ENT_NOQUOTES); + $MessagesFmt[] = "<div class='wikimessage'>$errmsg</div>"; + } + return HandleDispatch($pagename, 'browse'); + } + # $GLOBALS['EnableRedirect'] = 0; + if (@$opt['successpage']) Redirect(MakePageName($pagename, $opt['successpage'])); + Redirect($pagename, '{$PageUrl}?pmform=success'); +}
Will do (both), thanks! --Petko May 07, 2010, at 05:43 AM
Conflict: Your pmform.php seems to be outdated (2007), PmForm offers $RecipeInfo['PmForm']['Version'] = '2011-02-16'; instead. Anyway, it seems that your additions (# Commented) are included - and I didn't find the critical difference... Jazzvox
You can use 4 tildes ~~
~~
to enter your name and date/time stamp. Petko December 17, 2011, at 10:20 AM only 4 tildes - Thanks!
I'm not sure what you mean by "outdated", the file dated 2011-02-16 is actually more recent than this PITS entry. Where can you get a pmform.php file from 2007 (I may have to update some forgotten file)? --Petko December 17, 2011, at 10:20 AM
Nepherim-BlogIt-1.7.0-0-geb80dae/cookbook/pmform.php ['Version'] = '2007-06-12'
I have the "New Entry in SideBar and Form not showing" problem, therefore searching for a solution. After I've installed BlogIt at the very beginning (my setup at AuthDNS-Talk) it worked as expected. Now that I've added AuthUser and PmForm I get a regular page instead of NewEntry :( Please check http://www.pmwiki.org/pmwiki/uploads/Cookbook/toPetko.zip to see my config.php - as differing recipe sequence advisories are confusing me. In addition, the archive contains a completed German language file: Site.XLPage-BlogIt-DE --Jazzvox December 18, 2011, at 05:14 AM
DaveG January 20, 2012, at 03:08 PM: BlogIt has not yet been upgraded to use the new version of PmForms, and uses a version from 2007. It will be done in the next release. For now, I've copied Jazzvox's question over to the BlogIt talk page, and will address it there.
I just tried to install the current BlogIt version (1.7.0) and found that it still contains the older pmform.php. Until BlogIt resolves this, what shall I use? The latest from pmform which implements the PmFormExit function or the one from BlogIt? I have installed pmform only to use BlogIt, so I don't rely on other pmform functionality. But I hate to keep seeing the reminder that I'm using an outdated cookbook when using the Analyser. Tempel December 04, 2012, at 09:56 AM