ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

user_view.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
26 class user_view_1_0_0{
27
38 var $CachedMultyFS = false;
39 var $ContextSet = false;
40 var $Security = false;
41 var $String = false;
42 var $UserAccess = false;
43 var $UserAlgorithms = false;
44
55 var $Output = false;
56
67 var $EnableRegistration = 1;
68
79 var $RegistrationConfirm = 1;
80
91 var $EmailAsLogin = 0;
92
107 function load_settings()
108 {
109 try
110 {
111 $Settings = get_package_object( 'settings::settings' , 'last' , __FILE__ );
112 $Settings->load_package_settings( 'user::user_controller' , 'last' , 'cf_user' );
113 $this->EnableRegistration = intval( $Settings->get_setting( 'enable_registration' , 1 ) );
114 $this->RegistrationConfirm = intval( $Settings->get_setting( 'registration_confirm' , 1 ) );
115 $this->EmailAsLogin = intval( $Settings->get_setting( 'email_as_login' , 0 ) );
116 }
117 catch( Exception $e )
118 {
119 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
120 }
121 }
122
137 function __construct()
138 {
139 try
140 {
141 $this->CachedMultyFS = get_package( 'cached_multy_fs' , 'last' , __FILE__ );
142 $this->Security = get_package( 'security' , 'last' , __FILE__ );
143 $this->String = get_package( 'string' , 'last' , __FILE__ );
144 $this->UserAccess = get_package( 'user::user_access' , 'last' , __FILE__ );
145 $this->UserAlgorithms = get_package( 'user::user_algorithms' , 'last' , __FILE__ );
146
147 $this->load_settings();
148 }
149 catch( Exception $e )
150 {
151 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
152 }
153 }
154
173 function pre_generation( &$Options )
174 {
175 try
176 {
177 $PageJS = get_package( 'page::page_js' , 'last' , __FILE__ );
178
179 $PackagePath = _get_package_relative_path_ex( 'user::user_view' , '1.0.0::1.0.0' );
180
181 $PageJS->add_javascript( "{http_host}/$PackagePath/include/js/user_view.js" );
182
183 $Lang = get_package( 'lang' , 'last' , __FILE__ );
184 $Lang->include_strings_js( 'user::user_view' );
185 }
186 catch( Exception $e )
187 {
188 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
189 }
190 }
191
210 function login_form( &$Options )
211 {
212 try
213 {
214 $this->Output = $this->CachedMultyFS->get_template(
215 __FILE__ , $this->EmailAsLogin ? 'email_as_login_form.tpl' : 'login_form.tpl'
216 );
217
218 if( $this->EnableRegistration === 1 )
219 {
220 $Code = '&nbsp;{href:page=registration.html;text=registration}';
221 $this->Output = str_replace( '{registration_link}' , $Code , $this->Output );
222 }
223 }
224 catch( Exception $e )
225 {
226 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
227 }
228 }
229
244 private function show_registration_confirm_form()
245 {
246 try
247 {
248 if( $this->RegistrationConfirm )
249 {
250 $this->Output = $this->CachedMultyFS->get_template( __FILE__ , 'confirm_registration.tpl' );
251 }
252 else
253 {
254 $this->Output = '{lang:registration_complete}';
255 }
256 }
257 catch( Exception $e )
258 {
259 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
260 }
261 }
262
277 private function compile_registration_form()
278 {
279 try
280 {
281 $Template = $this->CachedMultyFS->get_template(
282 __FILE__ , $this->EmailAsLogin ? 'email_as_login_registration_form.tpl' : 'registration_form.tpl'
283 );
284
285 $Template = $this->String->print_record( $Template , $_POST );
286
287 $this->Output = $Template;
288 }
289 catch( Exception $e )
290 {
291 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
292 }
293 }
294
313 function show_registration_form( &$Options )
314 {
315 try
316 {
317 $PermitAlgorithms = get_package( 'permit::permit_algorithms' , 'last' , __FILE__ );
318 $HasUserManagerPermit = $PermitAlgorithms->object_has_permit( false , 'user' , 'user_manager' );
319 if( $this->EnableRegistration != 1 && $HasUserManagerPermit == false )
320 {
321 $this->Output = '{lang:registration_is_disabled}';
322 return;
323 }
324
325 $UserController = get_package( 'user::user_controller' , 'last' , __FILE__ );
326 if( $this->Security->get_gp( 'user_action' ) && $UserController->RegistrationWasPassed )
327 {
328 $this->show_registration_confirm_form();
329 }
330 else
331 {
332 $this->compile_registration_form();
333 }
334 }
335 catch( Exception $e )
336 {
337 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
338 }
339 }
340
359 function short_profile( &$Options )
360 {
361 try
362 {
363 $UserId = $Options->get_setting( 'user_id' , false );
364
365 $User = $this->UserAlgorithms->get_by_id( $UserId );
366
367 $this->Output = $this->CachedMultyFS->get_template( __FILE__ , 'short_profile.tpl' );
368
369 $this->Output = $this->String->print_record( $this->Output , $User );
370 }
371 catch( Exception $e )
372 {
373 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
374 }
375 }
376
395 function full_profile( &$Options )
396 {
397 try
398 {
399 if( $this->Security->get_gp( 'login' , 'set' ) )
400 {
401 $UserLogin = $this->Security->get_gp( 'login' , 'string' );
402 $User = $this->UserAccess->get_user( $UserLogin );
403 }
404 else
405 {
406 $UserId = $this->Security->get_gp( 'user_id' , 'integer' , 0 );
407 if( $UserId == 0 )
408 {
409 $UserId = $this->UserAlgorithms->get_id();
410 }
411
412 $User = $this->UserAlgorithms->get_by_id( $UserId );
413 }
414
415 $this->Output = $this->CachedMultyFS->get_template( __FILE__ , 'full_profile.tpl' );
416 $this->Output = $this->String->print_record( $this->Output , $User );
417 }
418 catch( Exception $e )
419 {
420 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
421 }
422 }
423
438 private function compile_update_user_form()
439 {
440 try
441 {
442 $Changed = false;
443 $this->Output = $this->String->hide_block(
444 $this->Output , 'permit:user_manager' , 'permit:~user_manager' , $Changed
445 );
446
447 $User = $this->UserAlgorithms->get_user();
448 $ContextSetUtilities = get_package( 'gui::context_set::context_set_utilities' , 'last' , __FILE__ );
449 $this->Output = $ContextSetUtilities->set_form_data( $this->Output , $User );
450 }
451 catch( Exception $e )
452 {
453 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
454 }
455 }
456
475 function update_user_form( &$Options )
476 {
477 try
478 {
479 $Path = _get_package_relative_path_ex( 'user::user_manager' , 'last' );
480 $Template = $this->CachedMultyFS->get_template( "$Path/unexisting.php" , 'update_user_form.tpl' );
481
482 $User = $this->UserAlgorithms->get_user();
483 $this->Output = $this->String->print_record( $Template , $User );
484 $this->Output = str_replace( '{prefix}' , 'user' , $this->Output );
485
486 $this->compile_update_user_form();
487 }
488 catch( Exception $e )
489 {
490 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
491 }
492 }
493
532 function selec_users_for_list_view( $Start = false , $Limit = false , $Field = false ,
533 $Order = false , $Condition = '1 = 1' )
534 {
535 try
536 {
537 $Condition = '( NOT ( '.$this->UserAccess->NativeTable.".id IN ( 1 , 2 , 3 ) ) ) AND $Condition";
538 return( $this->UserAccess->select( $Start , $Limit , $Field , $Order , $Condition ) );
539 }
540 catch( Exception $e )
541 {
542 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
543 }
544 }
545
564 private function get_contexts()
565 {
566 try
567 {
568 return(
569 array(
570 'cfcxs_user_line' , 'cfcx_login_form' , 'cfcx_logout_form' , 'cfcx_auto_open_login_dialog' ,
571 'cfcx_switch_user_form' , 'cfcx_registration_form' , 'cfcx_update_user_form' ,
572 'cfcx_short_profile' , 'cfcx_full_profile' , 'cfcx_activate_user_form' ,
573 'cfcx_restore_password_form' , 'cfcx_login_button' , 'cfcx_logout_button' ,
574 'cfcx_logout_img_button' , 'cfcx_switch_user_button' , 'cfcx_update_profile_button'
575 )
576 );
577 }
578 catch( Exception $e )
579 {
580 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
581 }
582 }
583
606 function view( &$Options )
607 {
608 try
609 {
610 if( $this->ContextSet === false )
611 {
612 $this->ContextSet = get_package( 'gui::context_set' , 'last' , __FILE__ );
613 }
614
615 $this->ContextSet->add_contexts( $Options , dirname( __FILE__ ) , $this->get_contexts() );
616
617 $this->ContextSet->execute( $Options , $this , __FILE__ );
618
619 return( $this->Output );
620 }
621 catch( Exception $e )
622 {
623 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
624 }
625 }
626 }
627
628 ?>