Changeset View
Changeset View
Standalone View
Standalone View
src/applications/people/markup/PhabricatorMentionRemarkupRule.php
Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | public function didMarkupText() { | ||||
$mentioned_key = self::KEY_MENTIONED; | $mentioned_key = self::KEY_MENTIONED; | ||||
$mentioned = $engine->getTextMetadata($mentioned_key, array()); | $mentioned = $engine->getTextMetadata($mentioned_key, array()); | ||||
foreach ($users as $row) { | foreach ($users as $row) { | ||||
$actual_users[strtolower($row->getUserName())] = $row; | $actual_users[strtolower($row->getUserName())] = $row; | ||||
$mentioned[$row->getPHID()] = $row->getPHID(); | $mentioned[$row->getPHID()] = $row->getPHID(); | ||||
} | } | ||||
$engine->setTextMetadata($mentioned_key, $mentioned); | $engine->setTextMetadata($mentioned_key, $mentioned); | ||||
$context_object = $engine->getConfig('contextObject'); | |||||
epriestley: Prefer `$context_object` for consistency. | |||||
foreach ($metadata as $username => $tokens) { | foreach ($metadata as $username => $tokens) { | ||||
$exists = isset($actual_users[$username]); | $exists = isset($actual_users[$username]); | ||||
$user_has_no_permission = false; | |||||
if ($exists) { | if ($exists) { | ||||
$user = $actual_users[$username]; | $user = $actual_users[$username]; | ||||
Javelin::initBehavior('phabricator-hovercards'); | Javelin::initBehavior('phabricator-hovercards'); | ||||
// Check if the user has view access to the object she was mentioned in | |||||
if ($context_object | |||||
&& $context_object instanceof PhabricatorPolicyInterface) { | |||||
if (!PhabricatorPolicyFilter::hasCapability( | |||||
$user, | |||||
$context_object, | |||||
PhabricatorPolicyCapability::CAN_VIEW)) { | |||||
// User mentioned has no permission to this object | |||||
$user_has_no_permission = true; | |||||
} | |||||
} | |||||
$user_href = '/p/'.$user->getUserName().'/'; | $user_href = '/p/'.$user->getUserName().'/'; | ||||
if ($engine->isHTMLMailMode()) { | if ($engine->isHTMLMailMode()) { | ||||
$user_href = PhabricatorEnv::getProductionURI($user_href); | $user_href = PhabricatorEnv::getProductionURI($user_href); | ||||
Not Done Inline ActionsLet's change these properties for now: border-color: #92969D; color: #92969D; background: #F7F7F7; And keep everything else the same. I think that'll look reasonable, and it's easy to tweak later. epriestley: Let's change these properties for now:
border-color: #92969D;
color: #92969D;
background… | |||||
if ($user_has_no_permission) { | |||||
Not Done Inline ActionsWe should move to CSS, inline styles are an old-old-Phabricator relic. chad: We should move to CSS, inline styles are an old-old-Phabricator relic. | |||||
$colors = ' | |||||
border-color: #92969D; | |||||
color: #92969D; | |||||
background-color: #F7F7F7;'; | |||||
} else { | |||||
$colors = ' | |||||
border-color: #f1f7ff; | |||||
color: #19558d; | |||||
background-color: #f1f7ff;'; | |||||
} | |||||
$tag = phutil_tag( | $tag = phutil_tag( | ||||
'a', | 'a', | ||||
array( | array( | ||||
'href' => $user_href, | 'href' => $user_href, | ||||
'style' => 'background-color: #f1f7ff; | 'style' => $colors.' | ||||
border-color: #f1f7ff; | |||||
border: 1px solid transparent; | border: 1px solid transparent; | ||||
border-radius: 3px; | border-radius: 3px; | ||||
color: #19558d; | |||||
font-weight: bold; | font-weight: bold; | ||||
padding: 0 4px;', | padding: 0 4px;', | ||||
), | ), | ||||
'@'.$user->getUserName()); | '@'.$user->getUserName()); | ||||
} else { | } else { | ||||
$tag = id(new PHUITagView()) | $tag = id(new PHUITagView()) | ||||
->setType(PHUITagView::TYPE_PERSON) | ->setType(PHUITagView::TYPE_PERSON) | ||||
->setPHID($user->getPHID()) | ->setPHID($user->getPHID()) | ||||
->setName('@'.$user->getUserName()) | ->setName('@'.$user->getUserName()) | ||||
->setHref($user_href); | ->setHref($user_href); | ||||
if ($user_has_no_permission) { | |||||
$tag->addClass('phabricator-remarkup-mention-nopermission'); | |||||
Not Done Inline ActionsLet's add this: $tag->addClass('phabricator-remarkup-mention-nopermission'); Then add this rule to webroot/rsrc/css/core/remarkup.css: .phabricator-remarkup-mention-nopermission .phui-tag-core { background: {$lightgreybackground}; color: {$lightgreytext}; } epriestley: Let's add this:
$tag->addClass('phabricator-remarkup-mention-nopermission');
Then add this… | |||||
} | |||||
Not Done Inline ActionsIt might also be nice to do: $tag->addSigil('has-tooltip'); $tag->setMetadata( array( 'tip' => pht( 'This user does not have permission to view this page.'), 'size' => 350, )); ...but I think that might be overkill. Let's try without that first and see if the feature is confusing to users. epriestley: It might also be nice to do:
$tag->addSigil('has-tooltip');
$tag… | |||||
if (!$user->isUserActivated()) { | if (!$user->isUserActivated()) { | ||||
$tag->setDotColor(PHUITagView::COLOR_GREY); | $tag->setDotColor(PHUITagView::COLOR_GREY); | ||||
} else { | } else { | ||||
$status = idx($user_statuses, $user->getPHID()); | $status = idx($user_statuses, $user->getPHID()); | ||||
if ($status) { | if ($status) { | ||||
$status = $status->getStatus(); | $status = $status->getStatus(); | ||||
if ($status == PhabricatorCalendarEvent::STATUS_AWAY) { | if ($status == PhabricatorCalendarEvent::STATUS_AWAY) { | ||||
$tag->setDotColor(PHUITagView::COLOR_RED); | $tag->setDotColor(PHUITagView::COLOR_RED); | ||||
Show All 31 Lines |
Prefer $context_object for consistency.