ultimix

- Main Page
- Data Structures
- Files
- Examples

- Data Structures
- Data Structure Index
- Data Fields

Public Member Functions | Data Fields
user_controller_1_0_0 Class Reference

## Public Member Functions
| load_settings ()
| load_common_packages ()
| __construct ()
| do_login ($Login, &$Options)
| login (&$Options)
| logout (&$Options)
| activate_user (&$Options)
| admin_activate_user (&$Options)
| admin_deactivate_user (&$Options)
| restore_password (&$Options)
| try_reset_password ()
| update_user (&$Options)
| registration (&$Options)
| set_avatar (&$Options)
| controller (&$Options)

## Data Fields
| $ContextSet = false
| $EventManager = false
| $Messages = false
| $PageComposerUtilities = false
| $Security = false
| $UserAccess = false
| $UserAlgorithms = false
| $UserControllerUtilities = false
| $EnableRegistration = 1
| $RegistrationConfirm = 1
| $RegistrationWasPassed = false
| $EmailSender = 'System'
| $SystemEmail = 'ultimix@localhost'

## Detailed Description

Working with user's accounts.

Author
  Dodonov A.A.

Definition at line 26 of file user_controller.php.

## Constructor & Destructor Documentation

__construct | ( |  | ) |

Constructor.

Author
  Dodonov A.A.

Definition at line 174 of file user_controller.php.

