Skip to content

Commit

Permalink
replacing legacy calls
Browse files Browse the repository at this point in the history
  • Loading branch information
toyomoyo committed Sep 14, 2006
1 parent 8d9a0ae commit 61b03dc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion file.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
// warning: it may break backwards compatibility
if ((!empty($CFG->preventaccesstohiddenfiles))
and (count($args) >= 2)
and (!isteacher($course->id))) {
and (!has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_COURSE, $course->id))) {

$reference = ltrim($relativepath, "/{$args[0]}/");

Expand Down
21 changes: 18 additions & 3 deletions lib/datalib.php
Original file line number Diff line number Diff line change
Expand Up @@ -584,14 +584,29 @@ function get_courses_page($categoryid="all", $sort="c.sortorder ASC", $fields="c
* @param int $userid The user of interest
* @param string $sort ?
* @return object {@link $COURSE} records
* @todo XXX Convert to Roles
*/
function get_my_courses($userid, $sort='visible DESC,sortorder ASC') {

global $CFG, $USER;

$course = array();
$mycourses = array();
$SQL = "SELECT * from {$CFG->prefix}course WHERE 1 ORDER BY $sort";
$courses = get_records_sql($SQL);

foreach ($courses as $course) {
if ($course->id != SITEID) {
// users with moodle/course:view are considered course participants
// the course needs to be visible, or user must have moodle/course:viewhiddencourses capability set to view
// hidden courses
if (has_capability('moodle/course:view', get_context_instance(CONTEXT_COURSE, $course->id), $userid)
&& ($course->visible || has_capability('moodle/course:viewhiddencourses', get_context_instance(CONTEXT_COURSE, $course->id), $userid))) {
$mycourses[] = $course;
}
}
}

return $mycourses;
/*
if ($students = get_records('user_students', 'userid', $userid, '', 'id, course')) {
foreach ($students as $student) {
$course[$student->course] = $student->course;
Expand Down Expand Up @@ -620,7 +635,7 @@ function get_my_courses($userid, $sort='visible DESC,sortorder ASC') {
$courseids = implode(',', $course);
return get_records_list('course', 'id', $courseids, $sort);

*/
// The following is correct but VERY slow with large datasets
//
// return get_records_sql("SELECT c.*
Expand Down

0 comments on commit 61b03dc

Please sign in to comment.