Documentation

GRIS_AUTH
in package

Class for authenticate uses

With this class users are autheticated for viewing page content or get permissions for actions

PHP version 7

Copyright (c) 2012, Holger Heuser, GESIS Leibniz Institute for the Social Sciences Unter Sachsenhausen 6-8 50667 Cologne, Germany

Tags
copyright

Copyright (c) 2012, Holger Heuser, GESIS Leibniz Institute for the Social Sciences

link

GESIS Leibniz Institute for the Social Sciences

since
1

File available since Release 1.0

version
1.0
author

Holger Heuser holger.heuser@gesis.org

Table of Contents

dbtable  = 'gris_user'
The constant for the database table where the settings are stored
settings_group  = "auth"
The constant for the settings group
$classname  : object
The name of the class
$dbconnection  : object
The database object for managing the connection
$i18n  : object
The object for translations
$ldap  : object
The object for ldap
$session_variable  : string
The auth variable of the session
$settings  : object
The object for settings
$state  : object
The object for logs
__construct()  : mixed
The class constructor
check_login_state()  : bool
Checks the current login state and logs the user out if the session is not set or invalid (timeout)
clean_files()  : bool
Delete all orphaned files (images and pdf)
create_user()  : bool
Creates a new user account
delete_user()  : mixed
Delete a user from gris_user table by a given username
get_group()  : int
Get the group for a given person ID
get_loginbox()  : bool
Returns a login box
get_person_id()  : int
Get the person ID of an existing object guid
get_samaccountName()  : string
Get the sAMAccountName from gris_user table by the person ID
get_switch_users()  : array<string|int, mixed>
Returns all IDs and Names of users the current user is allowed to switch to
get_username()  : string
Get the user name by ID
get_users()  : array<string|int, mixed>
Get all active users
is_admin()  : bool
Check if person is admin
login()  : string
Check the login data of the current user and logs him in if username and password are correct
logout()  : mixed
Logs out the current user and destroys the session
set_auth_session()  : mixed
Sets the auth session attribute
update_active_users()  : bool
Returns all active users in the system and deletes alls users that are not in AD (only in the user table, not in the whole system)
update_person_id()  : mixed
Update the person ID in gris_user table
update_user()  : mixed
Update the user data in gris_user table
delete_file()  : bool
Deletes a file
get_directory()  : array<string|int, mixed>
Returns the files of a directory

Constants

dbtable

The constant for the database table where the settings are stored

public mixed dbtable = 'gris_user'

settings_group

The constant for the settings group

public mixed settings_group = "auth"

Properties

$classname

The name of the class

protected object $classname = NULL
Tags
access

private

$dbconnection

The database object for managing the connection

private object $dbconnection = null
Tags
access

private

$i18n

The object for translations

private object $i18n
Tags
access

private

$ldap

The object for ldap

private object $ldap
Tags
access

private

$session_variable

The auth variable of the session

private string $session_variable
Tags
access

private

$settings

The object for settings

private object $settings = null
Tags
access

private

$state

The object for logs

private object $state
Tags
access

private

Methods

__construct()

The class constructor

public __construct() : mixed

Initializes the login state and checks wether the user is already logged in

Return values
mixed

check_login_state()

Checks the current login state and logs the user out if the session is not set or invalid (timeout)

public check_login_state() : bool
Return values
bool

The current state of the login

clean_files()

Delete all orphaned files (images and pdf)

public clean_files([bool $verbose = false ][, mixed $simulate = false ]) : bool
Parameters
$verbose : bool = false

Output all operations (e. g. for debug)

$simulate : mixed = false
Return values
bool

Returns true

create_user()

Creates a new user account

public create_user(string $username, string $ip, string $person_id, string $objectguid, string $sn, string $givenname, string $mail[, string $group = null ]) : bool
Parameters
$username : string

The username

$ip : string

The current user IP

$person_id : string

The person ID

$objectguid : string

The UID (from LDAP/AD)

$sn : string

The first name

$givenname : string

The last name

$mail : string

The email

$group : string = null

The user group in GRIS (not in AD/LADP)

Return values
bool

Returns true

delete_user()

Delete a user from gris_user table by a given username

public delete_user(string $username) : mixed
Parameters
$username : string

The username

Return values
mixed

get_group()

Get the group for a given person ID

public get_group(int $person_id[, booelan $name = false ]) : int
Parameters
$person_id : int

The person ID

$name : booelan = false

Returns also the name (default is ID)

Return values
int

Returns the group ID (optional an array with ID and name) or NULL if not found

get_loginbox()

Returns a login box

public get_loginbox(string $state, bool $error) : bool
Parameters
$state : string

The state message for the login box

$error : bool

An error has appeared

Return values
bool

true

get_person_id()

Get the person ID of an existing object guid

public get_person_id(string $objectguid) : int
Parameters
$objectguid : string

The object guid

Return values
int

Returns the person ID or NULL if not found

get_samaccountName()

Get the sAMAccountName from gris_user table by the person ID

public get_samaccountName(int $person_id) : string
Parameters
$person_id : int

The person ID

Return values
string

Returns the sAMAccountName or NULL if not found

get_switch_users()

Returns all IDs and Names of users the current user is allowed to switch to

public get_switch_users(string $person_id[, bool $ids_only = false ]) : array<string|int, mixed>
Parameters
$person_id : string

The person ID

$ids_only : bool = false

Return only the person IDs

Return values
array<string|int, mixed>

The array with names and IDs (or just the IDs)

get_username()

Get the user name by ID

public get_username(string $id) : string
Parameters
$id : string

The user ID

Return values
string

Returns the user name or NULL if not found

get_users()

Get all active users

public get_users() : array<string|int, mixed>
Return values
array<string|int, mixed>

The list of users

is_admin()

Check if person is admin

public is_admin(string $person_id) : bool
Parameters
$person_id : string

The person ID

Return values
bool

Returns true if person is admin, otherwise false

login()

Check the login data of the current user and logs him in if username and password are correct

public login(string $username, string $password) : string
Parameters
$username : string

The username

$password : string

The password

Return values
string

The state of the succesful login or a login box (html)

logout()

Logs out the current user and destroys the session

public logout() : mixed
Return values
mixed

set_auth_session()

Sets the auth session attribute

public set_auth_session(string $state) : mixed
Parameters
$state : string

The state of the login

Return values
mixed

update_active_users()

Returns all active users in the system and deletes alls users that are not in AD (only in the user table, not in the whole system)

public update_active_users([bool $verbose = false ][, mixed $simulate = false ]) : bool
Parameters
$verbose : bool = false

Output all operations (e. g. for debug)

$simulate : mixed = false
Return values
bool

Returns true for success

update_person_id()

Update the person ID in gris_user table

public update_person_id(string $username, string $gris_person_id) : mixed
Parameters
$username : string

The username

$gris_person_id : string

The person ID

Return values
mixed

update_user()

Update the user data in gris_user table

public update_user(string $objectguid, string $username, string $sn, string $mail, string $givenname) : mixed
Parameters
$objectguid : string

The object guid

$username : string

The username

$sn : string

The name of the user

$mail : string

The mail address

$givenname : string

The given name of the user

Return values
mixed

delete_file()

Deletes a file

private delete_file(string $filename, bool $simulate) : bool
Parameters
$filename : string

The filename (with complete path)

$simulate : bool

Only simulate the deletions

Return values
bool

Returns true on success or false on error

get_directory()

Returns the files of a directory

private get_directory(bool $directory) : array<string|int, mixed>
Parameters
$directory : bool

The name of the directory

Return values
array<string|int, mixed>

Returns all files as an array

Search results