Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / blocks / login / block_login.php
blob65fa64b2dfda59996d901ecdac77af43441cae01
1 <?PHP //$Id$
3 class block_login extends block_base {
4 function init() {
5 $this->title = get_string('login');
6 $this->version = 2006102700; //TODO
9 function applicable_formats() {
10 return array('site' => true);
13 function get_content () {
14 global $USER, $CFG;
15 $wwwroot = '';
16 $signup = '';
18 if ($this->content !== NULL) {
19 return $this->content;
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);
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"><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"><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;