ultimix
user_manager.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 $PageComposer = false;
39  var $PermitAlgorithms = false;
40  var $Security = false;
41  var $SecurityUtilities = false;
42  var $UserAccess = false;
43  var $UserAlgorithms = false;
44 
55  function __construct()
56  {
57  try
58  {
59  $this->PageComposer = get_package( 'page::page_composer' , 'last' , __FILE__ );
60  $this->PermitAlgorithms = get_package( 'permit::permit_algorithms' , 'last' , __FILE__ );
61  $this->Security = get_package( 'security' , 'last' , __FILE__ );
62  $this->SecurityUtilities = get_package( 'security::security_utilities' , 'last' , __FILE__ );
63  $this->UserAccess = get_package( 'user::user_access' , 'last' , __FILE__ );
64  $this->UserAlgorithms = get_package( 'user::user_algorithms' , 'last' , __FILE__ );
65  }
66  catch( Exception $e )
67  {
68  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
69  }
70  }
71 
90  function pre_generation( &$Options )
91  {
92  try
93  {
94  $Lang = get_package( 'lang' , 'last' , __FILE__ );
95  $Lang->include_strings_js( 'user::user_manager' );
96  }
97  catch( Exception $e )
98  {
99  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
100  }
101  }
102 
113  var $Output = false;
114 
137  function validate_account_password( $User )
138  {
139  try
140  {
141  if( $this->PermitAlgorithms->object_has_permit( false , 'user' , 'user_manager' ) === false )
142  {
143  $Password = $this->Security->get_p( 'current_password' , 'string' );
144  if( $this->UserAlgorithms->validate_auth( $User->login , $Password ) === false )
145  {
146  $this->PageComposer->add_error_message( 'illegal_current_password' );
147  return( false );
148  }
149  }
150 
151  return( true );
152  }
153  catch( Exception $e )
154  {
155  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
156  }
157  }
158 
181  function validate_account_fields( $Options )
182  {
183  try
184  {
185  $User = $this->UserAccess->select_list( $this->Security->get_p( 'user_record_id' , 'integer_list' ) );
186  $User = $User[ 0 ];
187 
188  $Email = $this->Security->get_p( 'email' , 'email' );
189  if( $User->email != $Email && $this->UserAlgorithms->email_exists( $Email ) )
190  {
191  $this->PageComposer->add_error_message( 'email_exists' );
192  return( false );
193  }
194 
195  if( $this->validate_account_password( $User ) === false )
196  {
197  return( false );
198  }
199 
200  return( true );
201  }
202  catch( Exception $e )
203  {
204  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
205  }
206  }
207 
230  function vaidate_non_system( $Options )
231  {
232  try
233  {
234  $ids = $this->SecurityUtilities->get_global( '_id_' , 'integer' , CHECKBOX_IDS );
235 
236  if( isset( $ids[ 0 ] ) )
237  {
238  $ids = implode( ',' , $ids );
239 
240  $Users = $this->UserAccess->unsafe_select( $this->UserAccess->NativeTable.
241  ".id IN( $ids ) AND `system` = 1" );
242 
243  if( isset( $Users[ 0 ] ) )
244  {
245  $PageComposer = get_package( 'page::page_composer' , 'last' , __FILE__ );
246  $PageComposer->add_error_message( 'cant_delete_system_users' );
247 
248  return( false );
249  }
250 
251  return( true );
252  }
253 
254  return( false );
255  }
256  catch( Exception $e )
257  {
258  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
259  }
260  }
261 
280  function controller( $Options )
281  {
282  try
283  {
284  $ContextSet = get_package( 'gui::context_set' , 'last' , __FILE__ );
285 
286  $ContextSet->execute( $Options , $this , __FILE__ );
287  }
288  catch( Exception $e )
289  {
290  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
291  }
292  }
293 
316  function view( $Options )
317  {
318  try
319  {
320  $ContextSet = get_package( 'gui::context_set' , 'last' , __FILE__ );
321 
322  $ContextSet->execute( $Options , $this , __FILE__ );
323 
324  return( $this->Output );
325  }
326  catch( Exception $e )
327  {
328  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
329  }
330  }
331  }
332 
333 ?>