diff --git a/src/applications/calendar/storage/PhabricatorCalendarEventInvitee.php b/src/applications/calendar/storage/PhabricatorCalendarEventInvitee.php index 34d4c85fcf..b238b614ab 100644 --- a/src/applications/calendar/storage/PhabricatorCalendarEventInvitee.php +++ b/src/applications/calendar/storage/PhabricatorCalendarEventInvitee.php @@ -1,127 +1,127 @@ setInviterPHID($actor->getPHID()) ->setStatus(self::STATUS_INVITED) ->setEventPHID($event->getPHID()); } protected function getConfiguration() { return array( self::CONFIG_COLUMN_SCHEMA => array( 'status' => 'text64', 'availability' => 'text64', ), self::CONFIG_KEY_SCHEMA => array( 'key_event' => array( 'columns' => array('eventPHID', 'inviteePHID'), 'unique' => true, ), 'key_invitee' => array( 'columns' => array('inviteePHID'), ), ), ) + parent::getConfiguration(); } public function isAttending() { return ($this->getStatus() == self::STATUS_ATTENDING); } public function isUninvited() { if ($this->getStatus() == self::STATUS_UNINVITED) { return true; } else { return false; } } public function getDisplayAvailability(PhabricatorCalendarEvent $event) { switch ($this->getAvailability()) { case self::AVAILABILITY_DEFAULT: case self::AVAILABILITY_BUSY: return self::AVAILABILITY_BUSY; case self::AVAILABILITY_AWAY: return self::AVAILABILITY_AWAY; default: return null; } } public static function getAvailabilityMap() { return array( self::AVAILABILITY_AVAILABLE => array( 'color' => 'green', 'name' => pht('Available'), ), self::AVAILABILITY_BUSY => array( - 'color' => 'yellow', + 'color' => 'orange', 'name' => pht('Busy'), ), self::AVAILABILITY_AWAY => array( 'color' => 'red', 'name' => pht('Away'), ), ); } public static function getAvailabilitySpec($const) { return idx(self::getAvailabilityMap(), $const, array()); } public static function getAvailabilityName($const) { $spec = self::getAvailabilitySpec($const); return idx($spec, 'name', $const); } public static function getAvailabilityColor($const) { $spec = self::getAvailabilitySpec($const); return idx($spec, 'color', 'indigo'); } /* -( PhabricatorPolicyInterface )----------------------------------------- */ public function getCapabilities() { return array( PhabricatorPolicyCapability::CAN_VIEW, ); } public function getPolicy($capability) { switch ($capability) { case PhabricatorPolicyCapability::CAN_VIEW: return PhabricatorPolicies::getMostOpenPolicy(); } } public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { return false; } public function describeAutomaticCapability($capability) { return null; } } diff --git a/src/applications/people/markup/PhabricatorMentionRemarkupRule.php b/src/applications/people/markup/PhabricatorMentionRemarkupRule.php index 8049866118..92697f018c 100644 --- a/src/applications/people/markup/PhabricatorMentionRemarkupRule.php +++ b/src/applications/people/markup/PhabricatorMentionRemarkupRule.php @@ -1,185 +1,190 @@ getEngine(); if ($engine->isTextMode()) { return $engine->storeText($matches[0]); } $token = $engine->storeText(''); // Store the original text exactly so we can preserve casing if it doesn't // resolve into a username. $original_key = self::KEY_RULE_MENTION_ORIGINAL; $original = $engine->getTextMetadata($original_key, array()); $original[$token] = $matches[1]; $engine->setTextMetadata($original_key, $original); $metadata_key = self::KEY_RULE_MENTION; $metadata = $engine->getTextMetadata($metadata_key, array()); $username = strtolower($matches[1]); if (empty($metadata[$username])) { $metadata[$username] = array(); } $metadata[$username][] = $token; $engine->setTextMetadata($metadata_key, $metadata); return $token; } public function didMarkupText() { $engine = $this->getEngine(); $metadata_key = self::KEY_RULE_MENTION; $metadata = $engine->getTextMetadata($metadata_key, array()); if (empty($metadata)) { // No mentions, or we already processed them. return; } $original_key = self::KEY_RULE_MENTION_ORIGINAL; $original = $engine->getTextMetadata($original_key, array()); $usernames = array_keys($metadata); $users = id(new PhabricatorPeopleQuery()) ->setViewer($this->getEngine()->getConfig('viewer')) ->withUsernames($usernames) ->needAvailability(true) ->execute(); $actual_users = array(); $mentioned_key = self::KEY_MENTIONED; $mentioned = $engine->getTextMetadata($mentioned_key, array()); foreach ($users as $row) { $actual_users[strtolower($row->getUserName())] = $row; $mentioned[$row->getPHID()] = $row->getPHID(); } $engine->setTextMetadata($mentioned_key, $mentioned); $context_object = $engine->getConfig('contextObject'); foreach ($metadata as $username => $tokens) { $exists = isset($actual_users[$username]); $user_has_no_permission = false; if ($exists) { $user = $actual_users[$username]; Javelin::initBehavior('phui-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().'/'; if ($engine->isHTMLMailMode()) { $user_href = PhabricatorEnv::getProductionURI($user_href); if ($user_has_no_permission) { $colors = ' border-color: #92969D; color: #92969D; background-color: #F7F7F7;'; } else { $colors = ' border-color: #f1f7ff; color: #19558d; background-color: #f1f7ff;'; } $tag = phutil_tag( 'a', array( 'href' => $user_href, 'style' => $colors.' border: 1px solid transparent; border-radius: 3px; font-weight: bold; padding: 0 4px;', ), '@'.$user->getUserName()); } else { if ($engine->getConfig('uri.full')) { $user_href = PhabricatorEnv::getURI($user_href); } $tag = id(new PHUITagView()) ->setType(PHUITagView::TYPE_PERSON) ->setPHID($user->getPHID()) ->setName('@'.$user->getUserName()) ->setHref($user_href); if ($user_has_no_permission) { $tag->addClass('phabricator-remarkup-mention-nopermission'); } if (!$user->isUserActivated()) { $tag->setDotColor(PHUITagView::COLOR_GREY); } else { if ($user->getAwayUntil()) { - $tag->setDotColor(PHUITagView::COLOR_RED); + $away = PhabricatorCalendarEventInvitee::AVAILABILITY_AWAY; + if ($user->getDisplayAvailability() == $away) { + $tag->setDotColor(PHUITagView::COLOR_RED); + } else { + $tag->setDotColor(PHUITagView::COLOR_ORANGE); + } } } } foreach ($tokens as $token) { $engine->overwriteStoredText($token, $tag); } } else { // NOTE: The structure here is different from the 'exists' branch, // because we want to preserve the original text capitalization and it // may differ for each token. foreach ($tokens as $token) { $tag = phutil_tag( 'span', array( 'class' => 'phabricator-remarkup-mention-unknown', ), '@'.idx($original, $token, $username)); $engine->overwriteStoredText($token, $tag); } } } // Don't re-process these mentions. $engine->setTextMetadata($metadata_key, array()); } }