Exemplo n.º 1
0
 protected function initProfile()
 {
     if (isset($_GET['id'])) {
         $userId = (int) $_GET['id'];
     } elseif (isset($_GET['profile'])) {
         $userId = (int) $_GET['profile'];
     }
     if ($userId) {
         $user = UserAccount::model()->findByPk($userId);
         if (!$user) {
             throw new CHttpException(404);
         }
         if (!Yii::app()->user->isGuest && $userId == Yii::app()->user->id) {
             $this->self = true;
         }
     } else {
         $user = Yii::app()->user;
         if ($user->isGuest) {
             $this->redirect('/');
         }
         $this->self = true;
     }
     $this->profile = $user->profile;
 }