function get_content() { global $USER, $CFG, $SESSION, $OUTPUT; require_once $CFG->libdir . '/authlib.php'; $wwwroot = ''; $signup = ''; if ($this->content !== NULL) { return $this->content; } if (empty($CFG->loginhttps)) { $wwwroot = $CFG->wwwroot; } else { // This actually is not so secure ;-), 'cause we're // in unencrypted connection... $wwwroot = str_replace("http://", "https://", $CFG->wwwroot); } if (signup_is_enabled()) { $signup = $wwwroot . '/login/signup.php'; } // TODO: now that we have multiauth it is hard to find out if there is a way to change password $forgot = $wwwroot . '/login/forgot_password.php'; if (!empty($CFG->loginpasswordautocomplete)) { $autocomplete = 'autocomplete="off"'; } else { $autocomplete = ''; } $username = get_moodle_cookie(); $this->content = new stdClass(); $this->content->footer = ''; $this->content->text = ''; if (!isloggedin() or isguestuser()) { // Show the block if (empty($CFG->authloginviaemail)) { $strusername = get_string('username'); } else { $strusername = get_string('usernameemail'); } $this->content->text .= "\n" . '<form class="loginform" id="login" method="post" action="' . get_login_url() . '" ' . $autocomplete . '>'; $this->content->text .= '<div class="form-group"><label for="login_username">' . $strusername . '</label>'; $this->content->text .= '<input type="text" name="username" id="login_username" class="form-control" value="' . s($username) . '" /></div>'; $this->content->text .= '<div class="form-group"><label for="login_password">' . get_string('password') . '</label>'; $this->content->text .= '<input type="password" name="password" id="login_password" class="form-control" value="" ' . $autocomplete . ' /></div>'; if (isset($CFG->rememberusername) and $CFG->rememberusername == 2) { $checked = $username ? 'checked="checked"' : ''; $this->content->text .= '<div class="form-check">'; $this->content->text .= '<label class="form-check-label">'; $this->content->text .= '<input type="checkbox" name="rememberusername" id="rememberusername" class="form-check-input" value="1" ' . $checked . '/> '; $this->content->text .= get_string('rememberusername', 'admin') . '</label>'; $this->content->text .= '</div>'; } $this->content->text .= '<div class="form-group">'; $this->content->text .= '<input type="submit" class="btn btn-primary btn-block" value="' . get_string('login') . '" />'; $this->content->text .= '</div>'; $this->content->text .= "</form>\n"; if (!empty($signup)) { $this->content->text .= '<div><a href="' . $signup . '">' . get_string('startsignup') . '</a></div>'; } if (!empty($forgot)) { $this->content->text .= '<div><a href="' . $forgot . '">' . get_string('forgotaccount') . '</a></div>'; } $authsequence = get_enabled_auth_plugins(true); // Get all auths, in sequence. $potentialidps = array(); foreach ($authsequence as $authname) { $authplugin = get_auth_plugin($authname); $potentialidps = array_merge($potentialidps, $authplugin->loginpage_idp_list($this->page->url->out(false))); } if (!empty($potentialidps)) { $this->content->text .= '<div class="potentialidps">'; $this->content->text .= '<h6>' . get_string('potentialidps', 'auth') . '</h6>'; $this->content->text .= '<div class="potentialidplist">'; foreach ($potentialidps as $idp) { $this->content->text .= '<div class="potentialidp"><a href="' . $idp['url']->out() . '" title="' . s($idp['name']) . '">'; $this->content->text .= $OUTPUT->render($idp['icon'], $idp['name']) . s($idp['name']) . '</a></div>'; } $this->content->text .= '</div>'; $this->content->text .= '</div>'; } } return $this->content; }
* user signup page. * * @package core * @subpackage auth * @copyright 1999 onwards Martin Dougiamas http://dougiamas.com * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require '../config.php'; require_once $CFG->dirroot . '/user/editlib.php'; require_once $CFG->libdir . '/authlib.php'; // Try to prevent searching for sites that allow sign-up. if (!isset($CFG->additionalhtmlhead)) { $CFG->additionalhtmlhead = ''; } $CFG->additionalhtmlhead .= '<meta name="robots" content="noindex" />'; if (!($authplugin = signup_is_enabled())) { print_error('notlocalisederrormessage', 'error', '', 'Sorry, you may not use this page.'); } //HTTPS is required in this page when $CFG->loginhttps enabled $PAGE->https_required(); $PAGE->set_url('/login/signup.php'); $PAGE->set_context(context_system::instance()); // If wantsurl is empty or /login/signup.php, override wanted URL. // We do not want to end up here again if user clicks "Login". if (empty($SESSION->wantsurl)) { $SESSION->wantsurl = $CFG->wwwroot . '/'; } else { $wantsurl = new moodle_url($SESSION->wantsurl); if ($PAGE->url->compare($wantsurl, URL_MATCH_BASE)) { $SESSION->wantsurl = $CFG->wwwroot . '/'; }
/** * Returns a list of the site public settings, those not requiring authentication. * * @return array with the settings and warnings */ public static function get_public_config() { global $CFG, $SITE, $PAGE, $OUTPUT; require_once $CFG->libdir . '/authlib.php'; $context = context_system::instance(); // We need this to make work the format text functions. $PAGE->set_context($context); list($authinstructions, $notusedformat) = external_format_text($CFG->auth_instructions, FORMAT_MOODLE, $context->id); list($maintenancemessage, $notusedformat) = external_format_text($CFG->maintenance_message, FORMAT_MOODLE, $context->id); $settings = array('wwwroot' => $CFG->wwwroot, 'httpswwwroot' => $CFG->httpswwwroot, 'sitename' => external_format_string($SITE->fullname, $context->id, true), 'guestlogin' => $CFG->guestloginbutton, 'rememberusername' => $CFG->rememberusername, 'authloginviaemail' => $CFG->authloginviaemail, 'registerauth' => $CFG->registerauth, 'forgottenpasswordurl' => $CFG->forgottenpasswordurl, 'authinstructions' => $authinstructions, 'authnoneenabled' => (int) is_enabled_auth('none'), 'enablewebservices' => $CFG->enablewebservices, 'enablemobilewebservice' => $CFG->enablemobilewebservice, 'maintenanceenabled' => $CFG->maintenance_enabled, 'maintenancemessage' => $maintenancemessage); $typeoflogin = get_config('tool_mobile', 'typeoflogin'); // Not found, edge case. if ($typeoflogin === false) { $typeoflogin = self::LOGIN_VIA_APP; // Defaults to via app. } $settings['typeoflogin'] = $typeoflogin; // Check if the user can sign-up to return the launch URL in that case. $cansignup = signup_is_enabled(); if ($typeoflogin == self::LOGIN_VIA_BROWSER or $typeoflogin == self::LOGIN_VIA_EMBEDDED_BROWSER or $cansignup) { $url = new moodle_url("/{$CFG->admin}/tool/mobile/launch.php"); $settings['launchurl'] = $url->out(false); } if ($logourl = $OUTPUT->get_logo_url()) { $settings['logourl'] = $logourl->out(false); } if ($compactlogourl = $OUTPUT->get_compact_logo_url()) { $settings['compactlogourl'] = $compactlogourl->out(false); } return $settings; }