/** * 新增/编辑授课教师来源AJAX方法 * @param int $ctf_id 旧ID,若为0表新增,否则表编辑 * @param array $param map<string,varaint>类型的新属性 * int ctf_id 新ID * string ctf_name 新名称 */ public function setCTFFunc($ctf_id, $param) { $resp = new AjaxResponse(); $param = Func::param_copy($param, 'ctf_id', 'ctf_name'); if ($ctf_id) { if (!$this->check_power_new('course_setctfinfo', false)) { $resp->alert('您没有权限执行该功能'); return $resp; } } else { if (!$this->check_power_new('course_addctfinfo', false)) { $resp->alert('您没有权限执行该功能'); return $resp; } } if (!Validate::isInt($param['ctf_id'])) { $resp->alert('培训课程授课教师来源ID必须为整数'); return $resp; } if ($param['ctf_name'] == '') { $resp->alert('培训课程授课教师来源名称不可为空'); return $resp; } try { if ($ctf_id) { CourseModel::setCourseTeachfrom($ctf_id, $param); admin_log('edit', '', "授课教师来源 ctf_id: " . $param['ctf_id']); } else { CourseModel::addCourseTeachfrom($param); admin_log('add', '', "授课教师来源 ctf_id: " . $param['ctf_id']); } $resp->call('location.reload'); } catch (Exception $e) { $resp->alert($e->getMessage()); } return $resp; }