diff --git a/grade/import/csv/db/access.php b/grade/import/csv/db/access.php index 139597f9cb0..63ab19a3681 100644 --- a/grade/import/csv/db/access.php +++ b/grade/import/csv/db/access.php @@ -1,2 +1,17 @@ + array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_COURSE, + 'legacy' => array( + 'editingteacher' => CAP_ALLOW, + 'admin' => CAP_ALLOW + ) + ) +); + +?> diff --git a/grade/import/csv/index.php b/grade/import/csv/index.php index 1bbaa020618..21b15c38975 100755 --- a/grade/import/csv/index.php +++ b/grade/import/csv/index.php @@ -1,17 +1,20 @@ -libdir.'/gradelib.php'); +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/'; diff --git a/grade/import/csv/version.php b/grade/import/csv/version.php new file mode 100644 index 00000000000..fda21d0e8fd --- /dev/null +++ b/grade/import/csv/version.php @@ -0,0 +1,6 @@ +version = 2007072401; +$plugin->requires = 2007072402; + +?> diff --git a/grade/import/xml/db/access.php b/grade/import/xml/db/access.php new file mode 100644 index 00000000000..c221c464523 --- /dev/null +++ b/grade/import/xml/db/access.php @@ -0,0 +1,17 @@ + array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_COURSE, + 'legacy' => array( + 'editingteacher' => CAP_ALLOW, + 'admin' => CAP_ALLOW + ) + ) +); + +?> + + diff --git a/grade/import/xml/index.php b/grade/import/xml/index.php index e03b383df9a..b8591738962 100755 --- a/grade/import/xml/index.php +++ b/grade/import/xml/index.php @@ -1,21 +1,26 @@ -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'); diff --git a/grade/import/xml/version.php b/grade/import/xml/version.php new file mode 100644 index 00000000000..fda21d0e8fd --- /dev/null +++ b/grade/import/xml/version.php @@ -0,0 +1,6 @@ +version = 2007072401; +$plugin->requires = 2007072402; + +?>