original_string: public function actionFriend($id = null)
      {
          if (Podium::getInstance()->user->isGuest) {
              return $this->redirect(['forum/index']);
          }
  
          $model = User::find()->where(['and',
                  ['id' => $id],
                  ['!=', 'status', User::STATUS_REGISTERED]
              ])->limit(1)->one();
          if (empty($model)) {
              $this->error(Yii::t('podium/flash', 'Sorry! We can not find Member with this ID.'));
              return $this->redirect(['members/index']);
          }
  
          $logged = User::loggedId();
  
          if ($model->id == $logged) {
              $this->error(Yii::t('podium/flash', 'Sorry! You can not befriend your own account.'));
              return $this->redirect(['members/view', 'id' => $model->id, 'slug' => $model->podiumSlug]);
          }
  
          if ($model->updateFriend($logged)) {
              if ($model->isBefriendedBy($logged)) {
                  $this->success(Yii::t('podium/flash', 'User is your friend now.'));
              } else {
                  $this->success(Yii::t('podium/flash', 'User is not your friend anymore.'));
              }
          } else {
              $this->error(Yii::t('podium/flash', 'Sorry! There was some error while performing this action.'));
          }
          return $this->redirect(['members/view', 'id' => $model->id, 'slug' => $model->podiumSlug]);
      }
code: public function actionFriend($id = null)
      {
          if (Podium::getInstance()->user->isGuest) {
              return $this->redirect(['forum/index']);
          }
  
          $model = User::find()->where(['and',
                  ['id' => $id],
                  ['!=', 'status', User::STATUS_REGISTERED]
              ])->limit(1)->one();
          if (empty($model)) {
              $this->error(Yii::t('podium/flash', 'Sorry! We can not find Member with this ID.'));
              return $this->redirect(['members/index']);
          }
  
          $logged = User::loggedId();
  
          if ($model->id == $logged) {
              $this->error(Yii::t('podium/flash', 'Sorry! You can not befriend your own account.'));
              return $this->redirect(['members/view', 'id' => $model->id, 'slug' => $model->podiumSlug]);
          }
  
          if ($model->updateFriend($logged)) {
              if ($model->isBefriendedBy($logged)) {
                  $this->success(Yii::t('podium/flash', 'User is your friend now.'));
              } else {
                  $this->success(Yii::t('podium/flash', 'User is not your friend anymore.'));
              }
          } else {
              $this->error(Yii::t('podium/flash', 'Sorry! There was some error while performing this action.'));
          }
          return $this->redirect(['members/view', 'id' => $model->id, 'slug' => $model->podiumSlug]);
      }
code_tokens: public function actionFriend ( $ id = null ) { if ( Podium :: getInstance ( ) -> user -> isGuest ) { return $ this -> redirect ( [ 'forum/index' ] ) ; } $ model = User :: find ( ) -> where ( [ 'and' , [ 'id' => $ id ] , [ '!=' , 'status' , User :: STATUS_REGISTERED ] ] ) -> limit ( 1 ) -> one ( ) ; if ( empty ( $ model ) ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! We can not find Member with this ID.' ) ) ; return $ this -> redirect ( [ 'members/index' ] ) ; } $ logged = User :: loggedId ( ) ; if ( $ model -> id == $ logged ) { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! You can not befriend your own account.' ) ) ; return $ this -> redirect ( [ 'members/view' , 'id' => $ model -> id , 'slug' => $ model -> podiumSlug ] ) ; } if ( $ model -> updateFriend ( $ logged ) ) { if ( $ model -> isBefriendedBy ( $ logged ) ) { $ this -> success ( Yii :: t ( 'podium/flash' , 'User is your friend now.' ) ) ; } else { $ this -> success ( Yii :: t ( 'podium/flash' , 'User is not your friend anymore.' ) ) ; } } else { $ this -> error ( Yii :: t ( 'podium/flash' , 'Sorry! There was some error while performing this action.' ) ) ; } return $ this -> redirect ( [ 'members/view' , 'id' => $ model -> id , 'slug' => $ model -> podiumSlug ] ) ; }
docstring: Adding or removing user as a friend.
  @param int $id user ID
  @return Response
  @since 0.2
docstring_tokens: Adding or removing user as a friend .