ultimix
user_access_1_0_0 Class Reference

Public Member Functions

 __construct ()
 set_add_limitations ($theAddLimitation)
 unsafe_select ($Condition= '1=1')
 get_user ($Login)
 reset_password ($Login, $Password)
 set_avatar ($Login, $ImageId)
 update ($id, &$Record)
 delete ($ids)
 activate_users ($Ids)
 deactivate_users ($Ids)
 activate_user ($Hash)
 deactivate_user ($id)
 create ($Record)
 select_list ($id)
 select ($Start=false, $Limit=false, $Field=false, $Order=false, $Condition= '1=1')
 simple_select ()

Data Fields

 $NativeTable = '`umx_user`'
 $GuestUserId = 2
 $Database = false
 $DatabaseAlgorithms = false
 $Security = false
 $SecurityParser = false
 $UserAccessUtilities = false
 $UsersCache = array()
 $AddLimitations = '1 = 1'

Detailed Description

Class for authentification.

Author
Dodonov A.A.

Definition at line 26 of file user_access.php.

Constructor & Destructor Documentation

__construct ( )

Constructor.

Author
Dodonov A.A.

Definition at line 90 of file user_access.php.

{
try
{
$this->Database = get_package( 'database' , 'last' , __FILE__ );
$this->DatabaseAlgorithms = get_package( 'database::database_algorithms' , 'last' , __FILE__ );
$this->Security = get_package( 'security' , 'last' , __FILE__ );
$this->SecurityParser = get_package( 'security::security_parser' , 'last' , __FILE__ );
$this->UserAccessUtilities = get_package(
'user::user_access::user_access_utilities' , 'last' , __FILE__
);
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

Member Function Documentation

activate_user (   $Hash)

Function activates user.

Parameters
$Hash- Activation hash.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 564 of file user_access.php.

{
try
{
$Hash = $this->Security->get( $Hash , 'command' );
$Users = $this->unsafe_select( "active LIKE '$Hash'" );
if( isset( $Users[ 0 ] ) )
{
$Ids = get_field_ex( $Users , 'id' );
$this->activate_users( $Ids );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
activate_users (   $Ids)

Function activates users.

Parameters
$Ids- id of the activating users.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 488 of file user_access.php.

{
try
{
$Ids = $this->Security->get( $Ids , 'integer' );
$Record = array( 'active' => '1' );
$this->update( implode( ',' , $Ids ) , $Record );
foreach( $Ids as $id )
{
$this->UserAccessUtilities->rise_activate_event( '' , $id );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
create (   $Record)

Creating record.

Parameters
$Record- Example for creation.
Returns
array( $id , hash ).
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 673 of file user_access.php.

{
try
{
$Record = $this->SecurityParser->parse_parameters(
$Record ,
'login:string;password:string;email:email;name:string;sex:integer;site:string;about:string'
);
$this->set_fields( $Record );
list( $Fields , $Values ) = $this->DatabaseAlgorithms->compile_fields_values( $Record );
$Fields [] = 'registered';
$Values [] = 'NOW()';
$id = $this->DatabaseAlgorithms->create( $this->NativeTable , $Fields , $Values );
$this->UserAccessUtilities->rise_create_event( get_field( $Record , 'login' ) , $id );
return( array( $id , get_field( $Record , 'active' ) ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
deactivate_user (   $id)

Function activates user.

Parameters
$id- User's id.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 603 of file user_access.php.

{
try
{
$id = $this->Security->get( $id , 'integer' );
$Record = array( 'active' => '0' );
$this->update( $id , $Record );
$this->UserAccessUtilities->rise_deactivate_event( $id );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
deactivate_users (   $Ids)

Function activates users.

Parameters
$Ids- id of the activating users.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 526 of file user_access.php.

{
try
{
$Ids = $this->Security->get( $Ids , 'integer' );
$Record = array( 'active' => 'inactive' );
$this->update( implode( ',' , $Ids ) , $Record );
foreach( $Ids as $id )
{
$this->UserAccessUtilities->rise_activate_event( '' , $id );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
delete (   $ids)

Function deletes user

Parameters
$ids- id of the deleting user.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 451 of file user_access.php.

{
try
{
$ids = $this->Security->get( $ids , 'integer_list' );
$this->Database->delete( $this->NativeTable , "( $this->AddLimitations ) AND id IN ( $ids )" );
$this->Database->commit();
$Link = get_package( 'link' , 'last' , __FILE__ );
$Link->delete_link( "$ids" , false , 'user' , 'permit' );
$Link->delete_link( "$ids" , false , 'user' , 'group' );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_user (   $Login)

Function returns user by it's login.

Parameters
$Login-Login of the searching user.
Returns
User object.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 227 of file user_access.php.

{
try
{
if( isset( $this->UsersCache[ $Login ] ) )
{
return( $this->UsersCache[ $Login ] );
}
$Login = $this->Security->get( $Login , 'string' );
$Users = $this->unsafe_select( "login LIKE '$Login'" );
if( count( $Users ) === 0 || count( $Users ) > 1 )
{
throw( new Exception( 'User with login '.$Login.' was not found' ) );
}
else
{
$this->UsersCache[ $Login ] = $Users[ 0 ];
return( $Users[ 0 ] );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
reset_password (   $Login,
  $Password 
)

Function resets password.

Parameters
$Login- Login.
$Password- New password.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 278 of file user_access.php.

{
try
{
$Login = $this->Security->get( $Login , 'string' );
$Password = $this->Security->get( $Password , 'string' );
$Users = $this->unsafe_select( "login LIKE '$Login'" );
$User = $this->get_user( $Login );
$Record = array( 'password' => "md5( '$Password' )" );
$this->update( get_field( $User , 'id' ) , $Record );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
select (   $Start = false,
  $Limit = false,
  $Field = false,
  $Order = false,
  $Condition = '1 = 1' 
)

Function returns list of records.

Parameters
$Start- Number of the first record.
$Limit- Count of records limitation.
$Field- Field to sort by.
$Order- Sorting order.
$Condition- Additional conditions.
Returns
List of records.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 775 of file user_access.php.

{
try
{
$Condition = $this->DatabaseAlgorithms->select_condition(
$Start , $Limit , $Field , $Order , $Condition , $this->NativeTable
);
return( $this->unsafe_select( $Condition ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
select_list (   $id)

Function selects list of objects.

Parameters
$id- Comma separated list of record's id.
Returns
Array of records.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 723 of file user_access.php.

{
try
{
$id = $this->Security->get( $id , 'integer_list' );
return( $this->unsafe_select( $this->NativeTable.".id IN ( $id )" ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
set_add_limitations (   $theAddLimitation)

Function sets additional limitations.

Parameters
$theAddLimitation- Additional limitations.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 138 of file user_access.php.

{
try
{
if( $this->AddLimitations === '1 = 1' )
{
$this->AddLimitations = $theAddLimitation;
}
else
{
throw( new Exception( '"AddLimitations" was already set' ) );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
set_avatar (   $Login,
  $ImageId 
)

Function sets avatar.

Parameters
$Login- Login.
$ImageId- Image id.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 320 of file user_access.php.

{
try
{
$Login = $this->Security->get( $Login , 'string' );
$ImageId = $this->Security->get( $ImageId , 'integer' );
$User = $this->get_user( $Login );
$Record = array( 'avatar' => "$ImageId" );
$this->update( get_field( $User , 'id' ) , $Record );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
simple_select ( )

Function selects list of objects.

Returns
Array of records.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 810 of file user_access.php.

{
try
{
$Records = $this->unsafe_select( '1 = 1' );
foreach( $Records as $k => $v )
{
$Records[ $k ]->title = $v->id ? $v->login : '{lang:not_defined}';
}
return( $Records );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
unsafe_select (   $Condition = '1 = 1')

Selecting users.

Parameters
$Conditionnot used.
Returns
Array of objects.
Note
Not safe.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 183 of file user_access.php.

{
try
{
$this->Database->query_as( DB_OBJECT );
return(
$this->Database->select(
$this->NativeTable.'.* , file_path AS avatar_path , '.
'IF( banned_to >= NOW() , 1 , 0 ) AS banned' ,
$this->NativeTable.' , umx_uploaded_file' ,
"( $this->AddLimitations ) AND umx_uploaded_file.id = ".
$this->NativeTable.".avatar AND $Condition"
)
);
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
update (   $id,
$Record 
)

Updating record.

Parameters
$id- Comma separated list of record's id.
$Record- Example for update.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 403 of file user_access.php.

{
try
{
$id = $this->Security->get( $id , 'integer_list' );
list( $Fields , $Values ) = $this->fetch_update_data( $Record );
if( count( $Fields ) == 0 )
{
return;
}
$this->EventManager = get_package( 'event_manager' , 'last' , __FILE__ );
$this->EventManager->trigger_event(
'on_before_update_user' , array( 'id' => $id , 'data' => $Record )
);
$this->Database->update(
$this->NativeTable , $Fields , $Values , "( $this->AddLimitations ) AND id IN ( $id )"
);
$this->Database->commit();
$this->UserAccessUtilities->rise_update_event( $id );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

Field Documentation

$AddLimitations = '1 = 1'

Definition at line 118 of file user_access.php.

$Database = false

Cached objects.

Author
Dodonov A.A.

Definition at line 62 of file user_access.php.

$DatabaseAlgorithms = false

Definition at line 63 of file user_access.php.

$GuestUserId = 2

Guest's id.

Author
Dodonov A.A.

Definition at line 50 of file user_access.php.

$NativeTable = '`umx_user`'

Table name in wich objects of this entity are stored.

Author
Dodonov A.A.

Definition at line 38 of file user_access.php.

$Security = false

Definition at line 64 of file user_access.php.

$SecurityParser = false

Definition at line 65 of file user_access.php.

$UserAccessUtilities = false

Definition at line 66 of file user_access.php.

$UsersCache = array()

Cache of users.

Author
Dodonov A.A.

Definition at line 78 of file user_access.php.


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