mirror of
https://github.com/moodle/moodle.git
synced 2025-02-19 07:41:02 +01:00
Merge branch 'w48_MDL-30467_m22_delusers' of git://github.com/skodak/moodle
This commit is contained in:
commit
5c0b8ea3f1
@ -192,7 +192,10 @@ function upgrade_migrate_user_icons() {
|
||||
upgrade_set_timeout(60); /// Give upgrade at least 60 more seconds
|
||||
$pbar->update($i, $count, "Migrated user icons $i/$count.");
|
||||
|
||||
$context = get_context_instance(CONTEXT_USER, $user->id);
|
||||
if (!$context = get_context_instance(CONTEXT_USER, $user->id)) {
|
||||
// deleted user
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($fs->file_exists($context->id, 'user', 'icon', 0, '/', 'f1.jpg')) {
|
||||
// already converted!
|
||||
|
@ -10,6 +10,7 @@ removed unused libraries:
|
||||
API changes:
|
||||
* new admin/tool plugin type
|
||||
* new context API - old API is still available
|
||||
* deleted users do not have context any more
|
||||
* removed global search
|
||||
|
||||
|
||||
|
@ -324,7 +324,7 @@ function tag_print_user_box($user, $return=false) {
|
||||
$usercontext = get_context_instance(CONTEXT_USER, $user->id);
|
||||
$profilelink = '';
|
||||
|
||||
if ( has_capability('moodle/user:viewdetails', $usercontext) || has_coursecontact_role($user->id) ) {
|
||||
if ($usercontext and (has_capability('moodle/user:viewdetails', $usercontext) || has_coursecontact_role($user->id))) {
|
||||
$profilelink = $CFG->wwwroot .'/user/view.php?id='. $user->id;
|
||||
}
|
||||
|
||||
|
@ -57,6 +57,15 @@ if (!empty($CFG->forceloginforprofiles)) {
|
||||
|
||||
$userid = $userid ? $userid : $USER->id; // Owner of the page
|
||||
$user = $DB->get_record('user', array('id' => $userid));
|
||||
|
||||
if ($user->deleted) {
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('userdeleted'));
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
|
||||
$currentuser = ($user->id == $USER->id);
|
||||
$context = $usercontext = get_context_instance(CONTEXT_USER, $userid, MUST_EXIST);
|
||||
|
||||
|
@ -48,7 +48,7 @@ $currentuser = ($user->id == $USER->id);
|
||||
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$usercontext = get_context_instance(CONTEXT_USER, $user->id, MUST_EXIST);
|
||||
$usercontext = get_context_instance(CONTEXT_USER, $user->id, IGNORE_MISSING);
|
||||
|
||||
// Require login first
|
||||
if (isguestuser($user)) {
|
||||
@ -68,7 +68,7 @@ $PAGE->set_other_editing_capability('moodle/course:manageactivities');
|
||||
|
||||
$isparent = false;
|
||||
|
||||
if (!$currentuser
|
||||
if (!$currentuser and !$user->deleted
|
||||
and $DB->record_exists('role_assignments', array('userid'=>$USER->id, 'contextid'=>$usercontext->id))
|
||||
and has_capability('moodle/user:viewdetails', $usercontext)) {
|
||||
// TODO: very ugly hack - do not force "parents" to enrol into course their child is enrolled in,
|
||||
@ -109,7 +109,7 @@ if ($currentuser) {
|
||||
|
||||
// check course level capabilities
|
||||
if (!has_capability('moodle/user:viewdetails', $coursecontext) && // normal enrolled user or mnager
|
||||
!has_capability('moodle/user:viewdetails', $usercontext)) { // usually parent
|
||||
($user->deleted or !has_capability('moodle/user:viewdetails', $usercontext))) { // usually parent
|
||||
print_error('cannotviewprofile');
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user