$schema = Schema::get();
// For storing user-submitted flags on profiles
-
- $schema->ensureTable('user_flag_profile',
- array(new ColumnDef('profile_id', 'integer', null,
- false, 'PRI'),
- new ColumnDef('user_id', 'integer', null,
- false, 'PRI'),
- new ColumnDef('created', 'datetime', null,
- false, 'MUL'),
- new ColumnDef('cleared', 'datetime', null,
- true, 'MUL')));
-
+ $schema->ensureTable('user_flag_profile', User_flag_profile::schemaDef());
return true;
}
/**
* 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('main/flag/profile', array('action' => 'flagprofile'));
$m->connect('main/flag/clear', array('action' => 'clearflag'));
- $m->connect('admin/profile/flag', array('action' => 'adminprofileflag'));
+ $m->connect('panel/profile/flag', array('action' => 'adminprofileflag'));
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 'flagprofileaction':
- case 'adminprofileflagaction':
- case 'clearflagaction':
- include_once INSTALLDIR.'/plugins/UserFlag/' .
- strtolower(mb_substr($cls, 0, -6)) . '.php';
- return false;
- case 'flagprofileform':
- case 'clearflagform':
- include_once INSTALLDIR.'/plugins/UserFlag/' . strtolower($cls . '.php');
- return false;
- case 'user_flag_profile':
- include_once INSTALLDIR.'/plugins/UserFlag/'.ucfirst(strtolower($cls)).'.php';
- return false;
- default:
- return true;
- }
- }
-
/**
* Add a 'flag' button to profile page
*
- * @param Action &$action The action being called
+ * @param Action $action The action being called
* @param Profile $profile Profile being shown
*
* @return boolean hook result
*/
- function onEndProfilePageActionsElements(&$action, $profile)
+ function onEndProfilePageActionsElements($action, $profile)
{
- $user = common_current_user();
-
- if (!empty($user) && ($user->id != $profile->id)) {
-
- $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,
- array('action' => 'showstream',
- 'nickname' => $profile->nickname));
- $form->show();
- }
-
- $action->elementEnd('li');
- }
+ $this->showFlagButton($action, $profile,
+ array('action' => 'showstream',
+ 'nickname' => $profile->nickname));
return true;
}
*/
function onEndProfileListItemActionElements($item)
{
- $user = common_current_user();
-
- if (!empty($user)) {
-
- list($action, $args) = $item->action->returnToArgs();
-
- $args['action'] = $action;
-
- $form = new FlagProfileForm($item->action, $item->profile, $args);
-
- $item->action->elementStart('li', 'entity_flag');
- $form->show();
- $item->action->elementEnd('li');
- }
+ list($action, $args) = $item->action->returnToArgs();
+ $args['action'] = $action;
+ $this->showFlagButton($item->action, $item->profile, $args);
return true;
}
/**
- * Initialize any flagging buttons on the page
+ * Actually output a flag button. If the target profile has already been
+ * flagged by the current user, a null-action faux button is shown.
*
- * @param Action $action action being shown
- *
- * @return boolean hook result
+ * @param Action $action
+ * @param Profile $profile
+ * @param array $returnToArgs
*/
- function onEndShowScripts($action)
+ protected function showFlagButton($action, $profile, $returnToArgs)
{
- $action->inlineScript('if ($(".form_entity_flag").length > 0) { '.
- '$(".form_entity_flag").bind("click", function() {'.
- 'SN.U.FormXHR($(this)); return false; }); }');
- return true;
+ $user = common_current_user();
+
+ if (!empty($user) && ($user->id != $profile->id)) {
+
+ $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', _m('Flagged'));
+ } else {
+ $form = new FlagProfileForm($action, $profile, $returnToArgs);
+ $form->show();
+ }
+
+ $action->elementEnd('li');
+ }
}
/**
*
* @return boolean hook value
*/
- function onPluginVersion(&$versions)
+ function onPluginVersion(array &$versions)
{
- $url = 'http://status.net/wiki/Plugin:UserFlag';
+ $url = 'https://git.gnu.io/gnu/gnu-social/tree/master/plugins/UserFlag';
$versions[] = array('name' => 'UserFlag',
- 'version' => STATUSNET_VERSION,
+ 'version' => GNUSOCIAL_VERSION,
'author' => 'Evan Prodromou',
'homepage' => $url,
'rawdescription' =>