]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-17773 new get_login_url() function - fixes missing httpslogin tweaks
authorskodak <skodak>
Fri, 2 Jan 2009 22:56:48 +0000 (22:56 +0000)
committerskodak <skodak>
Fri, 2 Jan 2009 22:56:48 +0000 (22:56 +0000)
36 files changed:
admin/settings/users.php
backup/backup.php
backup/backup_check.html
backup/backup_execute.html
backup/backup_form.html
backup/restore.php
backup/restore_check.html
backup/restore_execute.html
backup/restore_form.html
backup/restore_precheck.html
blocks/login/block_login.php
blocks/tags/block_tags.php
course/enrol.php
enrol/manual/enrol.html
lib/moodlelib.php
lib/sessionlib.php
lib/weblib.php
login/change_password.php
login/forgot_password.php
login/signup.php
message/edit.php
mod/chat/view.php
mod/choice/view.php
mod/forum/markposts.php
mod/forum/post.php
mod/forum/subscribe.php
mod/quiz/view.php
my/index.php
search/add.php
search/delete.php
search/indexer.php
search/indexersplash.php
search/tests/index.php
search/update.php
user/edit.php
user/view.php

index c4ddfd17c99cae61e92cc635e91be28f5a349ba1..84690cd1805d617158c1b0b094d7681b827b7d76 100644 (file)
@@ -22,7 +22,7 @@ if ($hassiteconfig
     $temp->add(new admin_setting_configselect('guestloginbutton', get_string('guestloginbutton', 'auth'),
                                               get_string('showguestlogin', 'auth'), '1', array('0'=>get_string('hide'), '1'=>get_string('show'))));
     $temp->add(new admin_setting_configtext('alternateloginurl', get_string('alternateloginurl', 'auth'),
-                                            get_string('alternatelogin', 'auth', htmlspecialchars($CFG->wwwroot.'/login/index.php')), ''));
+                                            get_string('alternatelogin', 'auth', htmlspecialchars(get_login_url())), ''));
     $temp->add(new admin_setting_configtext('forgottenpasswordurl', get_string('forgottenpasswordurl', 'auth'),
                                             get_string('forgottenpassword', 'auth'), ''));
     $temp->add(new admin_setting_configtextarea('auth_instructions', get_string('instructions', 'auth'),
index 861b122571c7f92f61249b0327a7e706b587b307..630bd51f553d3075e3146c3bd55c2acf3b49deab 100644 (file)
     $cancel = optional_param( 'cancel' );
     $launch = optional_param( 'launch' );
 
+    $loginurl = get_login_url();
 
     if (!empty($id)) {
         require_login($id);
         if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $id))) {
-            print_error('cannotuseadminadminorteacher', 'error', "$CFG->wwwroot/login/index.php");
+            print_error('cannotuseadminadminorteacher', 'error', $loginurl);
         }
     } else {
         require_login();
         if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM))) {
-            print_error('cannotuseadmin', 'error', "$CFG->wwwroot/login/index.php");
+            print_error('cannotuseadmin', 'error', $loginurl);
         }
     }
 
     if (!empty($to)) {
         if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $to))) {
-            print_error('cannotuseadminadminorteacher', 'error', "$CFG->wwwroot/login/index.php");
+            print_error('cannotuseadminadminorteacher', 'error', $loginurl);
         }
     }
 
index 09b6fd4e8e93fef6f42eeafc8699cde273875c69..94d92b623691716def9c87fbe7ea60e28a2d787b 100644 (file)
@@ -4,19 +4,21 @@
     //Check login
     require_login();
 
+    $loginurl = get_login_url();
+
     if (!empty($course->id)) {
         if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $course->id))) {
             if (empty($to)) {
-                print_error("cannotuseadminadminorteacher", '', "$CFG->wwwroot/login/index.php");
+                print_error("cannotuseadminadminorteacher", '', $loginurl);
             } else {
                 if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $to))) {
-                    print_error("cannotuseadminadminorteacher", '', "$CFG->wwwroot/login/index.php");
+                    print_error("cannotuseadminadminorteacher", '', $loginurl);
                 }
             }
         }
     } else {
         if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM))) {
-            print_error("cannotuseadmin", '', "$CFG->wwwroot/login/index.php");
+            print_error("cannotuseadmin", '', $loginurl);
         }
     }
 
