/** * 编辑授课教师AJAX方法 * @param array $param map<stirng,variant>类型的参数 * int scht_schid 学校id * int ct_id 教师ID,若为0表新增 * string ct_name 名称 * string subject_id_str 形如1,3,4样式的学科ID列表 * string grade_id_str 形如1,3,4样式的年级ID列表 * int ct_flag 状态,-1已删,0禁用,1启用,大于1待审 */ public function setSchoolTeacherFunc($param) { $resp = new AjaxResponse(); if (!$this->check_power_new('school_editteacher', false)) { $resp->alert('您没有权限执行该功能'); return $resp; } $param = Func::param_copy($param, 'scht_schid', 'ct_id', 'ct_name', 'ct_contact', 'subject_id_str', 'grade_id_str', 'ct_flag', 'cct_ccid_str', 'ct_memo'); if (!Validate::isInt($param['scht_schid']) || $param['scht_schid'] <= 0) { $resp->alert('教师所属学校不正确'); return $resp; } if (!Validate::isInt($param['ct_id']) || $param['ct_id'] < 0) { $resp->alert('教师ID不正确'); return $resp; } if ($param['ct_name'] == '') { $resp->alert('教师名称不正确'); return $resp; } if (!Validate::isJoinedIntStr($param['grade_id_str'])) { $resp->alert('所选年级不正确'); return $resp; } if (!Validate::isJoinedIntStr($param['subject_id_str'])) { $resp->alert('所选学科不正确'); return $resp; } $param['subjectid_list'] = array_unique(explode(',', $param['subject_id_str'])); $param['gradeid_list'] = array_unique(explode(',', $param['grade_id_str'])); if (count($param['gradeid_list']) == count(C('grades'))) { $param['gradeid_list'] = array(0); } try { if ($param['ct_id']) { SchoolModel::setSchoolTeacher($param); admin_log('edit', 'school_teacher', "ct_id: " . $param['ct_id']); } else { $param['ct_id'] = SchoolModel::addSchoolTeacher($param); admin_log('add', 'school_teacher', "ct_id: " . $param['ct_id']); } $resp->redirect('/admin/school/teacherlist/' . $param['scht_schid']); } catch (Exception $e) { $resp->alert($e->getMessage()); } return $resp; }