ultimix
user_controller_utilities.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 $Messages = false;
39  var $Security = false;
40  var $UserAccess = false;
41  var $UserAlgorithms = false;
42 
53  function __construct()
54  {
55  try
56  {
57  $this->Messages = get_package( 'page::messages' , 'last' , __FILE__ );
58  $this->Security = get_package( 'security' , 'last' , __FILE__ );
59  $this->UserAccess = get_package( 'user::user_access' , 'last' , __FILE__ );
60  $this->UserAlgorithms = get_package( 'user::user_algorithms' , 'last' , __FILE__ );
61  }
62  catch( Exception $e )
63  {
64  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
65  }
66  }
67 
94  function handle_login_errors( $UserExists , $UserActive , $AuthValid )
95  {
96  try
97  {
98  if( $UserExists == false )
99  {
100  $this->Messages->add_error_message( 'user_does_not_exists' );
101  }
102  elseif( $UserActive == false )
103  {
104  $this->Messages->add_error_message( 'registration_was_not_confirmed' );
105  }
106  elseif( $AuthValid == false )
107  {
108  $this->Messages->add_error_message( 'authentification_error' );
109  }
110  }
111  catch( Exception $e )
112  {
113  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
114  }
115  }
116 
136  {
137  try
138  {
139  if( $this->UserAlgorithms->user_exists( $this->Security->get_gp( 'login' , 'string' ) ) )
140  {
141  $this->Messages->add_error_message( 'user_already_exists' );
142  return( true );
143  }
144 
145  if( $this->UserAlgorithms->email_exists( $this->Security->get_gp( 'email' , 'string' ) ) )
146  {
147  $this->Messages->add_error_message( 'email_already_exists' );
148  return( true );
149  }
150 
151  return( false );
152  }
153  catch( Exception $e )
154  {
155  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
156  }
157  }
158 
189  function send_email( $SystemEmail , $EmailSender , $Message , $Subject , $Email = false )
190  {
191  try
192  {
193  $Email = $Email === false ? $this->Security->get_gp( 'email' , 'string' ) : $Email;
194 
195  $Mail = get_package( 'mail' , 'last' , __FILE__ );
196  $Mail->send_email(
197  $SystemEmail , $Email , $Subject , $Message , $EmailSender
198  );
199  }
200  catch( Exception $e )
201  {
202  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
203  }
204  }
205 
224  function add_default_permits( $id )
225  {
226  try
227  {
228  $id = $this->Security->get( $id , 'integer' );
229 
230  $PermitAccess = get_package( 'permit::permit_access' , 'last' , __FILE__ );
231  $PermitAccess->add_permit_for_object( 'public' , $id , 'user' );
232  $PermitAccess->add_permit_for_object( 'registered' , $id , 'user' );
233  }
234  catch( Exception $e )
235  {
236  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
237  }
238  }
239 
258  function get_configs()
259  {
260  try
261  {
262  return(
263  array(
264  'cfcx_update_user' , 'cfcx_activate_user' , 'cfcx_admin_activate_user' ,
265  'cfcx_admin_deactivate_user' , 'cfcx_restore_password' , 'cfcx_registration' ,
266  'cfcx_user_set_avatar' , 'cfcx_login' , 'cfcx_logout'
267  )
268  );
269  }
270  catch( Exception $e )
271  {
272  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
273  }
274  }
275  }
276 ?>