index 7c4bfc86ae5e24686044d7a291559c64aaae86a5..1ca0344b411b792af88ce0550ebaa2d3c228f96a 100644 (file)
@@ -4,19 +4,21 @@
     //Check login   
     require_login();
 
+    $loginurl = get_login_url();
+
     if (!empty($course->id)) {
         if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $course->id))) {
             if (empty($to)) {
-                print_error("cannotuseadminadminorteacher", '', "$CFG->wwwroot/login/index.php");
+                print_error("cannotuseadminadminorteacher", '', $loginurl);
             } else {
                 if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $to))) {
-                    print_error("cannotuseadminadminorteacher", '', "$CFG->wwwroot/login/index.php");
+                    print_error("cannotuseadminadminorteacher", '', $loginurl);
                 }
             }
         }
     } else {
         if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM))) {
-            print_error("cannotuseadmin", '', "$CFG->wwwroot/login/index.php");
+            print_error("cannotuseadmin", '', $loginurl);
         }
     }
 
index b94e15f1505951aec4936446c2bfafa0ba1eda40..06653c394e4e2aa188b230e6cccd5b130421921a 100644 (file)
@@ -5,19 +5,21 @@
     //Check login
     require_login();
 
+    $loginurl = get_login_url();
+
     if (!empty($course->id)) {
         if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $course->id))) {
             if (empty($to)) {
-                print_error("cannotuseadminadminorteacher", '', "$CFG->wwwroot/login/index.php");
+                print_error("cannotuseadminadminorteacher", '', $loginurl);
             } else {
                 if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_COURSE, $to))) {
-                    print_error("cannotuseadminadminorteacher", '', "$CFG->wwwroot/login/index.php");
+                    print_error("cannotuseadminadminorteacher", '', $loginurl);
                 }
             }
         }
     } else {
         if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM))) {
-            print_error("cannotuseadmin", '', "$CFG->wwwroot/login/index.php");
+            print_error("cannotuseadmin", '', $loginurl);
         }
     }
 
index f79fd96499ee3230cb93dc1438849e96f558b5a0..ff4299cac0d2ac67cdac28e4359ea58f7de0f09e 100644 (file)
         $to = $SESSION->restore->course_id;
     }
 
+    $loginurl = get_login_url();
+
     if (!empty($id)) {
         require_login($id);
         if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) {
             if (empty($to)) {
-                print_error("cannotuseadminadminorteacher", '', "$CFG->wwwroot/login/index.php");
+                print_error("cannotuseadminadminorteacher", '', $loginurl);
             } else {
                 if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $to))
                     && !has_capability('moodle/site:import',  get_context_instance(CONTEXT_COURSE, $to))) {
-                    print_error("cannotuseadminadminorteacher", '', "$CFG->wwwroot/login/index.php");
+                    print_error("cannotuseadminadminorteacher", '', $loginurl);
                 }
             }
         }
     } else {
         if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM))) {
-            print_error("cannotuseadmin", '', "$CFG->wwwroot/login/index.php");
+            print_error("cannotuseadmin", '', $loginurl);
         }
     }
 
index ac35bedda1f6ee5415f961b7628c6018d536002f..871febb3790160b3c63789de9782a1cb19dcf1e0 100644 (file)
     //Check login
     require_login();
 
+    $loginurl = get_login_url();
+
     //Check admin
     if (!empty($id)) {
         if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) {
-            print_error("cannotuseadminadminorteacher", '', "$CFG->wwwroot/login/index.php");
+            print_error("cannotuseadminadminorteacher", '', $loginurl);
         }
     } else {
         if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM))) {
-            print_error("cannotuseadmin", '', "$CFG->wwwroot/login/index.php");
+            print_error("cannotuseadmin", '', $loginurl);
         }
     }
 
index 1216fe39331e26a96443943174101b0eac83d11a..4c10580c15b987f5504bd41ebdfe947dcce1a4dd 100644 (file)
     //Check login
     require_login();
 
