public function delete($id) { if (!$this->check_power('skill_delete')) { return; } $id = intval($id); $id && ($row = SkillModel::get_skill($id)); if (empty($row)) { message('技能不存在'); return; } if (!QuestionModel::check_subject_power($row['subject_id'], 'w')) { return; } $this->db->delete('skill', array('id' => $id)); admin_log('delete', 'skill', $id); message('技能删除成功', 'admin/skill/index/'); }
private function _delete($id) { $id = intval($id); $item = GroupTypeModel::get_group_type($id); if (empty($item)) { // 知识点不存在 return -1; } $query = $this->db->select('count(*) num')->get_where('group_type', array('pid' => $id)); $row = $query->row_array(); if ($row['num']) { //该信息提取方式还存在下级分类; return -2; } $query = $this->db->select('count(*) num')->get_where('relate_group_type', array('group_type_id' => $id, 'is_child' => 0)); $row = $query->row_array(); if ($row['num']) { //该信息提取方式还存在关联试题; return -3; } if (!QuestionModel::check_subject_power($item['subject_id'], 'w', false)) { //没有权限 return -4; } try { $this->db->delete('group_type', array('id' => $id)); admin_log('delete', 'group_type', $id); } catch (Exception $e) { return FALSE; } return TRUE; }