ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
Anonymous.php
Go to the documentation of this file.
1 <?php
2 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
3 
29 require_once 'Auth.php';
30 
47 class Auth_Anonymous extends Auth
48 {
49 
50  // {{{ properties
51 
57  var $allow_anonymous = true;
58 
64  var $anonymous_username = 'anonymous';
65 
66  // }}}
67  // {{{ Auth_Anonymous() [constructor]
68 
84  function Auth_Anonymous($storageDriver, $options = '', $loginFunction = '', $showLogin = true) {
85  parent::Auth($storageDriver, $options, $loginFunction, $showLogin);
86  }
87 
88  // }}}
89  // {{{ login()
90 
102  function login() {
103  if ( $this->allow_anonymous
104  && empty($this->username)
105  && empty($this->password) ) {
106  $this->setAuth($this->anonymous_username);
107  if (is_callable($this->loginCallback)) {
108  call_user_func_array($this->loginCallback, array($this->username, $this) );
109  }
110  } else {
111  // Call normal login system
112  parent::login();
113  }
114  }
115 
116  // }}}
117  // {{{ forceLogin()
118 
127  function forceLogin() {
128  $this->allow_anonymous = false;
129  if( !empty($this->session['username']) && $this->session['username'] == $this->anonymous_username ) {
130  $this->logout();
131  }
132  }
133 
134  // }}}
135 
136 }
137 
138 ?>