+    $loginurl = get_login_url();
+
     //Check admin
     if (!empty($id)) {
         if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) {
             if (empty($to)) {
-                print_error("cannotuseadminadminorteacher", '', "$CFG->wwwroot/login/index.php");
+                print_error("cannotuseadminadminorteacher", '', $loginurl);
             } else {
                 if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $to)) 
                     && !has_capability('moodle/site:import',  get_context_instance(CONTEXT_COURSE, $to))) {
-                    print_error("cannotuseadminadminorteacher", '', "$CFG->wwwroot/login/index.php");
+                    print_error("cannotuseadminadminorteacher", '', $loginurl);
                 }
             }
         }
     } else {
         if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM))) {
-            print_error("cannotuseadmin", '', "$CFG->wwwroot/login/index.php");
+            print_error("cannotuseadmin", '', $loginurl);
         }
     }
 
index 704e37f7be0e7d69da35dbb105c626291ac564c7..d501cb20dd0aee026d1e2237ea0ab9358faa1cfe 100644 (file)
     //Check login
     require_login();
 
+    $loginurl = get_login_url();
+
     //Check admin
     if (!empty($id)) {
         if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) {
-            print_error('cannotuseadminadminorteacher', '', '$CFG->wwwroot/login/index.php');
+            print_error('cannotuseadminadminorteacher', '', $loginurl);
         }
     } else {
         if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM))) {
-            print_error('cannotuseadmin', '', '$CFG->wwwroot/login/index.php');
+            print_error('cannotuseadmin', '', $loginurl);
         }
     }
 
index e14d2fbe873e8810651eb96019e6058e7496f170..e6cecbab11640b2ffb51a6862e4ee8afcac22847 100644 (file)
 
     //Check login   
     require_login();
+
+    $loginurl = get_login_url();
+
     //Check admin
     if (!empty($id)) {
         if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) {
             if (empty($to)) {
-                print_error("cannotuseadminadminorteacher", '', "$CFG->wwwroot/login/index.php");
+                print_error("cannotuseadminadminorteacher", '', $loginurl);
             } else {
                 if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $to))
                     && !has_capability('moodle/site:import',  get_context_instance(CONTEXT_COURSE, $to))) {
-                    print_error("cannotuseadminadminorteacher", '', "$CFG->wwwroot/login/index.php");
+                    print_error("cannotuseadminadminorteacher", '', $loginurl);
                 }
             }
         }
     } else {
         if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM))) {
-            print_error("cannotuseadmin", '', "$CFG->wwwroot/login/index.php");   
+            print_error("cannotuseadmin", '', $loginurl);
         }
     }
 
index 8d924e885fcfa5fa5d9db1991b6eb339bbb93d0d..4befcac740efc539891de903aa1745bc76034953 100644 (file)
@@ -43,7 +43,7 @@ class block_login extends block_base {
 
         if (!isloggedin() or isguestuser()) {   // Show the block
 
-            $this->content->text .= "\n".'<form class="loginform" id="login" method="post" action="'.$wwwroot.'/login/index.php">';
+            $this->content->text .= "\n".'<form class="loginform" id="login" method="post" action="'.get_login_url().'">';
 
             $this->content->text .= '<div class="c1 fld username"><label for="login_username">'.get_string('username').'</label>';
             $this->content->text .= '<input type="text" name="username" id="login_username" value="'.s($username).'" /></div>';
index fecd63475fe0932722131cb6a879f94746d4a985..67da56c80219b6dd5bcc6cc17ef94e27d9c66f94 100644 (file)
@@ -309,7 +309,7 @@ EOT;
             } else {
                 //if not logged in
                 $this->content->footer = '<hr />'.get_string('please', $tagslang).'
-                    <a href="'.$CFG->wwwroot.'/login/index.php">'.get_string('login', $tagslang).'
+                    <a href="'.get_login_url().'">'.get_string('login', $tagslang).'
                         </a> '.get_string('tagunits', $tagslang);
             }
         }
