예제 #1
0
 /**
  * Executes view action : displays the user profile
  */
 public function executeView()
 {
     $id = $this->getRequestParameter('id');
     parent::executeView();
     $hasPublicProfile = UserPrivateData::hasPublicProfile($id);
     if (!$this->getUser()->isConnected() && !$hasPublicProfile) {
         // page owner has not allowed anonymous users to access his personal page
         $this->setTemplate('login');
     } else {
         if (!$this->document->isArchive() && $this->document['redirects_to'] == NULL) {
             if ($hasPublicProfile) {
                 $this->getResponse()->addMeta('robots', 'index, follow');
             } else {
                 $this->getResponse()->addMeta('robots', 'noindex, nofollow');
             }
             // get associated outings
             $associated_outings = array();
             $nb_outings = count(Association::countAllLinked(array($id), 'uo'));
             $nb_outings_limit = 0;
             if ($nb_outings > 0) {
                 $outing_params = array('users' => $id);
                 $nb_outings_limit = sfConfig::get('app_users_outings_limit');
                 $associated_outings = Outing::listLatest($nb_outings_limit, array(), array(), array(), $outing_params, false, false);
                 $associated_outings = Language::getTheBest($associated_outings, 'Outing');
             }
             $this->nb_outings = $nb_outings;
             $this->nb_outings_limit = $nb_outings_limit;
             $this->associated_outings = $associated_outings;
             $forum_nickname = Punbb::getNickname($id);
             $this->forum_nickname = $forum_nickname[0]['username'];
             // check if user is forum and / or topoguide moderator
             $this->forum_moderator = UserPrivateData::isForumModerator($id);
             $user_permissions = Doctrine_Query::create()->from('User.groups.permissions, User.permissions')->where('User.id = ?', $id)->execute(array(), Doctrine::FETCH_ARRAY);
             $topoguide_moderator = false;
             $moderator_credential = sfConfig::get('app_credentials_moderator');
             foreach ($user_permissions[0]['groups'] as $group) {
                 foreach ($group['permissions'] as $permission) {
                     if ($permission['name'] == $moderator_credential) {
                         $topoguide_moderator = true;
                         break 2;
                     }
                 }
             }
             foreach ($user_permissions[0]['permissions'] as $permission) {
                 if ($permission['name'] == $moderator_credential) {
                     $topoguide_moderator = true;
                     break;
                 }
             }
             $this->topoguide_moderator = $topoguide_moderator;
         } else {
             // only moderators and user itself should see archive versions of user docs
             $this->filterAuthorizedPeople($id);
         }
     }
 }