예제 #1
0
 public function batch_unrelate()
 {
     $ids = $this->input->post('ids');
     if (empty($ids) or !is_array($ids)) {
         message('请选择要操作的项目!');
         return;
     }
     $success = $fail = 0;
     foreach ($ids as $id) {
         $this->examine_permission($id);
         $be_tested = QuestionModel::question_has_test_action($id);
         if ($be_tested) {
             $fail++;
             continue;
         }
         $num = QuestionModel::unrelate($id);
         if ($num > 0) {
             $success += $num;
         } else {
             $fail++;
         }
     }
     $back_url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'admin/question_external/index';
     message('批量操作完成,成功取消关联:' . $success . ' 个,失败:' . $fail . ' 个(可能原因:试题已被考过 或者 正在被考 或者 关联失败 或者 没权限)。', $back_url);
 }
예제 #2
0
 public function batch_unrelate()
 {
     if (!$this->check_power('question_manage')) {
         return;
     }
     $ids = $this->input->post('ids');
     if (empty($ids) or !is_array($ids)) {
         message('请选择要操作的项目!');
         return;
     }
     $success = $fail = 0;
     foreach ($ids as $id) {
         $be_tested = QuestionModel::question_has_test_action($id);
         $has_edit_power = QuestionModel::check_question_power($id, 'w', false);
         if ($be_tested || !$has_edit_power) {
             $fail++;
             continue;
         }
         $num = QuestionModel::unrelate($id);
         if ($num > 0) {
             $success += $num;
         } else {
             $fail++;
         }
     }
     $back_url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'admin/question/index';
     message('批量操作完成,成功取消关联:' . $success . ' 个,失败:' . $fail . ' 个(可能原因:试题已被考过 或者 正在被考 或者 关联失败 或者 没权限)。', $back_url);
 }