Skip to content

Commit

Permalink
MDL-15516 prvent access to deleted profiles and other user areas
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Jul 5, 2008
1 parent d6ace12 commit f5fc83e
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 4 deletions.
7 changes: 7 additions & 0 deletions blog/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@
if (!$user = $DB->get_record('user', array('id'=>$filterselect))) {
print_error('invaliduserid');
}
if ($user->deleted) {
print_header();
print_heading(get_string('userdeleted'));
print_footer();
die;
}

if ($USER->id == $filterselect) {
if (!has_capability('moodle/blog:create', $sitecontext)
and !has_capability('moodle/blog:view', $sitecontext)) {
Expand Down
9 changes: 8 additions & 1 deletion course/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,16 @@
print_error('invaliduserid', 'error');
}

//require_login($course);
require_login();
$COURSE = clone($course);

if ($user->deleted) {
print_header();
print_heading(get_string('userdeleted'));
print_footer();
die;
}

$coursecontext = get_context_instance(CONTEXT_COURSE, $id);
$personalcontext = get_context_instance(CONTEXT_USER, $user->id);

Expand Down
7 changes: 7 additions & 0 deletions message/discussion.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
print_error('invaliduserid');
}

if ($user->deleted) {
print_header();
print_heading(get_string('userdeleted'));
print_footer();
die;
}

/// Check if frame&jsless mode selected
if (!get_user_preferences('message_noframesjs', 0) and !$noframesjs) {

Expand Down
7 changes: 7 additions & 0 deletions mod/forum/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@
require_course_login($course);
}

if ($user->deleted) {
print_header();
print_heading(get_string('userdeleted'));
print_footer($course);
die;
}

add_to_log($course->id, "forum", "user report",
"user.php?course=$course->id&id=$user->id&mode=$mode", "$user->id");

Expand Down
8 changes: 8 additions & 0 deletions notes/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@
}
$filtertype = 'user';
$filterselect = $user->id;

if ($user->deleted) {
print_header();
print_heading(get_string('userdeleted'));
print_footer();
die;
}

} else {
$filtertype = 'course';
$filterselect = $course->id;
Expand Down
7 changes: 7 additions & 0 deletions user/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@
}
}

if ($user->deleted) {
print_header();
print_heading(get_string('userdeleted'));
print_footer($course);
die;
}

//load user preferences
useredit_load_preferences($user);

Expand Down
7 changes: 7 additions & 0 deletions user/editadvanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@
print_error('guestnoeditprofileother');
}

if ($user->deleted) {
print_header();
print_heading(get_string('userdeleted'));
print_footer($course);
die;
}

//load user preferences
useredit_load_preferences($user);

Expand Down
12 changes: 9 additions & 3 deletions user/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@

if ($user->deleted) {
print_heading(get_string('userdeleted'));
if (!has_capability('moodle/user:update', $coursecontext)) {
print_footer($course);
die;
}
}

/// OK, security out the way, now we are showing the user
Expand Down Expand Up @@ -171,7 +175,9 @@

$currenttab = 'profile';
$showroles = 1;
include('tabs.php');
if (!$user->deleted) {
include('tabs.php');
}

if (is_mnet_remote_user($user)) {
$sql = "
Expand Down Expand Up @@ -458,7 +464,7 @@
}
}

if ($USER->id != $user->id && empty($USER->realuser) && has_capability('moodle/user:loginas', $coursecontext) &&
if (!$user->deleted and $USER->id != $user->id && empty($USER->realuser) && has_capability('moodle/user:loginas', $coursecontext) &&
! has_capability('moodle/site:doanything', $coursecontext, $user->id, false)) {
echo '<form action="'.$CFG->wwwroot.'/course/loginas.php" method="get">';
echo '<div>';
Expand All @@ -470,7 +476,7 @@
echo '</form>';
}

if (!empty($CFG->messaging) and !isguest() and has_capability('moodle/site:sendmessage', get_context_instance(CONTEXT_SYSTEM))) {
if (!$user->deleted and !empty($CFG->messaging) and !isguest() and has_capability('moodle/site:sendmessage', get_context_instance(CONTEXT_SYSTEM))) {
if (!empty($USER->id) and ($USER->id == $user->id)) {
if ($countmessages = $DB->count_records('message', array('useridto'=>$user->id))) {
$messagebuttonname = get_string("messages", "message")."($countmessages)";
Expand Down

0 comments on commit f5fc83e

Please sign in to comment.