Skip to content

Commit

Permalink
MDL-10890 all require_login() in modules reviewed and fixed use of $cm
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Aug 17, 2007
1 parent a104deb commit bb5b722
Show file tree
Hide file tree
Showing 20 changed files with 26 additions and 21 deletions.
6 changes: 5 additions & 1 deletion mod/chat/gui_header_js/insert.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
error('Could not find the course this belongs to!');
}

require_login($course->id);
if (!$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
error('Course Module ID was incorrect');
}

require_login($course->id, false, $cm);

if (isguest()) {
error('Guest does not have access to chat rooms');
Expand Down
2 changes: 2 additions & 0 deletions mod/data/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
}
}

require_login($course, false, $cm);

$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/data:uploadentries', $context);

Expand Down
2 changes: 0 additions & 2 deletions mod/data/templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
require_once('lib.php');
require_once($CFG->libdir.'/blocklib.php');

require_login();

$id = optional_param('id', 0, PARAM_INT); // course module id
$d = optional_param('d', 0, PARAM_INT); // database id
$mode = optional_param('mode', 'singletemplate', PARAM_ALPHA);
Expand Down
2 changes: 1 addition & 1 deletion mod/glossary/editcategories.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
}
}

require_login($course->id, false);
require_login($course->id, false, $cm);

$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/glossary:managecategories', $context);
Expand Down
2 changes: 1 addition & 1 deletion mod/glossary/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
error("Course module is incorrect");
}

require_login($course->id, false);
require_login($course->id, false, $cm);

$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/glossary:export', $context);
Expand Down
2 changes: 1 addition & 1 deletion mod/glossary/exportfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
error("Course module is incorrect");
}

require_login($course->id, false);
require_login($course->id, false, $cm);

$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/glossary:export', $context);
Expand Down
2 changes: 1 addition & 1 deletion mod/glossary/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
error("Course module is incorrect");
}

require_login($course->id, false);
require_login($course->id, false, $cm);

$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/glossary:import', $context);
Expand Down
2 changes: 1 addition & 1 deletion mod/hotpot/attempt.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
}

// make sure this user is enrolled in this course
require_login($course->id);
require_login($course, true, $cm);

$next_url = "$CFG->wwwroot/course/view.php?id=$course->id";
$time = time();
Expand Down
2 changes: 1 addition & 1 deletion mod/hotpot/report.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
// set homeurl of couse (for error messages)
$course_homeurl = "$CFG->wwwroot/course/view.php?id=$course->id";

require_login($course->id);
require_login($course, true, $cm);

// get report mode
if (has_capability('mod/hotpot:viewreport',$modulecontext)) {
Expand Down
3 changes: 2 additions & 1 deletion mod/hotpot/review.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@
if (! $attempt = get_record("hotpot_attempts", "id", $attempt)) {
error("Attempt ID was incorrect");
}

require_login($course, true, $cm);

$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_login($course->id);
if (!has_capability('mod/hotpot:viewreport',$context)) {
if (!$hotpot->review) {
error(get_string("noreview", "quiz"));
Expand Down
2 changes: 1 addition & 1 deletion mod/hotpot/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
}

}
require_login($course->id);
require_login($course, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
}
// set nextpage (for error messages)
Expand Down
2 changes: 1 addition & 1 deletion mod/journal/report.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
error("Course module is misconfigured");
}

require_login($course->id, false);
require_login($course->id, false, $cm);

if (!isteacher($course->id)) {
error("Only teachers can look at this page");
Expand Down
2 changes: 1 addition & 1 deletion mod/lams/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
error("Course module is incorrect");
}

require_login($course->id);
require_login($course, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);

add_to_log($course->id, "lams", "view", "view.php?id=$cm->id", "$lams->id");
Expand Down
2 changes: 1 addition & 1 deletion mod/lesson/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
}


require_login($course->id, false);
require_login($course->id, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/lesson:edit', $context);

Expand Down
2 changes: 1 addition & 1 deletion mod/lesson/importppt.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
error("Course module is incorrect");
}

require_login($course->id, false);
require_login($course->id, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/lesson:edit', $context);

Expand Down
2 changes: 1 addition & 1 deletion mod/lesson/report.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
}

// make sure people are where they should be
require_login($course->id, false);
require_login($course->id, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/lesson:manage', $context);

Expand Down
4 changes: 2 additions & 2 deletions mod/quiz/comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
error('Attempt has not closed yet');
}

require_login($course->id);

$cm = get_coursemodule_from_instance('quiz', $quiz->id);
require_login($course, true, $cm);

$context = get_context_instance(CONTEXT_MODULE, $cm->id);

require_capability('mod/quiz:grade', $context);
Expand Down
2 changes: 1 addition & 1 deletion mod/quiz/report.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
}
}

require_login($course->id, false);
require_login($course, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/quiz:viewreports', $context);

Expand Down
2 changes: 1 addition & 1 deletion mod/survey/download.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
error("Course is misconfigured");
}

require_login($course->id, false);
require_login($course->id, false, $cm);
require_capability('mod/survey:download', get_context_instance(CONTEXT_MODULE, $cm->id)) ;

if (! $survey = get_record("survey", "id", $cm->instance)) {
Expand Down
2 changes: 1 addition & 1 deletion mod/survey/report.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
error("Course is misconfigured");
}

require_login($course->id, false);
require_login($course->id, false, $cm);

$context = get_context_instance(CONTEXT_MODULE, $cm->id);

Expand Down

0 comments on commit bb5b722

Please sign in to comment.