[geeklog-devel] Geeklog 2.0.0 - Comments, Captcha and Plugins
Tom
websitemaster at cogeco.net
Wed Jan 2 15:06:20 EST 2013
A note to all plugin developers:
If your plugin uses comments and you have the Captcha plugin installed you
will need to update your code slightly for the function
plugin_savecomment_foo
You will now need to take into account the constant COMMENT_ON_SAME_PAGE. If
the attempt to save a comment by a user errors out (ie due to an incorrect
captcha code), if the comment is on the same page as your plugin content
then you need to only return the comment form, if it is not then you need to
return the whole document. You can see the Staticpage and polls plugin in
the repository for an example or see the code below:
function plugin_savecomment_polls($title, $comment, $id, $pid, $postmode)
{
global $_CONF, $_TABLES, $LANG03, $_USER;
$retval = '';
$commentcode = DB_getItem ($_TABLES['polltopics'], 'commentcode',
"pid = '$id'");
if ($commentcode != 0) {
return COM_refresh ($_CONF['site_url'] . '/index.php');
}
$ret = CMT_saveComment ($title, $comment, $id, $pid, 'polls',
$postmode);
if ($ret > 0) { // failure //FIXME: some failures should not return to
comment form
$retval .= CMT_commentForm ($title, $comment, $id, $pid, 'polls',
$LANG03[14], $postmode);
if (!defined('COMMENT_ON_SAME_PAGE')) {
$retval = COM_createHTMLDocument($retval, array('pagetitle' =>
$LANG03[1]));
} else {
if (!COMMENT_ON_SAME_PAGE) {
$retval = COM_createHTMLDocument($retval, array('pagetitle'
=> $LANG03[1]));
}
}
} else { // success
$retval = COM_refresh ($_CONF['site_url']
. "/polls/index.php?pid=$id");
}
return $retval;
}
More information about the geeklog-devel
mailing list