username = idx($data, 'username'); $this->page = idx($data, 'page'); } public function processRequest() { $viewer = $this->getRequest()->getUser(); $user = id(new PhabricatorUser())->loadOneWhere( 'userName = %s', $this->username); if (!$user) { return new Aphront404Response(); } $profile = id(new PhabricatorUserProfile())->loadOneWhere( 'userPHID = %s', $user->getPHID()); if (!$profile) { $profile = new PhabricatorUserProfile(); } $links = array(); if ($user->getPHID() == $viewer->getPHID()) { $links[] = phutil_render_tag( 'a', array( 'href' => '/settings/page/profile/', ), 'Edit Profile'); } $oauths = id(new PhabricatorUserOAuthInfo())->loadAllWhere( 'userID = %d', $user->getID()); $oauths = mpull($oauths, null, 'getOAuthProvider'); $providers = PhabricatorOAuthProvider::getAllProviders(); foreach ($providers as $provider) { if (!$provider->isProviderEnabled()) { continue; } $provider_key = $provider->getProviderKey(); if (!isset($oauths[$provider_key])) { continue; } $name = $provider->getProviderName().' Profile'; $href = $oauths[$provider_key]->getAccountURI(); if ($href) { $links[] = phutil_render_tag( 'a', array( 'href' => $href, ), phutil_escape_html($name)); } } // TODO: perhaps, if someone wants to add to the profile of the user the // ability to show the task/revisions where he is working/commenting // on, this has to be changed to something like // |$this->page = key($pages)|, since the "page" regexp was added to // the aphrontconfiguration. if (empty($links[$this->page])) { $this->page = 'action'; } switch ($this->page) { default: $content = $this->renderBasicInformation($user, $profile); break; } $src_phid = $profile->getProfileImagePHID(); if (!$src_phid) { $src_phid = $user->getProfileImagePHID(); } $picture = PhabricatorFileURI::getViewURIForPHID($src_phid); $title = nonempty($profile->getTitle(), 'Untitled Document'); $realname = '('.$user->getRealName().')'; $profile = new PhabricatorProfileView(); $profile->setProfilePicture($picture); $profile->setProfileNames( $user->getUserName(), $realname, $title); foreach ($links as $page => $name) { if (is_integer($page)) { $profile->addProfileItem( phutil_render_tag( 'span', array(), $name)); } else { $profile->addProfileItem($page); } } $profile->appendChild($content); return $this->buildStandardPageResponse( $profile, array( 'title' => $user->getUsername(), )); } private function renderBasicInformation($user, $profile) { $blurb = nonempty( $profile->getBlurb(), '//Nothing is known about this rare specimen.//'); $engine = PhabricatorMarkupEngine::newProfileMarkupEngine(); $blurb = $engine->markupText($blurb); $commit_list = phutil_render_tag( 'a', array( 'href' => '/diffusion/author/'. phutil_escape_uri($user->getUsername()), ), 'Recent Commits'); $viewer = $this->getRequest()->getUser(); $content = '

Basic Information

PHID '.phutil_escape_html($user->getPHID()).'
User Since '.phabricator_datetime($user->getDateCreated(), $viewer). '
'; $content .= '

Flavor Text

Blurb '.$blurb.'
'; $content .= '

Recent Activities

Commits '.$commit_list.'
'; return $content; } }