var $contact;
var $debug;
- function onInitializePlugin()
+ function onInitializePlugin()
{
if(!isset($this->debug))
{
if (!empty($default)) {
$this->contact = $default;
}
- }
+ }
}
function onPluginVersion(&$versions)
function onStartRegistrationFormData($action)
{
-
- $instr = 'Note you will initially be "sandboxed" so your posts will not appear in the public timeline.';
+ $instr = _m('Note you will initially be "sandboxed" so your posts will not appear in the public timeline.');
if (isset($this->contact)) {
$contactuser = User::staticGet('nickname', $this->contact);
if (!empty($contactuser)) {
$contactlink = "@<a href=\"$contactuser->uri\">$contactuser->nickname</a>";
- $instr = $instr . " Send a message to $contactlink to speed up the unsandboxing process.";
+ $instr = _m("Note you will initially be \"sandboxed\" so your posts will not appear in the public timeline. ".
+ 'Send a message to $contactlink to speed up the unsandboxing process.');
}
- }
+ }
$output = common_markup_to_html($instr);
$action->elementStart('div', 'instructions');
function onInitializePlugin(){
parent::onInitializePlugin();
if(!isset($this->serviceUrl)){
- throw new Exception("must specify a serviceUrl");
+ throw new Exception(_m("You must specify a serviceUrl."));
}
}
return true;
}
}
-
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
-
class BlacklistPlugin extends Plugin
{
const VERSION = STATUSNET_VERSION;
*
* @return boolean hook value
*/
-
function onCheckSchema()
{
$schema = Schema::get();
// For storing blacklist patterns for nicknames
-
$schema->ensureTable('nickname_blacklist',
array(new ColumnDef('pattern',
'varchar',
*
* @return array configuration values
*/
-
function _configArray($section, $setting)
{
$config = common_config($section, $setting);
*
* @return boolean hook value
*/
-
function onStartRegistrationTry($action)
{
$homepage = strtolower($action->trimmed('homepage'));
if (!empty($homepage)) {
if (!$this->_checkUrl($homepage)) {
- $msg = sprintf(_m("You may not register with homepage '%s'"),
+ $msg = sprintf(_m("You may not register with homepage '%s'."),
$homepage);
throw new ClientException($msg);
}
if (!empty($nickname)) {
if (!$this->_checkNickname($nickname)) {
- $msg = sprintf(_m("You may not register with nickname '%s'"),
+ $msg = sprintf(_m("You may not register with nickname '%s'."),
$nickname);
throw new ClientException($msg);
}
*
* @return boolean hook value
*/
-
function onStartProfileSaveForm($action)
{
$homepage = strtolower($action->trimmed('homepage'));
if (!empty($homepage)) {
if (!$this->_checkUrl($homepage)) {
- $msg = sprintf(_m("You may not use homepage '%s'"),
+ $msg = sprintf(_m("You may not use homepage '%s'."),
$homepage);
throw new ClientException($msg);
}
if (!empty($nickname)) {
if (!$this->_checkNickname($nickname)) {
- $msg = sprintf(_m("You may not use nickname '%s'"),
+ $msg = sprintf(_m("You may not use nickname '%s'."),
$nickname);
throw new ClientException($msg);
}
*
* @return boolean hook value
*/
-
function onStartNoticeSave(&$notice)
{
common_replace_urls_callback($notice->content,
*
* @return boolean hook value
*/
-
function checkNoticeUrl($url)
{
// It comes in special'd, so we unspecial it
$url = htmlspecialchars_decode($url);
if (!$this->_checkUrl($url)) {
- $msg = sprintf(_m("You may not use url '%s' in notices"),
+ $msg = sprintf(_m("You may not use UTL \"%s\" in notices."),
$url);
throw new ClientException($msg);
}
*
* @return boolean true means it's OK, false means it's bad
*/
-
private function _checkUrl($url)
{
$patterns = $this->_getUrlPatterns();
*
* @return boolean true means it's OK, false means it's bad
*/
-
private function _checkNickname($nickname)
{
$patterns = $this->_getNicknamePatterns();
*
* @return boolean hook return
*/
-
function onRouterInitialized($m)
{
$m->connect('admin/blacklist', array('action' => 'blacklistadminpanel'));
*
* @return boolean hook return
*/
-
function onAutoload($cls)
{
switch (strtolower($cls))
*
* @return boolean hook value
*/
-
function onPluginVersion(&$versions)
{
$versions[] = array('name' => 'Blacklist',
'homepage' =>
'http://status.net/wiki/Plugin:Blacklist',
'description' =>
- _m('Keep a blacklist of forbidden nickname '.
+ _m('Keeps a blacklist of forbidden nickname '.
'and URL patterns.'));
return true;
}
*
* @return boolean hook value
*/
-
function onEndAdminPanelNav($nav)
{
if (AdminPanelAction::canAdmin('blacklist')) {
$action_name = $nav->action->trimmed('action');
$nav->out->menuItem(common_local_url('blacklistadminpanel'),
- _('Blacklist'),
- _('Blacklist configuration'),
+ _m('Blacklist'),
+ _m('Blacklist configuration'),
$action_name == 'blacklistadminpanel',
'nav_blacklist_admin_panel');
}
$action->elementStart('li');
$this->checkboxAndText($action,
'blacklistnickname',
- _('Add this nickname pattern to blacklist'),
+ _m('Add this nickname pattern to blacklist'),
'blacklistnicknamepattern',
$this->patternizeNickname($user->nickname));
$action->elementEnd('li');
$action->elementStart('li');
$this->checkboxAndText($action,
'blacklisthomepage',
- _('Add this homepage pattern to blacklist'),
+ _m('Add this homepage pattern to blacklist'),
'blacklisthomepagepattern',
$this->patternizeHomepage($profile->homepage));
$action->elementEnd('li');
*
* @see DB_DataObject
*/
-
class Homepage_blacklist extends Memcached_DataObject
{
public $__table = 'homepage_blacklist'; // table name
* @return Homepage_blacklist object found, or null for no hits
*
*/
-
function staticGet($k, $v=null)
{
return Memcached_DataObject::staticGet('Homepage_blacklist', $k, $v);
*
* @return array array of column definitions
*/
-
function table()
{
return array('pattern' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
*
* @return array key definitions
*/
-
function keys()
{
return array_keys($this->keyTypes());
*
* @return array key definitions
*/
-
function keyTypes()
{
return array('pattern' => 'K');
*
* @return array string patterns to check
*/
-
static function getPatterns()
{
$patterns = self::cacheGet('homepage_blacklist:patterns');
*
* @return array of patterns to check
*/
-
static function saveNew($newPatterns)
{
$oldPatterns = self::getPatterns();
// Delete stuff that's old that not in new
-
$toDelete = array_diff($oldPatterns, $newPatterns);
// Insert stuff that's in new and not in old
-
$toInsert = array_diff($newPatterns, $oldPatterns);
foreach ($toDelete as $pattern) {
*
* @see DB_DataObject
*/
-
class Nickname_blacklist extends Memcached_DataObject
{
public $__table = 'nickname_blacklist'; // table name
* @return Nickname_blacklist object found, or null for no hits
*
*/
-
function staticGet($k, $v=null)
{
return Memcached_DataObject::staticGet('Nickname_blacklist', $k, $v);
*
* @return array array of column definitions
*/
-
function table()
{
return array('pattern' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
*
* @return array key definitions
*/
-
function keys()
{
return array_keys($this->keyTypes());
*
* @return array key definitions
*/
-
function keyTypes()
{
return array('pattern' => 'K');
*
* @return array string patterns to check
*/
-
static function getPatterns()
{
$patterns = self::cacheGet('nickname_blacklist:patterns');
*
* @return array of patterns to check
*/
-
static function saveNew($newPatterns)
{
$oldPatterns = self::getPatterns();
// Delete stuff that's old that not in new
-
$toDelete = array_diff($oldPatterns, $newPatterns);
// Insert stuff that's in new and not in old
-
$toInsert = array_diff($newPatterns, $oldPatterns);
foreach ($toDelete as $pattern) {
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
* @link http://status.net/
*/
-
class BlacklistadminpanelAction extends AdminPanelAction
{
/**
*
* @return string title
*/
-
function title()
{
- return _('Blacklist');
+ return _m('Blacklist');
}
/**
*
* @return string instructions
*/
-
function getInstructions()
{
- return _('Blacklisted URLs and nicknames');
+ return _m('Blacklisted URLs and nicknames');
}
/**
*
* @see BlacklistAdminPanelForm
*/
-
function showForm()
{
$form = new BlacklistAdminPanelForm($this);
*
* @return void
*/
-
function saveSettings()
{
$nickPatterns = $this->splitPatterns($this->trimmed('blacklist-nicknames'));
*
* @return boolean success flag
*/
-
function validate(&$values)
{
return true;
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
* @link http://status.net/
*/
-
class BlacklistAdminPanelForm extends Form
{
/**
*
* @return string ID
*/
-
function id()
{
return 'blacklistadminpanel';
*
* @return string class
*/
-
function formClass()
{
return 'form_settings';
*
* @return string action URL
*/
-
function action()
{
return common_local_url('blacklistadminpanel');
*
* @return void
*/
-
function formData()
{
$this->out->elementStart('ul', 'form_data');
$this->out->textarea('blacklist-nicknames', _m('Nicknames'),
implode("\r\n", $nickPatterns),
- _('Patterns of nicknames to block, one per line'));
+ _m('Patterns of nicknames to block, one per line'));
$this->out->elementEnd('li');
$urlPatterns = Homepage_blacklist::getPatterns();
$this->out->elementStart('li');
$this->out->textarea('blacklist-urls', _m('URLs'),
implode("\r\n", $urlPatterns),
- _('Patterns of URLs to block, one per line'));
+ _m('Patterns of URLs to block, one per line'));
$this->out->elementEnd('li');
$this->out->elementEnd('ul');
*
* @return void
*/
-
function formActions()
{
$this->out->submit('submit',
- _('Save'),
+ _m('Save'),
'submit',
null,
- _('Save site settings'));
+ _m('Save site settings'));
}
}