public function defaultAction()
 {
     $pageSize = 20;
     // 获取参数
     $page = Pager::get();
     $status = (int) Request::getGET('status', -1);
     $contestId = (int) Request::getGET('contest-id', 0);
     $where = array();
     $where[] = array('is_diy', '=', 0);
     if (!empty($contestId)) {
         $where[] = array('contest_id', '=', $contestId);
     }
     if ($status != -1) {
         $where[] = array('status', '=', $status);
     }
     // 获取数据
     $offset = ($page - 1) * $pageSize;
     $applyList = OjContestApplyInterface::getList(array('where' => $where, 'limit' => $pageSize, 'offset' => $offset));
     $allCount = 0;
     $userHash = array();
     $contestHash = array();
     if (!empty($applyList)) {
         $allCount = OjContestApplyInterface::getCount($where);
         $userIds = array_column($applyList, 'user_id');
         $userHash = UserCommonInterface::getById(array('id' => $userIds));
         $contestIds = array_unique(array_column($applyList, 'contest_id'));
         $contestHash = OjContestInterface::getById(array('id' => $contestIds));
     }
     // 缓存部分的html
     $html = array();
     $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php');
     $this->renderFramework(array('html' => $html, 'applyList' => $applyList, 'contestHash' => $contestHash, 'userHash' => $userHash), 'contest/apply_list.php');
 }
 public function defaultAction()
 {
     $pageSize = 50;
     // 获取参数
     $page = Pager::get();
     $contestId = (int) Request::getGET('contest-id');
     $status = (int) Request::getGET('status', -1);
     $contestInfo = OjContestInterface::getById(array('id' => $contestId));
     if (empty($contestInfo) || $contestInfo['hidden'] || $contestInfo['type'] != ContestVars::TYPE_APPLY) {
         $this->renderError('竞赛不存在,或者竞赛不需要报名!');
     }
     // 构建where
     $where = array();
     $where[] = array('contest_id', '=', $contestId);
     if ($status != -1) {
         $where[] = array('status', '=', $status);
     }
     // 获取数据
     $offset = ($page - 1) * $pageSize;
     $applyList = OjContestApplyInterface::getList(array('where' => $where, 'limit' => $pageSize, 'offset' => $offset));
     $allCount = OjContestApplyInterface::getCount($where);
     // userHash
     $userIds = array_unique(array_column($applyList, 'user_id'));
     $userHash = UserCommonInterface::getById(array('id' => $userIds));
     // 缓存部分的html
     $html = array();
     $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php');
     $this->renderFramework(array('html' => $html, 'applyList' => $applyList, 'contestInfo' => $contestInfo, 'userHash' => $userHash), 'contest/apply_list.php');
 }
 public function defaultAction()
 {
     $pageSize = 20;
     // 获取参数
     $page = Pager::get();
     $status = (int) Request::getGET('status', -1);
     $contestId = (int) Request::getGET('contest-id', 0);
     // 获取属于用户的竞赛
     $where = array(array('user_id', '=', $this->loginUserInfo['id']), array('is_diy', '=', 1));
     $contestHash = OjContestInterface::getList(array('where' => $where));
     $contestHash = Arr::listToHash('id', $contestHash);
     $contestIds = array_keys($contestHash);
     $userHash = array();
     $applyList = array();
     $allCount = 0;
     if (!empty($contestIds)) {
         if ($contestId > 0 && !in_array($contestId, $contestIds)) {
             $where = false;
         } else {
             if ($contestId > 0 && in_array($contestId, $contestIds)) {
                 $where = array(array('contest_id', '=', $contestId));
             } else {
                 $where = array(array('contest_id', 'IN', $contestIds));
             }
         }
         if (false !== $where) {
             if ($status != -1) {
                 $where[] = array('status', '=', $status);
             }
             $offset = ($page - 1) * $pageSize;
             $applyList = OjContestApplyInterface::getList(array('where' => $where, 'limit' => $pageSize, 'offset' => $offset));
             if (!empty($applyList)) {
                 $allCount = OjContestApplyInterface::getCount($where);
                 $userIds = array_column($applyList, 'user_id');
                 $userHash = UserCommonInterface::getById(array('id' => $userIds));
             }
         }
     }
     // 缓存部分的html
     $html = array();
     $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php');
     $this->renderFramework(array('html' => $html, 'applyList' => $applyList, 'contestHash' => $contestHash, 'userHash' => $userHash), 'setup/contest/apply_list.php');
 }