index 6d2e79c257b22816ad3372b3d8043b1562d5db2d..76b95bd4dbac687613e2bcfb3a501e1d2b5e3f97 100644 (file)
     $loginasguest = optional_param('loginasguest', 0, PARAM_BOOL); // hmm, is this still needed?
 
     if (!isloggedin()) {
-        $wwwroot = $CFG->wwwroot;
-        if (!empty($CFG->loginhttps)) {
-            $wwwroot = str_replace('http:','https:', $wwwroot);
-        }
         // do not use require_login here because we are usually comming from it
-        redirect($wwwroot.'/login/index.php');
+        redirect(get_login_url());
     }
 
     if (!$course = $DB->get_record('course', array('id'=>$id))) {
index 93012ea3b55320631bd3e6444fb92c28c763ecdc..919a2da826fefffc637b5854c236f161573bb0fe 100644 (file)
 
     if (isguestuser()) {
         print_box_start('centerpara');
-        if (empty($CFG->loginhttps)) {
-            $loginurl = $CFG->wwwroot .'/login/index.php';
-        } else {
-            $wwwroot = str_replace('http:','https:', $CFG->wwwroot);
-            $loginurl = $wwwroot .'/login/index.php';
-        }
+        $loginurl = get_login_url();
         print_single_button($loginurl, null, get_string('login'));
         print_box_end();
     }
index a3b434924cdcd30e588a1befab54fa894da91755..c63a6bcd6e213a6e4b10a4963683368b0bf27293 100644 (file)
@@ -1861,6 +1861,27 @@ function course_setup($courseorid=0) {
 
 }
 
+/**
+ * Returns full login url.
+ *
+ * @param bool $loginguest add login guest param
+ * @return string login url
+ */
+function get_login_url($loginguest=false) {
+    global $CFG;
+
+    if (empty($CFG->loginhttps) or $loginguest) { //do not require https for guest logins
+        $loginguest = $loginguest ? '?loginguest=true' : '';
+        $url = "$CFG->wwwroot/login/index.php$loginguest";
+
+    } else {
+        $wwwroot = str_replace('http:','https:', $CFG->wwwroot);
+        $url = "$wwwroot/login/index.php";
+    }
+
+    return $url;
+}
+
 /**
  * This function checks that the current user is logged in and has the
  * required privileges
@@ -1906,17 +1927,12 @@ function require_login($courseorid=0, $autologinguest=true, $cm=null, $setwantsu
             $SESSION->fromurl  = $_SERVER['HTTP_REFERER'];
         }
         if ($autologinguest and !empty($CFG->guestloginbutton) and !empty($CFG->autologinguests) and ($COURSE->id == SITEID or $COURSE->guest) ) {
-            $loginguest = '?loginguest=true';
-        } else {
-            $loginguest = '';
-        }
-        if (empty($CFG->loginhttps) or $loginguest) { //do not require https for guest logins
-            redirect($CFG->wwwroot .'/login/index.php'. $loginguest);
+            $loginguest = true;
         } else {
-            $wwwroot = str_replace('http:','https:', $CFG->wwwroot);
-            redirect($wwwroot .'/login/index.php');
+            $loginguest = false;
         }
-        exit;
+        redirect(get_login_url($loginguest));
+        exit; // never reached
     }
 
 /// loginas as redirection if needed
@@ -1956,13 +1972,6 @@ function require_login($courseorid=0, $autologinguest=true, $cm=null, $setwantsu
         redirect($CFG->wwwroot .'/user/edit.php?id='. $USER->id .'&amp;course='. SITEID);
     }
 
-/// Make sure current IP matches the one for this session (if required)
-    if (!empty($CFG->tracksessionip)) {
-        if ($USER->sessionIP != md5(getremoteaddr())) {
-            print_error('sessionipnomatch', 'error');
-        }
-    }
-
 /// Make sure the USER has a sesskey set up.  Used for checking script parameters.
     sesskey();
 
@@ -2069,7 +2078,7 @@ function require_login($courseorid=0, $autologinguest=true, $cm=null, $setwantsu
                 case 1:    /// Guests always allowed
                     if (!has_capability('moodle/course:view', $COURSE->context)) {    // Prohibited by capability
                         print_header_simple();
-                        notice(get_string('guestsnotallowed', '', format_string($COURSE->fullname)), "$CFG->wwwroot/login/index.php");
+                        notice(get_string('guestsnotallowed', '', format_string($COURSE->fullname)), get_login_url());
                     }
                     if (!empty($cm) and !$cm->visible) { // Not allowed to see module, send to course page
                         redirect($CFG->wwwroot.'/course/view.php?id='.$cm->course,
@@ -2094,7 +2103,7 @@ function require_login($courseorid=0, $autologinguest=true, $cm=null, $setwantsu
                     print_header_simple('', '',
                             build_navigation(array(array('name' => $strloggedinasguest, 'link' => null, 'type' => 'misc'))));
                     if (empty($USER->access['rsw'][$COURSE->context->path])) {  // Normal guest
-                        notice(get_string('guestsnotallowed', '', format_string($COURSE->fullname)), "$CFG->wwwroot/login/index.php");
+                        notice(get_string('guestsnotallowed', '', format_string($COURSE->fullname)), get_login_url());
                     } else {
                         notify(get_string('guestsnotallowed', '', format_string($COURSE->fullname)));
                         echo '<div class="notifyproblem">'.switchroles_form($COURSE->id).'</div>';
index 82a5b5595d954168d67750deb7e3438e4d306c5e..470e7701be994bd22704faf054d647872bbbbd31 100644 (file)
@@ -95,6 +95,29 @@ class moodle_session {
         session_set_user($user);
     }
 
+    protected function check_security() {
+        global $CFG;
+
+        if (!empty($_SESSION['USER']->id)) {
+            /// Make sure current IP matches the one for this session (if required)
+            $remoteaddr = getremoteaddr();
+
+            if (empty($_SESSION['USER']->sessionip)) {
+                $_SESSION['USER']->sessionip = $remoteaddr;
+            }
+
+            if ($_SESSION['USER']->sessionip != $remoteaddr) {
+                if (!is_guestuser($_SESSION['USER'])) {
+                    $link = '';
+                } else {
+                    
+                }
+                print_error('sessionipnomatch', 'error');
+            }
+        }
+
+    }
+
     /**
      * Terminates active moodle session
      */
index 39c5eb2847ff0d952bf80ddc2a61f45c03ed5a8b..464e6c8afb8db6ee9100305c244272e7db03ccae 100644 (file)
@@ -3506,11 +3506,7 @@ function user_login_string($course=NULL, $user=NULL) {
         $realuserinfo = '';
     }
 
-    if (empty($CFG->loginhttps)) {
-        $wwwroot = $CFG->wwwroot;
-    } else {
-        $wwwroot = str_replace('http:','https:',$CFG->wwwroot);
-    }
+    $loginurl = get_login_url();
 
     if (empty($course->id)) {
         // $course->id is not defined during installation
@@ -3525,7 +3521,7 @@ function user_login_string($course=NULL, $user=NULL) {
         }
         if (isset($user->username) && $user->username == 'guest') {
             $loggedinas = $realuserinfo.get_string('loggedinasguest').
-                      " (<a $CFG->frametarget href=\"$wwwroot/login/index.php\">".get_string('login').'</a>)';
+                      " (<a $CFG->frametarget href=\"$loginurl\">".get_string('login').'</a>)';
         } else if (!empty($user->access['rsw'][$context->path])) {
             $rolename = '';
             if ($role = $DB->get_record('role', array('id'=>$user->access['rsw'][$context->path]))) {
@@ -3540,7 +3536,7 @@ function user_login_string($course=NULL, $user=NULL) {
         }
     } else {
         $loggedinas = get_string('loggedinnot', 'moodle').
-                      " (<a $CFG->frametarget href=\"$wwwroot/login/index.php\">".get_string('login').'</a>)';
+                      " (<a $CFG->frametarget href=\"$loginurl\">".get_string('login').'</a>)';
     }
     return '<div class="logininfo">'.$loggedinas.'</div>';
 }
index e4d895a610b0b10422f9afc067affa643cba2e18..577593694256debbc30e35bdfef8fb716f2d4aa7 100644 (file)
@@ -21,7 +21,7 @@
         if (empty($SESSION->wantsurl)) {
             $SESSION->wantsurl = $CFG->httpswwwroot.'/login/change_password.php';
         }
-        redirect($CFG->httpswwwroot.'/login/index.php');
+        redirect(get_login_url());
     }
 
     // do not require change own password cap if change forced
index 8a04a55a37830e481d96c7c4ef7f8fc2ca782be5..1598ca6d89599a6bbc36c06769ef1ad2de18a17c 100644 (file)
@@ -18,7 +18,7 @@ $systemcontext = get_context_instance(CONTEXT_SYSTEM);
 $strforgotten = get_string('passwordforgotten');
 $strlogin     = get_string('login');
 
-$navigation = build_navigation(array(array('name' => $strlogin, 'link' => "$CFG->wwwroot/login/index.php", 'type' => 'misc'),
+$navigation = build_navigation(array(array('name' => $strlogin, 'link' => get_login_url(), 'type' => 'misc'),
                                      array('name' => $strforgotten, 'link' => null, 'type' => 'misc')));
 
 // if alternatepasswordurl is defined, then we'll just head there
@@ -91,7 +91,7 @@ if ($p_secret !== false) {
 $mform = new login_forgot_password_form();
 
 if ($mform->is_cancelled()) {
-    redirect($CFG->httpswwwroot.'/login/index.php');
+    redirect(get_login_url());
 
 } else if ($data = $mform->get_data()) {
 /// find the user in the database and mail info
index 4ee44b361c579b74614de041e2f97085b1b7cfd3..124759083e07f08ab1556f46f820565a2fb29e41 100644 (file)
@@ -29,7 +29,7 @@
     $mform_signup = new login_signup_form();
 
     if ($mform_signup->is_cancelled()) {
-        redirect($CFG->httpswwwroot.'/login/index.php');
+        redirect(get_login_url());
 
     } else if ($user = $mform_signup->get_data()) {
         $user->confirmed   = 0;
index a339fc9cea38bc25c1367f0918e65b1ca41e1665..491dd6d49fa970dc14f3b859407a4fac1ec98df2 100644 (file)
@@ -51,7 +51,7 @@
             if (empty($SESSION->wantsurl)) {
                 $SESSION->wantsurl = $CFG->httpswwwroot.'/message/edit.php';
             }
-            redirect($CFG->httpswwwroot.'/login/index.php');
+            redirect(get_login_url());
         }
     }
 
index 028c3b9b366be02300e8c9bc4aee7689664f321a..60944b7eed9175f15ade9d014d2b6a30f03acb6e 100644 (file)
         $navigation = build_navigation('', $cm);
         print_header_simple(format_string($chat->name), '', $navigation,
                       '', '', true, '', navmenu($course, $cm));
-        $wwwroot = $CFG->wwwroot.'/login/index.php';
-        if (!empty($CFG->loginhttps)) {
-            $wwwroot = str_replace('http:','https:', $wwwroot);
-        }
 
         notice_yesno(get_string('noguests', 'chat').'<br /><br />'.get_string('liketologin'),
-                $wwwroot, $CFG->wwwroot.'/course/view.php?id='.$course->id);
+                get_login_url(), $CFG->wwwroot.'/course/view.php?id='.$course->id);
 
         print_footer($course);
         exit;
index c1664e9506be2c38660b27cc7fc7a203977d1e1d..6b00ca350468781ed4e4bde85411268d9688aced 100644 (file)
         $sitecontext = get_context_instance(CONTEXT_SYSTEM);
 
         if (has_capability('moodle/legacy:guest', $sitecontext, NULL, false)) {      // Guest on whole site
-            $wwwroot = $CFG->wwwroot.'/login/index.php';
-            if (!empty($CFG->loginhttps)) {
-                $wwwroot = str_replace('http:','https:', $wwwroot);
-            }
             notice_yesno(get_string('noguestchoose', 'choice').'<br /><br />'.get_string('liketologin'),
-                         $wwwroot, $_SERVER['HTTP_REFERER']);
+                         get_login_url(), $_SERVER['HTTP_REFERER']);
 
         } else if (has_capability('moodle/legacy:guest', $context, NULL, false)) {   // Guest in this course only
             $SESSION->wantsurl = $FULLME;
index 564065d7ace61d8f3bc502156a369b339456bb66..6210a9bd98d234e7f2a27307e571d2fd9ae8e650 100644 (file)
     }
 
     if (isguest()) {   // Guests can't change forum
-        $wwwroot = $CFG->wwwroot.'/login/index.php';
-        if (!empty($CFG->loginhttps)) {
-            $wwwroot = str_replace('http:','https:', $wwwroot);
-        }
-
         $navigation = build_navigation('', $cm);
         print_header($course->shortname, $course->fullname, $navigation, '', '', true, "", navmenu($course, $cm));
         notice_yesno(get_string('noguesttracking', 'forum').'<br /><br />'.get_string('liketologin'),
-                     $wwwroot, $returnto);
+                     get_login_url(), $returnto);
         print_footer($course);
         exit;
     }
index 28ef64cbc9dcab6c0c3ff4b86a51f18edf32af1a..e451b888626cba86a113cb7e2f46720e9b76b18a 100644 (file)
 
     if (has_capability('moodle/legacy:guest', $sitecontext, NULL, false)) {
 
-        $wwwroot = $CFG->wwwroot.'/login/index.php';
-        if (!empty($CFG->loginhttps)) {
-            $wwwroot = str_replace('http:', 'https:', $wwwroot);
-        }
-
         if (!empty($forum)) {      // User is starting a new discussion in a forum
             if (! $forum = $DB->get_record('forum', array('id' => $forum))) {
                 print_error('invalidforumid', 'forum');
@@ -62,7 +57,7 @@
         print_header($course->shortname, $course->fullname, $navigation, '' , '', true, "", navmenu($course, $cm));
 
         notice_yesno(get_string('noguestpost', 'forum').'<br /><br />'.get_string('liketologin'),
-                     $wwwroot, get_referer(false));
+                     get_login_url(), get_referer(false));
         print_footer($course);
         exit;
     }
index fbcf8c61dce6761f9cfaabfb2f9bbf7203f5f77a..c2876e4eceb8f784e1ac2cc963e8ebf3a9b44417 100644 (file)
     require_login($course->id, false, $cm);
 
     if (isguest()) {   // Guests can't subscribe
-        $wwwroot = $CFG->wwwroot.'/login/index.php';
-        if (!empty($CFG->loginhttps)) {
-            $wwwroot = str_replace('http:','https:', $wwwroot);
-        }
 
         $navigation = build_navigation('', $cm);
         print_header($course->shortname, $course->fullname, $navigation, '', '', true, "", navmenu($course, $cm));
 
         notice_yesno(get_string('noguestsubscribe', 'forum').'<br /><br />'.get_string('liketologin'),
-                     $wwwroot, $_SERVER['HTTP_REFERER']);
+                     get_login_url(), $_SERVER['HTTP_REFERER']);
         print_footer($course);
         exit;
     }
index dda980a5883b4a193623cc8799810015099c4b64..388bdaebdb716be2ae4599050704bf538116bacd 100644 (file)
 
 /// Guests can't do a quiz, so offer them a choice of logging in or going back.
     if (isguestuser()) {
-        $loginurl = $CFG->wwwroot.'/login/index.php';
-        if (!empty($CFG->loginhttps)) {
-            $loginurl = str_replace('http:','https:', $loginurl);
-        }
-
         notice_yesno('<p>' . get_string('guestsno', 'quiz') . "</p>\n\n<p>" .
-                get_string('liketologin') . "</p>\n", $loginurl, get_referer(false));
+                get_string('liketologin') . "</p>\n", get_login_url(), get_referer(false));
         finish_page($course);
     }
 
