Blog

Luis Majano

July 22, 2016

Spread the word


Share your thoughts

ContentBox sports many out of the box comment moderation tools.

From the screenshot you can appreciate all the different tuning you can do for comment moderation:

  • All comments moderated
  • User must have an approved comment to be approved consequentely
  • Auto-deletion of comments that are moderated
  • Moderated keywords (ip addresses, authors, emails, or content)
  • Blocked keywords (ip addresses, authors, emails, or content)

My favorite setting is the auto-deletion of moderated comments. I have never ever ever ever cleaned up spam anymore. I let ContentBox do it every X number of days and I truly appreciate that as it is one less thing to worry about.

Comment Events

As you can see, you have many options when it comes to comment moderation and even blocking. You can also tap into the commenting life-cycle with interception events. Below are all the events you can listen to that deal with comments:

  • cbui_preCommentPost - Before a comment is posted
  • cbui_onCommentPost - After a comment is posted
  • cbui_onCommentModerationRules - After all comment moderation and blocking rules have executed. Your chance to change them or add to them.
  • cbadmin_onCommentStatusUpdate - When the status of a comment is changed
  • cbadmin_preCommentSave - Before a comment is saved by an editor
  • cbadmin_postCommentSave - After a comment is saved by an editor
  • cbadmin_preCommentRemove - Before a comment is removed
  • cbadmin_postCommentRemove - After a comment is removed
  • cbadmin_preCommentRemoveAllModerated - Before all comments moderated comments are auto-deleted
  • cbadmin_postCommentRemoveAllModerated - After all comments moderated comments are auto-deleted
  • cbadmin_preCommentSettingsSave - Before saving comment settings
  • cbadmin_postCommentSettingsSave - After saving comment settings
  • cbadmin_onCommentSettingsNav - On the comment navigation tab
  • cbadmin_onCommentSettingsContent - On the comment content tab

All you have to do is create interceptors or modules that listen to these event functions and you can extend ContentBox your way. Here is a real example from our Akismet moderating module:

function cbui_onCommentModerationRules( event, interceptData, buffer ){
	var oComment = arguments.interceptData.comment;
	var settings = coldbox.getSetting( "modules" )[ "contentbox-akismet" ].settings;
	
	// check if key is empty? If it is, just return
	if( !len( settings.api_key ) ){
		return;
	}		

	// verify if spam?
	var isSpam = akismet.isCommentSpam(
		author = oComment.getAuthor(),
		authorURL = oComment.getAuthorURL(),
		authorEmail = oComment.getAuthorEmail(),
		content = oComment.getContent(),
		permalink = cb.linkContent( oComment.getRelatedContent() )
	);

	// if block is setup and comment is spam, then ignore.
	if( settings.block and isSpam ){
		oComment.setIsApproved( false );
		arguments.interceptData.allowSave = false;
		log.info( "Incoming comment is spam and block enabled, ignoring comment.", oComment.getMemento() );
	}
	// else, if spam, mark it
	else if( !settings.block AND isSpam ){
		oComment.setIsApproved( false );
		log.info( "Incoming comment is spam so moderating it.", oComment.getMemento() );
	}

}

Add Your Comment

Recent Entries

Ortus June 2024 Newsletter!

Ortus June 2024 Newsletter!

Welcome to the latest edition of the Ortus Newsletter! This month, we're excited to bring you highlights from our sessions at CFCamp and Open South Code, as well as a sneak peek into our upcoming events. Discover the latest developments in BoxLang, our dynamic new JVM language, and catch up on all the insightful presentations by our expert team. Let's dive in!

Maria Jose Herrera
Maria Jose Herrera
June 28, 2024
BoxLang June 2024 Newsletter!

BoxLang June 2024 Newsletter!

We're thrilled to bring you the latest updates and exciting developments from the world of BoxLang. This month, we're diving into the newest beta release, introducing a new podcast series, showcasing innovative integrations, and sharing insights from recent events. Whether you're a seasoned developer or just getting started, there's something here for everyone to explore and enjoy.

Maria Jose Herrera
Maria Jose Herrera
June 28, 2024
BoxLang 1.0.0 Beta 3 Launched

BoxLang 1.0.0 Beta 3 Launched

We are thrilled to announce the release of BoxLang 1.0.0-Beta 3! This latest beta version is packed with exciting new features and essential bug fixes, including robust encryption functionality, enhanced Java interoperability, and more efficient event handling. Key highlights include the introduction of query caching capabilities, seamless coercion of Java Single Abstract Method (SAM) interfaces from BoxLang functions, and support for virtual thread executors. So, let’s dive into the details of what’s new in BoxLang 1.0.0-Beta 3 and how you can start leveraging these updates today!

Luis Majano
Luis Majano
June 28, 2024