Example #1
0
 public function actionAdmin()
 {
     // delete comment request
     if (Rays::isPost()) {
         if (isset($_POST['checked_comments'])) {
             $commentIds = $_POST['checked_comments'];
             foreach ($commentIds as $id) {
                 if (!is_numeric($id)) {
                     return;
                 } else {
                     $comment = new Comment();
                     $comment->id = $id;
                     $comment->delete();
                 }
             }
         }
     }
     $curPage = $this->getPage("page");
     $pageSize = $this->getPageSize('pagesize', 10);
     $count = Comment::find()->count();
     $comments = Comment::find()->join("user")->join("topic")->order_desc("id")->range(($curPage - 1) * $pageSize, $pageSize);
     $pager = new RPager('page', $count, $pageSize, RHtml::siteUrl('comment/admin'), $curPage);
     $this->layout = 'admin';
     $this->setHeaderTitle("Comments administration");
     $data = array('count' => $count, 'comments' => $comments, 'pager' => $pager->showPager());
     $this->render('admin', $data, false);
 }
Example #2
0
 /**
  * View system logs
  */
 public function actionLogs()
 {
     $curPage = $this->getPage("page");
     $pageSize = $this->getPageSize("pagesize", 10);
     $count = SystemLog::find()->count();
     $logs = SystemLog::find()->order_desc("id")->join('user')->range(($curPage - 1) * $pageSize, $pageSize);
     $pager = new RPager('page', $count, $pageSize, RHtml::siteUrl('admin/logs'), $curPage);
     $this->setHeaderTitle("System logs");
     $this->render('logs', ['logs' => $logs, 'pager' => $pager->showPager(), 'count' => $count], false);
 }
Example #3
0
 /**
  * View messages
  * @access authenticated user
  * @param string $msgType
  */
 public function actionView($msgType = 'unread')
 {
     $this->setHeaderTitle("My Messages");
     $userId = Rays::user()->id;
     $curPage = $this->getPage('page');
     $pageSize = $this->getPageSize("pagesize", 5);
     /* TODO: Maybe move these model-related things into Message model directly */
     $query = Message::find("receiverId", $userId);
     switch ($msgType) {
         case "all":
             $query = $query->where("[status] != ? ", array(Message::STATUS_TRASH));
             break;
         case "read":
             $query = $query->find("status", Message::STATUS_READ);
             break;
         case "unread":
             $query = $query->find("status", Message::STATUS_UNREAD);
             break;
         case "trash":
             $query = $query->find("status", Message::STATUS_TRASH);
             break;
         default:
             $this->page404();
             return;
     }
     $count = $query->count();
     $messages = $query->join('type')->order_desc("id")->range(($curPage - 1) * $pageSize, $pageSize);
     $data = array('msgs' => $messages, 'type' => $msgType, 'count' => $count);
     if ($count > $pageSize) {
         $url = RHtml::siteUrl('message/view/' . $msgType);
         $pager = new RPager('page', $count, $pageSize, $url, $curPage);
         $data['pager'] = $pager->showPager();
     }
     $this->render('view', $data, false);
 }
Example #4
0
 public function actionAdmin()
 {
     $this->setHeaderTitle('Advertisement');
     $this->layout = 'admin';
     if (Rays::isPost()) {
         if (isset($_POST['checked_ads'])) {
             $selected = $_POST['checked_ads'];
             if (is_array($selected)) {
                 $operation = $_POST['operation_type'];
                 foreach ($selected as $id) {
                     $ad = Ads::get($id);
                     if ($ad == null) {
                         break;
                     }
                     switch ($operation) {
                         case "block":
                             $ad->status = Ads::BLOCKED;
                             $ad->save();
                             break;
                         case "active":
                             $ad->status = Ads::APPROVED;
                             $ad->save();
                             break;
                     }
                 }
             }
         }
     }
     $curPage = $this->getPage('page');
     $pageSize = $this->getPageSize("pagesize", 10);
     $filterStr = Rays::getParam('search', null);
     $query = Ads::find()->join("publisher");
     if ($name = trim($filterStr)) {
         $names = preg_split("/[\\s]+/", $name);
         foreach ($names as $key) {
             $query = $query->like("name", $key);
         }
     }
     $count = $query->count();
     $ads = $query->order_desc("id")->range($pageSize * ($curPage - 1), $pageSize);
     $data = ['ads' => $ads, 'count' => $count];
     $url = RHtml::siteUrl('ads/admin');
     if ($filterStr != null) {
         $url .= '?search=' . urlencode(trim($filterStr));
     }
     $pager = new RPager('page', $count, $pageSize, $url, $curPage);
     $data['pager'] = $pager->showPager();
     $this->render('admin', $data, false);
 }
