X-Git-Url: https://git.mxchange.org/?p=quix0rs-gnu-social.git;a=blobdiff_plain;f=plugins%2FBlacklist%2FBlacklistPlugin.php;h=d1ee2912afa8f1b965cc53cb0656cd60fbe34628;hp=babf7031313e22565e0a0b366a009940834e585d;hb=dd93420b08910a8bf9967dad7906351695d1ac55;hpb=d594c83a5a9a9d42fce917b544c28591fcadb1aa diff --git a/plugins/Blacklist/BlacklistPlugin.php b/plugins/Blacklist/BlacklistPlugin.php index babf703131..d1ee2912af 100644 --- a/plugins/Blacklist/BlacklistPlugin.php +++ b/plugins/Blacklist/BlacklistPlugin.php @@ -42,7 +42,7 @@ if (!defined('STATUSNET')) { */ class BlacklistPlugin extends Plugin { - const VERSION = STATUSNET_VERSION; + const VERSION = GNUSOCIAL_VERSION; public $nicknames = array(); public $urls = array(); @@ -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; } @@ -141,7 +122,7 @@ class BlacklistPlugin extends Plugin * * @return boolean hook value */ - function onStartRegisterUser(&$user, &$profile) + function onStartRegisterUser(User &$user, Profile &$profile) { $homepage = strtolower($profile->homepage); @@ -293,40 +274,16 @@ class BlacklistPlugin extends Plugin /** * Add our actions to the URL router * - * @param Net_URL_Mapper $m URL mapper for this hit + * @param URLMapper $m URL mapper for this hit * * @return boolean hook return */ - function onRouterInitialized($m) + public function onRouterInitialized(URLMapper $m) { $m->connect('panel/blacklist', array('action' => 'blacklistadminpanel')); 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 * @@ -334,7 +291,7 @@ class BlacklistPlugin extends Plugin * * @return boolean hook value */ - function onPluginVersion(&$versions) + function onPluginVersion(array &$versions) { $versions[] = array('name' => 'Blacklist', 'version' => self::VERSION, @@ -373,7 +330,7 @@ class BlacklistPlugin extends Plugin * * @return boolean hook value */ - function onEndAdminPanelNav($nav) + function onEndAdminPanelNav(Menu $nav) { if (AdminPanelAction::canAdmin('blacklist')) { @@ -391,7 +348,7 @@ class BlacklistPlugin extends Plugin return true; } - function onEndDeleteUserForm($action, $user) + function onEndDeleteUserForm(Action $action, User $user) { $cur = common_current_user(); @@ -429,7 +386,7 @@ class BlacklistPlugin extends Plugin $action->elementEnd('ul'); } - function onEndDeleteUser($action, $user) + function onEndDeleteUser(Action $action, User $user) { if ($action->boolean('blacklisthomepage')) { $pattern = $action->trimmed('blacklisthomepagepattern'); @@ -444,7 +401,7 @@ class BlacklistPlugin extends Plugin return true; } - function checkboxAndText($action, $checkID, $label, $textID, $value) + private function checkboxAndText(Action $action, $checkID, $label, $textID, $value) { $action->element('input', array('name' => $checkID, 'type' => 'checkbox', @@ -476,17 +433,17 @@ class BlacklistPlugin extends Plugin return $hostname; } - function onStartHandleFeedEntry($activity) + function onStartHandleFeedEntry(Activity $activity) { return $this->_checkActivity($activity); } - function onStartHandleSalmon($activity) + function onStartHandleSalmon(Activity $activity) { return $this->_checkActivity($activity); } - function _checkActivity($activity) + function _checkActivity(Activity $activity) { $actor = $activity->actor; @@ -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) {