Pages (5):    1 2 3 4 5   
Member
Member
vincent3569   02-12-2011, 13:29
#21

hi

It seems to work with [8548] :
when I disapprove or approve a comment, the filter is registreted and the new function of my plugin is called.

Thanks !

I have another question : I wish to verify the akismet key when the options of the plugin are saved.

There is a method of akismet to do that.
I suppose I have to do the same thing I have done for submit false positives/negatives SPAM : triggered a new function on "save" action on admin/options/comment, but I don't know which filter I could use.

could you help me ?

Administrator
Administrator
acrylian   02-12-2011, 14:15
#22

You would actually need a filter that is called on saving plugin options. Not sure we have one at the moment, but sbillard will know it for sure.

Edit: Is probably possible without a filter. Use the OPTION_TYPE_CUSTOM and create a check with in handleOption(). It would then work like 1. Save the key 2. on page reload this function gets that value and checks it. Then you can put out a warning right with the text field.

Member
Member
sbillard   02-12-2011, 17:42
#23

You do not actually have to change the option type. Just add code in the getSupportedOptions() method to check the validity of the key. If it is not valid (and probably also not empty) add the message to the option description.

Administrator
Administrator
acrylian   02-12-2011, 17:51
#24

True, why easy if possible complicated...;-)

Member
Member
vincent3569   03-12-2011, 17:34
#25

thanks sbillard, but could you give me an example how to add code in getSupportedOptions() ?

fyi, I have a new methoe of SpamFilter :
`
function isValidKey() {
$zp_galerieUrl = FULLWEBPATH; // Set the webpath for the Akismet server
$zp_akismetKey = getOption('Akismet_key');

    $akismet = new Akismet($zp_galerieUrl, $zp_akismetKey);

    if($akismet->isKeyValid()) {
        return true;
    } else {
        return false;
    }
}

`
how can I do to call this method on validation ?
how can I add a specific message on zenphoto admin : 'your Akismet key is empty or invalid' if the function returns false ?

Administrator
Administrator
acrylian   03-12-2011, 18:04
#26

Within getSupportedOptions() call your method and add the text about failure if it fails to the option text itself for example.

Member
Member
sbillard   03-12-2011, 18:52
#27

function getOptionsSupported() { if (getOption('Akismet_key') && $this->isValidKey()) { $msg = ''; } else { $msg = Gettext('You need to provide a valid Akismet key'); } return array( gettext('Akismet key') => array('key' => 'Akismet_key', 'type' => 0, 'desc' => gettext('Proper operation requires an Akismet API key obtained by signing up for a Akismet account.').$msg), gettext('Forgiving') => array('key' => 'Forgiving', 'type' => 1, 'desc' => gettext('Mark suspected SPAM for moderation rather than as SPAM')) ); }
Here is a simple example based on your plugin. Of course the text of the message could be better, and maybe also styled as a notice.

Administrator
Administrator
acrylian   03-12-2011, 19:16
#28

I guess a wrong key is actually an error. We have serveral predefined class for styling you can use:
.errorbox, .warningbox and .notebox. The latter is the orange box we often use to highlight. We have also one for "successes" .messagebox which is used on successful saves for example.

Member
Member
vincent3569   03-12-2011, 21:41
#29

thanks !

the new release of the plugin is ready.
improvement :

  • vadidate the provided akismet key in the admin
  • send feedback to Akismet and signal a false negative (no detected SPAM by akismet) / false positive.

I have to do some testing and I will give it to the community when the 1.4.2 release of Zenphoto will be published.

Administrator
Administrator
acrylian   04-12-2011, 09:24
#30

Great. You also could release it as a beta so people interessted could try it before 1.4.2 so possible bugs are sorted out.

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