Overview   Package   Tree   Index 
Tv2 documentation
PREV  NEXT FRAMES  NO FRAME 
SUMMARY:  FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

tv2-engine
Class ctlSecurity


class ctlSecurity

Security class - manages users, groups and permissions

Authors:
Emilis Dambauskas (emilis@gildija.lt)
Version:
$Id: ctlSecurity.class.php,v 1.7 2004/04/19 21:39:16 lunaticlt Exp $
Copyright:
2002–2003 Emilis Dambauskas under Artistic license

Field Summary
private array$curr_user
Current user data
private object$db
Database abstraction object: link to db.
private string$group_table
group table name
private array$groups
group array
private array$sec
permission array
private string$sec_table
permission table name
private string$sequence
db sequence name
private string$ugroup_table
user-group table name
private array$ugroups
links between user and group array elements
private string$user_table
user table name
private array$users
user array

Constructor Summary
void ctlSecurity()
Constructor.

Method Summary
boolean add(string $type, integer $id, string $access, [string $ug], [integer $ug_id])
Add permission on a given object
mixed addGroup(string $name)
creates new group
mixed addUser(string $login, string $pass, [array $groups])
Creates new user
boolean check(string $type, integer $id, string $access, [string $ug], [integer $ug_id])
Checks if user has permission to do something.
private boolean error(string $msg)
Sends an error to the errors object and returns FALSE
mixed findGroup(mixed $id)
Returns group id for a group name
mixed findUser(mixed $id)
Returns user id for user name
mixed get(string $type, integer $id)
Gets permissions of an object
array getActiveUser()
Alias of ctlSecurity::getCurrentUser
string getActiveUserName()
Returns login of the current user
array getAllGroups()
Returns an array of all groups
array getAllUsers()
Returns an array of all users.
array getCurrentUser()
Returns current user data
boolean isNotDefaultUser()
Checks if current user is not default user (usually to check if user is logged in).
boolean isRoot()
Checks if current user is root user
boolean load()
Loads data arrays from a database.
boolean login(string $login, string $password)
Changes current user if login and password match
boolean logout()
Changes current user to default user.
boolean remove(string $type, integer $id, [string $ug], [mixed $ug_id])
Removes permission[s] from an object
boolean removeGroup(mixed $id)
Removes group.
boolean removeUser(integer $id)
Removes user.
boolean reset(string $type, integer $id, array $permissions)
Resets permissions for an object (clears all permissions and creates new permissions)
array setActiveUser([mixed $id])
Alias of ctlSecurity::setCurrentUser
array setCurrentUser([mixed $id])
Changes current user
private integer translatePermission(mixed $string)
Changes textual permission into numeric
private mixed translateUG(mixed $string)
Translates 'u'/'g' string into integer
boolean update(string $type, integer $id, mixed $access, string $ug, mixed $ug_id)
Updates permissions of an object for a user/group
mixed updateGroup(mixed $id, array $data)
Changes group data.
boolean updateUser(integer $id, array $data)
Updates user information (login, password, group membership)


Field Detail

curr_user

private array $curr_user

Current user data


db

private object $db

Database abstraction object: link to db.


group_table

private string $group_table

group table name


groups

private array $groups

group array


sec

private array $sec

permission array


sec_table

private string $sec_table

permission table name


sequence

private string $sequence

db sequence name


ugroup_table

private string $ugroup_table

user-group table name


ugroups

private array $ugroups

links between user and group array elements


user_table

private string $user_table

user table name


users

private array $users

user array


Constructor Detail

ctlSecurity()

void ctlSecurity()

Constructor. Sets table names.

Uses the global variables:
db, $config
To Do:
  • remove references to $config

Method Detail

add()

boolean add(string $type, integer $id, string $access, [string $ug], [integer $ug_id])

Add permission on a given object

Parameters:
type - Object type
id - Object id
access - r/w/x/o/d or their integer representation
ug - user/group?
ug_id - user/group id.
Returns:
TRUE on success, FALSE on failure

addGroup()

mixed addGroup(string $name)

creates new group

Parameters:
name - group name
Returns:
group data array on success, FALSE on failure

addUser()

mixed addUser(string $login, string $pass, [array $groups])

Creates new user

Parameters:
login - user login name
pass - user password
groups - array of group names
Returns:
user data array on success, FALSE on failure

check()

boolean check(string $type, integer $id, string $access, [string $ug], [integer $ug_id])

Checks if user has permission to do something.