index 449a9541e6adb00d2576c52555d68bd755c1befa..1c052e6291996d34fe9c2b7df48bd19db540c9e9 100644 (file)
     $mymoodlestr = get_string('mymoodle','my');
 
     if (isguest()) {
-        $wwwroot = $CFG->wwwroot.'/login/index.php';
-        if (!empty($CFG->loginhttps)) {
-            $wwwroot = str_replace('http:','https:', $wwwroot);
-        }
-
         print_header($mymoodlestr);
         notice_yesno(get_string('noguest', 'my').'<br /><br />'.get_string('liketologin'),
-                     $wwwroot, $CFG->wwwroot);
+                     get_login_url(), $CFG->wwwroot);
         print_footer();
         die();
     }
index 8973ed9e77c43859460bd756f84a8bc21d1161b3..26eb4159d94a0eac0a09d8854f9aa84b0124bb6c 100644 (file)
@@ -35,7 +35,7 @@
     }
 
     if (!has_capability('moodle/site:doanything', get_context_instance(CONTEXT_SYSTEM))) {
-        print_error('beadmin', 'search', "$CFG->wwwroot/login/index.php");
+        print_error('beadmin', 'search', get_login_url());
     }
 
 /// check for php5 (lib.php)
index 4f4790d2b6258a116365e31976027fb60a905238..5ab8d5e3bb2a0e4f1b592b32e8fc83ff905639aa 100644 (file)
@@ -32,7 +32,7 @@
     }
 
     if (!has_capability('moodle/site:doanything', get_context_instance(CONTEXT_SYSTEM))) {
-        print_error('beadmin', 'search', "$CFG->wwwroot/login/index.php");
+        print_error('beadmin', 'search', get_login_url());
     } //if
 
     try {
index 84bfb842d7ce54b7dfd537386c90405fa2f88ad0..c4b4e294156fc39584d6ff40c2ce5fd44b6efeeb 100644 (file)
@@ -49,7 +49,7 @@ $separator = (array_key_exists('WINDIR', $_SERVER)) ? ';' : ':' ;
     }
 
     if (!has_capability('moodle/site:doanything', get_context_instance(CONTEXT_SYSTEM))) {
-        print_error('beadmin', 'search', "$CFG->wwwroot/login/index.php");
+        print_error('beadmin', 'search', get_login_url());
     }
 
 /// confirmation flag to prevent accidental reindexing (indexersplash.php is the correct entry point)
