ultimix
user_manager_controller.php
Go to the documentation of this file.
1 <?php
2 
3  /*
4  * This source code is a part of the Ultimix Project.
5  * It is distributed under BSD license. All other third side source code (like tinyMCE) is distributed under
6  * it's own license wich could be found from the corresponding files or sources.
7  * This source code is provided "as is" without any warranties or garanties.
8  *
9  * Have a nice day!
10  *
11  * @url http://ultimix.sorceforge.net
12  *
13  * @author Alexey "gdever" Dodonov
14  */
15 
27 
38  var $Database = false;
39  var $PageComposer = false;
40  var $PermitAlgorithms = false;
41  var $Security = false;
42  var $SecurityUtilities = false;
43  var $UserAccess = false;
44  var $UserAlgorithms = false;
45 
56  function __construct()
57  {
58  try
59  {
60  $this->Database = get_package( 'database' , 'last' , __FILE__ );
61  $this->PageComposer = get_package( 'page::page_composer' , 'last' , __FILE__ );
62  $this->PermitAlgorithms = get_package( 'permit::permit_algorithms' , 'last' , __FILE__ );
63  $this->Security = get_package( 'security' , 'last' , __FILE__ );
64  $this->SecurityUtilities = get_package( 'security::security_utilities' , 'last' , __FILE__ );
65  $this->UserAccess = get_package( 'user::user_access' , 'last' , __FILE__ );
66  $this->UserAlgorithms = get_package( 'user::user_algorithms' , 'last' , __FILE__ );
67  }
68  catch( Exception $e )
69  {
70  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
71  }
72  }
73 
96  function validate_account_password( $User )
97  {
98  try
99  {
100  if( $this->PermitAlgorithms->object_has_permit( false , 'user' , 'user_manager' ) === false )
101  {
102  $Password = $this->Security->get_p( 'current_password' , 'string' );
103  if( $this->UserAlgorithms->validate_auth( $User->login , $Password ) === false )
104  {
105  $this->PageComposer->add_error_message( 'illegal_current_password' );
106  return( false );
107  }
108  }
109 
110  return( true );
111  }
112  catch( Exception $e )
113  {
114  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
115  }
116  }
117 
140  function validate_account_fields( $Options )
141  {
142  try
143  {
144  $User = $this->UserAccess->select_list( $this->Security->get_p( 'user_record_id' , 'integer_list' ) );
145  $User = $User[ 0 ];
146 
147  $Email = $this->Security->get_p( 'email' , 'email' );
148  if( $User->email != $Email && $this->UserAlgorithms->email_exists( $Email ) )
149  {
150  $this->PageComposer->add_error_message( 'email_exists' );
151  return( false );
152  }
153 
154  if( $this->validate_account_password( $User ) === false )
155  {
156  return( false );
157  }
158 
159  return( true );
160  }
161  catch( Exception $e )
162  {
163  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
164  }
165  }
166 
189  function vaidate_non_system( $Options )
190  {
191  try
192  {
193  $ids = $this->SecurityUtilities->get_global( '_id_' , 'integer' , CHECKBOX_IDS );
194 
195  if( isset( $ids[ 0 ] ) )
196  {
197  $ids = implode( ',' , $ids );
198 
199  $Users = $this->UserAccess->unsafe_select( $this->UserAccess->NativeTable.
200  ".id IN( $ids ) AND `system` = 1" );
201 
202  if( isset( $Users[ 0 ] ) )
203  {
204  $PageComposer = get_package( 'page::page_composer' , 'last' , __FILE__ );
205  $PageComposer->add_error_message( 'cant_delete_system_users' );
206 
207  return( false );
208  }
209 
210  return( true );
211  }
212 
213  return( false );
214  }
215  catch( Exception $e )
216  {
217  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
218  }
219  }
220 
239  function controller( $Options )
240  {
241  try
242  {
243  $ContextSet = get_package( 'gui::context_set' , 'last' , __FILE__ );
244 
245  $ContextSet->execute( $Options , $this , __FILE__ );
246  }
247  catch( Exception $e )
248  {
249  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
250  }
251  }
252  }
253 
254 ?>