Changeset View
Changeset View
Standalone View
Standalone View
src/applications/people/markup/PhabricatorMentionRemarkupRule.php
| Show First 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | public function didMarkupText() { | ||||
| 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'); | $context_object = $engine->getConfig('contextObject'); | ||||
| $policy_object = null; | |||||
| if ($context_object) { | |||||
| if ($context_object instanceof PhabricatorPolicyInterface) { | |||||
| $policy_object = $context_object; | |||||
| } | |||||
| } | |||||
| if ($policy_object) { | |||||
| $policy_set = new PhabricatorPolicyFilterSet(); | |||||
| foreach ($actual_users as $user) { | |||||
| $policy_set->addCapability( | |||||
| $user, | |||||
| $policy_object, | |||||
| PhabricatorPolicyCapability::CAN_VIEW); | |||||
| } | |||||
| } | |||||
| 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; | $user_can_not_view = false; | ||||
| if ($exists) { | if ($exists) { | ||||
| $user = $actual_users[$username]; | $user = $actual_users[$username]; | ||||
| Javelin::initBehavior('phui-hovercards'); | Javelin::initBehavior('phui-hovercards'); | ||||
| // Check if the user has view access to the object she was mentioned in | // Check if the user has view access to the object she was mentioned in | ||||
| if ($context_object | if ($policy_object) { | ||||
| && $context_object instanceof PhabricatorPolicyInterface) { | $user_can_not_view = !$policy_set->hasCapability( | ||||
| if (!PhabricatorPolicyFilter::hasCapability( | |||||
| $user, | $user, | ||||
| $context_object, | $policy_object, | ||||
| PhabricatorPolicyCapability::CAN_VIEW)) { | 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); | ||||
| if ($user_has_no_permission) { | if ($user_can_not_view) { | ||||
| $colors = ' | $colors = ' | ||||
| border-color: #92969D; | border-color: #92969D; | ||||
| color: #92969D; | color: #92969D; | ||||
| background-color: #F7F7F7;'; | background-color: #F7F7F7;'; | ||||
| } else { | } else { | ||||
| $colors = ' | $colors = ' | ||||
| border-color: #f1f7ff; | border-color: #f1f7ff; | ||||
| color: #19558d; | color: #19558d; | ||||
| Show All 17 Lines | foreach ($metadata as $username => $tokens) { | ||||
| } | } | ||||
| $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) { | if ($user_can_not_view) { | ||||
| $tag->addClass('phabricator-remarkup-mention-nopermission'); | $tag->addClass('phabricator-remarkup-mention-nopermission'); | ||||
| } | } | ||||
| if ($user->getIsDisabled()) { | if ($user->getIsDisabled()) { | ||||
| $tag->setDotColor(PHUITagView::COLOR_GREY); | $tag->setDotColor(PHUITagView::COLOR_GREY); | ||||
| } else if (!$user->isResponsive()) { | } else if (!$user->isResponsive()) { | ||||
| $tag->setDotColor(PHUITagView::COLOR_VIOLET); | $tag->setDotColor(PHUITagView::COLOR_VIOLET); | ||||
| } else { | } else { | ||||
| Show All 35 Lines | |||||