Gurucms

Posted on: Mar 23, 2011


User Authentication


In this section it is described the variables that store the necessary information for the users statuses.

Admin User

The variable $admin holds the information if the user is admin.

Example Smarty code
 
{if $admin eq 1}
     The user is administrator
{/if}

Example PHP code
 
if($session->isAdmin())
{  
     $admin = 1;
}

Returned Variables
 
1 - Administrator
0 - User

LDAP

If you have installed the LDAP module, the authentication is taken place through this functionality.

Example PHP Code
 
$loginLdap = $_SESSION['loginLdap'];

$usernameLdap = $_SESSION['usernameLdap'];

Example Smarty Code

{$loginLdap}

{$usernameLdap}


Returned Variables
 
0 - User is not logged in

1 - User is logged in

The username of the user under LDAP

- The $forCheckLdap holds the information if the LDAP module is installed and enabled.

Example PHP Code
 
if($forCheckLdap=='1')
{
  //do something
}

Returned Variables
 
0 - LDAP is not installed or enabled

1 - LDAP is installed and enabled

- The $loginLdap holds the information if the user is logged in or not

Example PHP Code
 
if($loginLdap=='1')
{
  // do something
}

Returned Variables
 
0 - The user is not logged in

1 - The user is logged in

- The $adminLdap holds the information if the user that is logged in under LDAP is Administrator

Example PHP Code
 
if($adminLdap =='1')
{
  //do something
}

Returned Variables
 
0 - User

1 - Administrator

- The $suAuthorsLdap holds the information if the user that is logged in under LDAP is Super Author

Example PHP Code
 
if($suAuthorsLdap)
{
  // do something
}

Returned Variables
 
0 - User

1 - Super Authors level

- The $authorsLdap holds the information if the user that is logged in under LDAP is Author

Example PHP Code
 
if($authorsLdap=='1')
{
   // do something
}

Returned Variables
 
0 - User

1 - Authors level

Login User

The variable $login holds the information if user is logged in or not.
Example Smarty code
 
{if $login eq 1}
        The user is logged in
{/if}

Example PHP code
 
if($session->logged_in)
{
    $login = 1;
}
else
{
    $login = 0;
}


Returned Variables
 
1 - Logged in user
0 - Guest

If the user is logged in, we can retrieve the username by using the variable $username
Example Smarty code
 
{$username}

Example PHP code
 
$username = $session->username;

Returned Variables
 
Returns the username of the logged in user

User Level

The variable $userlevel holds the information of user's level.

By default there are available the following user levels and cannot by changed as it is necessary for the core functionality of CMS.
 
- Users
- Authors
- Super Authors
- Administrators

Example Smarty Code
 
{$userlevel}

{$userlevel_name}

Example PHP Code

Getting the id of the user level:
 
$userlevel = $session->userlevel;

Getting the name of the user level:
 
$userlevel_name

Returned Variables
 
1 - Administrators
2 - Users
3 - Super Authors
4 - Authors