implementing moodle/user:viewdetails

This commit is contained in:
toyomoyo
2006-12-07 06:08:02 +00:00
parent 2da1b09809
commit 380199a948
4 changed files with 26 additions and 4 deletions
+5
View File
@@ -290,6 +290,11 @@ $moodle_capabilities = array(
'captype' => 'read',
'contextlevel' => CONTEXT_SYSTEM,
'legacy' => array(
'guest' => CAP_ALLOW,
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'coursecreator' => CAP_ALLOW,
'admin' => CAP_ALLOW
)
),
+9
View File
@@ -61,6 +61,15 @@ function xmldb_main_upgrade($oldversion=0) {
execute_sql("DELETE FROM {$CFG->prefix}course_display where userid=$guest->id ;", true);
}
}
if ($oldversion < 2006101009) { // add moodle/user:viewdetails to all roles!
if ($roles = get_records('role')) {
$context = get_context_instance(CONTEXT_SYSTEM);
foreach ($roles as $roleid=>$role) {
assign_capability('moodle/user:viewdetails', CAP_ALLOW, $roleid, $context->id);
}
}
}
return $result;
}
+11 -3
View File
@@ -548,10 +548,18 @@
$country = $countries[$user->country];
}
}
$usercontext = get_context_instance(CONTEXT_USER, $user->id);
if ($piclink = ($USER->id == $user->id || has_capability('moodle/user:viewdetails', $context) ||has_capability('moodle/user:viewdetails', $context))) {
$profilelink = '<strong><a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&amp;course='.$course->id.'">'.fullname($user).'</a></strong>';
} else {
$profilelink = '<strong>'.fullname($user).'</strong>';
}
$data = array (
print_user_picture($user->id, $course->id, $user->picture, false, true),
'<strong><a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&amp;course='.$course->id.'">'.fullname($user).'</a></strong>');
print_user_picture($user->id, $course->id, $user->picture, false, true, $piclink),
$profilelink);
if (!isset($hiddenfields['city'])) {
$data[] = $user->city;
}
+1 -1
View File
@@ -6,7 +6,7 @@
// This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php)
$version = 2006101008; // YYYYMMDD = date of the 1.7 branch (don't change)
$version = 2006101009; // YYYYMMDD = date of the 1.7 branch (don't change)
// X = release number 1.7.[0,1,2,3...]
// Y = micro-increments between releases