id;
}
if (! $user = get_record("user", "id", $id) ) {
error("No such user in this course");
}
if (! $course = get_record("course", "id", $course) ) {
error("No such course id");
}
if (!empty($CFG->forcelogin) || $course->id != SITEID) {
require_login($course->id);
}
if (!empty($CFG->forceloginforprofiles)) {
require_login();
if (isguest()) {
redirect("$CFG->wwwroot/login/index.php");
}
}
add_to_log($course->id, "user", "view", "view.php?id=$user->id&course=$course->id", "$user->id");
if ($course->id != SITEID) {
if ($student = get_record("user_students", "userid", $user->id, "course", $course->id)) {
$user->lastaccess = $student->timeaccess;
} else if ($teacher = get_record("user_teachers", "userid", $user->id, "course", $course->id)) {
$user->lastaccess = $teacher->timeaccess;
}
}
$fullname = fullname($user, isteacher($course->id));
$personalprofile = get_string("personalprofile");
$participants = get_string("participants");
if (empty($USER->id)) {
$currentuser = false;
} else {
$currentuser = ($user->id == $USER->id);
}
if (groupmode($course) == SEPARATEGROUPS and !isteacheredit($course->id)) { // Groups must be kept separate
require_login();
///this is changed because of mygroupid
$gtrue = false;
if ($mygroups = mygroupid($course->id)){
foreach ($mygroups as $group){
if (ismember($group, $user->id)){
$gtrue = true;
}
}
}
if (!$currentuser && !isteacheredit($course->id, $user->id) && !$gtrue) {
print_header("$personalprofile: ", "$personalprofile: ",
"id\">$course->shortname ->
id\">$participants",
"", "", true, " ", navmenu($course));
error(get_string("groupnotamember"), "../course/view.php?id=$course->id");
}
}
if ($course->id == SITEID and !$currentuser) { // To reduce possibility of "browsing" userbase at site level
if ($CFG->forceloginforprofiles and !isteacherinanycourse() and !isteacherinanycourse($user->id)) { // Teachers can browse and be browsed at site level. If not forceloginforprofiles, allow access (bug #4366)
print_header("$personalprofile: ", "$personalprofile: ",
"id\">$participants",
"", "", true, " ", navmenu($course));
print_heading(get_string('usernotavailable', 'error'));
print_footer($course);
die;
}
}
if ($course->category) {
print_header("$personalprofile: $fullname", "$personalprofile: $fullname",
"id\">$course->shortname ->
id\">$participants -> $fullname",
"", "", true, " ", navmenu($course));
} else {
print_header("$course->fullname: $personalprofile: $fullname", "$course->fullname",
"$fullname", "", "", true, " ", navmenu($course));
}
if ($course->category and ! isguest() ) { // Need to have access to a course to see that info
if (!isstudent($course->id, $user->id) && !isteacher($course->id, $user->id)) {
print_heading(get_string("notenrolled", "", $fullname));
print_footer($course);
die;
}
}
if ($user->deleted) {
print_heading(get_string("userdeleted"));
}
/// Get the hidden field list
if (isteacher($course->id) || isadmin()) {
$hiddenfields = array(); // teachers and admins are allowed to see everything
} else {
$hiddenfields = array_flip(explode(',', $CFG->hiddenuserfields));
}
/// Print tabs at top
/// This same call is made in:
/// /user/view.php
/// /user/edit.php
/// /course/user.php
$currenttab = 'profile';
include('tabs.php');
echo "
";
echo "";
echo "";
print_user_picture($user->id, $course->id, $user->picture, true, false, false);
echo " | ";
// Print the description
if ($user->description && !isset($hiddenfields['description'])) {
echo format_text($user->description, FORMAT_MOODLE)." ";
}
// Print all the little details in a list
echo '';
if (($user->city or $user->country) and (!isset($hiddenfields['city']) or !isset($hiddenfields['country']))) {
$location = '';
if ($user->city && !isset($hiddenfields['city'])) {
$location .= $user->city;
}
if (!empty($countries[$user->country]) && !isset($hiddenfields['country'])) {
if ($user->city && !isset($hiddenfields['country'])) {
$location .= ', ';
}
$countries = get_list_of_countries();
$location .= $countries[$user->country];
}
print_row(get_string("location").":", $location);
}
if (isteacher($course->id)) {
if ($user->address) {
print_row(get_string("address").":", "$user->address");
}
if ($user->phone1) {
print_row(get_string("phone").":", "$user->phone1");
}
if ($user->phone2) {
print_row(get_string("phone").":", "$user->phone2");
}
}
if ($user->maildisplay == 1 or
($user->maildisplay == 2 and $course->category and !isguest()) or
isteacher($course->id)) {
$emailswitch = '';
if (isteacheredit($course->id) or $currentuser) { /// Can use the enable/disable email stuff
if (!empty($enable)) { /// Recieved a parameter to enable the email address
set_field('user', 'emailstop', 0, 'id', $user->id);
$user->emailstop = 0;
}
if (!empty($disable)) { /// Recieved a parameter to disable the email address
set_field('user', 'emailstop', 1, 'id', $user->id);
$user->emailstop = 1;
}
}
if (isteacheredit($course->id)) { /// Can use the enable/disable email stuff
if ($user->emailstop) {
$switchparam = 'enable';
$switchtitle = get_string('emaildisable');
$switchclick = get_string('emailenableclick');
$switchpix = 'emailno.gif';
} else {
$switchparam = 'disable';
$switchtitle = get_string('emailenable');
$switchclick = get_string('emaildisableclick');
$switchpix = 'email.gif';
}
$emailswitch = " id&course=$course->id&$switchparam=1\">".
" pixpath/t/$switchpix\" alt=\"\" />";
} else if ($currentuser) { /// Can only re-enable an email this way
if ($user->emailstop) { // Include link that tells how to re-enable their email
$switchparam = 'enable';
$switchtitle = get_string('emaildisable');
$switchclick = get_string('emailenableclick');
$emailswitch = " (id&course=$course->id&enable=1\">$switchtitle)";
}
}
print_row(get_string("email").":", obfuscate_mailto($user->email, '', $user->emailstop)."$emailswitch");
}
if ($user->url && !isset($hiddenfields['webpage'])) {
print_row(get_string("webpage").":", "url\">$user->url");
}
if ($user->icq && !isset($hiddenfields['icqnumber'])) {
print_row(get_string('icqnumber').':',"icq\">$user->icq icq&img=5\" width=\"18\" height=\"18\" border=\"0\" alt=\"\" />");
}
if ($user->skype && !isset($hiddenfields['skypeid'])) {
print_row(get_string('skypeid').':',''.s($user->skype).
' ');
}
if ($user->yahoo && !isset($hiddenfields['yahooid'])) {
print_row(get_string('yahooid').':', ''.s($user->yahoo).'');
}
if ($user->aim && !isset($hiddenfields['aimid'])) {
print_row(get_string('aimid').':', ''.s($user->aim).'');
}
if ($user->msn && !isset($hiddenfields['msnid'])) {
print_row(get_string('msnid').':', s($user->msn));
}
if (isteacher($course->id)) {
if ($mycourses = get_my_courses($user->id)) {
$courselisting = '';
foreach ($mycourses as $mycourse) {
if ($mycourse->visible and $mycourse->category) {
if ($mycourse->id != $course->id){
$courselisting .= "wwwroot/user/view.php?id=$user->id&course=$mycourse->id\">$mycourse->fullname, ";
}
else {
$courselisting .= "$mycourse->fullname, ";
}
}
}
print_row(get_string('courses').':', rtrim($courselisting,', '));
}
}
if (!isset($hiddenfields['lastaccess'])) {
if ($user->lastaccess) {
$datestring = userdate($user->lastaccess)." (".format_time(time() - $user->lastaccess).")";
} else {
$datestring = get_string("never");
}
print_row(get_string("lastaccess").":", $datestring);
}
/// Printing groups
$isseparategroups = ($course->groupmode == SEPARATEGROUPS and $course->groupmodeforce and
!isteacheredit($course->id));
if (!$isseparategroups){
if ($usergroups = user_group($course->id, $user->id)){
$groupstr = '';
foreach ($usergroups as $group){
$groupstr .= ' '.$group->name.',';
}
print_row(get_string("group").":", rtrim($groupstr, ', '));
}
}
/// End of printing groups
echo " ";
echo " |
";
$internalpassword = false;
if (is_internal_auth($user->auth) or (!empty($CFG->{'auth_'.$user->auth.'_stdchangepassword'}))) {
if (empty($CFG->loginhttps)) {
$internalpassword = "$CFG->wwwroot/login/change_password.php";
} else {
$internalpassword = str_replace('http','https',$CFG->wwwroot.'/login/change_password.php');
}
}
// Print other functions
echo '\n";
print_footer($course);
/// Functions ///////
function print_row($left, $right) {
echo "\n$left | $right |
\n";
}
?>