2010-05-04 13:04:35 +00:00
|
|
|
<?php
|
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Public Profile -- a user's public profile page
|
|
|
|
*
|
|
|
|
* - each user can currently have their own page (cloned from system and then customised)
|
|
|
|
* - users can add any blocks they want
|
|
|
|
* - the administrators can define a default site public profile for users who have
|
|
|
|
* not created their own public profile
|
|
|
|
*
|
|
|
|
* This script implements the user's view of the public profile, and allows editing
|
|
|
|
* of the public profile.
|
|
|
|
*
|
2014-02-18 10:12:42 +13:00
|
|
|
* @package core_user
|
2010-05-04 13:04:35 +00:00
|
|
|
* @copyright 2010 Remote-Learner.net
|
|
|
|
* @author Hubert Chathi <hubert@remote-learner.net>
|
|
|
|
* @author Olav Jordan <olav.jordan@remote-learner.net>
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once(dirname(__FILE__) . '/../config.php');
|
|
|
|
require_once($CFG->dirroot . '/my/lib.php');
|
2011-04-17 11:07:57 +02:00
|
|
|
require_once($CFG->dirroot . '/tag/lib.php');
|
2010-05-04 13:04:35 +00:00
|
|
|
require_once($CFG->dirroot . '/user/profile/lib.php');
|
2011-01-03 16:46:16 +00:00
|
|
|
require_once($CFG->libdir.'/filelib.php');
|
2010-05-04 13:04:35 +00:00
|
|
|
|
2014-06-12 14:02:04 +08:00
|
|
|
$userid = optional_param('id', 0, PARAM_INT);
|
|
|
|
$edit = optional_param('edit', null, PARAM_BOOL); // Turn editing on and off.
|
|
|
|
$reset = optional_param('reset', null, PARAM_BOOL);
|
|
|
|
$showallcourses = optional_param('showallcourses', 0, PARAM_INT);
|
2010-05-04 13:04:35 +00:00
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
$PAGE->set_url('/user/profile.php', array('id' => $userid));
|
2011-02-14 15:42:26 +01:00
|
|
|
|
2010-05-04 13:04:35 +00:00
|
|
|
if (!empty($CFG->forceloginforprofiles)) {
|
|
|
|
require_login();
|
|
|
|
if (isguestuser()) {
|
2011-02-14 15:42:26 +01:00
|
|
|
$SESSION->wantsurl = $PAGE->url->out(false);
|
2014-09-14 20:49:16 +08:00
|
|
|
|
|
|
|
$PAGE->set_context(context_system::instance());
|
|
|
|
echo $OUTPUT->header();
|
|
|
|
echo $OUTPUT->confirm(get_string('guestcantaccessprofiles', 'error'),
|
|
|
|
get_login_url(),
|
|
|
|
$CFG->wwwroot);
|
|
|
|
echo $OUTPUT->footer();
|
|
|
|
die;
|
2010-05-04 13:04:35 +00:00
|
|
|
}
|
|
|
|
} else if (!empty($CFG->forcelogin)) {
|
|
|
|
require_login();
|
|
|
|
}
|
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
$userid = $userid ? $userid : $USER->id; // Owner of the page.
|
2013-06-15 12:17:54 +02:00
|
|
|
if ((!$user = $DB->get_record('user', array('id' => $userid))) || ($user->deleted)) {
|
2012-07-26 11:38:02 +08:00
|
|
|
$PAGE->set_context(context_system::instance());
|
2011-11-25 08:46:38 +01:00
|
|
|
echo $OUTPUT->header();
|
2013-06-15 12:17:54 +02:00
|
|
|
if (!$user) {
|
|
|
|
echo $OUTPUT->notification(get_string('invaliduser', 'error'));
|
|
|
|
} else {
|
|
|
|
echo $OUTPUT->notification(get_string('userdeleted'));
|
|
|
|
}
|
2011-11-25 08:46:38 +01:00
|
|
|
echo $OUTPUT->footer();
|
|
|
|
die;
|
|
|
|
}
|
|
|
|
|
2010-05-04 13:04:35 +00:00
|
|
|
$currentuser = ($user->id == $USER->id);
|
2012-07-26 11:38:02 +08:00
|
|
|
$context = $usercontext = context_user::instance($userid, MUST_EXIST);
|
2010-05-04 13:04:35 +00:00
|
|
|
|
|
|
|
if (!$currentuser &&
|
2010-08-25 08:32:59 +00:00
|
|
|
!empty($CFG->forceloginforprofiles) &&
|
2010-07-29 03:03:03 +00:00
|
|
|
!has_capability('moodle/user:viewdetails', $context) &&
|
2010-06-29 14:29:28 +00:00
|
|
|
!has_coursecontact_role($userid)) {
|
2011-03-12 19:04:26 +01:00
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
// Course managers can be browsed at site level. If not forceloginforprofiles, allow access (bug #4366).
|
2010-05-04 13:04:35 +00:00
|
|
|
$struser = get_string('user');
|
2012-07-26 11:38:02 +08:00
|
|
|
$PAGE->set_context(context_system::instance());
|
2014-02-18 10:12:42 +13:00
|
|
|
$PAGE->set_title("$SITE->shortname: $struser"); // Do not leak the name.
|
2010-05-04 13:04:35 +00:00
|
|
|
$PAGE->set_heading("$SITE->shortname: $struser");
|
2014-02-18 10:12:42 +13:00
|
|
|
$PAGE->set_url('/user/profile.php', array('id' => $userid));
|
2010-05-04 13:04:35 +00:00
|
|
|
$PAGE->navbar->add($struser);
|
|
|
|
echo $OUTPUT->header();
|
2012-03-09 13:33:09 +02:00
|
|
|
echo $OUTPUT->notification(get_string('usernotavailable', 'error'));
|
2010-05-04 13:04:35 +00:00
|
|
|
echo $OUTPUT->footer();
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the profile page. Should always return something unless the database is broken.
|
|
|
|
if (!$currentpage = my_get_page($userid, MY_PAGE_PUBLIC)) {
|
|
|
|
print_error('mymoodlesetup');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$currentpage->userid) {
|
2014-02-18 10:12:42 +13:00
|
|
|
$context = context_system::instance(); // A trick so that we even see non-sticky blocks.
|
2010-05-04 13:04:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$PAGE->set_context($context);
|
2013-06-12 13:29:45 +01:00
|
|
|
$PAGE->set_pagelayout('mypublic');
|
2010-05-04 13:04:35 +00:00
|
|
|
$PAGE->set_pagetype('user-profile');
|
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
// Set up block editing capabilities.
|
|
|
|
if (isguestuser()) { // Guests can never edit their profile.
|
|
|
|
$USER->editing = $edit = 0; // Just in case.
|
|
|
|
$PAGE->set_blocks_editing_capability('moodle/my:configsyspages'); // unlikely :).
|
2010-05-04 13:04:35 +00:00
|
|
|
} else {
|
|
|
|
if ($currentuser) {
|
|
|
|
$PAGE->set_blocks_editing_capability('moodle/user:manageownblocks');
|
|
|
|
} else {
|
|
|
|
$PAGE->set_blocks_editing_capability('moodle/user:manageblocks');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-29 03:03:03 +00:00
|
|
|
if (has_capability('moodle/user:viewhiddendetails', $context)) {
|
|
|
|
$hiddenfields = array();
|
|
|
|
} else {
|
2014-03-04 14:21:41 +08:00
|
|
|
$hiddenfields = array_flip(explode(',', $CFG->hiddenuserfields));
|
2010-07-29 03:03:03 +00:00
|
|
|
}
|
2010-05-04 13:04:35 +00:00
|
|
|
|
2012-08-27 14:23:17 +08:00
|
|
|
if (has_capability('moodle/site:viewuseridentity', $context)) {
|
2014-03-04 14:21:41 +08:00
|
|
|
$identityfields = array_flip(explode(',', $CFG->showuseridentity));
|
2012-08-27 14:23:17 +08:00
|
|
|
} else {
|
|
|
|
$identityfields = array();
|
|
|
|
}
|
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
// Start setting up the page.
|
2010-05-04 13:04:35 +00:00
|
|
|
$strpublicprofile = get_string('publicprofile');
|
|
|
|
|
|
|
|
$PAGE->blocks->add_region('content');
|
|
|
|
$PAGE->set_subpage($currentpage->id);
|
2010-07-12 13:42:42 +00:00
|
|
|
$PAGE->set_title(fullname($user).": $strpublicprofile");
|
|
|
|
$PAGE->set_heading(fullname($user).": $strpublicprofile");
|
2010-05-17 05:38:59 +00:00
|
|
|
|
|
|
|
if (!$currentuser) {
|
|
|
|
$PAGE->navigation->extend_for_user($user);
|
2010-06-10 07:29:02 +00:00
|
|
|
if ($node = $PAGE->settingsnav->get('userviewingsettings'.$user->id)) {
|
2010-05-17 05:38:59 +00:00
|
|
|
$node->forceopen = true;
|
2010-05-14 07:07:15 +00:00
|
|
|
}
|
2010-05-17 05:38:59 +00:00
|
|
|
} else if ($node = $PAGE->settingsnav->get('usercurrentsettings', navigation_node::TYPE_CONTAINER)) {
|
|
|
|
$node->forceopen = true;
|
|
|
|
}
|
|
|
|
if ($node = $PAGE->settingsnav->get('root')) {
|
|
|
|
$node->forceopen = false;
|
2010-05-14 07:07:15 +00:00
|
|
|
}
|
2010-05-04 13:04:35 +00:00
|
|
|
|
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
// Toggle the editing state and switches.
|
2010-05-04 13:04:35 +00:00
|
|
|
if ($PAGE->user_allowed_editing()) {
|
2012-07-25 13:33:29 +01:00
|
|
|
if ($reset !== null) {
|
|
|
|
if (!is_null($userid)) {
|
2014-02-18 10:12:42 +13:00
|
|
|
if (!$currentpage = my_reset_page($userid, MY_PAGE_PUBLIC, 'user-profile')) {
|
2012-07-25 13:33:29 +01:00
|
|
|
print_error('reseterror', 'my');
|
|
|
|
}
|
2014-07-01 19:19:59 +02:00
|
|
|
redirect(new moodle_url('/user/profile.php', array('id' => $userid)));
|
2012-07-25 13:33:29 +01:00
|
|
|
}
|
2014-02-18 10:12:42 +13:00
|
|
|
} else if ($edit !== null) { // Editing state was specified.
|
|
|
|
$USER->editing = $edit; // Change editing state.
|
2010-05-04 13:04:35 +00:00
|
|
|
if (!$currentpage->userid && $edit) {
|
|
|
|
// If we are viewing a system page as ordinary user, and the user turns
|
|
|
|
// editing on, copy the system pages as new user pages, and get the
|
2014-02-18 10:12:42 +13:00
|
|
|
// new page record.
|
2014-06-24 10:02:56 +01:00
|
|
|
if (!$currentpage = my_copy_page($userid, MY_PAGE_PUBLIC, 'user-profile')) {
|
2010-05-04 13:04:35 +00:00
|
|
|
print_error('mymoodlesetup');
|
|
|
|
}
|
|
|
|
$PAGE->set_context($usercontext);
|
|
|
|
$PAGE->set_subpage($currentpage->id);
|
|
|
|
}
|
2014-02-18 10:12:42 +13:00
|
|
|
} else { // Editing state is in session.
|
|
|
|
if ($currentpage->userid) { // It's a page we can edit, so load from session.
|
2010-05-04 13:04:35 +00:00
|
|
|
if (!empty($USER->editing)) {
|
|
|
|
$edit = 1;
|
|
|
|
} else {
|
|
|
|
$edit = 0;
|
|
|
|
}
|
2014-02-18 10:12:42 +13:00
|
|
|
} else { // It's a system page and they are not allowed to edit system pages.
|
|
|
|
$USER->editing = $edit = 0; // Disable editing completely, just to be safe.
|
2010-05-04 13:04:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
// Add button for editing page.
|
2014-06-24 10:02:56 +01:00
|
|
|
$params = array('edit' => !$edit, 'id' => $userid);
|
2010-05-04 13:04:35 +00:00
|
|
|
|
2012-07-25 13:33:29 +01:00
|
|
|
$resetbutton = '';
|
|
|
|
$resetstring = get_string('resetpage', 'my');
|
2014-06-24 10:02:56 +01:00
|
|
|
$reseturl = new moodle_url("$CFG->wwwroot/user/profile.php", array('edit' => 1, 'reset' => 1, 'id' => $userid));
|
2012-07-25 13:33:29 +01:00
|
|
|
|
2010-05-04 13:04:35 +00:00
|
|
|
if (!$currentpage->userid) {
|
2014-02-18 10:12:42 +13:00
|
|
|
// Viewing a system page -- let the user customise it.
|
2010-05-04 13:04:35 +00:00
|
|
|
$editstring = get_string('updatemymoodleon');
|
|
|
|
$params['edit'] = 1;
|
|
|
|
} else if (empty($edit)) {
|
|
|
|
$editstring = get_string('updatemymoodleon');
|
2012-07-25 13:33:29 +01:00
|
|
|
$resetbutton = $OUTPUT->single_button($reseturl, $resetstring);
|
2010-05-04 13:04:35 +00:00
|
|
|
} else {
|
|
|
|
$editstring = get_string('updatemymoodleoff');
|
2012-07-25 13:33:29 +01:00
|
|
|
$resetbutton = $OUTPUT->single_button($reseturl, $resetstring);
|
2010-05-04 13:04:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$url = new moodle_url("$CFG->wwwroot/user/profile.php", $params);
|
|
|
|
$button = $OUTPUT->single_button($url, $editstring);
|
2012-07-25 13:33:29 +01:00
|
|
|
$PAGE->set_button($resetbutton . $button);
|
2010-05-04 13:04:35 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
$USER->editing = $edit = 0;
|
|
|
|
}
|
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
// HACK WARNING! This loads up all this page's blocks in the system context.
|
2010-05-04 13:04:35 +00:00
|
|
|
if ($currentpage->userid == 0) {
|
|
|
|
$CFG->blockmanagerclass = 'my_syspage_block_manager';
|
|
|
|
}
|
|
|
|
|
2014-05-21 10:11:12 +08:00
|
|
|
// Trigger a user profile viewed event.
|
|
|
|
$event = \core\event\user_profile_viewed::create(array(
|
|
|
|
'objectid' => $user->id,
|
|
|
|
'relateduserid' => $user->id,
|
|
|
|
'context' => $usercontext
|
|
|
|
));
|
|
|
|
$event->add_record_snapshot('user', $user);
|
|
|
|
$event->trigger();
|
|
|
|
|
2010-05-04 13:04:35 +00:00
|
|
|
// TODO WORK OUT WHERE THE NAV BAR IS!
|
|
|
|
echo $OUTPUT->header();
|
2010-05-16 08:21:12 +00:00
|
|
|
echo '<div class="userprofile">';
|
2010-05-04 13:04:35 +00:00
|
|
|
|
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
// Print the standard content of this page, the basic profile info.
|
2010-05-04 13:04:35 +00:00
|
|
|
echo $OUTPUT->heading(fullname($user));
|
|
|
|
|
|
|
|
if (is_mnet_remote_user($user)) {
|
2010-07-01 12:56:31 +00:00
|
|
|
$sql = "SELECT h.id, h.name, h.wwwroot,
|
|
|
|
a.name as application, a.display_name
|
|
|
|
FROM {mnet_host} h, {mnet_application} a
|
|
|
|
WHERE h.id = ? AND h.applicationid = a.id";
|
2010-05-04 13:04:35 +00:00
|
|
|
|
|
|
|
$remotehost = $DB->get_record_sql($sql, array($user->mnethostid));
|
2010-07-01 12:56:31 +00:00
|
|
|
$a = new stdclass();
|
|
|
|
$a->remotetype = $remotehost->display_name;
|
|
|
|
$a->remotename = $remotehost->name;
|
|
|
|
$a->remoteurl = $remotehost->wwwroot;
|
2010-05-04 13:04:35 +00:00
|
|
|
|
2010-07-01 12:56:31 +00:00
|
|
|
echo $OUTPUT->box(get_string('remoteuserinfo', 'mnet', $a), 'remoteuserinfo');
|
2010-05-04 13:04:35 +00:00
|
|
|
}
|
|
|
|
|
2010-05-16 22:57:31 +00:00
|
|
|
echo '<div class="userprofilebox clearfix"><div class="profilepicture">';
|
2014-02-18 10:12:42 +13:00
|
|
|
echo $OUTPUT->user_picture($user, array('size' => 100));
|
2010-05-04 13:04:35 +00:00
|
|
|
echo '</div>';
|
|
|
|
|
2010-05-16 22:57:31 +00:00
|
|
|
echo '<div class="descriptionbox"><div class="description">';
|
2014-02-18 10:12:42 +13:00
|
|
|
// Print the description.
|
2010-05-04 13:04:35 +00:00
|
|
|
if ($user->description && !isset($hiddenfields['description'])) {
|
2014-02-18 10:12:42 +13:00
|
|
|
if (!empty($CFG->profilesforenrolledusersonly) && !$currentuser &&
|
|
|
|
!$DB->record_exists('role_assignments', array('userid' => $user->id))) {
|
2010-05-04 13:04:35 +00:00
|
|
|
echo get_string('profilenotshown', 'moodle');
|
|
|
|
} else {
|
2014-02-18 10:12:42 +13:00
|
|
|
$user->description = file_rewrite_pluginfile_urls($user->description, 'pluginfile.php', $usercontext->id, 'user',
|
|
|
|
'profile', null);
|
|
|
|
$options = array('overflowdiv' => true);
|
2010-11-05 02:53:47 +00:00
|
|
|
echo format_text($user->description, $user->descriptionformat, $options);
|
2010-05-04 13:04:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
echo '</div>';
|
|
|
|
|
2010-07-12 13:31:32 +00:00
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
// Print all the little details in a list.
|
|
|
|
echo html_writer::start_tag('dl', array('class' => 'list'));
|
2013-01-10 13:11:38 +08:00
|
|
|
if (!isset($hiddenfields['country']) && $user->country) {
|
|
|
|
echo html_writer::tag('dt', get_string('country'));
|
|
|
|
echo html_writer::tag('dd', get_string($user->country, 'countries'));
|
2010-05-04 13:04:35 +00:00
|
|
|
}
|
|
|
|
|
2013-01-10 13:11:38 +08:00
|
|
|
if (!isset($hiddenfields['city']) && $user->city) {
|
|
|
|
echo html_writer::tag('dt', get_string('city'));
|
|
|
|
echo html_writer::tag('dd', $user->city);
|
2010-05-04 13:04:35 +00:00
|
|
|
}
|
|
|
|
|
2012-08-27 14:23:17 +08:00
|
|
|
if (isset($identityfields['address']) && $user->address) {
|
2013-01-10 13:11:38 +08:00
|
|
|
echo html_writer::tag('dt', get_string('address'));
|
|
|
|
echo html_writer::tag('dd', $user->address);
|
2012-08-27 14:23:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($identityfields['phone1']) && $user->phone1) {
|
2013-01-10 13:11:38 +08:00
|
|
|
echo html_writer::tag('dt', get_string('phone'));
|
|
|
|
echo html_writer::tag('dd', $user->phone1);
|
2012-08-27 14:23:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($identityfields['phone2']) && $user->phone2) {
|
2013-01-10 13:11:38 +08:00
|
|
|
echo html_writer::tag('dt', get_string('phone2'));
|
|
|
|
echo html_writer::tag('dd', $user->phone2);
|
2010-05-04 13:04:35 +00:00
|
|
|
}
|
|
|
|
|
2012-08-27 14:23:17 +08:00
|
|
|
if (isset($identityfields['institution']) && $user->institution) {
|
2013-01-10 13:11:38 +08:00
|
|
|
echo html_writer::tag('dt', get_string('institution'));
|
|
|
|
echo html_writer::tag('dd', $user->institution);
|
2012-08-27 14:23:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($identityfields['department']) && $user->department) {
|
2013-01-10 13:11:38 +08:00
|
|
|
echo html_writer::tag('dt', get_string('department'));
|
|
|
|
echo html_writer::tag('dd', $user->department);
|
2012-08-27 14:23:17 +08:00
|
|
|
}
|
|
|
|
|
2012-09-03 11:41:07 +12:00
|
|
|
if (isset($identityfields['idnumber']) && $user->idnumber) {
|
2013-01-10 13:11:38 +08:00
|
|
|
echo html_writer::tag('dt', get_string('idnumber'));
|
|
|
|
echo html_writer::tag('dd', $user->idnumber);
|
2010-05-04 13:04:35 +00:00
|
|
|
}
|
|
|
|
|
2012-09-03 11:41:07 +12:00
|
|
|
if (isset($identityfields['email']) and ($currentuser
|
2011-03-12 19:04:26 +01:00
|
|
|
or $user->maildisplay == 1
|
|
|
|
or has_capability('moodle/course:useremail', $context)
|
2012-09-03 11:41:07 +12:00
|
|
|
or ($user->maildisplay == 2 and enrol_sharing_course($user, $USER)))) {
|
2013-01-10 13:11:38 +08:00
|
|
|
echo html_writer::tag('dt', get_string('email'));
|
|
|
|
echo html_writer::tag('dd', obfuscate_mailto($user->email, ''));
|
2010-05-04 13:04:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($user->url && !isset($hiddenfields['webpage'])) {
|
|
|
|
$url = $user->url;
|
|
|
|
if (strpos($user->url, '://') === false) {
|
|
|
|
$url = 'http://'. $url;
|
|
|
|
}
|
2013-01-10 13:11:38 +08:00
|
|
|
$webpageurl = new moodle_url($url);
|
|
|
|
echo html_writer::tag('dt', get_string('webpage'));
|
|
|
|
echo html_writer::tag('dd', html_writer::link($webpageurl, s($user->url)));
|
2010-05-04 13:04:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($user->icq && !isset($hiddenfields['icqnumber'])) {
|
2014-02-18 10:12:42 +13:00
|
|
|
$imurl = new moodle_url('http://web.icq.com/wwp', array('uin' => $user->icq) );
|
|
|
|
$iconurl = new moodle_url('http://web.icq.com/whitepages/online', array('icq' => $user->icq, 'img' => '5'));
|
|
|
|
$statusicon = html_writer::tag('img', '', array('src' => $iconurl, 'class' => 'icon icon-post', 'alt' => get_string('status')));
|
2013-01-10 13:11:38 +08:00
|
|
|
echo html_writer::tag('dt', get_string('icqnumber'));
|
|
|
|
echo html_writer::tag('dd', html_writer::link($imurl, s($user->icq) . $statusicon));
|
2010-05-04 13:04:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($user->skype && !isset($hiddenfields['skypeid'])) {
|
2013-01-10 13:11:38 +08:00
|
|
|
$imurl = 'skype:'.urlencode($user->skype).'?call';
|
2014-06-04 13:55:11 +08:00
|
|
|
$iconurl = new moodle_url('http://mystatus.skype.com/smallicon/'.urlencode($user->skype));
|
2014-08-15 15:41:56 +01:00
|
|
|
if (is_https()) {
|
2012-12-21 17:26:36 +01:00
|
|
|
// Bad luck, skype devs are lazy to set up SSL on their servers - see MDL-37233.
|
|
|
|
$statusicon = '';
|
|
|
|
} else {
|
2014-02-18 10:12:42 +13:00
|
|
|
$statusicon = html_writer::empty_tag('img',
|
|
|
|
array('src' => $iconurl, 'class' => 'icon icon-post', 'alt' => get_string('status')));
|
2012-12-21 17:26:36 +01:00
|
|
|
}
|
2013-01-10 13:11:38 +08:00
|
|
|
echo html_writer::tag('dt', get_string('skypeid'));
|
|
|
|
echo html_writer::tag('dd', html_writer::link($imurl, s($user->skype) . $statusicon));
|
2010-05-04 13:04:35 +00:00
|
|
|
}
|
|
|
|
if ($user->yahoo && !isset($hiddenfields['yahooid'])) {
|
2014-02-18 10:12:42 +13:00
|
|
|
$imurl = new moodle_url('http://edit.yahoo.com/config/send_webmesg', array('.target' => $user->yahoo, '.src' => 'pg'));
|
|
|
|
$iconurl = new moodle_url('http://opi.yahoo.com/online', array('u' => $user->yahoo, 'm' => 'g', 't' => '0'));
|
|
|
|
$statusicon = html_writer::tag('img', '',
|
|
|
|
array('src' => $iconurl, 'class' => 'iconsmall icon-post', 'alt' => get_string('status')));
|
2013-01-10 13:11:38 +08:00
|
|
|
echo html_writer::tag('dt', get_string('yahooid'));
|
|
|
|
echo html_writer::tag('dd', html_writer::link($imurl, s($user->yahoo) . $statusicon));
|
2010-05-04 13:04:35 +00:00
|
|
|
}
|
|
|
|
if ($user->aim && !isset($hiddenfields['aimid'])) {
|
2013-01-10 13:11:38 +08:00
|
|
|
$imurl = 'aim:goim?screenname='.urlencode($user->aim);
|
|
|
|
echo html_writer::tag('dt', get_string('aimid'));
|
|
|
|
echo html_writer::tag('dd', html_writer::link($imurl, s($user->aim)));
|
2010-05-04 13:04:35 +00:00
|
|
|
}
|
|
|
|
if ($user->msn && !isset($hiddenfields['msnid'])) {
|
2013-01-10 13:11:38 +08:00
|
|
|
echo html_writer::tag('dt', get_string('msnid'));
|
|
|
|
echo html_writer::tag('dd', s($user->msn));
|
2010-05-04 13:04:35 +00:00
|
|
|
}
|
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
// Print the Custom User Fields.
|
2010-05-04 13:04:35 +00:00
|
|
|
profile_display_fields($user->id);
|
|
|
|
|
|
|
|
|
|
|
|
if (!isset($hiddenfields['mycourses'])) {
|
2014-02-18 10:12:42 +13:00
|
|
|
if ($mycourses = enrol_get_all_users_courses($user->id, true, null, 'visible DESC, sortorder ASC')) {
|
|
|
|
$shown = 0;
|
2010-05-04 13:04:35 +00:00
|
|
|
$courselisting = '';
|
|
|
|
foreach ($mycourses as $mycourse) {
|
|
|
|
if ($mycourse->category) {
|
2012-11-20 10:07:06 +00:00
|
|
|
context_helper::preload_from_record($mycourse);
|
|
|
|
$ccontext = context_course::instance($mycourse->id);
|
2014-07-18 15:30:33 +08:00
|
|
|
$linkattributes = null;
|
2010-05-04 13:04:35 +00:00
|
|
|
if ($mycourse->visible == 0) {
|
MDL-21782 reworked enrolment framework, the core infrastructure is in place, the basic plugins are all implemented; see the tracker issue for list of unfinished bits, expect more changes and improvements during the next week
AMOS START
MOV [sendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage,enrol_self]
MOV [configsendcoursewelcomemessage,core_admin],[sendcoursewelcomemessage_desc,enrol_self]
MOV [enrolstartdate,core],[enrolstartdate,enrol_self]
MOV [enrolenddate,core],[enrolenddate,enrol_self]
CPY [welcometocourse,core],[welcometocourse,enrol_self]
CPY [welcometocoursetext,core],[welcometocoursetext,enrol_self]
MOV [notenrollable,core],[notenrollable,core_enrol]
MOV [enrolenddaterror,core],[enrolenddaterror,enrol_self]
MOV [enrolmentkeyhint,core],[passwordinvalidhint,enrol_self]
MOV [coursemanager,core_admin],[coursecontact,core_admin]
MOV [configcoursemanager,core_admin],[coursecontact_desc,core_admin]
MOV [enrolledincourserole,core],[enrolledincourserole,enrol_manual]
MOV [enrolme,core],[enrolme,core_enrol]
MOV [unenrol,core],[unenrol,core_enrol]
MOV [unenrolme,core],[unenrolme,core_enrol]
MOV [enrolmentnew,core],[enrolmentnew,core_enrol]
MOV [enrolmentnewuser,core],[enrolmentnewuser,core_enrol]
MOV [enrolments,core],[enrolments,core_enrol]
MOV [enrolperiod,core],[enrolperiod,core_enrol]
MOV [unenrolroleusers,core],[unenrolroleusers,core_enrol]
AMOS END
2010-06-21 15:30:49 +00:00
|
|
|
if (!has_capability('moodle/course:viewhiddencourses', $ccontext)) {
|
|
|
|
continue;
|
|
|
|
}
|
2014-07-18 15:30:33 +08:00
|
|
|
$linkattributes['class'] = 'dimmed';
|
2010-05-04 13:04:35 +00:00
|
|
|
}
|
2014-06-16 13:22:18 +08:00
|
|
|
$params = array('id' => $user->id, 'course' => $mycourse->id);
|
|
|
|
if ($showallcourses) {
|
|
|
|
$params['showallcourses'] = 1;
|
|
|
|
}
|
|
|
|
$url = new moodle_url('/user/view.php', $params);
|
2014-07-18 15:30:33 +08:00
|
|
|
$courselisting .= html_writer::link($url, $ccontext->get_context_name(false), $linkattributes);
|
2014-06-16 13:22:18 +08:00
|
|
|
$courselisting .= ', ';
|
2010-05-04 13:04:35 +00:00
|
|
|
}
|
|
|
|
$shown++;
|
2014-06-12 14:02:04 +08:00
|
|
|
if (!$showallcourses && $shown == 20) {
|
2014-06-16 13:22:18 +08:00
|
|
|
$url = new moodle_url('/user/profile.php', array('id' => $user->id, 'showallcourses' => 1));
|
2014-06-24 15:38:15 +08:00
|
|
|
$courselisting .= html_writer::link($url, '...', array('title' => get_string('viewmore')));
|
2010-05-04 13:04:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-01-10 13:11:38 +08:00
|
|
|
echo html_writer::tag('dt', get_string('courseprofiles'));
|
2014-02-18 10:12:42 +13:00
|
|
|
echo html_writer::tag('dd', rtrim($courselisting, ', '));
|
2010-05-04 13:04:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!isset($hiddenfields['firstaccess'])) {
|
|
|
|
if ($user->firstaccess) {
|
|
|
|
$datestring = userdate($user->firstaccess)." (".format_time(time() - $user->firstaccess).")";
|
|
|
|
} else {
|
|
|
|
$datestring = get_string("never");
|
|
|
|
}
|
2014-09-23 15:05:22 +08:00
|
|
|
echo html_writer::tag('dt', get_string('firstsiteaccess'));
|
2013-01-10 13:11:38 +08:00
|
|
|
echo html_writer::tag('dd', $datestring);
|
2010-05-04 13:04:35 +00:00
|
|
|
}
|
|
|
|
if (!isset($hiddenfields['lastaccess'])) {
|
|
|
|
if ($user->lastaccess) {
|
|
|
|
$datestring = userdate($user->lastaccess)." (".format_time(time() - $user->lastaccess).")";
|
|
|
|
} else {
|
|
|
|
$datestring = get_string("never");
|
|
|
|
}
|
2014-09-23 15:05:22 +08:00
|
|
|
echo html_writer::tag('dt', get_string('lastsiteaccess'));
|
2013-01-10 13:11:38 +08:00
|
|
|
echo html_writer::tag('dd', $datestring);
|
2010-05-04 13:04:35 +00:00
|
|
|
}
|
|
|
|
|
2013-07-29 11:21:38 -03:00
|
|
|
if (has_capability('moodle/user:viewlastip', $usercontext) && !isset($hiddenfields['lastip'])) {
|
|
|
|
if ($user->lastip) {
|
2014-06-24 10:02:56 +01:00
|
|
|
$iplookupurl = new moodle_url('/iplookup/index.php', array('ip' => $user->lastip, 'user' => $user->id));
|
2014-02-24 13:19:17 +08:00
|
|
|
$ipstring = html_writer::link($iplookupurl, $user->lastip);
|
2013-07-29 11:21:38 -03:00
|
|
|
} else {
|
|
|
|
$ipstring = get_string("none");
|
|
|
|
}
|
|
|
|
echo html_writer::tag('dt', get_string('lastip'));
|
|
|
|
echo html_writer::tag('dd', $ipstring);
|
|
|
|
}
|
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
// Printing tagged interests.
|
2010-05-04 13:04:35 +00:00
|
|
|
if (!empty($CFG->usetags)) {
|
|
|
|
if ($interests = tag_get_tags_csv('user', $user->id) ) {
|
2013-01-10 13:11:38 +08:00
|
|
|
echo html_writer::tag('dt', get_string('interests'));
|
|
|
|
echo html_writer::tag('dd', $interests);
|
2010-05-04 13:04:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-03 13:18:06 +01:00
|
|
|
if (!isset($hiddenfields['suspended'])) {
|
|
|
|
if ($user->suspended) {
|
2013-01-10 13:11:38 +08:00
|
|
|
echo html_writer::tag('dt', ' ');
|
|
|
|
echo html_writer::tag('dd', get_string('suspended', 'auth'));
|
2012-01-03 13:18:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-02 13:57:39 +13:00
|
|
|
require_once($CFG->libdir . '/badgeslib.php');
|
|
|
|
if (!empty($CFG->enablebadges)) {
|
|
|
|
profile_display_badges($user->id);
|
|
|
|
}
|
|
|
|
|
2013-01-10 13:11:38 +08:00
|
|
|
echo html_writer::end_tag('dl');
|
|
|
|
echo "</div></div>"; // Closing desriptionbox and userprofilebox.
|
2014-02-24 10:38:17 +13:00
|
|
|
|
|
|
|
echo $OUTPUT->custom_block_region('content');
|
2010-05-04 13:04:35 +00:00
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
// Print messaging link if allowed.
|
2010-07-12 13:31:32 +00:00
|
|
|
if (isloggedin() && has_capability('moodle/site:sendmessage', $context)
|
2010-08-25 08:32:59 +00:00
|
|
|
&& !empty($CFG->messaging) && !isguestuser() && !isguestuser($user) && ($USER->id != $user->id)) {
|
2010-07-12 13:31:32 +00:00
|
|
|
echo '<div class="messagebox">';
|
|
|
|
echo '<a href="'.$CFG->wwwroot.'/message/index.php?id='.$user->id.'">'.get_string('messageselectadd').'</a>';
|
|
|
|
echo '</div>';
|
|
|
|
}
|
|
|
|
|
2014-02-18 10:12:42 +13:00
|
|
|
echo '</div>'; // Userprofile class.
|
2013-04-02 13:57:39 +13:00
|
|
|
echo $OUTPUT->footer();
|