<?php
/**
* Version $Id $
*
* Badwords2 Text Filtering 'bot!
* @ Copyright (C) 2005 - 2006 Wim Albers, Niels Vandekeybus, Robert Anthony Pitera
* @ All rights reserved
* @ Badwords2 Text Filter component is Free Software
* @ Released under GNU/GPL License : http://www.gnu.org/copyleft/gpl.html
*
**/

/** ensure this file is being included by a parent file */
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

$_MAMBOTS->registerFunction( 'onPrepareContent', 'botBadwords' );

/**
* Text filter bot
*
* <b>Usage:</b>
*
*/
function botBadwords( $published, &$row, $mask=0, $page=0  ) {
  global $mosConfig_absolute_path, $my;
  $is_editor = (strtolower($my->usertype) == 'editor' || strtolower($my->usertype) == 'publisher' || strtolower($my->usertype) == 'manager' || strtolower($my->usertype) == 'administrator' || strtolower($my->usertype) == 'super administrator' );
  if (!$published || $is_editor) {
    return true;
  }

  require_once( $mosConfig_absolute_path . '/components/com_badwords2/class.badwords2.php' );
  # do flush
  $row->title = Badword::flush($row->title, $my);
  $row->text = Badword::flush($row->text, $my);

  return true;
}
?>