need help with 1st module: Custom Filter as user preference

sunset_bill - April 29, 2008 - 13:47

I want to do some word filtering/replacement on my site using Custom Filter, but, rather than turning my filters on in Input Formats and censoring content for everybody, like it or not, I want to leave postings untouched and let users turn censorship on or off as a personal preference. Lots of searching and more than a couple posts on the forums here have turned up nothing for an existing module to do this, so I'm gonna give it a shot as my first module attempt.

I've got a censorship option in user profile, Custom Filter is working, and I've found an example module for output filtering that looks like a good place to start:
(http://api.drupal.org/api/file/developer/examples/filter_example.module)

My question at this point is, how do (can?) I hook into Custom Filter to have it do the substitutions for me instead of hard-coding regex's into my module?

Thanks for any enlightenment

Updating

sunset_bill - April 30, 2008 - 18:13

Just for fun...

Turns out it was real easy to take http://drupal.org/project/workflow_wordfilter and modify it to workflow_customfilter. It's currently moderating new posts and setting them to unpublished if they've got words I'm filtering on, and I'm working on a censor function to do substitutions on content at time of viewing, to wit:

<?php
function workflow_customfilter_action_censor_node($node){
 
$node->title = _customfilter_process(1, '', $node->title);
 
$node->body = _customfilter_process(1, '', $node->body);
  return array (
'node' => $node);
}
?>

What I don't like about this is that returning that array updates the node (corrupts my database) with the filtered values; if I comment that line out, I get the unfiltered text. How do I just display the filtered text without updating the node in the database?

thanks

 
 

Drupal is a registered trademark of Dries Buytaert.