MDL-10579 capabilities for grade import plugins

This commit is contained in:
skodak 2007-07-24 09:30:46 +00:00
parent c71fea5986
commit e77bcaa30d
6 changed files with 71 additions and 19 deletions

View File

@ -1,2 +1,17 @@
<?php // $Id$
$gradeimport_csv_capabilities = array(
'gradeimport/csv:view' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
'legacy' => array(
'editingteacher' => CAP_ALLOW,
'admin' => CAP_ALLOW
)
)
);
?>

View File

@ -1,17 +1,20 @@
<?php
require_once('../../../config.php');
include_once($CFG->libdir.'/gradelib.php');
<?php //$Id$
require_once '../../../config.php';
require_once $CFG->dirroot.'/grade/lib.php';
require_once '../grade_import_form.php';
require_once '../lib.php';
$id = required_param('id', PARAM_INT); // course id
$course = get_record('course', 'id', $id); // actual course
// capability check
require_login($id);
require_capability('moodle/grade:import', get_context_instance(CONTEXT_COURSE, $course->id));
if (!$course = get_record('course', 'id', $id)) {
print_error('nocourseid');
}
require_login($course);
$context = get_context_instance(CONTEXT_COURSE, $id);
require_capability('moodle/grade:import', $context);
require_capability('gradeimport/csv:view', $context);
require_once('../grade_import_form.php');
require_once($CFG->dirroot.'/grade/lib.php');
require_once('../lib.php');
// sort out delimiter
$csv_encode = '/\&\#44/';

View File

@ -0,0 +1,6 @@
<?PHP // $Id$
$plugin->version = 2007072401;
$plugin->requires = 2007072402;
?>

View File

@ -0,0 +1,17 @@
<?php // $Id$
$gradeimport_xml_capabilities = array(
'gradeimport/xml:view' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
'legacy' => array(
'editingteacher' => CAP_ALLOW,
'admin' => CAP_ALLOW
)
)
);
?>

View File

@ -1,21 +1,26 @@
<?php
<?php //$Id$
/**
* code in development
* does xml plugin need some flexibility/mapping of columns?
*/
require_once('../../../config.php');
require_once '../../../config.php';
require_once $CFG->dirroot.'/grade/lib.php';
require_once '../grade_import_form.php';
require_once '../lib.php';
$id = required_param('id', PARAM_INT); // course id
$course = get_record('course', 'id', $id); // actual course
// capability check
require_login($id);
require_capability('moodle/grade:import', get_context_instance(CONTEXT_COURSE, $course->id));
if (!$course = get_record('course', 'id', $id)) {
print_error('nocourseid');
}
require_login($course);
$context = get_context_instance(CONTEXT_COURSE, $id);
require_capability('moodle/grade:import', $context);
require_capability('gradeimport/xml:view', $context);
require_once('../lib.php');
require_once('../grade_import_form.php');
require_once($CFG->dirroot.'/grade/lib.php');
// print header
$strgrades = get_string('grades', 'grades');

View File

@ -0,0 +1,6 @@
<?PHP // $Id$
$plugin->version = 2007072401;
$plugin->requires = 2007072402;
?>