Source for file _comment.class.php
Documentation is available at _comment.class.php
* This file implements the Comment class.
* This file is part of the b2evolution/evocms project - {@link http://b2evolution.net/}.
* See also {@link http://sourceforge.net/projects/evocms/}.
* @copyright (c)2003-2010 by Francois PLANQUE - {@link http://fplanque.net/}.
* Parts of this file are copyright (c)2004-2005 by Daniel HAHLER - {@link http://thequod.de/contact}.
* @license http://b2evolution.net/about/license.html GNU General Public License (GPL)
* {@internal Open Source relicensing agreement:
* Daniel HAHLER grants Francois PLANQUE the right to license
* Daniel HAHLER's contributions to this file and the b2evolution project
* under any OSI approved OSS license (http://www.opensource.org/licenses/).
* {@internal Below is a list of authors who have contributed to design/coding of this file: }}
* @author blueyed: Daniel HAHLER.
* @author fplanque: Francois PLANQUE
* @version $Id: _comment.class.php,v 1.52 2010/03/04 18:21:26 fplanque Exp $
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
load_class( '_core/model/dataobjects/_dataobject.class.php', 'DataObject' );
* The item (parent) of this Comment (lazy-filled).
* @see Comment::get_Item()
* @see Comment::set_Item()
* The ID of the comment's Item.
* The comment's user, this is NULL for (anonymous) visitors (lazy-filled).
* @see Comment::get_author_User()
* @see Comment::set_author_User()
* The ID of the author's user. NULL for anonymous visitors.
* Comment type: 'comment', 'linkback', 'trackback' or 'pingback'
* Comment visibility status: 'published', 'deprecated', 'redirected', 'protected', 'private' or 'draft'
* Name of the (anonymous) visitor (if any).
* Email address of the (anonymous) visitor (if any).
* URL/Homepage of the (anonymous) visitor (if any).
* IP address of the comment's author (while posting).
* Date of the comment (MySQL DATETIME - use e.g. {@link mysql2timestamp()}); local time ({@link $localtimenow})
* Spam karma of the comment (0-100), 0 being "probably no spam at all"
* Does an anonymous commentator allow to send messages through a message form?
// Call parent constructor:
parent::DataObject( 'T_comments', 'comment_', 'comment_ID' );
$this->ID =
$db_row['comment_ID'];
$this->item_ID =
$db_row['comment_post_ID'];
if( ! empty($db_row['comment_author_ID']) )
$this->type =
$db_row['comment_type'];
$this->status =
$db_row['comment_status'];
$this->author =
$db_row['comment_author'];
$url =
trim( $db_row['comment_author_url'] );
if( ! empty($url) &&
! preg_match( '~^\w+://~', $url ) )
{ // URL given and does not start with a protocol:
$this->author_IP =
$db_row['comment_author_IP'];
$this->date =
$db_row['comment_date'];
$this->content =
$db_row['comment_content'];
$this->rating =
$db_row['comment_rating'];
$this->featured =
$db_row['comment_featured'];
$this->nofollow =
$db_row['comment_nofollow'];
$this->spam_karma =
$db_row['comment_spam_karma'];
$this->secret =
$db_row['comment_secret'];
* Get the author User of the comment. This is NULL for anonymous visitors.
* Get the Item this comment relates to
if( ! isset
($this->Item) )
$this->Item =
& $ItemCache->get_by_ID( $this->item_ID );
* Get a member param by its name
* @param mixed Name of parameter
* @return mixed Value of parameter
return T_( $post_statuses[$this->status] );
return parent::get( $parname );
* @param string parameter name
* @param mixed parameter value
* @param boolean true to set to NULL if empty value
* @return boolean true, if a value has been set; false if it has not changed
function set( $parname, $parvalue, $make_null =
false )
return $this->set_param( $parname, 'string', $parvalue, true );
return $this->set_param( $parname, 'string', $parvalue, $make_null );
* Set Item this comment relates to
parent::set_param( 'post_ID', 'number', $Item->ID );
* Set author User of this comment
parent::set_param( 'author_ID', 'number', $author_User->ID );
* Set the spam karma, as a number.
* @param integer Spam karma (-100 - 100)
return $this->set_param( 'spam_karma', 'number', $spam_karma );
* Get the anchor-ID of the comment
* Template function: display anchor for permalinks to refer to
* Get the comment author's name.
* Get the EMail of the comment's author.
* Get the URL of the comment's author.
* Template function: display the avatar of the comment's author.
function avatar( $size =
'crop-64x64', $class =
'bCommentAvatar', $params =
array() )
if( $r =
$this->get_avatar( $size, $class, $params ) )
* Get the avatar of the comment's author.
function get_avatar( $size =
'crop-64x64', $class =
'bCommentAvatar', $params =
array() )
global $Plugins, $default_avatar;
if( $r =
$comment_author_User->get_avatar_imgtag( $size, $class ) )
// See if plugin supplies an image
// $img_url = $Plugins->trigger_event( 'GetCommentAvatar', array( 'Comment' => & $this, 'size' => $size ) );
'default' =>
$default_avatar,
if( !empty($params['rating']) )
$img_url .=
'&rating='.
$params['rating'];
if( !empty($params['size']) )
$img_url .=
'&size='.
$params['size'];
if( !empty($params['default']) )
$img_url .=
'&default='.
urlencode($params['default']);
'width' =>
$params['size'], // dh> NOTE: works with gravatar, check if extending
'height' =>
$params['size'], // dh> NOTE: works with gravatar, check if extending
$img_params['class'] =
$class;
* Template function: display author of comment
* @param string String to display before author name if not a user
* @param string String to display after author name if not a user
* @param string String to display before author name if he's a user
* @param string String to display after author name if he's a user
* @param string Output format, see {@link format_to_output()}
* @param boolean true for link, false if you want NO html link
function author( $before =
'', $after =
'#', $before_user =
'', $after_user =
'#',
$format =
'htmlbody', $makelink =
false )
echo
$this->get_author($before, $after, $before_user, $after_user, $format, $makelink);
* @param string String to display before author name if not a user
* @param string String to display after author name if not a user
* @param string String to display before author name if he's a user
* @param string String to display after author name if he's a user
* @param string Output format, see {@link format_to_output()}
* @param boolean true for link, false if you want NO html link
function get_author( $before =
'', $after =
'#', $before_user =
'', $after_user =
'#',
$format =
'htmlbody', $makelink =
false )
if( $after_user ==
'#' ) $after_user =
' ['.
T_('Member').
']';
{ // Display info recorded at edit time:
if( $after ==
'#' ) $after =
' ['.
T_('Visitor').
']';
$author_name =
$this->dget( 'author', $format );
{ // Display the name: (NOTE: get_author_url_link( with nolink option ) would NOT handle this correctly when url is empty
$r =
$before.
$author_name.
$after;
$Plugins->trigger_event( 'FilterCommentAuthor', array( 'data' =>
& $r, 'makelink' =>
$makelink, 'Comment' =>
$this ) );
* Template function: display comment's author's IP
* @param string String to display before IP, if IP exists
* @param string String to display after IP, if IP exists
// Filter the IP by plugins for display, allowing e.g. the DNSBL plugin to add a link that displays info about the IP:
echo
$Plugins->get_trigger_event( 'FilterIpAddress', array(
* Template function: display link to comment author's provided email
* @param string String to display for link: leave empty to display email
* @param string String to display before email, if email exists
* @param string String to display after email, if email exists
* @param boolean false if you want NO html link
function author_email( $linktext=
'', $before=
'', $after=
'', $makelink =
true )
if( $makelink ) echo
'<a href="mailto:'.
$email.
'">';
echo
($linktext !=
'') ?
$linktext :
$email;
if( $makelink ) echo
'</a>';
* Get link to comment author's provided URL
* @param string String to display for link: leave empty to display URL
* @param string String to display before link, if link exists
* @param string String to display after link, if link exists
* @param boolean false if you want NO html link
* @return boolean true if URL has been displayed
$r .=
'href="'.
$url.
'">';
$r .=
( empty($linktext) ?
$url :
$linktext );
if( $makelink ) $r .=
'</a>';
$Plugins->trigger_event( 'FilterCommentAuthorUrl', array( 'data' =>
& $r, 'makelink' =>
$makelink, 'Comment' =>
$this ) );
* Template function: display link to comment author's provided URL
* @param string String to display for link: leave empty to display URL
* @param string String to display before link, if link exists
* @param string String to display after link, if link exists
* @param boolean false if you want NO html link
* @return boolean true if URL has been displayed
function author_url( $linktext=
'', $before=
'', $after=
'', $makelink =
true )
* Template function: display spam karma of the comment (in percent)
* "%s" gets replaced by the karma value
* @param string Template string to display, if we have a karma value
* @param string Template string to display, if we have no karma value (pre-Phoenix)
function spam_karma( $template =
'%s%', $template_unknown =
NULL )
if( ! isset
($template_unknown) )
echo
/* TRANS: "not available" */ T_('N/A');
* Provide link to edit a comment if user has edit rights
* @param string to display before link
* @param string to display after link
* @param string link text
* @param string link title
* @param string class name
function edit_link( $before =
' ', $after =
' ', $text =
'#', $title =
'#', $class =
'', $glue =
'&', $save_context =
true )
global $current_User, $admin_url;
if( ! $current_User->check_perm( 'blog_comments', '', false, $this->Item->get_blog_ID() ) )
{ // If User has no permission to edit comments:
if( $text ==
'#' ) $text =
get_icon( 'edit' ).
' '.
T_('Edit...');
if( $title ==
'#' ) $title =
T_('Edit this comment');
echo
'<a href="'.
$admin_url.
'?ctrl=comments&action=edit&comment_ID='.
$this->ID;
echo
'" title="'.
$title.
'"';
if( !empty( $class ) ) echo
' class="'.
$class.
'"';
* Display delete icon for deleting author_url if user has proper rights
* @param boolean true if create ajax button
* @param glue between url params
global $current_User, $admin_url;
if( ! $current_User->check_perm( 'blog_comments', '', false, $this->Item->get_blog_ID() ) )
{ // If User has no permission to edit comments:
echo
' <a href="javascript:delete_comment_url('.
$this->ID.
');"'.
get_icon( 'delete' ).
'</a>';
$url =
$admin_url.
'?ctrl=comments&action=delete_url&comment_ID='.
$this->ID.
'&'.
url_crumb('comment') ;
* Displays button for deleeing the Comment if user has proper rights
* @param string to display before link
* @param string to display after link
* @param string link text
* @param string link title
* @param string class name
* @param boolean true to make this a button instead of a link
* @param string glue between url params
* @param boolean save context?
* @param boolean true if create AJAX button
function delete_link( $before =
' ', $after =
' ', $text =
'#', $title =
'#', $class =
'', $button =
false, $glue =
'&', $save_context =
true, $ajax_button =
false )
global $current_User, $admin_url;
if( ! $current_User->check_perm( 'blog_comments', '', false, $this->Item->get_blog_ID() ) )
{ // If User has no permission to edit comments:
{ // Use icon+text as default, if not displayed as button (otherwise just the text)
$text =
get_icon( 'delete', 'imgtag' ).
' '.
T_('Delete!');
if( $title ==
'#' ) $title =
T_('Delete this comment');
$url =
$admin_url.
'?ctrl=comments&action=delete&comment_ID='.
$this->ID.
'&'.
url_crumb('comment') ;
echo
'<a href="javascript:deleteComment('.
$this->ID.
');" title="'.
$title.
'" onclick="return confirm(\'';
echo
TS_('You are about to delete this comment!\\nThis cannot be undone!');
if( !empty( $class ) ) echo
' class="'.
$class.
'"';
echo
'<input type="button"';
echo
' value="'.
$text.
'" title="'.
$title.
'" onclick="if ( confirm(\'';
echo
TS_('You are about to delete this comment!\\nThis cannot be undone!');
echo
'\') ) { document.location.href=\''.
$url.
'\' }"';
if( !empty( $class ) ) echo
' class="'.
$class.
'"';
echo
'<a href="'.
$url.
'" title="'.
$title.
'" onclick="return confirm(\'';
echo
TS_('You are about to delete this comment!\\nThis cannot be undone!');
if( !empty( $class ) ) echo
' class="'.
$class.
'"';
* Provide link to deprecate a comment if user has edit rights
* @param string to display before link
* @param string to display after link
* @param string link text
* @param string link title
* @param string class name
* @param string glue between url params
* @param boolean save context?
* @param boolean true if create AJAX button
function get_deprecate_link( $before =
' ', $after =
' ', $text =
'#', $title =
'#', $class =
'', $glue =
'&', $save_context =
true, $ajax_button =
false )
global $current_User, $admin_url;
if( ($this->status ==
'deprecated') // Already deprecateded!
||
! $current_User->check_perm( 'blog_comments', '', false, $this->Item->get_blog_ID() ) )
{ // If User has no permission to edit comments:
if( $text ==
'#' ) $text =
get_icon( 'deprecate', 'imgtag' ).
' '.
T_('Deprecate!');
if( $title ==
'#' ) $title =
T_('Deprecate this comment!');
$r .=
'javascript:setCommentStatus('.
$this->ID.
', \'deprecated\');';
$r .=
$admin_url.
'?ctrl=comments'.
$glue.
'action=deprecate'.
$glue.
'comment_ID='.
$this->ID.
'&'.
url_crumb('comment');
$r .=
'" title="'.
$title.
'"';
if( !empty( $class ) ) $r .=
' class="'.
$class.
'"';
* Display link to deprecate a comment if user has edit rights
* @param string to display before link
* @param string to display after link
* @param string link text
* @param string link title
* @param string class name
* @param string glue between url params
* @param boolean save context?
* @param boolean true if create AJAX button
function deprecate_link( $before =
' ', $after =
' ', $text =
'#', $title =
'#', $class =
'', $glue =
'&', $save_context =
true, $ajax_button =
false )
echo
$this->get_deprecate_link( $before, $after, $text, $title, $class, $glue, $save_context, $ajax_button );
* Provide link to publish a comment if user has edit rights
* @param string to display before link
* @param string to display after link
* @param string link text
* @param string link title
* @param string class name
* @param string glue between url params
* @param boolean save context?
* @param boolean true if create AJAX button
function get_publish_link( $before =
' ', $after =
' ', $text =
'#', $title =
'#', $class =
'', $glue =
'&', $save_context =
true, $ajax_button =
false )
global $current_User, $admin_url;
if( ($this->status ==
'published') // Already published!
||
! $current_User->check_perm( 'blog_comments', '', false, $this->Item->get_blog_ID() ) )
{ // If User has no permission to edit comments:
if( $text ==
'#' ) $text =
get_icon( 'publish', 'imgtag' ).
' '.
T_('Publish!');
if( $title ==
'#' ) $title =
T_('Publish this comment!');
$r .=
'javascript:setCommentStatus('.
$this->ID.
', \'published\');';
$r .=
$admin_url.
'?ctrl=comments'.
$glue.
'action=publish'.
$glue.
'comment_ID='.
$this->ID.
'&'.
url_crumb('comment');
$r .=
'" title="'.
$title.
'"';
if( !empty( $class ) ) $r .=
' class="'.
$class.
'"';
* Display link to publish a comment if user has edit rights
* @param string to display before link
* @param string to display after link
* @param string link text
* @param string link title
* @param string class name
* @param string glue between url params
* @param boolean save context?
* @param boolean true if create AJAX button
function publish_link( $before =
' ', $after =
' ', $text =
'#', $title =
'#', $class =
'', $glue =
'&', $save_context =
true, $ajax_button =
false )
echo
$this->get_publish_link( $before, $after, $text, $title, $class, $glue, $save_context, $ajax_button );
* Provide link to message form for this comment's author
* @param string url of the message form
* @param string to display before link
* @param string to display after link
* @param string link text
* @param string link title
* @param string class name
function msgform_link( $form_url, $before =
' ', $after =
' ', $text =
'#', $title =
'#', $class =
'' )
{ // This comment is from a registered user:
{ // We have no email for this Author :(
{ // User does not allow message form
{ // This comment is from a visitor:
{ // We have no email for this comment :(
{ // Anonymous commentator does not allow message form (for this comment)
if( $title ==
'#' ) $title =
T_('Send email to comment author');
if( $text ==
'#' ) $text =
get_icon( 'email', 'imgtag', array( 'class' =>
'middle', 'title' =>
$title ) );
echo
'<a href="'.
$form_url.
'" title="'.
$title.
'"';
if( !empty( $class ) ) echo
' class="'.
$class.
'"';
// TODO: have an SEO setting for nofollow here, default to nofollow
* Generate permalink to this comment.
* Note: This actually only returns the URL, to get a real link, use Comment::get_permanent_link()
$post_permalink =
$this->Item->get_single_url( 'auto' );
* Template function: display permalink to this comment
* Note: This actually only returns the URL, to get a real link, use Comment::permanent_link()
* @param string 'urltitle', 'pid', 'archive#id' or 'archive#title'
* @param string url to use
* Returns a permalink link to the Comment
* Note: If you only want the permalink URL, use Comment::get_permanent_url()
* @param string link text or special value: '#', '#icon#', '#text#'
* @param string link title
* @param string class name
global $current_User, $baseurl;
$text =
get_icon( 'permalink' ).
T_('Permalink');
if( $title ==
'#' ) $title =
T_('Permanent link to this comment');
$r =
'<a href="'.
$url.
'" title="'.
$title.
'"';
if( !empty( $class ) ) $r .=
' class="'.
$class.
'"';
if( !empty( $nofollow ) ) $r .=
' rel="nofollow"';
* Displays a permalink link to the Comment
* Note: If you only want the permalink URL, use Comment::permanent_url()
// Make sure we are not missing any param:
echo
$this->get_permanent_link( $params['text'], $params['title'], $params['class'], $params['nofollow'] );
* Template function: get content of comment
* @param string Output format, see {@link format_to_output()}
// fp> obsolete: $comment = str_replace('<trackback />', '', $comment);
$Plugins->trigger_event( 'FilterCommentContent', array( 'data' =>
& $comment, 'Comment' =>
$this ) );
* Template function: display content of comment
* @param string Output format, see {@link format_to_output()}
function content( $format =
'htmlbody' )
* Get title of comment, e.g. "Comment from: Foo Bar"
* 'author_format': Formatting of the author (%s gets replaced with
if( empty($params['author_format']) )
$params['author_format'] =
'%s';
switch( $this->get( 'type' ) )
case 'comment':
// Display a comment:
$s =
T_('Comment from %s');
case 'trackback':
// Display a trackback:
$s =
T_('Trackback from %s');
case 'pingback':
// Display a pingback:
$s =
T_('Pingback from %s');
* Template function: display date (datetime) of comment
* @param string date/time format: leave empty to use locale default date format
* @param boolean true if you want GMT
function date( $format=
'', $useGM =
false )
* Template function: display time (datetime) of comment
* @param string date/time format: leave empty to use locale default time format
* @param boolean true if you want GMT
function time( $format=
'', $useGM =
false )
* Template tag: display rating
function rating( $params =
array() )
if( empty( $this->rating ) )
// Make sure we are not missing any param:
'before' =>
'<div class="comment_rating">',
'star_class' =>
'middle',
'label_low' =>
T_('Poor'),
'label_high' =>
T_('Excellent'),
echo
$params['label_low'];
echo
'<input type="radio" class="radio" name="comment_rating" value="'.
$i.
'"';
if( $this->rating ==
$i )
echo
' checked="checked"';
echo
$params['label_high'];
'label' =>
T_('No rating'),
echo
'<label><input type="radio" class="radio" name="comment_rating" value="0"';
if( empty($this->rating) )
echo
' checked="checked"';
echo
$params['label'].
'</label>';
* Template function: display status of comment
* @param string Output format, see {@link format_to_output()}
function status( $format =
'htmlbody' )
$this->disp( 'status', 'raw' );
* Send email notifications to subscribed users:
* @todo fp> SEPARATE MODERATION notifications from SUBSCRIPTION notifications
* @todo shall we notify suscribers of blog were this is in extra-cat?
* @todo cache message by locale like {@link Item::send_email_notifications()}
* @todo dh> Indicator in url to see where the user came from (&from=subnote ["subscription notification"]) - Problem: too long urls.
* @todo dh> "Beautify" like {@link Item::send_email_notifications()} ? fp > sure
* @todo Should include "visibility status" in the mail to the Item's Author
$edited_Blog =
& $edited_Item->get_Blog();
if( $edited_Blog->get_setting( 'allow_subscriptions' ) )
{ // Get list of users who want to be notfied:
// TODO: also use extra cats/blogs??
// So far you get notifications for everything. We'll need a setting to decide if you want to received unmoderated (aka unpublished) comments or not.
// Note: users receive comments on their own posts. This is done on purpose. Otherwise they think it's broken when they test the app.
$sql =
'SELECT DISTINCT user_email, user_locale
FROM T_subscriptions INNER JOIN T_users ON sub_user_ID = user_ID
WHERE sub_coll_ID = '.
$this->Item->get_blog_ID().
'
AND LENGTH(TRIM(user_email)) > 0';
$notify_list =
$DB->get_results( $sql );
foreach( $notify_list as $notification )
$notify_array[$notification->user_email] =
$notification->user_locale;
// Check if we need to include the author:
$item_author_User =
& $edited_Item->get_creator_User();
if( $item_author_User->notify
&&
( ! empty( $item_author_User->email ) ) )
{ // Author wants to be notified...
&&
$item_author_User->login ==
$this->author_User->login) ) // comment is from same user as post
{ // Author is not commenting on his own post...
$notify_array[$item_author_User->email] =
$item_author_User->locale;
if( ! count($notify_array) )
* We have a list of email addresses to notify:
// TODO: dh> this reveals the comments author's email address to all subscribers!!
// $notify_from should get used by default, unless the user has opted in to be the sender!
// fp>If the subscriber has permission to moderate the comments, he SHOULD receive the email address.
{ // Comment from a registered user:
{ // non-member, but with email address:
$mail_from_name =
$this->author;
{ // Fallback (we have no email address): fp>TODO: or the subscriber is not allowed to view it.
$mail_from =
$notify_from;
foreach( $notify_array as $notify_email =>
$notify_locale )
locale_temp_switch($notify_locale);
/* TRANS: Subject of the mail to send on new trackbacks. First %s is the blog's shortname, the second %s is the item's title. */
$subject =
T_('[%s] New trackback on "%s"');
/* TRANS: Subject of the mail to send on new comments. First %s is the blog's shortname, the second %s is the item's title. */
$subject =
T_('[%s] New comment on "%s"');
$subject =
sprintf( $subject, $edited_Blog->get('shortname'), $edited_Item->get('title') );
$notify_message =
T_('Blog').
': '.
$edited_Blog->get('shortname').
"\n"
// Mail bloat: .' ( '.str_replace('&', '&', $edited_Blog->gen_blogurl())." )\n"
.
T_('Post').
': '.
$edited_Item->get('title').
"\n";
// Mail bloat: .' ( '.str_replace('&', '&', $edited_Item->get_permanent_url())." )\n";
// TODO: fp> We MAY want to force short URL and avoid it to wrap on a new line in the mail which may prevent people from clicking
$notify_message .=
T_('Website').
": $this->author (IP: $this->author_IP, $user_domain)\n";
$notify_message .=
T_('Url').
": $this->author_url\n";
{ // Comment from a registered user:
{ // Comment from visitor:
$notify_message .=
T_('Author').
": $this->author (IP: $this->author_IP, $user_domain)\n";
$notify_message .=
T_('Url').
": $this->author_url\n";
// TODO: fp> We MAY want to force a short URL and avoid it to wrap on a new line in the mail which may prevent people from clicking
if( !empty( $this->rating ) )
$notify_message .=
T_('Rating').
": $this->rating\n";
$notify_message .=
$this->get('content')
if( $this->status ==
'draft' )
$secret_value =
'&secret='.
$this->secret;
$notify_message .=
T_('Quick moderation').
': '.
$baseurl.
'htsrv/comment_review.php?cmt_ID='.
$this->ID.
$secret_value.
"\n\n";
$notify_message .=
T_('Edit screen').
': '.
$admin_url.
'?ctrl=items&blog='.
$edited_Blog->ID.
'&p='.
$edited_Item->ID.
'&c=1#c'.
$this->ID.
"\n\n"
.
T_('Edit your subscriptions/notifications').
': '.
str_replace('&', '&', url_add_param( $edited_Blog->gen_blogurl(), 'disp=subs' ) ).
"\n";
$mail_dump =
"Sending notification to $notify_email:<pre>Subject: $subject\n$notify_message</pre>";
{ // output mail content - NOTE: this will kill sending of headers.
echo
"<p>$mail_dump</p>";
$Debuglog->add( $mail_dump, 'notification' );
send_mail( $notify_email, NULL, $subject, $notify_message, $mail_from, $mail_from_name );
locale_restore_previous();
* Trigger event AfterCommentUpdate after calling parent method.
* @return boolean true on success
if( $this->status !=
'draft' )
{ // We don't want to keep "secret" moderation access once we've published or deprecated a comment
$this->set( 'secret', null );
$dbchanges =
$this->dbchanges;
if( ( $r =
parent::dbupdate() ) !==
false )
$Plugins->trigger_event( 'AfterCommentUpdate', $params =
array( 'Comment' =>
& $this, 'dbchanges' =>
$dbchanges ) );
* Get karma and set it before adding the Comment to DB.
* @return boolean true on success, false if it did not get inserted
// Get karma percentage (interval -100 - 100)
$spam_karma =
$Plugins->trigger_karma_collect( 'GetSpamKarmaForComment', array( 'Comment' =>
& $this ) );
// Change status accordingly:
if( $spam_karma <
$Settings->get('antispam_threshold_publish') )
$this->set( 'status', 'published' );
elseif( $spam_karma >
$Settings->get('antispam_threshold_delete') )
if( $this->status ==
'draft' )
{ // We will allow "secret" moderation only to draft comments:
$dbchanges =
$this->dbchanges;
$Plugins->trigger_event( 'AfterCommentInsert', $params =
array( 'Comment' =>
& $this, 'dbchanges' =>
$dbchanges ) );
* Trigger event AfterCommentDelete after calling parent method.
* @return boolean true on success
// remember ID, because parent method resets it to 0
// re-set the ID for the Plugin event
$Plugins->trigger_event( 'AfterCommentDelete', $params =
array( 'Comment' =>
& $this ) );
* $Log: _comment.class.php,v $
* Revision 1.52 2010/03/04 18:21:26 fplanque
* Revision 1.51 2010/03/04 15:46:02 efy-asimo
* remove javascript from comment_review + add comment_secret just for draft comments
* Revision 1.50 2010/03/03 19:49:08 fplanque
* Revision 1.49 2010/03/03 16:29:15 fplanque
* Revision 1.48 2010/03/03 16:25:13 fplanque
* Revision 1.47 2010/03/01 08:34:25 efy-asimo
* delete url come back to the same screen
* Revision 1.46 2010/02/28 23:38:40 fplanque
* Revision 1.45 2010/02/10 11:45:04 efy-asimo
* Quick Edit option on comment notification
* Revision 1.44 2010/02/08 17:52:12 efy-yury
* Revision 1.43 2010/01/31 17:39:52 efy-asimo
* delete url from comments in dashboard and comments form
* Revision 1.42 2010/01/13 19:49:45 efy-yury
* update comments: crumbs
* Revision 1.41 2009/11/24 22:09:24 efy-maxim
* dashboard comments - ajax
* Revision 1.40 2009/09/30 00:38:14 sam2kb
* Space is not needed before get_field_attribs_as_string()
* Revision 1.39 2009/09/28 02:26:36 sam2kb
* 80x80px image looks weird, changed to 64x64
* Revision 1.38 2009/09/26 12:00:42 tblue246
* Revision 1.37 2009/09/25 07:32:52 efy-cantor
* replace get_cache to get_*cache
* Revision 1.36 2009/09/24 01:20:16 blueyed
* width and height for gravatar images
* Revision 1.35 2009/09/20 18:13:20 fplanque
* Revision 1.34 2009/09/20 13:48:46 blueyed
* Cleanup get_avatar some.
* Revision 1.33 2009/09/16 21:29:31 sam2kb
* Display user/visitor avatar in comments
* Revision 1.32 2009/09/14 12:46:36 efy-arrin
* Included the ClassName in load_class() call with proper UpperCase
* Revision 1.31 2009/08/30 17:27:03 fplanque
* better NULL param handling all over the app
* Revision 1.30 2009/08/25 17:01:50 tblue246
* Bugfix #2, not my day today...
* Revision 1.27 2009/03/08 23:57:42 fplanque
* Revision 1.26 2009/02/25 22:17:53 blueyed
* ItemLight: lazily load blog_ID and main_Chapter.
* There is more, but I do not want to skim the diff again, after
* "cvs ci" failed due to broken pipe.
* Revision 1.25 2009/01/26 20:45:51 blueyed
* Fix Comment::get_author_name for User (returned and echoed). Used nowhere and buggy since move to MVC (2007-06-25) at least. Thanks Walter for finding it :)
* Revision 1.24 2008/12/18 00:34:13 blueyed
* - Add Comment::get_author() and make Comment::author() use it
* - Add Comment::get_title() and use it in Dashboard and Admin comment list
* Revision 1.23 2008/07/01 08:32:12 fplanque
* Revision 1.22 2008/04/13 22:07:59 fplanque
* Revision 1.21 2008/04/13 15:15:59 fplanque
* attempt to fix email headers for non latin charsets
* Revision 1.20 2008/03/31 00:27:49 fplanque
* Enhanced comment moderation
* Revision 1.19 2008/03/30 23:04:23 fplanque
* Revision 1.18 2008/03/16 22:39:07 fplanque
* Revision 1.17 2008/03/16 13:57:01 fplanque
* Revision 1.15 2008/02/10 00:58:56 fplanque
* Revision 1.14 2008/01/21 09:35:27 fplanque
* Revision 1.13 2008/01/11 19:18:29 fplanque
* Revision 1.12 2008/01/10 19:59:51 fplanque
* Revision 1.11 2008/01/08 20:15:21 personman2
* Post author no longer gets emails when he comments on his own post
* Revision 1.10 2007/12/28 13:45:33 fplanque
* Revision 1.9 2007/12/28 13:24:29 fplanque
* Revision 1.8 2007/12/26 20:04:26 fplanque
* fixed missing nofollow handling
* Revision 1.7 2007/12/23 20:10:49 fplanque
* Revision 1.6 2007/12/22 17:24:35 fplanque
* Revision 1.5 2007/12/18 23:51:32 fplanque
* nofollow handling in comment urls
* Revision 1.4 2007/11/03 04:56:03 fplanque
* permalink / title links cleanup
* Revision 1.3 2007/11/02 01:50:54 fplanque
* Revision 1.2 2007/09/04 19:51:26 fplanque
* in-context comment editing
* Revision 1.1 2007/06/25 10:59:40 fplanque
* MODULES (refactored MVC)
* Revision 1.65 2007/05/28 15:18:30 fplanque
* Revision 1.64 2007/05/20 20:54:49 fplanque
* better comment moderation links
* Revision 1.63 2007/04/26 00:11:08 fplanque
* Revision 1.62 2007/03/24 20:41:16 fplanque
* Refactored a lot of the link junk.
* Made options blog specific.
* Some junk still needs to be cleaned out. Will do asap.
* Revision 1.61 2007/03/22 00:03:40 blueyed
* Escape author_url and author_User->url in author_url() template function
* Revision 1.60 2007/03/11 23:57:06 fplanque
* item editing: allow setting to 'redirected' status
* Revision 1.59 2007/02/28 23:37:52 blueyed
* Revision 1.58 2007/02/25 01:34:19 fplanque
* Revision 1.57 2007/02/21 23:59:00 blueyed
* Trigger FilterIpAddress event in author_ip()
* Revision 1.56 2006/12/26 00:08:29 fplanque
* Revision 1.55 2006/12/16 01:30:46 fplanque
* Setting to allow/disable email subscriptions on a per blog basis
* Revision 1.54 2006/12/12 02:53:56 fplanque
* Activated new item/comments controllers + new editing navigation
* Some things are unfinished yet. Other things may need more testing.
* Revision 1.53 2006/12/07 23:13:10 fplanque
* @var needs to have only one argument: the variable type
* Otherwise, I can't code!
* Revision 1.52 2006/12/03 18:10:22 fplanque
* Not releasable. Discussion by email.
* Revision 1.51 2006/11/26 02:30:39 fplanque
* Revision 1.50 2006/11/17 18:36:23 blueyed
* dbchanges param for AfterItemUpdate, AfterItemInsert, AfterCommentUpdate and AfterCommentInsert
* Revision 1.49 2006/11/16 22:41:59 blueyed
* Fixed email from address in notifications, but also added TODO
* Revision 1.48 2006/11/16 19:23:12 fplanque
* Revision 1.47 2006/11/14 21:02:57 blueyed
* Revision 1.46 2006/11/06 00:05:36 blueyed
* Encoding of "&" in Comment::author_url makes no sense, should get done on output.
* Revision 1.45 2006/11/05 22:12:35 blueyed
* Revision 1.44 2006/10/23 22:19:02 blueyed
* Fixed/unified encoding of redirect_to param. Use just rawurlencode() and no funky & replacements
* Revision 1.43 2006/10/18 00:03:50 blueyed
* Some forgotten url_rel_to_same_host() additions