Pages (5):    1 2 3 4 5   
Administrator
Administrator
acrylian   30-11-2011, 11:53
#11

looks better. I am not in detail familiar with the spam filters but if the class object is already created elsewhere you might want to use a global variable so you don't need to create an extra one within the function.

Member
Member
vincent3569   30-11-2011, 12:23
#12

the class object is created when a visitor add a comment
and, of course, for each call of akismet to signalize a SPAM.
so I need a new object on each comment, don't you think ?

I do some tests but I am unable to verify the improvement (I can't see if the function submitSpam() is called by the filter).

Is there a way to add some trace for debugging the code (to generate zp-date/debug.log or something like that) ?

thanks for your help

Member
Member
vincent3569   30-11-2011, 12:48
#13

ok, I have found and I have set DEBUG_PLUGINS and DEBUG_FILTERS to true in global-definitions.

I can't see a call of the hook 'comment_disapprove' when I choose a comment as a Spam.

I can see the registration, only if I go to admin/options/comment.

could you help me ?

Administrator
Administrator
acrylian   30-11-2011, 13:13
#14

Probably you need the class object. As said I am not familiar with the spam(comment) stuff.

There are several debugLog functions for that within /zp-core/functions.php.

Member
Member
vincent3569   30-11-2011, 18:29
#15

not sure it is the only problem.

with DEBUG_FILTERS, I can see :

  • the function submitSpam is only registred when I navigate on admin/options/comment.

  • wathever I do, the test if ( !isset($_zp_filters[$hook]) ) on function zp_apply_filter is false, so my function is not triggered.

I really need some help on that subject

Administrator
Administrator
acrylian   30-11-2011, 19:45
#16

I will pass answering to sbillard, he surely can help better.

Member
Member
sbillard   30-11-2011, 22:11
#17

You are supposed to be able to attach class methods to filters, but I do not know if anyone has ever really done that.

Also, it seems that because the spam filters do not follow the normal filter implementation there is an issue of the filter not getting loaded.

A work-around would be to create a new plugin that contains the filtering code. It would have to do the "require_once" on the spam filter to get it loaded. Otherwise your code could pretty much stay as above.

`require_once(SERVERPATH.'/'.USER_PLUGIN_FOLDER.'/spamfilters/akismet_php5.php');
zp_register_filter('comment_disapprove', 'submitSpam');

function submitSpam($comment) {
[...]
$spamfilter = new SpamFilter();
$spamfilter->feedbackMessage($author, $email, $website, $body, false);
return $comment;
}'

Really what is needed is to recast the spam filters into normal plugins. But that is a 1.4.3 issue. Still, I think we will do that, so be on notice that the akismit filter will probably need to be change then.

I will look further to see if some other method will work. I will keep you posted.

Member
Member
sbillard   30-11-2011, 22:56
#18

I think maybe I have a solution. Please try the nightly Beta [8548] admin-comments.php will now load the spam filter. This should make your above code work unchanged.

Let us know. If it does not work we will have some more digging to do.

Member
Member
vincent3569   30-11-2011, 23:21
#19

It seems we have the same idea :-)
I will have a look as soon as possible

just a question : what is the need to add "$spamfilter = new SpamFilter();" in the code above ?

I was thinking the 1st part was necessary.

21 if (!(false === ($requirePath = getPlugin('spamfilters/'.getOption('spam_filter').'.php')))) { 22 require_once($requirePath); 23 $spamfilter = new SpamFilter(); 24 }

Member
Member
sbillard   01-12-2011, 02:01
#20

It is probably not needed. Just thought maybe the comment script might someday want to use it. All that is really needed for the filters to be register is for the script to be loaded by the require_once.

Pages (5):    1 2 3 4 5   
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.