From e4e0bf836669b5419a0e2c86409c46898beef5b4 Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Wed, 1 Feb 2012 21:47:40 +0100 Subject: Added on_comment_store event. --- ratatoeskr/frontend.php | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) (limited to 'ratatoeskr/frontend.php') diff --git a/ratatoeskr/frontend.php b/ratatoeskr/frontend.php index 8aca311..b89fe3a 100644 --- a/ratatoeskr/frontend.php +++ b/ratatoeskr/frontend.php @@ -82,8 +82,7 @@ function tag_transform_ste($tag, $lang) * * custom (array: name=>value) * * status (numeric) * * section (sub-fields: ) - * * timestamp - * * tags (sub-fields: ) + * * timestamp, tags (array(sub-fields: )) * * languages (array: language name=>url) * * comments_allowed */ @@ -397,6 +396,8 @@ $ste->register_tag("article_comments", function($ste, $params, $sub) * You might also want to define this: * * * - For a preview of the comment. + * + * If the parameter default is not empty, the tag's content will be thrown away. * * Returns: * The finished HTML form. @@ -680,30 +681,17 @@ $comment_validators = array( if(time() - $_SESSION["ratatoeskr_comment_tokens"][$_POST["comment_token"]] < 10) /* Comment filled in in under 10 seconds? Most likely a spambot. */ throw new CommentRejected($translation["comment_too_fast"]); unset($_SESSION["ratatoeskr_comment_tokens"][$_POST["comment_token"]]); - }, + } ); -/* - * Function: register_comment_validator - * Register a comment validator. - * - * A comment validator is a function, that checks the $_POST fields and decides whether a comment should be stored or not (throws an exception with the rejection reason as the message). - * - * Parameters: - * $fx - The validator function (function()). - */ -function register_comment_validator($fx) -{ - global $comment_validators; - $comment_validators[] = $fx; -} +$on_comment_store = array(); /* * Function: frontend_url_handler */ function frontend_url_handler(&$data, $url_now, &$url_next) { - global $ste, $ratatoeskr_settings, $languages, $metasections, $comment_validators; + global $ste, $ratatoeskr_settings, $languages, $metasections, $comment_validators, $on_comment_store; $path = array_merge(array($url_now), $url_next); $url_next = array(); @@ -793,6 +781,8 @@ function frontend_url_handler(&$data, $url_now, &$url_next) $comment->text = $_POST["comment_text"]; $comment->save(); $ste->vars["current"]["commented"] = "Yes"; + foreach($on_comment_store as $ocs_fx) + call_user_func($ocs_fx, $comment); } } } -- cgit v1.2.3-54-g00ecf