mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
Merge branch 'w07_MDL-26389_20_profile' of git://github.com/skodak/moodle
This commit is contained in:
commit
76b7e2d1d6
5 changed files with 49 additions and 21 deletions
|
@ -216,19 +216,8 @@ abstract class session_stub implements moodle_session {
|
||||||
$user = null;
|
$user = null;
|
||||||
|
|
||||||
if (!empty($CFG->opentogoogle) and !NO_MOODLE_COOKIES) {
|
if (!empty($CFG->opentogoogle) and !NO_MOODLE_COOKIES) {
|
||||||
if (!empty($_SERVER['HTTP_USER_AGENT'])) {
|
if (is_web_crawler()) {
|
||||||
// allow web spiders in as guest users
|
$user = guest_user();
|
||||||
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Googlebot') !== false ) {
|
|
||||||
$user = guest_user();
|
|
||||||
} else if (strpos($_SERVER['HTTP_USER_AGENT'], 'google.com') !== false ) { // Google
|
|
||||||
$user = guest_user();
|
|
||||||
} else if (strpos($_SERVER['HTTP_USER_AGENT'], 'Yahoo! Slurp') !== false ) { // Yahoo
|
|
||||||
$user = guest_user();
|
|
||||||
} else if (strpos($_SERVER['HTTP_USER_AGENT'], '[ZSEBOT]') !== false ) { // Zoomspider
|
|
||||||
$user = guest_user();
|
|
||||||
} else if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSNBOT') !== false ) { // MSN Search
|
|
||||||
$user = guest_user();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!empty($CFG->guestloginbutton) and !$user and !empty($_SERVER['HTTP_REFERER'])) {
|
if (!empty($CFG->guestloginbutton) and !$user and !empty($_SERVER['HTTP_REFERER'])) {
|
||||||
// automaticaly log in users coming from search engine results
|
// automaticaly log in users coming from search engine results
|
||||||
|
|
|
@ -1123,6 +1123,38 @@ function init_eaccelerator() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if current user is a web crawler.
|
||||||
|
*
|
||||||
|
* This list can not be made complete, this is not a security
|
||||||
|
* restriction, we make the list only to help these sites
|
||||||
|
* especially when automatic guest login is disabled.
|
||||||
|
*
|
||||||
|
* If admin needs security they should enable forcelogin
|
||||||
|
* and disable guest access!!
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function is_web_crawler() {
|
||||||
|
if (!empty($_SERVER['HTTP_USER_AGENT'])) {
|
||||||
|
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Googlebot') !== false ) {
|
||||||
|
return true;
|
||||||
|
} else if (strpos($_SERVER['HTTP_USER_AGENT'], 'google.com') !== false ) { // Google
|
||||||
|
return true;
|
||||||
|
} else if (strpos($_SERVER['HTTP_USER_AGENT'], 'Yahoo! Slurp') !== false ) { // Yahoo
|
||||||
|
return true;
|
||||||
|
} else if (strpos($_SERVER['HTTP_USER_AGENT'], '[ZSEBOT]') !== false ) { // Zoomspider
|
||||||
|
return true;
|
||||||
|
} else if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSNBOT') !== false ) { // MSN Search
|
||||||
|
return true;
|
||||||
|
} else if (strpos($_SERVER['HTTP_USER_AGENT'], 'Yandex') !== false ) {
|
||||||
|
return true;
|
||||||
|
} else if (strpos($_SERVER['HTTP_USER_AGENT'], 'AltaVista') !== false ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class solves the problem of how to initialise $OUTPUT.
|
* This class solves the problem of how to initialise $OUTPUT.
|
||||||
|
|
|
@ -106,11 +106,10 @@ switch ($mode) {
|
||||||
echo '<div class="user-content">';
|
echo '<div class="user-content">';
|
||||||
|
|
||||||
if ($course->id == SITEID) {
|
if ($course->id == SITEID) {
|
||||||
if (empty($CFG->forceloginforprofiles) || isloggedin()) {
|
$searchcourse = SITEID;
|
||||||
|
if (empty($CFG->forceloginforprofiles) or (isloggedin() and !isguestuser() and !is_web_crawler())) {
|
||||||
// Search throughout the whole site.
|
// Search throughout the whole site.
|
||||||
$searchcourse = 0;
|
$searchcourse = 0;
|
||||||
} else {
|
|
||||||
$searchcourse = SITEID;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Search only for posts the user made in this course.
|
// Search only for posts the user made in this course.
|
||||||
|
|
|
@ -42,9 +42,12 @@ require_once($CFG->libdir.'/filelib.php');
|
||||||
$userid = optional_param('id', 0, PARAM_INT);
|
$userid = optional_param('id', 0, PARAM_INT);
|
||||||
$edit = optional_param('edit', null, PARAM_BOOL); // Turn editing on and off
|
$edit = optional_param('edit', null, PARAM_BOOL); // Turn editing on and off
|
||||||
|
|
||||||
|
$PAGE->set_url('/user/profile.php', array('id'=>$userid));
|
||||||
|
|
||||||
if (!empty($CFG->forceloginforprofiles)) {
|
if (!empty($CFG->forceloginforprofiles)) {
|
||||||
require_login();
|
require_login();
|
||||||
if (isguestuser()) {
|
if (isguestuser()) {
|
||||||
|
$SESSION->wantsurl = $PAGE->url->out(false);
|
||||||
redirect(get_login_url());
|
redirect(get_login_url());
|
||||||
}
|
}
|
||||||
} else if (!empty($CFG->forcelogin)) {
|
} else if (!empty($CFG->forcelogin)) {
|
||||||
|
@ -106,8 +109,6 @@ if (has_capability('moodle/user:viewhiddendetails', $context)) {
|
||||||
// Start setting up the page
|
// Start setting up the page
|
||||||
$strpublicprofile = get_string('publicprofile');
|
$strpublicprofile = get_string('publicprofile');
|
||||||
|
|
||||||
$params = array('id'=>$userid);
|
|
||||||
$PAGE->set_url('/user/profile.php', $params);
|
|
||||||
$PAGE->blocks->add_region('content');
|
$PAGE->blocks->add_region('content');
|
||||||
$PAGE->set_subpage($currentpage->id);
|
$PAGE->set_subpage($currentpage->id);
|
||||||
$PAGE->set_title(fullname($user).": $strpublicprofile");
|
$PAGE->set_title(fullname($user).": $strpublicprofile");
|
||||||
|
|
|
@ -40,8 +40,7 @@ if ($courseid == SITEID) { // Since Moodle 2.0 all site-level profiles are sho
|
||||||
redirect($CFG->wwwroot.'/user/profile.php?id='.$id); // Immediate redirect
|
redirect($CFG->wwwroot.'/user/profile.php?id='.$id); // Immediate redirect
|
||||||
}
|
}
|
||||||
|
|
||||||
$url = new moodle_url('/user/view.php', array('id'=>$id,'course'=>$courseid));
|
$PAGE->set_url('/user/view.php', array('id'=>$id,'course'=>$courseid));
|
||||||
$PAGE->set_url($url);
|
|
||||||
|
|
||||||
$user = $DB->get_record('user', array('id'=>$id), '*', MUST_EXIST);
|
$user = $DB->get_record('user', array('id'=>$id), '*', MUST_EXIST);
|
||||||
$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST);
|
$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST);
|
||||||
|
@ -57,6 +56,14 @@ if (isguestuser($user)) {
|
||||||
print_error('invaliduserid');
|
print_error('invaliduserid');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($CFG->forceloginforprofiles)) {
|
||||||
|
require_login(); // we can not log in to course due to the parent hack bellow
|
||||||
|
if (isguestuser()) {
|
||||||
|
$SESSION->wantsurl = $PAGE->url->out(false);
|
||||||
|
redirect(get_login_url());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$PAGE->set_context($coursecontext);
|
$PAGE->set_context($coursecontext);
|
||||||
$PAGE->set_course($course);
|
$PAGE->set_course($course);
|
||||||
$PAGE->set_pagetype('course-view-' . $course->format); // To get the blocks exactly like the course
|
$PAGE->set_pagetype('course-view-' . $course->format); // To get the blocks exactly like the course
|
||||||
|
@ -76,7 +83,7 @@ if (!$currentuser
|
||||||
} else {
|
} else {
|
||||||
// normal course
|
// normal course
|
||||||
require_login($course);
|
require_login($course);
|
||||||
// what to do with users temporary accessing this course? shoudl they see the details?
|
// what to do with users temporary accessing this course? should they see the details?
|
||||||
}
|
}
|
||||||
|
|
||||||
$strpersonalprofile = get_string('personalprofile');
|
$strpersonalprofile = get_string('personalprofile');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue