function __construct() { $login = login_class(); if ($login->is_login()) { $list = []; switch ($login->getLoginType()) { case "admin": $list = db_class()->get_admin_allow_access($login->uid()); break; case "teacher": case "student": $list = db_class()->get_role_allow_access($login->role_id()); break; } $this->table = list2keymap($list, 'name', ['r', 'w']); } }
/** * Home page */ public function main() { if (!$this->is_login()) { redirect(['Home', 'login']); } $cgf = cfg(); $this->setTitle("管理"); switch (login_class()->getLoginType()) { case "teacher": $cgf->load(_RootPath_ . "/config/base_info.php"); $filed = $cgf->get('teacher_info', 'filed'); break; case "student": $cgf->load(_RootPath_ . "/config/base_info.php"); $filed = $cgf->get('student_info', 'filed'); break; } $role_access = list2keymap(db_class()->get_role_access_and_name(login_class()->role_id()), "p_id", ['ac_w', 'p_name', 'p_alias', 'ac_r']); $this->__view("home/main.php", compact('role_access', 'filed')); }
private function get_role_keymap() { $list = []; foreach (db_class()->get_role_list() as $v) { $list[$v['r_id']] = $v['r_name']; } asort($list); return $list; }
public function detail() { if ($this->status) { switch ($this->login_type) { case "admin": $this->db = db_class(); $access = $this->db->get_access($this->user_info['name']); return array_merge($access, ['user' => $this->user_info]); case "teacher": case "student": $this->db = db_class(); return array_merge($this->db->get_access_by_role_id($this->user_info['role_id']), ['user' => $this->user_info]); } } return NULL; }
public function post() { header("Content-Type: text/html; charset=utf-8"); $access = access_class(); if (!$access->read("scores_list_report")) { $this->permission_deny(); return; } $id_id = $this->__req->req('id_id'); $icl_id = $this->__req->req('icl_id'); $mc_number = $this->__req->req('mc_number'); $mc_year = $this->__req->req('mc_year'); $mc_s = compact('id_id', 'mc_number', 'mc_year'); $msg = ""; if (count($mc_s) != 3) { $msg = "提交数据不完全"; } else { foreach ($mc_s as $v) { if (empty($v)) { $msg = "数据存在空值"; break; } } } if ($msg) { $this->__view('report/error.php', compact('msg')); return; } $db = db_class(); $mc_list = $db->getDriver()->select("mg_curriculum", ["[><]info_curriculum" => ['cu_id' => "cu_id"]], ["mc_id", "cu_name"], ['AND' => $mc_s]); if (count($mc_list) < 1) { $msg = "无数据可供查询"; $this->__view('report/error.php', compact('msg')); return; } $mc_list = list2keymap($mc_list, "mc_id", "cu_name"); if (!empty($icl_id)) { $icl_id = ['info_student.icl_id' => $icl_id]; } else { $icl_id = []; } $table = []; foreach ($mc_list as $mc_id => $cu_name) { $now_select = $db->report_curriculum($mc_id, $icl_id); foreach ($now_select as $v) { if (!isset($table[$v['is_id']])) { $table[$v['is_id']] = []; $table[$v['is_id']]['name'] = $v['is_name']; $table[$v['is_id']]['class'] = $v['icl_number']; } if (!isset($table[$v['is_id']]['list'])) { $table[$v['is_id']]['list'] = []; } if (!isset($table[$v['is_id']]['list'][$mc_id])) { $table[$v['is_id']]['list'][$mc_id] = ['test' => $v['sc_test'], 'work' => $v['sc_work'], 'total' => $v['sc_total']]; } } } ksort($table); $info = $db->get_curriculum_info_by_mc_id(array_keys($mc_list)[0]); $this->__view('report/report.php', compact('info', 'table', 'mc_list', 'mc_s')); }
function scores_full_check(&$list) { $x = db_class()->getDriver()->select("info_student", ["[><]mg_curriculum" => ['id_id' => 'id_id']], ["info_student.is_id"], ['AND' => ['info_student.is_id' => $list['is_id'], 'mg_curriculum.mc_id' => $list['mc_id']]]); return count($x) > 0; }
public function add_ajax() { $access = access_class(); if (!$access->write("scores_add")) { $this->permission_deny(); return; } header("Content-Type: application/json; charset=utf-8"); $id_id = $this->__req->post('id_id'); $icl_id = $this->__req->post('icl_id'); $mc_id = $this->__req->post('mc_id'); $rt = ['msg' => NULL, 'status' => false]; if (!is_numeric($id_id) || !is_numeric($mc_id)) { $rt['msg'] = '专业字段或专业课程课号为空'; } else { $db = db_class(); if (!$db->check_mg_id_exists($id_id, $mc_id)) { $rt['msg'] = "专业与课程不匹配"; } else { if (!empty($icl_id)) { if (!$db->check_class_exists($id_id, $icl_id)) { $rt['msg'] = "无法找到对应的班级"; } else { $rt['msg'] = $db->insert_mc_id_class_list($id_id, $mc_id, $icl_id); if ($rt['msg'] === false) { $rt['msg'] = "插入失败,检测重复或异常"; } else { $rt['status'] = true; } } } else { $rt['msg'] = $db->insert_mc_id_list($id_id, $mc_id); if ($rt['msg'] === false) { $rt['msg'] = "插入失败,检测重复或异常"; } else { $rt['status'] = true; } } } } echo json_encode($rt); }
private function getLimit() { $this->number_all = db_class()->getDriver()->count($this->table, $this->where); $this->first = $this->n * ($this->p - 1); $this->all_page = ceil($this->number_all / $this->n); return [$this->first, $this->n]; }
</div> <div class="footer text-center"> <p class="help-block">页面加载耗时:<?php echo c()->getTimer()->get_second(); ?> s,数据库查询:<?php echo db_class()->getDriver()->get_query_count(); ?> 次。</p> </div></div> </div> </div> </body> </html>
public function add($type = NULL) { if (!isset($this->info_data[$type])) { $this->__load_404(); return; } $access = access_class(); if (!$access->write($type)) { $this->permission_deny(); return; } header("Content-Type: application/json; charset=utf-8"); $info = []; $rt = ['status' => false, 'msg' => NULL]; $filed_check = $this->filed_check($type, $info, "add"); if (!empty($filed_check)) { $rt['msg'] = '信息检测出错:' . $filed_check; } if (empty($rt['msg'])) { if (isset($this->info_data[$type]['full_check']) && !$this->info_data[$type]['full_check']($info)) { $rt['msg'] = "无法通过完整性约束检查"; } else { $i = db_class()->base_info_insert($this->info_data[$type]['table'], $info); if ($i >= 0) { $rt['status'] = true; } else { $rt['msg'] = "添加数据失败"; } } } echo json_encode($rt); }