-<?php\r
-\r
- require_once('../../config.php');\r
- require_once('lib.php');\r
- require_once($CFG->libdir.'/blocklib.php');\r
-\r
- require_once('pagelib.php');\r
- require_login();\r
-\r
- if (!isteacher()) {\r
- error(get_string('errormustbeteacher', 'data'));\r
- }\r
-\r
- if (confirm_sesskey()\r
- && ($recordid = required_param('recordid',PARAM_INT))\r
- && ($d = required_param('d',PARAM_INT))) {\r
- data_approve_record($recordid);\r
- }\r
-\r
- $page=optional_param('page','0',PARAM_INT);\r
- $rid = optional_param('rid','0', PARAM_INT);\r
- $search =optional_param('search','',PARAM_ALPHA);\r
- $sort= optional_param('sort','',PARAM_ALPHA);\r
- $order=optional_param('order','',PARAM_ALPHA);\r
-\r
- print_heading(get_string('recordapproved','data'));\r
- redirect('view.php?d='.$d.'&approved=1&page='.$page.'&rid='.$rid.'&search='.$search.'&sort='.$sort.'&order='.$order.'&');\r
-\r
-\r
-?>\r
+<?php // $Id$
+
+ require_once('../../config.php');
+ require_once('lib.php');
+
+ require_login();
+
+ $recordid = required_param('recordid',PARAM_INT);
+
+ $page = optional_param('page','0',PARAM_INT);
+ $rid = optional_param('rid','0', PARAM_INT);
+ $search = optional_param('search','',PARAM_ALPHA);
+ $sort = optional_param('sort','',PARAM_ALPHA);
+ $order = optional_param('order','',PARAM_ALPHA);
+
+ if (! $record = get_record('data_records', 'id', $recordid)) {
+ error('Record ID is incorrect');
+ }
+ if (! $data = get_record('data', 'id', $record->dataid)) {
+ error('Data ID is incorrect');
+ }
+ if (! $course = get_record('course', 'id', $data->course)) {
+ error('Course is misconfigured');
+ }
+
+ if (!isteacher($course->id)) {
+ error(get_string('errormustbeteacher', 'data'));
+ }
+
+ if (confirm_sesskey()) { /* Approve it! */
+ $newrecord->id = $record->id;
+ $newrecord->approved = 1;
+ update_record('data_records', $newrecord);
+ }
+
+ redirect('view.php?d='.$d.'&approved=1&page='.$page.'&rid='.$rid.'&search='.$search.'&sort='.$sort.'&order='.$order.'&', get_string('recordapproved','data'));
+
+
+?>