MDL-7821 wrong use of cm in data mod and added proper require_login()

This commit is contained in:
skodak
2006-12-06 20:17:58 +00:00
parent de312b53bb
commit c088d6039d
7 changed files with 18 additions and 27 deletions
+4 -15
View File
@@ -546,7 +546,7 @@ function data_numentries($data){
function data_add_record($data, $groupid=0){
global $USER;
$cm = data_get_cm($data);
$cm = get_coursemodule_from_instance('data', $data->id);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$record->userid = $USER->id;
@@ -811,7 +811,7 @@ function data_get_coursemodule_info($coursemodule) {
function data_print_template($template, $records, $data, $search='',$page=0, $return=false) {
global $CFG;
$cm = data_get_cm($data);
$cm = get_coursemodule_from_instance('data', $data->id);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
static $fields = NULL;
@@ -963,7 +963,7 @@ function data_print_preference_form($data, $perpage, $search, $sort='', $order='
function data_print_ratings($data, $record) {
global $USER;
$cm = data_get_cm($data);
$cm = get_coursemodule_from_instance('data', $data->id);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$ratingsmenuused = false;
@@ -1136,7 +1136,7 @@ function data_print_comment($data, $comment, $page=0) {
global $USER, $CFG;
$cm = data_get_cm($data);
$cm = get_coursemodule_from_instance('data', $data->id);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$stredit = get_string('edit');
@@ -1225,17 +1225,6 @@ function data_convert_arrays_to_strings(&$fieldinput) {
}
}
// returns the $cm given $data
function data_get_cm($data) {
global $CFG, $course;
$datamod = get_record('modules', 'name', 'data');
$SQL = "select * from {$CFG->prefix}course_modules
where course = $course->id and
module = $datamod->id and
instance = $data->id";
return get_record_sql($SQL);
}
/**
* Converts a database (module instance) to use the Roles System