學生若知道同門課中同學在 moodle 中的 id=11223,可直接修改 id=11223,就可查看該同學修課資料。取消此一查閱,限制沒有 moodle/site:viewuseridentity 能力的用戶都指向自己的資料。
[root@moodle user]# diff -uN ../../moodle/user/view.php view.php
--- ../../moodle/user/view.php 2012-07-06 08:44:31.000000000 +0800
+++ view.php 2014-09-23 17:53:15.366247750 +0800
@@ -31,7 +31,8 @@
$id = optional_param('id', 0, PARAM_INT); // user id
$courseid = optional_param('course', SITEID, PARAM_INT); // course id (defaults to Site)
-if (empty($id)) { // See your own profile by default
+if (empty($id) or ($id != $USER->id and !has_capability('moodle/site:viewuseridentity',
+ get_context_instance(CONTEXT_USER, $USER->id, IGNORE_MISSING))) ) { // See your own profile by default
require_login();
$id = $USER->id;
}