[pLog-svn] r5761 - in plugins/branches/lifetype-1.2/akismet: . class/security locale
pwestbro at devel.lifetype.net
pwestbro at devel.lifetype.net
Mon Jul 30 16:02:34 EDT 2007
Author: pwestbro
Date: 2007-07-30 16:02:34 -0400 (Mon, 30 Jul 2007)
New Revision: 5761
Modified:
plugins/branches/lifetype-1.2/akismet/class/security/Akismet.class.php
plugins/branches/lifetype-1.2/akismet/locale/locale_en_UK.php
plugins/branches/lifetype-1.2/akismet/pluginakismet.class.php
Log:
Added the ability to submit spam comments to Akismet.
I picked an icon, but it would be good to get an icon that represents
Akismet. I didn't see an icon on their website that looke appropriated
Potential future changes:
1) Allow a list of comments to be submitted at once
2) Delete comments after submitting. (Or at the minimum, mark them already
submitted).
Modified: plugins/branches/lifetype-1.2/akismet/class/security/Akismet.class.php
===================================================================
--- plugins/branches/lifetype-1.2/akismet/class/security/Akismet.class.php 2007-07-30 18:03:52 UTC (rev 5760)
+++ plugins/branches/lifetype-1.2/akismet/class/security/Akismet.class.php 2007-07-30 20:02:34 UTC (rev 5761)
@@ -70,7 +70,9 @@
'DOCUMENT_ROOT',
'SERVER_ADMIN',
'QUERY_STRING',
- 'PHP_SELF'
+ 'PHP_SELF',
+ 'argv',
+ 'argc'
);
Modified: plugins/branches/lifetype-1.2/akismet/locale/locale_en_UK.php
===================================================================
--- plugins/branches/lifetype-1.2/akismet/locale/locale_en_UK.php 2007-07-30 18:03:52 UTC (rev 5760)
+++ plugins/branches/lifetype-1.2/akismet/locale/locale_en_UK.php 2007-07-30 20:02:34 UTC (rev 5761)
@@ -11,6 +11,9 @@
$messages["akismet_missing_api_key"] = "Akismet API key needs to be specified!";
$messages["akismet_invalid_api_key"] = "Invalid Akismet API key!";
+$messages["akismet_failed_submit_spam"] = "Error submitting spam";
+$messages["akismet_sucess_submit_spam"] = "Spam submitted sucessfuly";
+
$messages["label_configuration"] = "Configuration";
$messages["label_enable"] = "Enable";
$messages["label_akismet_api_key"] = "Akismet API key";
Modified: plugins/branches/lifetype-1.2/akismet/pluginakismet.class.php
===================================================================
--- plugins/branches/lifetype-1.2/akismet/pluginakismet.class.php 2007-07-30 18:03:52 UTC (rev 5760)
+++ plugins/branches/lifetype-1.2/akismet/pluginakismet.class.php 2007-07-30 20:02:34 UTC (rev 5761)
@@ -32,7 +32,7 @@
$this->desc = "Akismet checks your comments against the Akismet web serivce to see if they look like spam or not.";
$this->author = "Paul Westbrook (Akismet php library provided by <a href=\"http://miphp.net/blog/view/php4_akismet_class\">Bret Kuhns</a>)";
$this->locales = Array( "en_UK" );
- $this->version = "20070713";
+ $this->version = "20070730";
if( $source == "admin" )
$this->initAdmin();
@@ -51,6 +51,10 @@
{
$this->init();
+ $this->registerNotification( EVENT_PROCESS_BLOG_ADMIN_TEMPLATE_OUTPUT );
+
+ $this->registerAdminAction( "akismetSubmitComment", "PluginAkismetSubmitCommentAction" );
+
$this->registerAdminAction( "akismet", "PluginAkismetConfigAction" );
$this->registerAdminAction( "updateAkismetConfig", "PluginAkismetUpdateConfigAction" );
@@ -71,6 +75,52 @@
return $this->pluginEnabled;
}
+
+ function process($event, $params){
+ // only process our expected event
+ if($event != EVENT_PROCESS_BLOG_ADMIN_TEMPLATE_OUTPUT)
+ return;
+
+ // only process the editcomments and edittrackbacks template
+ if($params["template"] == "editcomments")
+ $action = "akismetSubmitComment";
+ else
+ return;
+
+ // load the current contents of the template
+ $content = $params["content"];
+ $regexp = "/<div class=\"list_action_button\">.*?<\/div>/s";
+ preg_match_all($regexp, $content, $matches, PREG_SET_ORDER);
+
+ // now process each one of the matches and do the replacements
+ foreach($matches as $match){
+ if($action == "akismetSubmitComment"){
+ // fetch the comment id
+ $res = preg_match(
+ "/<a href=\"\?op=deleteComment&commentId=([0-9]+)&/i",
+ $match[0], $result);
+ }
+
+
+ if($res){
+ // regenerate the block, adding the new markup
+ $artId = $result[1];
+ $toAdd = "<a href='?op=$action&commentId={$artId}'>".
+ "<img src='imgs/admin/icon_mail-16.png' " .
+ "alt='{\$locale->tr('edit')}' /></a></div>";
+ $newStr = str_replace( "</div>", $toAdd, $match[0] );
+ // and now replace the old block with the new one in the global $content variable
+ $content = str_replace( $match[0], $newStr, $content );
+ }
+ else{
+ print "couldn't find id";
+ }
+ }
+
+ $params["content"] = $content;
+ }
+
+
function getPluginConfigurationKeys()
{
lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
More information about the pLog-svn
mailing list