* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
-
class UserFlagPlugin extends Plugin
{
const REVIEWFLAGS = 'UserFlagPlugin::reviewflags';
*
* @return boolean hook return
*/
-
function onCheckSchema()
{
$schema = Schema::get();
*
* @return boolean hook return
*/
-
function onRouterInitialized($m)
{
$m->connect('main/flag/profile', array('action' => 'flagprofile'));
*
* @return boolean hook return
*/
-
function onAutoload($cls)
{
switch (strtolower($cls))
*
* @return boolean hook result
*/
-
function onEndProfilePageActionsElements(&$action, $profile)
{
$user = common_current_user();
$action->elementStart('li', 'entity_flag');
if (User_flag_profile::exists($profile->id, $user->id)) {
+ // @todo FIXME: Add a title explaining what 'flagged' means?
+ // TRANS: Message added to a profile if it has been flagged for review.
$action->element('p', 'flagged', _('Flagged'));
} else {
$form = new FlagProfileForm($action, $profile,
*
* @return boolean hook result
*/
-
function onEndProfileListItemActionElements($item)
{
$user = common_current_user();
*
* @return boolean hook result
*/
-
function onEndShowScripts($action)
{
$action->inlineScript('if ($(".form_entity_flag").length > 0) { '.
*
* @return boolean hook result
*/
-
function onUserRightsCheck($user, $right, &$result)
{
switch ($right) {
*
* @return boolean hook result
*/
-
function onEndBlockProfile($user, $profile)
{
if ($this->flagOnBlock && !User_flag_profile::exists($profile->id,
*
* @return boolean hook result
*/
-
function onProfileDeleteRelated($profile, &$related)
{
$related[] = 'user_flag_profile';
*
* @return boolean hook result
*/
-
function onUserDeleteRelated($user, &$related)
{
$related[] = 'user_flag_profile';
return true;
}
+
+ /**
+ * Provide plugin version information.
+ *
+ * This data is used when showing the version page.
+ *
+ * @param array &$versions array of version data arrays; see EVENTS.txt
+ *
+ * @return boolean hook value
+ */
+ function onPluginVersion(&$versions)
+ {
+ $url = 'http://status.net/wiki/Plugin:UserFlag';
+
+ $versions[] = array('name' => 'UserFlag',
+ 'version' => STATUSNET_VERSION,
+ 'author' => 'Evan Prodromou',
+ 'homepage' => $url,
+ 'rawdescription' =>
+ // TRANS: Plugin description.
+ _m('This plugin allows flagging of profiles for review and reviewing flagged profiles.'));
+
+ return true;
+ }
}
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/
*/
-
class User_flag_profile extends Memcached_DataObject
{
###START_AUTOCODE
*
* @return array array of column definitions
*/
-
function table()
{
return array(
*
* @return array key definitions
*/
-
function keys()
{
return array('profile_id' => 'K', 'user_id' => 'K');
*
* @return array key definitions
*/
-
function keyTypes()
{
return $this->keys();
*
* @return User_flag_profile found object or null
*/
-
function pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('User_flag_profile', $kv);
*
* @return boolean true if exists, else false
*/
-
static function exists($profile_id, $user_id)
{
$ufp = User_flag_profile::pkeyGet(array('profile_id' => $profile_id,
*
* @return boolean success flag
*/
-
static function create($user_id, $profile_id)
{
$ufp = new User_flag_profile();
$ufp->created = common_sql_now();
if (!$ufp->insert()) {
- $msg = sprintf(_("Couldn't flag profile '%d' for review."),
+ // TRANS: Server exception.
+ $msg = sprintf(_m('Couldn\'t flag profile "%d" for review.'),
$profile_id);
throw new ServerException($msg);
}
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/
*/
-
class AdminprofileflagAction extends Action
{
var $page = null;
*
* @return boolean success flag
*/
-
function prepare($args)
{
parent::prepare($args);
*
* @return void
*/
-
function handle($args)
{
parent::handle($args);
*
* @return string Title of the page
*/
-
function title()
{
- return _('Flagged profiles');
+ // TRANS: Title for page with a list of profiles that were flagged for review.
+ return _m('Flagged profiles');
}
/**
*
* @return void
*/
-
function showContent()
{
$pl = new FlaggedProfileList($this->profiles, $this);
*
* @return Profile $profile Profile query results
*/
-
function getProfiles()
{
$ufp = new User_flag_profile();
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/
*/
-
class FlaggedProfileList extends ProfileList
{
/**
*
* @return ProfileListItem newly-created item
*/
-
function newListItem($profile)
{
return new FlaggedProfileListItem($this->profile, $this->action);
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/
*/
-
class FlaggedProfileListItem extends ProfileListItem
{
const MAX_FLAGGERS = 5;
*
* @return void
*/
-
function showActions()
{
$this->user = common_current_user();
$this->startActions();
if (Event::handle('StartProfileListItemActionElements', array($this))) {
$this->out->elementStart('li', 'entity_moderation');
- $this->out->element('p', null, _('Moderate'));
+ // TRANS: Header for moderation menu with action buttons for flagged profiles (like 'sandbox', 'silence', ...).
+ $this->out->element('p', null, _m('Moderate'));
$this->out->elementStart('ul');
$this->showSandboxButton();
$this->showSilenceButton();
*
* @return void
*/
-
function showSandboxButton()
{
if ($this->user->hasRight(Right::SANDBOXUSER)) {
*
* @return void
*/
-
function showSilenceButton()
{
if ($this->user->hasRight(Right::SILENCEUSER)) {
*
* @return void
*/
-
function showDeleteButton()
{
*
* @return void
*/
-
function showClearButton()
{
if ($this->user->hasRight(UserFlagPlugin::CLEARFLAGS)) {
*
* @return void
*/
-
function endProfile()
{
$this->showFlaggersList();
*
* @return void
*/
-
function showFlaggersList()
{
$flaggers = array();
}
if ($cnt > 0) {
- $text = _('Flagged by ');
-
- $text .= implode(', ', $lnks);
-
if ($others > 0) {
- $text .= sprintf(_(' and %d others'), $others);
+ $flagging_users = implode(', ', $lnks);
+ // TRANS: Message displayed on a profile if it has been flagged.
+ // TRANS: %1$s is a comma separated list of at most 5 user nicknames that flagged.
+ // TRANS: %2$d is a positive integer of additional flagging users. Also used for the plural.
+ $text .= sprintf(_m('Flagged by %1$s and %2$d other', 'Flagged by %1$s and %2$d others', $others), $flagging_users, $others);
+ } else {
+ // TRANS: Message displayed on a profile if it has been flagged.
+ // TRANS: %s is a comma separated list of at most 5 user nicknames that flagged.
+ $text .= sprintf(_m('Flagged by %s'), $flagging_users);
}
$this->out->elementStart('p', array('class' => 'flaggers'));
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/
*/
-
class ClearflagAction extends ProfileFormAction
{
/**
*
* @return void
*/
-
function handle($args)
{
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
*
* @return void
*/
-
function handlePost()
{
$ufp = new User_flag_profile();
'AND profile_id = ' . $this->profile->id);
if ($result == false) {
- $msg = sprintf(_("Couldn't clear flags for profile '%s'."),
+ // TRANS: Server exception given when flags could not be cleared.
+ $msg = sprintf(_m('Couldn\'t clear flags for profile "%s".'),
$this->profile->nickname);
throw new ServerException($msg);
}
*
* @return void
*/
-
function ajaxResults()
{
header('Content-Type: text/xml;charset=utf-8');
$this->xw->startDocument('1.0', 'UTF-8');
$this->elementStart('html');
$this->elementStart('head');
- $this->element('title', null, _('Flags cleared'));
+ // TRANS: Title for AJAX form to indicated that flags were removed.
+ $this->element('title', null, _m('Flags cleared'));
$this->elementEnd('head');
$this->elementStart('body');
- $this->element('p', 'cleared', _('Cleared'));
+ // TRANS: Body element for "flags cleared" form.
+ $this->element('p', 'cleared', _m('Cleared'));
$this->elementEnd('body');
$this->elementEnd('html');
}
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
-
class ClearFlagForm extends ProfileActionForm
{
/**
*
* @return string class of the form
*/
-
function formClass()
{
return 'form_user_clearflag';
*
* @return string Name of the action, lowercased.
*/
-
function target()
{
return 'clearflag';
*
* @return string Title of the form, internationalized
*/
-
function title()
{
- return _('Clear');
+ // TRANS: Form title for action on a profile.
+ return _m('Clear');
}
/**
function description()
{
- return _('Clear all flags');
+ // Form description for clearing flags from a profile.
+ return _m('Clear all flags');
}
}
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://status.net/
*/
-
class FlagprofileAction extends ProfileFormAction
{
/**
*
* @return boolean success flag
*/
-
function prepare($args)
{
if (!parent::prepare($args)) {
if (User_flag_profile::exists($this->profile->id,
$user->id)) {
- $this->clientError(_('Flag already exists.'));
+ // TRANS: Client error when setting flag that has already been set for a profile.
+ $this->clientError(_m('Flag already exists.'));
return false;
}
*
* @return void
*/
-
function handle($args)
{
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
*
* @return void
*/
-
function handlePost()
{
$user = common_current_user();
*
* @return void
*/
-
function ajaxResults()
{
header('Content-Type: text/xml;charset=utf-8');
$this->xw->startDocument('1.0', 'UTF-8');
$this->elementStart('html');
$this->elementStart('head');
- $this->element('title', null, _('Flagged for review'));
+ // TRANS: AJAX form title for a flagged profile.
+ $this->element('title', null, _m('Flagged for review'));
$this->elementEnd('head');
$this->elementStart('body');
- $this->element('p', 'flagged', _('Flagged'));
+ // TRANS: Body text for AJAX form when a profile has been flagged for review.
+ $this->element('p', 'flagged', _m('Flagged'));
$this->elementEnd('body');
$this->elementEnd('html');
}
}
-
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
*/
-
class FlagProfileForm extends ProfileActionForm
{
/**
*
* @return string class of the form
*/
-
function formClass()
{
return 'form_entity_flag';
*
* @return string Name of the action, lowercased.
*/
-
function target()
{
return 'flagprofile';
*
* @return string Title of the form, internationalized
*/
-
function title()
{
- return _('Flag');
+ // TRANS: Form title for flagging a profile for review.
+ return _m('Flag');
}
/**
*
* @return string description of the form, internationalized
*/
-
function description()
{
- return _('Flag profile for review');
+ // TRANS: Form description.
+ return _m('Flag profile for review.');
}
}