{
try
{
$this->load_common_packages();
$this->UserAccess = get_package( 'user::user_access' , 'last' , __FILE__ );
$this->UserAlgorithms = get_package( 'user::user_algorithms' , 'last' , __FILE__ );
$this->UserControllerUtilities = get_package(
'user::user_controller::user_controller_utilities' , 'last' , __FILE__
);
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

## Member Function Documentation

activate_user | ( | & | $Options | ) |

Function activates user.

Parameters

  $Options | - Settings.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 334 of file user_controller.php.

{
try
{
if( $this->EnableRegistration === 1 )
{
$Hash = $this->Security->get_gp( 'hash' , 'command' , false );
if( $Hash !== false )
{
$this->UserAccess->activate_user( $Hash );
$this->Messages->add_success_message( 'user_was_activated' );
}
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

admin_activate_user | ( | & | $Options | ) |

Function activates user.

Parameters

  $Options | - Settings.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 372 of file user_controller.php.

{
try
{
$Ids = $this->Security->get_gp( 'ids' , 'integer' );
if( is_array( $Ids ) === false )
{
$Ids = array( $Ids );
}
$this->UserAccess->activate_users( $Ids );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

admin_deactivate_user | ( | & | $Options | ) |

Function activates user.

Parameters

  $Options | - Settings.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 409 of file user_controller.php.

{
try
{
$Ids = $this->Security->get_gp( 'ids' , 'integer' );
if( is_array( $Ids ) === false )
{
$Ids = array( $Ids );
}
$this->UserAccess->deactivate_users( $Ids );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

controller | ( | & | $Options | ) |

Controller of the component.

Parameters

  $Options | - Settings.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 880 of file user_controller.php.

{
try
{
$this->ContextSet->add_contexts(
$Options , dirname( __FILE__ ) , $this->UserControllerUtilities->get_configs()
);
if( $this->ContextSet->execute( $Options , $this , __FILE__ ) )
{
return;
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

do_login | ( |  | $Login,
|  | & | $Options
| ) |  |

Login.

Parameters

  $Login | - Login.
  $Options | - Settings.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 214 of file user_controller.php.

{
try
{
$User = $this->UserAccess->get_user( $Login );
if( $this->UserAlgorithms->user_banned( $Login ) )
{
$this->Messages->add_error_message( 'user_is_banned_to '.$User->banned_to );
return;
}
$id = get_field( $User , 'id' );
$this->EventManager->trigger_event( 'on_before_login' , array( 'id' => $id ) );
$this->UserAlgorithms->login( $Login , $id );
$this->EventManager->trigger_event( 'on_after_login' , array( 'id' => $id ) );
$this->PageComposerUtilities->redirect_using_map( $Options );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

load_common_packages | ( |  | ) |

Function loads common packages.

Author
  Dodonov A.A.

Definition at line 148 of file user_controller.php.

{
try
{
$this->ContextSet = get_package( 'gui::context_set' , 'last' , __FILE__ );
$this->EventManager = get_package( 'event_manager' , 'last' , __FILE__ );
$this->Messages = get_package( 'page::messages' , 'last' , __FILE__ );
$this->PageComposerUtilities = get_package( 'page::page_composer_utilities' , 'last' , __FILE__ );
$this->Security = get_package( 'security' , 'last' , __FILE__ );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

load_settings | ( |  | ) |

Function loads settings.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 121 of file user_controller.php.

{
try
{
$Settings = get_package_object( 'settings::settings' , 'last' , __FILE__ );
$Settings->load_package_settings( 'page::page_composer' , 'last' , 'cf_site' );
$this->EnableRegistration = intval( $Settings->get_setting( 'enable_registration' , 1 ) );
$this->RegistrationConfirm = intval( $Settings->get_setting( 'registration_confirm' , 1 ) );
$this->EmailSender = $Settings->get_setting( 'email_sender' , $this->EmailSender );
$this->SystemEmail = $Settings->get_setting( 'system_email' , $this->SystemEmail );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

login | ( | & | $Options | ) |

Function logins user.

Parameters

  $Options | - Settings.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 257 of file user_controller.php.

{
try
{
$Login = $this->Security->get_gp( 'login' , 'string' );
$UserPassword = $this->Security->get_gp( 'password' , 'string' );
$UserExists = $this->UserAlgorithms->user_exists( $Login );
$UserActive = $AuthValid = true;
if( $UserExists )
{
if( $UserActive = $this->UserAlgorithms->user_active( $Login ) )
{
if( $AuthValid = $this->UserAlgorithms->validate_auth( $Login , $UserPassword ) )
{
$this->do_login( $Login , $Options );
}
}
}
$this->UserControllerUtilities->handle_login_errors( $UserExists , $UserActive , $AuthValid );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

logout | ( | & | $Options | ) |

Function logs out user.

Parameters

  $Options | - Settings.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 304 of file user_controller.php.

{
try
{
$this->UserAlgorithms->logout();
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

registration | ( | & | $Options | ) |

Function registers user.

Parameters

  $Options | - Settings.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 793 of file user_controller.php.

{
try
{
$PermitAlgorithms = get_package( 'permit::permit_algorithms' , 'last' , __FILE__ );
$HasPermit = $PermitAlgorithms->object_has_permit( false , 'user' , 'user_manager' );
if( $this->EnableRegistration === 1 || $HasPermit )
{
if( $this->UserControllerUtilities->handle_register_errors() )
{
return;
}
$this->register_do();
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

restore_password | ( | & | $Options | ) |

Function activates user.

Parameters

  $Options | - Settings.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 446 of file user_controller.php.

{
try
{
$Login = $this->Security->get_gp( 'rlogin' , 'string' );
$NewPassword = $this->UserAlgorithms->generate_password();
$CachedMultyFS = get_package( 'cached_multy_fs' , 'last' , __FILE__ );
$Message = str_replace(
'{new_password}' , $NewPassword ,
$CachedMultyFS->get_template( __FILE__ , 'password_restoration_email.tpl' )
);
$this->UserControllerUtilities->send_email(
$this->SystemEmail , $this->EmailSender , $Message ,
'{lang:password_restoration}' , get_field( $this->UserAccess->get_user( $Login ) , 'email' )
);
$this->UserAccess->reset_password( $Login , $NewPassword );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

set_avatar | ( | & | $Options | ) |

Function attaches file to the gallery.

Parameters

  $Options | - Settings.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 834 of file user_controller.php.

{
try
{
$FileInputController = get_package( 'file_input::file_input_controller' , 'last' , __FILE__ );
if( $FileInputController->UploadedFile )
{
$User = $this->UserAlgorithms->get_user();
$Avatar = get_field( $User , 'avatar' );
if( $Avatar > 0 )
{
$FileInputAccess = get_package( 'file_input::file_input_access' , 'last' , __FILE__ );
$FileInputAccess->delete( $Avatar );
}
$Login = get_field( $User , 'login' );
$FileId = get_field( $FileInputController->UploadedFile , 'id' );
$this->UserAccess->set_avatar( $Login , $FileId );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

try_reset_password | ( |  | ) |

Function changes password if necessary.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 486 of file user_controller.php.

{
try
{
$User = $this->UserAlgorithms->get_user();
$Login = get_field( $User , 'login' );
$Password = $this->Security->get_gp( 'password' , 'string' );
$PasswordConfirmation = $this->Security->get_gp( 'password_confirmation' , 'string' );
if( $Password == $PasswordConfirmation )
{
$this->UserAccess->reset_password( $Login , $Password );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

update_user | ( | & | $Options | ) |

Function updates user.

Parameters

  $Options | - Settings.

Exceptions

  Exception | - An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 600 of file user_controller.php.

{
try
{
$User = $this->UserAlgorithms->get_user();
list( $UserEmail , $Site , $About ) = $this->get_update_data();
$Record = array( 'email' => $UserEmail , 'site' => $Site , 'about' => $About );
$this->update( get_field( $User , 'id' ) , $Record );
$ChangePassword = $this->need_reset_password( $Login );
if( $ChangePassword )
{
$this->try_reset_password();
}
$this->Messages->add_success_message( 'user_update_was_completed' );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

## Field Documentation

$ContextSet = false

Cached packages.

Author
  Dodonov A.A.

Definition at line 38 of file user_controller.php.

$EmailSender = 'System'

Sender for all system notifications.

Author
  Dodonov A.A.

Definition at line 93 of file user_controller.php.

$EnableRegistration = 1

If the registration exists.

Author
  Dodonov A.A.

Definition at line 57 of file user_controller.php.

$EventManager = false

Definition at line 39 of file user_controller.php.

$Messages = false

Definition at line 40 of file user_controller.php.

$PageComposerUtilities = false

Definition at line 41 of file user_controller.php.

$RegistrationConfirm = 1

Registration confirm.

Author
  Dodonov A.A.

Definition at line 69 of file user_controller.php.

$RegistrationWasPassed = false

Was registration passed.

Author
  Dodonov A.A.

Definition at line 81 of file user_controller.php.

$Security = false

Definition at line 42 of file user_controller.php.

$SystemEmail = 'ultimix@localhost'

Sender's email for all system notifications.

Author
  Dodonov A.A.

Definition at line 105 of file user_controller.php.

$UserAccess = false

Definition at line 43 of file user_controller.php.

$UserAlgorithms = false

Definition at line 44 of file user_controller.php.

$UserControllerUtilities = false

Definition at line 45 of file user_controller.php.

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

- packages/user/packages/user_controller/user_controller.php