index c5790ae1d1ed72e76d4d029c22a2b5cdb3f0f479..b30b410301825363756d98bc65e8ed766d483827 100644 (file)
@@ -33,7 +33,7 @@ ini_set('include_path', $CFG->dirroot.'\search'.$separator.ini_get('include_path
     }
 
     if (!has_capability('moodle/site:doanything', get_context_instance(CONTEXT_SYSTEM))) {
-        print_error('beadmin', 'search', "$CFG->wwwroot/login/index.php");
+        print_error('beadmin', 'search', get_login_url());
     }
 
     require_once("$CFG->dirroot/search/indexlib.php");
index 31cb5e66130a61185256fd42d646602d53cfb0ce..9b7cb7a7d1b2530fd55ad7ca9bd92dd8443162cb 100644 (file)
@@ -24,7 +24,7 @@
     }
 
     if (!has_capability('moodle/site:doanything', get_context_instance(CONTEXT_SYSTEM))) {
-      print_error('onlyadmins', 'error', "$CFG->wwwroot/login/index.php");
+      print_error('onlyadmins', 'error', get_login_url());
     } //if
 
     mtrace('<pre>Server Time: '.date('r',time()));
index b5eaa445e2b8a8def5dbb046be50c512cbd410e8..ab5d56d95ef2b29461ebc82256d36624797aac8c 100644 (file)
@@ -35,7 +35,7 @@
     }
 
     if (!has_capability('moodle/site:doanything', get_context_instance(CONTEXT_SYSTEM))) {
-        print_error('beadmin', 'search', "$CFG->wwwroot/login/index.php");
+        print_error('beadmin', 'search', get_login_url());
     }
 
     try {
index 4544635bb2f67866bd54fbb6cef90743fb3ae593..15172d3d2a3004a72a98e140124d42573836bcc3 100644 (file)
@@ -22,7 +22,7 @@
         if (empty($SESSION->wantsurl)) {
             $SESSION->wantsurl = $CFG->httpswwwroot.'/user/edit.php';
         }
-        redirect($CFG->httpswwwroot.'/login/index.php');
+        redirect(get_login_url());
     }
 
     // Guest can not edit
index e00bbcb18d8ec267ed9e795d4426322f3dc100ea..e8983df682238f4a1cf3bf2ba6546a52d51f94ac 100644 (file)
@@ -50,7 +50,7 @@
     if (!empty($CFG->forceloginforprofiles)) {
         require_login();
         if (isguest()) {
-            redirect("$CFG->wwwroot/login/index.php");
+            redirect(get_login_url());
         }
     }