3 class block_login
extends block_base
{
5 $this->title
= get_string('login');
6 $this->version
= 2007101509;
9 function applicable_formats() {
10 return array('site' => true);
13 function get_content () {
18 if ($this->content
!== NULL) {
19 return $this->content
;
22 if (empty($CFG->loginhttps
)) {
23 $wwwroot = $CFG->wwwroot
;
25 // This actually is not so secure ;-), 'cause we're
26 // in unencrypted connection...
27 $wwwroot = str_replace("http://", "https://", $CFG->wwwroot
);
30 if (!empty($CFG->registerauth
)) {
31 $authplugin = get_auth_plugin($CFG->registerauth
);
32 if ($authplugin->can_signup()) {
33 $signup = $wwwroot . '/login/signup.php';
36 // TODO: now that we have multiauth it is hard to find out if there is a way to change password
37 $forgot = $wwwroot . '/login/forgot_password.php';
39 $username = get_moodle_cookie() === 'nobody' ?
'' : get_moodle_cookie();
41 $this->content
->footer
= '';
42 $this->content
->text
= '';
44 if (!isloggedin() or isguestuser()) { // Show the block
46 $this->content
->text
.= "\n".'<form class="loginform" id="login" method="post" action="'.$wwwroot.'/login/index.php">';
48 $this->content
->text
.= '<div class="c1 fld username"><label for="login_username">'.get_string('username').'</label>';
49 $this->content
->text
.= '<input type="text" name="username" id="login_username" value="'.s($username).'" /></div>';
51 $this->content
->text
.= '<div class="c1 fld password"><label for="login_password">'.get_string('password').'</label>';
52 $this->content
->text
.= '<input type="password" name="password" id="login_password" value="" /></div>';
54 $this->content
->text
.= '<div class="c1 btn"><input type="submit" value="'.get_string('login').'" /></div>';
56 $this->content
->text
.= "</form>\n";
58 if (!empty($signup)) {
59 $this->content
->footer
.= '<div><a href="'.$signup.'">'.get_string('startsignup').'</a></div>';
61 if (!empty($forgot)) {
62 $this->content
->footer
.= '<div><a href="'.$forgot.'">'.get_string('forgotaccount').'</a></div>';
66 return $this->content
;