UserFlagPlugin fix for ticket #2118 and ticket #2847: flagged state wasn't reflected in profile lists such as group members page and profile search .
Pulled common code for the profile page and profile list cases to give them the same logic on checking. Also fixes the problem that you'd get a flag button for yourself in profile lists, while we explicitly exclude that from the profile page -- it's now skipped in both places.
This commit is contained in:
parent
8e04e88800
commit
a3928e5583
|
@ -128,25 +128,9 @@ class UserFlagPlugin extends Plugin
|
||||||
*/
|
*/
|
||||||
function onEndProfilePageActionsElements(&$action, $profile)
|
function onEndProfilePageActionsElements(&$action, $profile)
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
$this->showFlagButton($action, $profile,
|
||||||
|
array('action' => 'showstream',
|
||||||
if (!empty($user) && ($user->id != $profile->id)) {
|
'nickname' => $profile->nickname));
|
||||||
|
|
||||||
$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');
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -160,24 +144,42 @@ class UserFlagPlugin extends Plugin
|
||||||
*/
|
*/
|
||||||
function onEndProfileListItemActionElements($item)
|
function onEndProfileListItemActionElements($item)
|
||||||
{
|
{
|
||||||
$user = common_current_user();
|
list($action, $args) = $item->action->returnToArgs();
|
||||||
|
$args['action'] = $action;
|
||||||
if (!empty($user)) {
|
$this->showFlagButton($item->action, $item->profile, $args);
|
||||||
|
|
||||||
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');
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
* @param Profile $profile
|
||||||
|
* @param array $returnToArgs
|
||||||
|
*/
|
||||||
|
protected function showFlagButton($action, $profile, $returnToArgs)
|
||||||
|
{
|
||||||
|
$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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize any flagging buttons on the page
|
* Initialize any flagging buttons on the page
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue
Block a user