Forum Index > Help > Les plugins New Topic Post Reply
 Les commentaires dans les plugins avec Geeklog 2
   
Ben
 03 janvier 2013 - 14:09 (Read 3985 times)  
AAAAA
Admin

Status: offline


Registered: 18/10/2006
Posts: 128
La nouvelle fonction permettant la saisie des commentaires sur la même page nécessite quelques ajustements dans le code des plugins qui utilisent la fonction des commentaires. Tom vient de publier une note à l'attention des développeurs.

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:

PHP Formatted Code
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;
}



 
Profile Email Website
 Quote
Content generated in: 0,36 seconds
New Topic Post Reply

Normal Topic Normal Topic
Sticky Topic Sticky Topic
Locked Topic Locked Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Anonymous users can post 
Filtered HTML Allowed 
Censored Content