ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
Auth_Controller Class Reference
+ Collaboration diagram for Auth_Controller:

Public Member Functions

 Auth_Controller (&$auth_obj, $login='login.php', $default='index.php', $accessList=array())
 Constructor.
 setAutoRedirectBack ($flag=true)
 Enables auto redirection when login is done.
 redirectBack ()
 Redirects Back to the calling page.
 redirectLogin ()
 Redirects to the login Page if not authorised.
 start ()
 Starts the Auth Procedure.
 isAuthorised ()
 Checks is the user is logged on.
 checkAuth ()
 Proxy call to auth.
 logout ()
 Proxy call to auth.
 getUsername ()
 Proxy call to auth.
 getStatus ()
 Proxy call to auth.

Data Fields

 $auth = null
 $login = null
 $default = null
 $autoRedirectBack = false

Detailed Description

Definition at line 61 of file Controller.php.

Member Function Documentation

Auth_Controller::Auth_Controller ( $auth_obj,
  $login = 'login.php',
  $default = 'index.php',
  $accessList = array() 
)

Constructor.

Parameters
AuthAn auth instance
stringThe login page
stringThe default page to go to if return page is not set
arraySome rules about which urls need to be sent to the login page
Returns
void
Todo:
Add a list of urls which need redirection

Definition at line 107 of file Controller.php.

References $_GET, $default, and $login.

{
$this->auth =& $auth_obj;
$this->_loginPage = $login;
$this->_defaultPage = $default;
@session_start();
if (!empty($_GET['return']) && $_GET['return'] && !strstr($_GET['return'], $this->_loginPage)) {
$this->auth->setAuthData('returnUrl', $_GET['return']);
}
if(!empty($_GET['authstatus']) && $this->auth->status == '') {
$this->auth->status = $_GET['authstatus'];
}
}
Auth_Controller::checkAuth ( )

Proxy call to auth.

See Also
Auth::checkAuth()

Definition at line 257 of file Controller.php.

{
return($this->auth->checkAuth());
}
Auth_Controller::getStatus ( )

Proxy call to auth.

See Also
Auth::getStatus()

Definition at line 293 of file Controller.php.

{
return($this->auth->getStatus());
}
Auth_Controller::getUsername ( )

Proxy call to auth.

See Also
Auth::getUsername()

Definition at line 281 of file Controller.php.

{
return($this->auth->getUsername());
}
Auth_Controller::isAuthorised ( )

Checks is the user is logged on.

See Also
Auth::checkAuth()

Definition at line 245 of file Controller.php.

{
return($this->auth->checkAuth());
}
Auth_Controller::logout ( )

Proxy call to auth.

See Also
Auth::logout()

Definition at line 269 of file Controller.php.

{
return($this->auth->logout());
}
Auth_Controller::redirectBack ( )

Redirects Back to the calling page.

Returns
void

Definition at line 145 of file Controller.php.

Referenced by start().

{
// If redirectback go there
// else go to the default page
$returnUrl = $this->auth->getAuthData('returnUrl');
if(!$returnUrl) {
$returnUrl = $this->_defaultPage;
}
// Add some entropy to the return to make it unique
// avoind problems with cached pages and proxies
if(strpos($returnUrl, '?') === false) {
$returnUrl .= '?';
}
$returnUrl .= uniqid('');
// Track the auth status
if($this->auth->status != '') {
$url .= '&authstatus='.$this->auth->status;
}
header('Location:'.$returnUrl);
print("You could not be redirected to <a href=\"$returnUrl\">$returnUrl</a>");
}

+ Here is the caller graph for this function:

Auth_Controller::redirectLogin ( )

Redirects to the login Page if not authorised.

put return page on the query or in auth

Returns
void

Definition at line 180 of file Controller.php.

Referenced by start().

{
// Go to the login Page
// For Auth, put some check to avoid infinite redirects, this should at least exclude
// the login page
$url = $this->_loginPage;
if(strpos($url, '?') === false) {
$url .= '?';
}
if(!strstr($_SERVER['PHP_SELF'], $this->_loginPage)) {
$url .= 'return='.urlencode($_SERVER['PHP_SELF']);
}
// Track the auth status
if($this->auth->status != '') {
$url .= '&authstatus='.$this->auth->status;
}
header('Location:'.$url);
print("You could not be redirected to <a href=\"$url\">$url</a>");
}

+ Here is the caller graph for this function:

Auth_Controller::setAutoRedirectBack (   $flag = true)

Enables auto redirection when login is done.

Parameters
boolSets the autoRedirectBack flag to this
See Also
Auth_Controller::autoRedirectBack
Returns
void

Definition at line 132 of file Controller.php.

{
$this->autoRedirectBack = $flag;
}
Auth_Controller::start ( )

Starts the Auth Procedure.

If the page requires login the user is redirected to the login page otherwise the Auth::start is called to initialize Auth

Returns
void
Todo:
Implement an access list which specifies which urls/pages need login and which do not

Definition at line 217 of file Controller.php.

References redirectBack(), and redirectLogin().

{
// Check the accessList here
// ACL should be a list of urls with allow/deny
// If allow set allowLogin to false
// Some wild card matching should be implemented ?,*
if(!strstr($_SERVER['PHP_SELF'], $this->_loginPage) && !$this->auth->checkAuth()) {
$this->redirectLogin();
} else {
$this->auth->start();
// Logged on and on login page
if(strstr($_SERVER['PHP_SELF'], $this->_loginPage) && $this->auth->checkAuth()){
$this->autoRedirectBack ?
$this->redirectBack() :
null ;
}
}
}

+ Here is the call graph for this function:

Field Documentation

Auth_Controller::$auth = null

Definition at line 71 of file Controller.php.

Auth_Controller::$autoRedirectBack = false

Definition at line 92 of file Controller.php.

Auth_Controller::$default = null

Definition at line 84 of file Controller.php.

Referenced by Auth_Controller().

Auth_Controller::$login = null

Definition at line 77 of file Controller.php.

Referenced by Auth_Controller().


The documentation for this class was generated from the following file: