public function __construct($year) { if (!isset($year)) { $year = ContestModel::getCurrentYear(); } $this->year = $year; $cond['id'] = $year; if (!DBModel::existUser('cernet_contest', $cond)) { DBModel::insertDB('cernet_contest', $cond); } }
/** * store the men and the teams in the table--second_award * @author panda */ public function storeAward() { $year = ContestModel::getCurrentYear(); $tables = ['cernet_user', 'cernet_team', 'cernet_teacher']; $model = new DBModel(); for ($i = 0; $i < 3; $i++) { $users = $model->getAward($tables[$i]); foreach ($users as $user) { $data = array('user_type' => $i, 'user_id' => $user['id'], 'award' => $user['prize'], 'contest_id' => $year); $model->insertDB('second_award', $data); } } }
public function award() { $cond['contest_id'] = (int) ContestModel::getCurrentYear(); $awards = DBModel::getByFields('second_award', $cond); $tables = ['second_user', 'second_team', 'second_teacher']; foreach ($awards as $k => $v) { $awards[$k]['uname'] = getNameById($tables[$v['user_type']], $v['user_id']); $awards[$k]['contest'] = $v['contest_id']; $awards[$k]['award'] = $v['award']; } $this->assign("award", $awards); $this->assign("type", $tables); $this->assign("less", "about" . ".less"); eval(NDSP); }
/** * Admin can manage all the notices here. */ public function manage_notice() { eval(ADMIN); // show the list of a year $year = $_GET["year"]; if (!isset($_GET["year"])) { $year = ContestModel::getCurrentYear(); } $cond["time"] = array("like", "{$year}%"); $noticelist = DBModel::getByFields("cernet_notice", $cond, true, 'time DESC'); $this->assign("noticelist", $noticelist); // show the year list $yearlist = DBModel::sqlquery("cernet_notice", "SELECT LEFT(time, 4) FROM `cernet_notice` GROUP BY LEFT(time, 4)"); $this->assign("yearlist", $yearlist); // dump($yearlist); $this->assign("less", __FUNCTION__ . ".less"); eval(NDSP); }