confirmed and !$user->email) { // Special case which can only occur when a new account // has just been created by EXTERNAL authentication // This is the only page in Moodle that has the exception // so that users can set up their accounts $newaccount = true; } else { $newaccount = false; require_login($course->id); } if ($USER->id <> $user->id and !isadmin()) { error("You can only edit your own information"); } if (isguest()) { error("The guest user cannot edit their profile."); } if (isguest($user->id)) { error("Sorry, the guest user cannot be edited."); } /// If data submitted, then process and store. if ($usernew = data_submitted()) { $usernew->firstname = strip_tags($usernew->firstname); $usernew->lastname = strip_tags($usernew->lastname); if (find_form_errors($user, $usernew, $err)) { if ($filename = valid_uploaded_file($_FILES['imagefile'])) { $usernew->picture = save_user_image($user->id, $filename); } $user = $usernew; } else { $timenow = time(); if ($filename = valid_uploaded_file($_FILES['imagefile'])) { $usernew->picture = save_user_image($user->id, $filename); } else { $usernew->picture = $user->picture; } $usernew->timemodified = time(); if (isadmin()) { if ($usernew->newpassword) { $usernew->password = md5($usernew->newpassword); } } else { if (isset($usernew->newpassword)) { error("You can not change the password like that"); } } if ($usernew->url and !(substr($usernew->url, 0, 4) == "http")) { $usernew->url = "http://".$usernew->url; } if (update_record("user", $usernew)) { add_to_log($course->id, "user", "update", "view.php?id=$user->id&course=$course->id", ""); if ($user->id == $USER->id) { // Copy data into $USER session variable $usernew = (array)$usernew; foreach ($usernew as $variable => $value) { $USER->$variable = $value; } save_session("USER"); redirect("view.php?id=$user->id&course=$course->id", get_string("changessaved")); } else { redirect("../admin/user.php", get_string("changessaved")); } } else { error("Could not update the user record ($user->id)"); } } } /// Otherwise fill and print the form. $streditmyprofile = get_string("editmyprofile"); $strparticipants = get_string("participants"); $strnewuser = get_string("newuser"); if (($user->firstname and $user->lastname) or $newaccount) { if ($newaccount) { $userfullname = $strnewuser; } else { $userfullname = "$user->firstname $user->lastname"; } if ($course->category) { print_header("$course->shortname: $streditmyprofile", "$course->fullname: $streditmyprofile", "wwwroot/course/view.php?id=$course->id\">$course->shortname -> id\">$strparticipants -> id&course=$course->id\">$userfullname -> $streditmyprofile", ""); } else { print_header("$course->shortname: $streditmyprofile", "$course->fullname", "id&course=$course->id\">$userfullname -> $streditmyprofile", ""); } } else { $userfullname = $strnewuser; $straddnewuser = get_string("addnewuser"); $stradministration = get_string("administration"); print_header("$course->shortname: $streditmyprofile", "$course->fullname", "wwwroot/admin\">$stradministration -> $straddnewuser", ""); } $teacher = strtolower($course->teacher); if (!isadmin()) { $teacheronly = "(".get_string("teacheronly", "", $teacher).")"; } else { $teacheronly = ""; } print_heading( get_string("userprofilefor", "", "$userfullname") ); print_simple_box_start("center", "", "$THEME->cellheading"); if (!empty($err)) { echo "