示例#1
0
 public function actionUserProfile()
 {
     if (!empty(Auth::getUser()['id'])) {
         $user = UsersModel::model()->where("`id`='" . Auth::getUser()['id'] . "'")->findRow();
         $linkCards = LinkingUserProfileModel::model()->where("`type`='1' AND `user_id`='" . Auth::getUser()['id'] . "'")->findAll();
         $LinkGifts = LinkingUserProfileModel::model()->where("`type`='2' AND `user_id`=" . Auth::getUser()['id'])->findAll();
         $rating = $this->declension($user->experience, array("очко", "очка", "очков"));
         $viewed_series = UserSeriesViewedModel::model()->where("user_id=" . Auth::getUser()['id'])->findAll();
         $userId = Auth::getUser()['id'];
         $favors = FavoritesModel::model()->where("`user_id`='{$userId}'")->findAll();
         $in = "(";
         foreach ($favors as $favor) {
             $in .= "'{$favor->video_id}'" . ", ";
         }
         $in = substr($in, 0, -2);
         $in .= ")";
         if ($in == ")") {
             $movies = array();
         } else {
             $movies_count = MoviesModel::model()->where("`id` IN {$in}")->countAll();
         }
         $dicts = DictModel::model()->where("`user_id`='" . Auth::getUser()['id'] . "'")->countAll();
         $this->view("profile/user_profile/show", array("user" => $user, "movies_count" => $movies_count, "dicts" => $dicts, "viewed_series" => $viewed_series, "gifts" => $LinkGifts, "cards" => $linkCards, "rating" => $rating), false);
     } else {
         $error = Lang::get("not_registered");
         $this->view("profile/user_profile/show", array("not_registered" => $error), false);
     }
 }
 private function getUserPrisent($userId)
 {
     $links = LinkingUserProfileModel::model()->where(" `type` = '2' AND `user_id` = '{$userId}' ")->findAll();
     $num = 0;
     $in = "";
     foreach ($links as $link) {
         if ($num == 0) {
             $in .= " AND id NOT IN (";
         }
         if ($num != 0) {
             $in .= ",";
         }
         $in .= $link->idPresent;
         $num++;
     }
     if ($num > 0) {
         $in .= ")";
     }
     return $in;
 }