Some cleaning up of user_login_string and SITE
This commit is contained in:
@@ -32,15 +32,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($USER->id)) {
|
||||
if (empty($CFG->loginhttps)) {
|
||||
$wwwroot = $CFG->wwwroot;
|
||||
} else {
|
||||
$wwwroot = str_replace('http', 'https', $CFG->wwwroot);
|
||||
}
|
||||
$loginstring = "<div class=\"logininfo\"><a href=\"$wwwroot/login/index.php\">".get_string('login').'</a></div>';
|
||||
} else {
|
||||
$loginstring = user_login_string($SITE);
|
||||
if (!empty($USER->id)) {
|
||||
add_to_log(SITEID, 'course', 'view', 'view.php?id='.SITEID, SITEID);
|
||||
}
|
||||
|
||||
@@ -60,7 +52,7 @@
|
||||
|
||||
print_header(strip_tags($SITE->fullname), $SITE->fullname, 'home', '',
|
||||
'<meta name="description" content="'. s(strip_tags($SITE->summary)) .'" />',
|
||||
true, '', $loginstring.$langmenu);
|
||||
true, '', user_login_string($SITE).$langmenu);
|
||||
|
||||
?>
|
||||
|
||||
|
||||
+11
-7
@@ -1335,18 +1335,16 @@ function get_courses_notin_metacourse($metacourseid,$count=false) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$site = get_site(); // we don't want the site course in here.
|
||||
|
||||
if ($count) {
|
||||
$sql = "SELECT COUNT(c.id)";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$sql = "SELECT c.id,c.shortname,c.fullname";
|
||||
}
|
||||
|
||||
$alreadycourses = get_courses_in_metacourse($metacourseid);
|
||||
|
||||
$sql .= " FROM {$CFG->prefix}course c WHERE ".((!empty($alreadycourses)) ? "c.id NOT IN (".implode(',',array_keys($alreadycourses)).") AND " : "")." c.id !=$metacourseid and c.id != $site->id and c.metacourse != 1";
|
||||
$sql .= " FROM {$CFG->prefix}course c WHERE ".((!empty($alreadycourses)) ? "c.id NOT IN (".implode(',',array_keys($alreadycourses)).")
|
||||
AND " : "")." c.id !=$metacourseid and c.id != ".SITEID." and c.metacourse != 1";
|
||||
|
||||
return get_records_sql($sql);
|
||||
}
|
||||
@@ -1999,9 +1997,15 @@ function user_group($courseid, $userid) {
|
||||
* @return course A {@link $COURSE} object for the site
|
||||
* @todo Finish documenting this function.
|
||||
*/
|
||||
function get_site () {
|
||||
function get_site() {
|
||||
|
||||
if ( $course = get_record('course', 'category', 0)) {
|
||||
global $SITE;
|
||||
|
||||
if (!empty($SITE->id)) { // We already have a global to use, so return that
|
||||
return $SITE;
|
||||
}
|
||||
|
||||
if ($course = get_record('course', 'category', 0)) {
|
||||
return $course;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
+8
-5
@@ -1501,7 +1501,7 @@ function highlightfast($needle, $haystack) {
|
||||
function print_header ($title='', $heading='', $navigation='', $focus='', $meta='',
|
||||
$cache=true, $button=' ', $menu='', $usexml=false, $bodytags='') {
|
||||
|
||||
global $USER, $CFG, $THEME, $SESSION, $ME;
|
||||
global $USER, $CFG, $THEME, $SESSION, $ME, $SITE;
|
||||
|
||||
/// This is an ugly hack to be replaced later by a proper global $COURSE
|
||||
global $course;
|
||||
@@ -1543,7 +1543,7 @@ function print_header ($title='', $heading='', $navigation='', $focus='', $meta=
|
||||
if (isset($course->id)) {
|
||||
$menu = user_login_string($course);
|
||||
} else {
|
||||
$menu = user_login_string(get_site());
|
||||
$menu = user_login_string($SITE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1908,15 +1908,18 @@ function theme_setup($theme = '', $params=NULL) {
|
||||
* @param course $course {@link $COURSE} object containing course information
|
||||
* @param user $user {@link $USER} object containing user information
|
||||
* @return string
|
||||
* @todo Finish documenting this function
|
||||
*/
|
||||
function user_login_string($course, $user=NULL) {
|
||||
global $USER, $CFG;
|
||||
function user_login_string($course=NULL, $user=NULL) {
|
||||
global $USER, $CFG, $SITE;
|
||||
|
||||
if (empty($user) and isset($USER->id)) {
|
||||
$user = $USER;
|
||||
}
|
||||
|
||||
if (empty($course)) {
|
||||
$course = $SITE;
|
||||
}
|
||||
|
||||
if (isset($user->realuser)) {
|
||||
if ($realuser = get_record('user', 'id', $user->realuser)) {
|
||||
$fullname = fullname($realuser, true);
|
||||
|
||||
Reference in New Issue
Block a user