Class: Comments

Source Location: /bblog/inc/comments.class.php ( Revision Log )

Class Comments

Class Overview

Beginnings of comment handling consolidation

Located in /bblog/inc/comments.class.php [line 12]



		
				Author(s):
		
		
		
Information Tags:
License:  GNU General Public License
Copyright:  Kenneth Power <kenneth.power@gmail.com>
Version:  $Id: $

Methods

[ Top ]
Method Summary
array   canProceed()   Initiates a variety of tests
void   encodeHTML()   Enforces HTML Encoding policy on comment text
bool   failsCaptcha()   Tests what user typed against the captcha
bool   isDisabled()   Checks whether commenting is disabled for this post
void   isFlooding()   Checks whether an attempt at comment flooding is being made
bool   needsModeration()   Tests comment text against moderation criteria
void   newComment()   Add a new comment to an article
void   notify()   Notifies blog author of new comment
void   prepFields()  
string   processCommentText()   Performs various transformations on text. Hyperlinks have the redirector added and are wrapped in A tags (if not already wrapped).
mixed   saveComment()   Save the comment/trackback
void   setCommentCookie()   Saves comment details in a cookie
void   updateCommentCount()  

[ Top ]
Methods
canProceed  [line 138]

  array canProceed( object &$db, object $post, object &$authImage, string $code, string $comment  )

Initiates a variety of tests

An array is returned with the following fields and values: +=============================================+ | proceed | true if all passed all tests | | | false if failed any test | +============+================================+ | message | An array of error messages: | | | array(message_title, | | | message_text); | +============+================================+

Parameters:
object   $db:  EZ SQL instance
object   $post:  The article receiving the comment
object   $authImage:  AuthImage instance
string   $code:  Captcha code as typed by the user
string   $comment:  Comment text


[ Top ]
encodeHTML  [line 274]

  void encodeHTML( mixed $comment  )

Enforces HTML Encoding policy on comment text

Policy states HTML special characters (&, ", etc) be translated to their HTML entity equivalents for HTML display purposes. In doing this, we must maintain the HTML tags (a, b, i, strong, code, acrynom, blockquote, abbr) policy allows.



[ Top ]
failsCaptcha  [line 233]

  bool failsCaptcha( object &$authImage, string $code  )

Tests what user typed against the captcha

Parameters:
object   $authImage:  Instance of AuthImage
string   $code:  Captcha code typed by user


[ Top ]
isDisabled  [line 163]

  bool isDisabled( object $post  )

Checks whether commenting is disabled for this post

Parameters:
object   $post: 


[ Top ]
isFlooding  [line 197]

  void isFlooding( object &$db, string $ip, int $now  )

Checks whether an attempt at comment flooding is being made

Parameters:
object   $db:  EZ SQL instance
string   $ip:  IP Address of commentor
int   $now:  Unix Timestamp of current time


[ Top ]
needsModeration  [line 104]

  bool needsModeration( string $comment  )

Tests comment text against moderation criteria

Parameters:
string   $comment:  The comment text


[ Top ]
newComment  [line 22]

  void newComment( object &$db, object &$authImage, object $post, int $replyto, mixed $post_vars  )

Add a new comment to an article

Parameters:
object   $db:  EZ SQL instance
object   $authImage:  AuthImage instance
object   $post:  The post receiving the comment
int   $replyto:  The ID of the parent comment


[ Top ]
notify  [line 254]

  void notify( string $name, string $link, int $onhold, string $comment  )

Notifies blog author of new comment

Parameters:
string   $name:  Commentors name
string   $link:  Link to comment entry
int   $onhold:  Whether or not comment requires moderation
string   $comment:  Text of the comment


[ Top ]
prepFields  [line 48]

  void prepFields( mixed $vars, mixed $replyto, mixed $id  )



[ Top ]
processCommentText  [line 178]

  string processCommentText( string $comment  )

Performs various transformations on text. Hyperlinks have the redirector added and are wrapped in A tags (if not already wrapped).

Special characters are transformed into HTML entities.

Parameters:
string   $comment:  Comment text


[ Top ]
saveComment  [line 82]

  mixed saveComment( object &$db, array $vars  )

Save the comment/trackback

The SQL statement for saving data is built based upon the values of `$vars`. It is an associative array where the keys are the `T_CONFIG` field names and the elements are values for the fields. On success, the row id(integer) is returned, on failure either false (boolean) or an error message (string) is returned.

Parameters:
object   $db:  EX SQL Instance
array   $vars:  An associative array


[ Top ]
setCommentCookie  [line 217]

  void setCommentCookie( string $name, string $email, string $website  )

Saves comment details in a cookie

Parameters:
string   $name:  Commentors name
string   $email:  Commentors email address
string   $website:  Commentors website


[ Top ]
updateCommentCount  [line 261]

  void updateCommentCount( mixed $db, mixed $postid  )



[ Top ]