Parameters:
type - type of permission
id - Id of object the user is trying to access
access - Access level (r/w/x/o/d or corresponding int values)
ug - user or group? (Needed if you are checking permission not for the current user.)
ug_id - user/group id. (Needed if you are checking permission not for the current user.)
Returns:
TRUE if permission granted, FALSE otherwise

error()

private boolean error(string $msg)

Sends an error to the errors object and returns FALSE

Parameters:
msg - error message
Returns:
always FALSE
Uses the global variables:
errors

findGroup()

mixed findGroup(mixed $id)

Returns group id for a group name

Parameters:
id - group id/name
Returns:
group id on success, FALSE on failure

findUser()

mixed findUser(mixed $id)

Returns user id for user name

Parameters:
id - user id/name
Returns:
user data on success, FALSE on failure

get()

mixed get(string $type, integer $id)

Gets permissions of an object

Parameters:
type - object type
id - object id
Returns:
Permission array on success, FALSE on failure

getActiveUser()

array getActiveUser()

Alias of ctlSecurity::getCurrentUser

Returns:
user data

getActiveUserName()

string getActiveUserName()

Returns login of the current user

Returns:
user name

getAllGroups()

array getAllGroups()

Returns an array of all groups

Returns:
group array

getAllUsers()

array getAllUsers()

Returns an array of all users.

Returns:
user array

getCurrentUser()

array getCurrentUser()

Returns current user data

Returns:
user data

isNotDefaultUser()

boolean isNotDefaultUser()

Checks if current user is not default user (usually to check if user is logged in).

Returns:
TRUE if not default user, FALSE if default user

isRoot()

boolean isRoot()

Checks if current user is root user

Returns:
TRUE if root user, FALSE otherwise

load()

boolean load()

Loads data arrays from a database.

Returns:
always TRUE

login()

boolean login(string $login, string $password)

Changes current user if login and password match

Parameters:
login - user login name
password - user password
Returns:
TRUE on success, FALSE on failure

logout()

boolean logout()

Changes current user to default user.

Returns:
TRUE on success, FALSE on failure

remove()

boolean remove(string $type, integer $id, [string $ug], [mixed $ug_id])

Removes permission[s] from an object

Parameters:
type - object type
id - object id
ug - User 'u' or group 'g'?
ug_id - user/group id or name
Returns:
TRUE on success, FALSE on failure

removeGroup()

boolean removeGroup(mixed $id)

Removes group.

Parameters:
id - group id/name
Returns:
TRUE on success, FALSE on failure

removeUser()

boolean removeUser(integer $id)

Removes user.

Parameters:
id - user id
Returns:
TRUE on success, FALSE on failure

reset()

boolean reset(string $type, integer $id, array $permissions)

Resets permissions for an object (clears all permissions and creates new permissions)

Parameters:
type - object type
id - object id
permissions - permission array. Format: array( 0 => array('ug'=>'..', 'user'=>'..', 'access'=>'..'), 1 => array(...))
Returns:
TRUE on success, FALSE on failure

setActiveUser()

array setActiveUser([mixed $id])

Alias of ctlSecurity::setCurrentUser

Parameters:
id - user id/name
Returns:
user data array

setCurrentUser()

array setCurrentUser([mixed $id])

Changes current user

Parameters:
id - user id/name
Returns:
user data array

translatePermission()

private integer translatePermission(mixed $string)

Changes textual permission into numeric

Parameters:
string - can be permission string or numeric value
Returns:
permission or FALSE on error

translateUG()

private mixed translateUG(mixed $string)

Translates 'u'/'g' string into integer

Parameters:
string - can be string or integer
Returns:
corresponding integer on success, FALSE on failure

update()

boolean update(string $type, integer $id, mixed $access, string $ug, mixed $ug_id)

Updates permissions of an object for a user/group

Parameters:
type - object type
id - object id
access - access level
ug - user 'u' or group 'g'?
ug_id - user/group id or name
Returns:
TRUE on success FALSE on failure

updateGroup()

mixed updateGroup(mixed $id, array $data)

Changes group data.

Parameters:
id - group id/name
data - group data
Returns:
group data array on success, FALSE on failure

updateUser()

boolean updateUser(integer $id, array $data)

Updates user information (login, password, group membership)

Parameters:
id - user id
data - user data
Returns:
TRUE on success, FALSE on failure

 Overview   Package   Tree   Index 
Tv2 documentation
PREV  NEXT FRAMES  NO FRAME 
SUMMARY:  FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Submit a bug

This document was generated by phpdocgen 0.17-rc3.
Copyright © 2002-03 Stéphane GALLAND (under the GNU General Public License)