]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/ActivitySpam/ActivitySpamPlugin.php
Merge remote-tracking branch 'upstream/master' into social-master
[quix0rs-gnu-social.git] / plugins / ActivitySpam / ActivitySpamPlugin.php
index 978f8b4cf8cf3c6f59b1a56bdfc189aa0be4182f..8d924dea97e015f6111de9c35b46d9bbfb01dbfb 100644 (file)
@@ -92,38 +92,6 @@ class ActivitySpamPlugin extends Plugin
         return true;
     }
 
-    /**
-     * Load related modules when needed
-     *
-     * @param string $cls Name of the class to be loaded
-     *
-     * @return boolean hook value; true means continue processing, false means stop.
-     */
-
-    function onAutoload($cls)
-    {
-        $dir = dirname(__FILE__);
-
-        switch ($cls)
-        {
-        case 'TrainAction':
-        case 'SpamAction':
-            include_once $dir . '/' . strtolower(mb_substr($cls, 0, -6)) . '.php';
-            return false;
-        case 'Spam_score':
-            include_once $dir . '/'.$cls.'.php';
-            return false;
-        case 'SpamFilter':
-        case 'SpamNoticeStream':
-        case 'TrainSpamForm':
-        case 'TrainHamForm':
-            include_once $dir . '/'.strtolower($cls).'.php';
-            return false;
-        default:
-            return true;
-        }
-    }
-
     /**
      * When a notice is saved, check its spam score
      * 
@@ -150,15 +118,15 @@ class ActivitySpamPlugin extends Plugin
         return true;
     }
 
-    function onNoticeDeleteRelated($notice) {
-        $score = Spam_score::staticGet('notice_id', $notice->id);
+    function onNoticeDeleteRelated(Notice $notice) {
+        $score = Spam_score::getKV('notice_id', $notice->id);
         if (!empty($score)) {
             $score->delete();
         }
         return true;
     }
 
-    function onUserRightsCheck($profile, $right, &$result) {
+    function onUserRightsCheck(Profile $profile, $right, &$result) {
         switch ($right) {
         case self::REVIEWSPAM:
         case self::TRAINSPAM:
@@ -185,7 +153,7 @@ class ActivitySpamPlugin extends Plugin
 
             if (!empty($notice)) {
 
-                $score = Spam_score::staticGet('notice_id', $notice->id);
+                $score = Spam_score::getKV('notice_id', $notice->id);
 
                 if (empty($score)) {
                     // If it's empty, we can train it.
@@ -207,12 +175,12 @@ class ActivitySpamPlugin extends Plugin
     /**
      * Map URLs to actions
      *
-     * @param Net_URL_Mapper $m path-to-action mapper
+     * @param URLMapper $m path-to-action mapper
      *
      * @return boolean hook value; true means continue processing, false means stop.
      */
 
-    function onRouterInitialized($m)
+    public function onRouterInitialized(URLMapper $m)
     {
         $m->connect('main/train/spam',
                     array('action' => 'train', 'category' => 'spam'));
@@ -223,7 +191,7 @@ class ActivitySpamPlugin extends Plugin
         return true;
     }
 
-    function onEndShowStyles($action)
+    function onEndShowStyles(Action $action)
     {
         $action->element('style', null,
                          '.form-train-spam input.submit { background: url('.$this->path('icons/bullet_black.png').') no-repeat 0px 0px } ' . "\n" .
@@ -247,10 +215,10 @@ class ActivitySpamPlugin extends Plugin
         return true;
     }
 
-    function onPluginVersion(&$versions)
+    function onPluginVersion(array &$versions)
     {
         $versions[] = array('name' => 'ActivitySpam',
-                            'version' => STATUSNET_VERSION,
+                            'version' => GNUSOCIAL_VERSION,
                             'author' => 'Evan Prodromou',
                             'homepage' => 'http://status.net/wiki/Plugin:ActivitySpam',
                             'description' =>
@@ -263,7 +231,7 @@ class ActivitySpamPlugin extends Plugin
         if ($this->hideSpam) {
             if ($bResult) {
 
-                $score = Spam_score::staticGet('notice_id', $notice->id);
+                $score = Spam_score::getKV('notice_id', $notice->id);
 
                 if (!empty($score) && $score->is_spam) {
                     if (empty($profile) ||
@@ -281,12 +249,9 @@ class ActivitySpamPlugin extends Plugin
     /**
      * Pre-cache our spam scores if needed.
      */
-    function onEndNoticeListPrefill(&$notices, &$profiles, $avatarSize) {
+    function onEndNoticeListPrefill(array &$notices, array &$profiles, array $notice_ids, Profile $scoped=null) {
         if ($this->hideSpam) {
-            foreach ($notices as $notice) {
-                $ids[] = $notice->id;
-            }
-            Memcached_DataObject::multiGet('Spam_score', 'notice_id', $ids);
+            Spam_score::multiGet('notice_id', $notice_ids);
         }
         return true;
     }