*/
class BlacklistPlugin extends Plugin
{
- const VERSION = STATUSNET_VERSION;
+ const VERSION = GNUSOCIAL_VERSION;
public $nicknames = array();
public $urls = array();
$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;
}
*
* @return boolean hook value
*/
- function onStartRegisterUser(&$user, &$profile)
+ function onStartRegisterUser(User &$user, Profile &$profile)
{
$homepage = strtolower($profile->homepage);
/**
* 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
*
*
* @return boolean hook value
*/
- function onPluginVersion(&$versions)
+ function onPluginVersion(array &$versions)
{
$versions[] = array('name' => 'Blacklist',
'version' => self::VERSION,
}
}
- $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);
+ }
}
}
/**
* 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) {