public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $uri = $request->getRequestURI();
     $project = id(new PhabricatorProject())->load($this->id);
     if (!$project) {
         return new Aphront404Response();
     }
     $profile = $project->loadProfile();
     if (!$profile) {
         $profile = new PhabricatorProjectProfile();
     }
     $src_phid = $profile->getProfileImagePHID();
     if (!$src_phid) {
         $src_phid = $user->getProfileImagePHID();
     }
     $picture = PhabricatorFileURI::getViewURIForPHID($src_phid);
     $pages = array('<h2>Information</h2>', 'edit' => 'Edit Project', 'affiliation' => 'Edit Affiliation');
     if (empty($pages[$this->page])) {
         $this->page = 'action';
     }
     switch ($this->page) {
         default:
             $content = $this->renderBasicInformation($project, $profile);
             break;
     }
     $profile = new PhabricatorProfileView();
     $profile->setProfilePicture($picture);
     $profile->setProfileNames($project->getName());
     foreach ($pages as $page => $name) {
         if (is_integer($page)) {
             $profile->addProfileItem(phutil_render_tag('span', array(), $name));
         } else {
             $uri->setPath('/project/' . $page . '/' . $project->getID() . '/');
             $profile->addProfileItem(phutil_render_tag('a', array('href' => $uri, 'class' => $this->page == $page ? 'phabricator-profile-item-selected' : null), phutil_escape_html($name)));
         }
     }
     $profile->appendChild($content);
     return $this->buildStandardPageResponse($profile, array('title' => $project->getName()));
 }
 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()));
 }