0) { App::redirect('/user/notifications/'); } else { App::redirect('/user/'.App::$user->id); } } else { App::redirect('/'); } } self::addStyle('/css/user.css?ver=' . App::getConfig('version')); $id = (int) App::getParam('id'); $user = User::model()->getByPK($id); if (!$user) { App::error404(); } if (!App::$user) { self::addScript('http://ulogin.ru/js/ulogin.js'); } if (App::$user && App::$user->id == $id) { $articles = Article::model()->getAll(array('where'=>'`author`='.(int)$user->id.' AND `status` != "del"', 'order' => '`pubDate` DESC')); } else { $articles = Article::model()->getAll(array('where'=>'`author`='.(int)$user->id . ' AND `status` = "published" ', 'order' => '`pubDate` DESC')); } $randomPoint = Point::model()->getRandom(); $randomPoint->description = mb_substr($randomPoint->description, 0, 400, 'UTF-8'); $randomPoint->description = Helper::replaceLinks($randomPoint->description); // $photos = ArticlePhotos::model()->getByUser($id, 5); $photos = NULL; // Скрыл фотоленту, так как туда могут попадать фотки неопубликованных статей self::render('user/index.php', array( 'user' => $user, 'articles' => $articles, 'photos' => $photos, 'imAuthor' => App::$user && App::$user->id == $id, 'randomPoint' => $randomPoint, )); } function actionNotifications() { if (!App::$user) { App::redirect('/'); } $notifications = Notifications::model()->getAll(array( 'where' => '`userId` = '.App::$user->id, 'order' => 'readed ASC, date DESC' )); Notifications::model()->setAllReaded(); $randomPoint = Point::model()->getRandom(); $randomPoint->description = mb_substr($randomPoint->description, 0, 400, 'UTF-8'); $randomPoint->description = Helper::replaceLinks($randomPoint->description); self::render('user/notifications.php', array( 'notifications' => $notifications, 'randomPoint' => $randomPoint, )); } function actionFavorites() { if (!App::$user) { App::redirect('/'); } $randomPoint = Point::model()->getRandom(); $randomPoint->description = mb_substr($randomPoint->description, 0, 400, 'UTF-8'); $randomPoint->description = Helper::replaceLinks($randomPoint->description); self::render('user/favorites.php', array( 'favorites' => Favorite::model()->getAllMy(), 'randomPoint' => $randomPoint, )); } }