Example #5
0
 public function actionMyFriend()
 {
     $this->layout = 'user';
     $user = Rays::user();
     $friends = new Friend();
     $curPage = $this->getPage("page");
     $pageSize = $this->getPageSize("pagesize", 36);
     list($friends, $count) = $friends->getFriends($user->id, $pageSize, [], ($curPage - 1) * $pageSize);
     $data['count'] = $count;
     $pager = new RPager('page', $count, $pageSize, RHtml::siteUrl('friend/myFriend'), $curPage);
     $data['friends'] = $friends;
     if ($count > $pageSize) {
         $data['pager'] = $pager->showPager();
     }
     $data['friNumber'] = $count;
     return $this->render('my_friend', $data);
 }
Example #6
0
 /**
  * Groups administration
  */
 public function actionAdmin()
 {
     $this->setHeaderTitle('Group administration');
     $this->layout = 'admin';
     $data = array();
     if (Rays::isPost()) {
         if (isset($_POST['checked_groups'])) {
             $groups = $_POST['checked_groups'];
             foreach ($groups as $group) {
                 if (!is_numeric($group)) {
                     break;
                 }
                 Group::deleteGroup(Group::get($group));
             }
         }
     }
     $searchStr = Rays::getParam('search', null);
     $query = Group::find();
     if ($name = trim($searchStr)) {
         $names = preg_split("/[\\s]+/", $name);
         foreach ($names as $key) {
             $query = $query->like("name", $key);
         }
     }
     $page = $this->getPage("page");
     $pageSize = $this->getPageSize("pagesize", 5);
     $count = $query->count();
     $query = $query->join("category")->join("groupCreator")->join("rating")->join("counter");
     $orderBy = Rays::getParam("orderBy", "id");
     $order = Rays::getParam("order", "desc");
     switch ($orderBy) {
         case "id":
             $query = $query->order($order, "[Group.id]");
             break;
         case "likes":
             $query = $query->order($order, "[RatingStatistic.value]");
             break;
         case "views":
             $query = $query->order($order, "[Counter.totalCount]");
             break;
         case "createTime":
             $query = $query->order($order, "[Group.id]");
             break;
         case "memberCount":
             $query = $query->order($order, "[Group.memberCount]");
             break;
         default:
             $query = $query->order_desc("id");
     }
     $groups = $query->range($pageSize * ($page - 1), $pageSize);
     $data['count'] = $count;
     $data['groups'] = $groups;
     $url = RHtml::siteUrl("group/admin?orderBy={$orderBy}&&order={$order}");
     if ($searchStr != null) {
         $url .= 'search=' . urlencode(trim($searchStr));
     }
     // pager
     $pager = new RPager('page', $count, $pageSize, $url, $page);
     $data['pager'] = $pager->showPager();
     $this->render('admin', $data, false);
 }
Example #7
0
 public function actionFind()
 {
     $this->layout = 'user';
     $page = $this->getPage("page");
     $pageSize = $this->getPageSize("pagesize", 24);
     $searchStr = '';
     if (Rays::isPost()) {
         $searchStr = $_POST['searchstr'];
     } else {
         if (isset($_GET['search'])) {
             $searchStr = $_GET['search'];
         }
     }
     $query = User::find();
     if ($name = trim($searchStr)) {
         $names = preg_split("/[\\s]+/", $name);
         foreach ($names as $key) {
             $query = $query->like("name", $key);
         }
     }
     $count = $query->count();
     $users = $query->range(($page - 1) * $pageSize, $pageSize);
     $url = RHtml::siteUrl('user/find' . ($searchStr != '') ? '?search=' . urlencode($searchStr) : "");
     $pager = new RPager('page', $count, $pageSize, $url, $page);
     $this->setHeaderTitle("Find User");
     $this->render("find", ['users' => $users, 'searchstr' => $searchStr, 'pager' => $pager->showPager()], false);
 }
Example #8
0
 /**
  * Find posts
  */
 public function actionFind($categoryId = null)
 {
     $data = [];
     $category = new Category();
     if (isset($categoryId) && (!is_numeric($categoryId) || ($category = Category::get($categoryId)) === null)) {
         $this->page404();
         return;
     } else {
         $data['category'] = $category;
         $data['subs'] = $category->children();
     }
     $page = $this->getPage("page");
     $pageSize = $this->getPageSize("pagesize", 10);
     $count = 0;
     $cat = new Category();
     if ($categoryId === null) {
         $count = $cat->getActivePostsCount();
         $data['posts'] = $cat->getActivePosts(null, ($page - 1) * $pageSize, $pageSize);
     } else {
         $count = $cat->getActivePostsCount($categoryId);
         $data['posts'] = $cat->getActivePosts($categoryId, ($page - 1) * $pageSize, $pageSize);
     }
     if ($count > $pageSize) {
         $url = RHtml::siteUrl("post/find" . ($categoryId != null ? "/" . $categoryId : ""));
         $pager = new RPager("page", $count, $pageSize, $url, $page);
         $data['pager'] = $pager->showPager();
     }
     $this->setHeaderTitle("Find posts");
     $this->addCss("/public/css/post.css");
     $this->addCss("/public/css/group.css");
     $this->render('find', $data, false);
 }