]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Blacklist/BlacklistPlugin.php
Tidying up getUser calls to profiles and some events
[quix0rs-gnu-social.git] / plugins / Blacklist / BlacklistPlugin.php
index babf7031313e22565e0a0b366a009940834e585d..142ec2d056d4c0adfa572d8ee3bcf5b5085c1c04 100644 (file)
@@ -80,27 +80,8 @@ class BlacklistPlugin extends Plugin
         $schema = Schema::get();
 
         // For storing blacklist patterns for nicknames
-        $schema->ensureTable('nickname_blacklist',
-                             array(new ColumnDef('pattern',
-                                                 'varchar',
-                                                 255,
-                                                 false,
-                                                 'PRI'),
-                                   new ColumnDef('created',
-                                                 'datetime',
-                                                 null,
-                                                 false)));
-
-        $schema->ensureTable('homepage_blacklist',
-                             array(new ColumnDef('pattern',
-                                                 'varchar',
-                                                 255,
-                                                 false,
-                                                 'PRI'),
-                                   new ColumnDef('created',
-                                                 'datetime',
-                                                 null,
-                                                 false)));
+        $schema->ensureTable('nickname_blacklist', Nickname_blacklist::schemaDef());
+        $schema->ensureTable('homepage_blacklist', Homepage_blacklist::schemaDef());
 
         return true;
     }
@@ -303,30 +284,6 @@ class BlacklistPlugin extends Plugin
         return true;
     }
 
-    /**
-     * Auto-load our classes if called
-     *
-     * @param string $cls Class to load
-     *
-     * @return boolean hook return
-     */
-    function onAutoload($cls)
-    {
-        switch (strtolower($cls))
-        {
-        case 'nickname_blacklist':
-        case 'homepage_blacklist':
-            include_once INSTALLDIR.'/plugins/Blacklist/'.ucfirst($cls).'.php';
-            return false;
-        case 'blacklistadminpanelaction':
-            $base = strtolower(mb_substr($cls, 0, -6));
-            include_once INSTALLDIR.'/plugins/Blacklist/'.$base.'.php';
-            return false;
-        default:
-            return true;
-        }
-    }
-
     /**
      * Plugin version data
      *
@@ -505,14 +462,16 @@ class BlacklistPlugin extends Plugin
             }
         }
 
-        $nickname = strtolower($actor->poco->preferredUsername);
+        if (!empty($actor->poco)) {
+            $nickname = strtolower($actor->poco->preferredUsername);
 
-        if (!empty($nickname)) {
-            if (!$this->_checkNickname($nickname)) {
-                // TRANS: Exception thrown trying to post a notice while having a blocked nickname. %s is the blocked nickname.
-                $msg = sprintf(_m("Notices from nickname \"%s\" disallowed."),
-                               $nickname);
-                throw new ClientException($msg);
+            if (!empty($nickname)) {
+                if (!$this->_checkNickname($nickname)) {
+                    // TRANS: Exception thrown trying to post a notice while having a blocked nickname. %s is the blocked nickname.
+                    $msg = sprintf(_m("Notices from nickname \"%s\" are disallowed."),
+                                   $nickname);
+                    throw new ClientException($msg);
+                }
             }
         }
 
@@ -522,7 +481,7 @@ class BlacklistPlugin extends Plugin
     /**
      * Check URLs and homepages for blacklisted users.
      */
-    function onStartSubscribe($subscriber, $other)
+    function onStartSubscribe(Profile $subscriber, Profile $other)
     {
         foreach (array($other->profileurl, $other->homepage) as $url) {