Skip to content

Commit

Permalink
Merge branch 'MDL-40464-master' of git://github.com/ankitagarwal/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
Damyon Wiese committed Jul 16, 2013
2 parents 924ea48 + 6acc54b commit 259e3c2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 27 deletions.
27 changes: 0 additions & 27 deletions lib/accesslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -7262,33 +7262,6 @@ function get_courseid_from_context(context $context) {
}
}

/**
* Get an array of courses where cap requested is available
* and user is enrolled, this can be relatively slow.
*
* @deprecated since 2.2, use enrol_get_users_courses() instead
* @param int $userid A user id. By default (null) checks the permissions of the current user.
* @param string $cap - name of the capability
* @param array $accessdata_ignored
* @param bool $doanything_ignored
* @param string $sort - sorting fields - prefix each fieldname with "c."
* @param array $fields - additional fields you are interested in...
* @param int $limit_ignored
* @return array $courses - ordered array of course objects - see notes above
*/
function get_user_courses_bycap($userid, $cap, $accessdata_ignored, $doanything_ignored, $sort = 'c.sortorder ASC', $fields = null, $limit_ignored = 0) {

$courses = enrol_get_users_courses($userid, true, $fields, $sort);
foreach ($courses as $id=>$course) {
$context = context_course::instance($id);
if (!has_capability($cap, $context, $userid)) {
unset($courses[$id]);
}
}

return $courses;
}

/**
* Extracts the relevant capabilities given a contextid.
* All case based, example an instance of forum context.
Expand Down
29 changes: 29 additions & 0 deletions lib/deprecatedlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -4166,3 +4166,32 @@ function get_course_context(context $context) {
debugging('get_course_context() is deprecated, please use $context->get_course_context(true) instead.', DEBUG_DEVELOPER);
return $context->get_course_context(true);
}

/**
* Get an array of courses where cap requested is available
* and user is enrolled, this can be relatively slow.
*
* @deprecated since 2.2
* @see enrol_get_users_courses()
* @param int $userid A user id. By default (null) checks the permissions of the current user.
* @param string $cap - name of the capability
* @param array $accessdata_ignored
* @param bool $doanything_ignored
* @param string $sort - sorting fields - prefix each fieldname with "c."
* @param array $fields - additional fields you are interested in...
* @param int $limit_ignored
* @return array $courses - ordered array of course objects - see notes above
*/
function get_user_courses_bycap($userid, $cap, $accessdata_ignored, $doanything_ignored, $sort = 'c.sortorder ASC', $fields = null, $limit_ignored = 0) {

debugging('get_user_courses_bycap() is deprecated, please use enrol_get_users_courses() instead.', DEBUG_DEVELOPER);
$courses = enrol_get_users_courses($userid, true, $fields, $sort);
foreach ($courses as $id=>$course) {
$context = context_course::instance($id);
if (!has_capability($cap, $context, $userid)) {
unset($courses[$id]);
}
}

return $courses;
}
1 change: 1 addition & 0 deletions lib/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ information provided here is intended especially for developers.
* delete_context() is deprecated, please use $context->delete_content() or context_helper::delete_instance().
* get_context_url() is deprecated, please use $context->get_url().
* get_course_context() is deprecated, please use $context->get_course_context().
* get_user_courses_bycap() is deprecated, please use enrol_get_users_courses().

=== 2.5.1 ===

Expand Down

0 comments on commit 259e3c2

Please sign in to comment.