~ubuntu-branches/ubuntu/hoary/moodle/hoary

« back to all changes in this revision

Viewing changes to blocks/login/block_login.php

  • Committer: Bazaar Package Importer
  • Author(s): Isaac Clerencia
  • Date: 2004-12-29 00:49:52 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20041229004952-gliyqzpj2w3e7clx
Tags: 1.4.3-1
* Urgency high as upstream release fixes several security bugs
* New upstream release
* Write database creation errors and warn the user about it, 
closes: #285842, #285842

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?PHP //$Id: block_login.php,v 1.2 2004/08/22 16:54:45 defacer Exp $
 
2
 
 
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;
 
9
    }
 
10
 
 
11
    function applicable_formats() {
 
12
        return array('site' => true);
 
13
    }
 
14
 
 
15
    function get_content () {
 
16
        global $USER, $CFG;
 
17
        $wwwroot = '';
 
18
        $signup = '';
 
19
 
 
20
        if ($this->content !== NULL) {
 
21
            return $this->content;
 
22
        }
 
23
 
 
24
        if (empty($CFG->loginhttps)) {
 
25
            $wwwroot = $CFG->wwwroot;
 
26
        } else {
 
27
            // This actually is not so secure ;-), 'cause we're
 
28
            // in unencrypted connection...
 
29
            $wwwroot = str_replace("http://", "https://", $CFG->wwwroot);
 
30
        }
 
31
 
 
32
        switch ($CFG->auth) {
 
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.
 
36
            case "email":
 
37
                $signup = $wwwroot . '/login/signup.php';
 
38
                break;
 
39
            case "none":
 
40
                // just for the user to see instructions!
 
41
                $signup = $wwwroot . '/login/index.php';
 
42
                break;
 
43
            default:
 
44
                $signup = '';
 
45
        }
 
46
 
 
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";
 
65
            }
 
66
            $this->content->text .= "</table>\n";
 
67
            $this->content->text .= "</form>\n";
 
68
        } else {
 
69
            $this->content->text = ''; // It's time to dissapear!
 
70
                                       // And keep the self test happy by
 
71
                                       // passing empty string!
 
72
        }
 
73
        return $this->content;
 
74
    }
 
75
}
 
76
 
 
77
?>