1
<?PHP //$Id: block_login.php,v 1.2 2004/08/22 16:54:45 defacer Exp $
3
class CourseBlock_login extends MoodleBlock {
4
function CourseBlock_login ($course) {
5
$this->title = get_string('login');
6
$this->content_type = BLOCK_TYPE_TEXT;
7
$this->course = $course;
8
$this->version = 2004081600;
11
function applicable_formats() {
12
return array('site' => true);
15
function get_content () {
20
if ($this->content !== NULL) {
21
return $this->content;
24
if (empty($CFG->loginhttps)) {
25
$wwwroot = $CFG->wwwroot;
27
// This actually is not so secure ;-), 'cause we're
28
// in unencrypted connection...
29
$wwwroot = str_replace("http://", "https://", $CFG->wwwroot);
33
// I'm not sure if user can create an account
34
// him/her self when using ldap authentication.
35
// If true, then there should be a method for it.
37
$signup = $wwwroot . '/login/signup.php';
40
// just for the user to see instructions!
41
$signup = $wwwroot . '/login/index.php';
47
$username = get_moodle_cookie();
48
if (empty($USER->loggedin)) {
49
$this->content->text = "<form name=\"blocklogin\" method=\"post\"";
50
$this->content->text .= " action=\"". $wwwroot ."/login/index.php\">\n";
51
$this->content->text .= "<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\"";
52
$this->content->text .= " width=\"100%\" style=\"font-size: small;\">\n";
53
$this->content->text .= "<tr>\n<td>". get_string("username") .":</td>\n</tr>\n";
54
$this->content->text .= "<tr>\n<td><input type=\"text\" name=\"username\" value=\"";
55
$this->content->text .= $username . "\" /></td>\n</tr>\n";
56
$this->content->text .= "<tr>\n<td>". get_string("password") .":</td>\n</tr>\n";
57
$this->content->text .= "<tr>\n<td><input type=\"password\" name=\"password\" /></td>\n</tr>\n";
58
$this->content->text .= "<tr>\n<td align=\"center\"><input type=\"submit\" value=\"";
59
$this->content->text .= get_string("login");
60
$this->content->text .= "\" /></td>\n</tr>\n";
61
if (!empty($signup)) {
62
$this->content->text .= "<tr><td align=\"center\"><a href=\"". $signup ."\">";
63
$this->content->text .= get_string('startsignup');
64
$this->content->text .= "</a></td></tr>\n";
66
$this->content->text .= "</table>\n";
67
$this->content->text .= "</form>\n";
69
$this->content->text = ''; // It's time to dissapear!
70
// And keep the self test happy by
71
// passing empty string!
73
return $this->content;