public function delete($id)
 {
     $this->db->trans_start();
     # remove all skills related by skill category
     $skill = new SkillModel();
     $skill->delete_by_category($id);
     # then remove the skill category
     $condition = array(SkillCategoryModel::$primary_key => $id);
     $this->db->delete(SkillCategoryModel::$table_name, $condition);
     $this->db->trans_complete();
     return $this->db->trans_status();
 }
Esempio n. 2
0
 public function skill()
 {
     $subject_id = intval($this->input->post('subject_id'));
     // 使用Yaf样式SkillModel代替
     $list = SkillModel::get_skills($subject_id);
     sort($list);
     echo json_encode($list);
 }
Esempio n. 3
0
 /**
  * load文件并给与权限判断
  */
 protected static function loadList($p_where = null, $p_order = null, $p_pageIndex = null, $p_pageSize = null, &$p_countThis = null, $isDetail = false)
 {
     $tmpResult = parent::loadList($p_where, $p_order, $p_pageIndex, $p_pageSize, $p_countThis, $isDetail);
     if (is_array($tmpResult) && array_key_exists('errorCode', $tmpResult)) {
         return $tmpResult;
     }
     switch ($auth = static::getAuthIfUserCanDoIt(Utility::getCurrentUserID(), $isDetail ? 'detail' : 'list', $tmpResult)) {
         case 'admin':
             //有管理权限
         //有管理权限
         case 'self':
             //作者
             break;
             //仅管理员和自己可见
         //仅管理员和自己可见
         case 'normal':
             //正常用户
         //正常用户
         case 'draft':
             //未激活
         //未激活
         case 'pending':
             //待审禁言
         //待审禁言
         case 'disabled':
             //封号
         //封号
         case 'visitor':
             //游客
             return Utility::getArrayForResults(RUNTIME_CODE_ERROR_NO_AUTH, '您没有权限执行该操作');
             //其他用户不可见
             break;
         case 'empty':
             //空
             return Utility::getArrayForResults(RUNTIME_CODE_ERROR_DATA_EMPTY, '不存在对应数据');
             break;
         default:
             return Utility::getArrayForResults(RUNTIME_CODE_ERROR_NO_AUTH, '您没有权限执行该操作');
             break;
     }
     SkillModel::$authViewDisabled = static::$authViewDisabledList[$auth];
     return $tmpResult;
 }
Esempio n. 4
0
 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/');
 }