MDL-22054 startinging blocks to pluginname
[moodle.git] / blocks / login / block_login.php
CommitLineData
4ca6cfbf 1<?php
284dc1a1 2
e89d741a 3class block_login extends block_base {
9b4b78fd 4 function init() {
2de43a56 5 $this->title = get_string('pluginname', 'block_login');
4ca6cfbf 6 $this->version = 2007101509;
284dc1a1 7 }
8
9 function applicable_formats() {
2b0d60ec 10 return array('site' => true);
284dc1a1 11 }
12
13 function get_content () {
a8bdedab 14 global $USER, $CFG, $SESSION;
284dc1a1 15 $wwwroot = '';
16 $signup = '';
17
18 if ($this->content !== NULL) {
19 return $this->content;
20 }
21
22 if (empty($CFG->loginhttps)) {
23 $wwwroot = $CFG->wwwroot;
24 } else {
25 // This actually is not so secure ;-), 'cause we're
26 // in unencrypted connection...
27 $wwwroot = str_replace("http://", "https://", $CFG->wwwroot);
28 }
4ca6cfbf 29
16ce6c0d 30 if (!empty($CFG->registerauth)) {
31 $authplugin = get_auth_plugin($CFG->registerauth);
6bc1e5d5 32 if ($authplugin->can_signup()) {
16ce6c0d 33 $signup = $wwwroot . '/login/signup.php';
34 }
284dc1a1 35 }
16ce6c0d 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';
284dc1a1 38
0ad6b20c 39 $username = get_moodle_cookie() === 'nobody' ? '' : get_moodle_cookie();
792197b0 40
c009421c 41 $this->content->footer = '';
42 $this->content->text = '';
43
083c3743 44 if (!isloggedin() or isguestuser()) { // Show the block
c009421c 45
93f66983 46 $this->content->text .= "\n".'<form class="loginform" id="login" method="post" action="'.get_login_url().'">';
c009421c 47
44578719 48 $this->content->text .= '<div class="c1 fld username"><label for="login_username">'.get_string('username').'</label>';
702cf10b 49 $this->content->text .= '<input type="text" name="username" id="login_username" value="'.s($username).'" /></div>';
c009421c 50
44578719 51 $this->content->text .= '<div class="c1 fld password"><label for="login_password">'.get_string('password').'</label>';
808c2a69 52 $this->content->text .= '<input type="password" name="password" id="login_password" value="" /></div>';
c009421c 53
9dd68bc7 54 $this->content->text .= '<div class="c1 btn"><input type="submit" value="'.get_string('login').'" /></div>';
808c2a69 55
56 $this->content->text .= "</form>\n";
c009421c 57
284dc1a1 58 if (!empty($signup)) {
c009421c 59 $this->content->footer .= '<div><a href="'.$signup.'">'.get_string('startsignup').'</a></div>';
60 }
61 if (!empty($forgot)) {
62 $this->content->footer .= '<div><a href="'.$forgot.'">'.get_string('forgotaccount').'</a></div>';
284dc1a1 63 }
284dc1a1 64 }
c009421c 65
284dc1a1 66 return $this->content;
67 }
68}
69
4ca6cfbf 70