| [ Index ] |
|
Code source de b2evolution 2.1.0-beta |
1 <?php 2 /** 3 * This file implements the UI view for the user properties. 4 * 5 * Called by {@link b2users.php} 6 * 7 * This file is part of the evoCore framework - {@link http://evocore.net/} 8 * See also {@link http://sourceforge.net/projects/evocms/}. 9 * 10 * @copyright (c)2003-2007 by Francois PLANQUE - {@link http://fplanque.net/} 11 * Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}. 12 * 13 * {@internal License choice 14 * - If you have received this file as part of a package, please find the license.txt file in 15 * the same folder or the closest folder above for complete license terms. 16 * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/) 17 * then you must choose one of the following licenses before using the file: 18 * - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php 19 * - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php 20 * }} 21 * 22 * {@internal Open Source relicensing agreement: 23 * Daniel HAHLER grants Francois PLANQUE the right to license 24 * Daniel HAHLER's contributions to this file and the b2evolution project 25 * under any OSI approved OSS license (http://www.opensource.org/licenses/). 26 * }} 27 * 28 * @package admin 29 * 30 * {@internal Below is a list of authors who have contributed to design/coding of this file: }} 31 * @author fplanque: Francois PLANQUE 32 * @author blueyed: Daniel HAHLER 33 * 34 * @version $Id: _user.form.php,v 1.1 2007/06/25 11:01:51 fplanque Exp $ 35 */ 36 if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); 37 38 /** 39 * @var User 40 */ 41 global $current_User; 42 /** 43 * @var AdminUI_general 44 */ 45 global $AdminUI; 46 /** 47 * @var User 48 */ 49 global $edited_User; 50 /** 51 * @var GeneralSettings 52 */ 53 global $Settings; 54 /** 55 * @var UserSettings 56 */ 57 global $UserSettings; 58 /** 59 * @var Plugins 60 */ 61 global $Plugins; 62 63 global $action, $user_profile_only; 64 65 // Begin payload block: 66 $this->disp_payload_begin(); 67 68 69 $Form = & new Form( NULL, 'user_checkchanges' ); 70 71 if( !$user_profile_only ) 72 { 73 $Form->global_icon( ( $action != 'view_user' ? T_('Cancel editing!') : T_('Close user profile!') ), 'close', regenerate_url( 'user_ID,action' ) ); 74 } 75 76 if( $edited_User->ID == 0 ) 77 { // Creating new user: 78 $creating = true; 79 $Form->begin_form( 'fform', T_('Create new user profile') ); 80 } 81 else 82 { // Editing existing user: 83 $creating = false; 84 $Form->begin_form( 'fform', T_('Profile for:').' '.$edited_User->dget('fullname').' ['.$edited_User->dget('login').']' ); 85 } 86 87 $Form->hidden_ctrl(); 88 $Form->hidden( 'user_ID', $edited_User->ID ); 89 90 // _____________________________________________________________________ 91 92 $Form->begin_fieldset( T_('User permissions'), array( 'class'=>'fieldset clear' ) ); 93 94 $edited_User->get_Group(); 95 96 if( $edited_User->ID != 1 && $current_User->check_perm( 'users', 'edit' ) ) 97 { // This is not Admin and we're not restricted: we're allowed to change the user group: 98 $chosengroup = ( $edited_User->Group === NULL ) ? $Settings->get('newusers_grp_ID') : $edited_User->Group->ID; 99 $GroupCache = & get_Cache( 'GroupCache' ); 100 $Form->select_object( 'edited_user_grp_ID', $chosengroup, $GroupCache, T_('User group') ); 101 } 102 else 103 { 104 echo '<input type="hidden" name="edited_user_grp_ID" value="'.$edited_User->Group->ID.'" />'; 105 $Form->info( T_('User group'), $edited_User->Group->dget('name') ); 106 } 107 108 $field_note = '[0 - 10] '.sprintf( T_('See <a %s>online manual</a> for details.'), 'href="http://manual.b2evolution.net/User_levels"' ); 109 if( $current_User->check_perm( 'users', 'edit' ) ) 110 { 111 $Form->text_input( 'edited_user_level', $edited_User->get('level'), 2, T_('User level'), $field_note, array( 'required' => true ) ); 112 } 113 else 114 { 115 $Form->info_field( T_('User level'), $edited_User->get('level'), array( 'note' => $field_note ) ); 116 } 117 118 $Form->end_fieldset(); 119 120 // _____________________________________________________________________ 121 122 $Form->begin_fieldset( T_('Email communications') ); 123 124 $email_fieldnote = '<a href="mailto:'.$edited_User->get('email').'">'.get_icon( 'email', 'imgtag', array('title'=>T_('Send an email')) ).'</a>'; 125 126 if( $action != 'view_user' ) 127 { // We can edit the values: 128 129 $Form->text_input( 'edited_user_email', $edited_User->email, 30, T_('Email'), $email_fieldnote, array( 'maxlength' => 100, 'required' => true ) ); 130 if( $current_User->check_perm( 'users', 'edit' ) ) 131 { // user has "edit users" perms: 132 $Form->checkbox( 'edited_user_validated', $edited_User->get('validated'), T_('Validated email'), T_('Has this email address been validated (through confirmation email)?') ); 133 } 134 else 135 { // info only: 136 $Form->info( T_('Validated email'), ( $edited_User->get('validated') ? T_('yes') : T_('no') ), T_('Has this email address been validated (through confirmation email)?') ); 137 } 138 $Form->checkbox( 'edited_user_allow_msgform', $edited_User->get('allow_msgform'), T_('Message form'), T_('Check this to allow receiving emails through a message form.') ); 139 $Form->checkbox( 'edited_user_notify', $edited_User->get('notify'), T_('Notifications'), T_('Check this to receive a notification whenever one of <strong>your</strong> posts receives comments, trackbacks, etc.') ); 140 141 } 142 else 143 { // display only 144 145 $Form->info( T_('Email'), $edited_User->get('email'), $email_fieldnote ); 146 $Form->info( T_('Validated email'), ( $edited_User->get('validated') ? T_('yes') : T_('no') ), T_('Has this email address been validated (through confirmation email)?') ); 147 $Form->info( T_('Message form'), ($edited_User->get('allow_msgform') ? T_('yes') : T_('no')) ); 148 $Form->info( T_('Notifications'), ($edited_User->get('notify') ? T_('yes') : T_('no')) ); 149 150 } 151 152 $Form->end_fieldset(); 153 154 // _____________________________________________________________________ 155 156 $Form->begin_fieldset( T_('Identity') ); 157 158 if( $action != 'view_user' ) 159 { // We can edit the values: 160 161 $Form->text_input( 'edited_user_login', $edited_User->login, 20, T_('Login'), '', array( 'required' => true ) ); 162 $Form->text_input( 'edited_user_firstname', $edited_User->firstname, 20, T_('First name'), '', array( 'maxlength' => 50 ) ); 163 $Form->text_input( 'edited_user_lastname', $edited_User->lastname, 20, T_('Last name'), '', array( 'maxlength' => 50 ) ); 164 $Form->text_input( 'edited_user_nickname', $edited_User->nickname, 20, T_('Nickname'), '', array( 'maxlength' => 50, 'required' => true ) ); 165 $Form->select( 'edited_user_idmode', $edited_User->get( 'idmode' ), array( &$edited_User, 'callback_optionsForIdMode' ), T_('Identity shown') ); 166 $Form->checkbox( 'edited_user_showonline', $edited_User->get('showonline'), T_('Show online'), T_('Check this to be displayed as online when visiting the site.') ); 167 $Form->checkbox( 'edited_user_set_login_multiple_sessions', $UserSettings->get('login_multiple_sessions', $edited_User->ID), T_('Multiple sessions'), 168 T_('Check this if you want to log in from different computers/browsers at the same time. Otherwise, logging in from a new computer/browser will disconnect you on the previous one.') ); 169 170 } 171 else 172 { // display only 173 174 $Form->info( T_('Login'), $edited_User->get('login') ); 175 $Form->info( T_('First name'), $edited_User->get('firstname') ); 176 $Form->info( T_('Last name'), $edited_User->get('lastname') ); 177 $Form->info( T_('Nickname'), $edited_User->get('nickname') ); 178 $Form->info( T_('Identity shown'), $edited_User->get('preferredname') ); 179 $Form->info( T_('Show online'), ($edited_User->get('showonline')) ? T_('yes') : T_('no') ); 180 $Form->info( T_('Multiple sessions'), ($UserSettings->get('login_multiple_sessions', $edited_User->ID) ? T_('Allowed') : T_('Forbidden')) ); 181 } 182 183 $Form->end_fieldset(); 184 185 // _____________________________________________________________________ 186 187 188 if( $action != 'view_user' ) 189 { // We can edit the values: 190 191 $Form->begin_fieldset( T_('Password') ); 192 193 $Form->password_input( 'edited_user_pass1', '', 20, T_('New password'), array( 'note' => ( !empty($edited_User->ID) ? T_('Leave empty if you don\'t want to change the password.') : '' ), 'maxlength' => 50, 'required' => ($edited_User->ID == 0) ) ); 194 $Form->password_input( 'edited_user_pass2', '', 20, T_('Confirm new password'), array( 'note'=>sprintf( T_('Minimum length: %d characters.'), $Settings->get('user_minpwdlen') ), 'maxlength' => 50, 'required' => ($edited_User->ID == 0) ) ); 195 196 $Form->end_fieldset(); 197 198 } 199 200 // _____________________________________________________________________ 201 202 203 $Form->begin_fieldset( T_('Preferences') ); 204 205 $value_admin_skin = get_param('edited_user_admin_skin'); 206 if( !$value_admin_skin ) 207 { // no value supplied through POST/GET 208 $value_admin_skin = $UserSettings->get( 'admin_skin', $edited_User->ID ); 209 } 210 if( !$value_admin_skin ) 211 { // Nothing set yet for the user, use the default 212 $value_admin_skin = $Settings->get('admin_skin'); 213 } 214 215 if( $action != 'view_user' ) 216 { // We can edit the values: 217 218 $Form->select( 'edited_user_locale', $edited_User->get('locale'), 'locale_options_return', T_('Preferred locale'), T_('Preferred locale for admin interface, notifications, etc.')); 219 220 $Form->select_input_array( 'edited_user_admin_skin', $value_admin_skin, get_admin_skins(), T_('Admin skin'), T_('The skin defines how the backoffice appears to you.') ); 221 222 // fp> TODO: We gotta have something like $edited_User->UserSettings->get('legend'); 223 // Icon/text thresholds: 224 $Form->text( 'edited_user_action_icon_threshold', $UserSettings->get( 'action_icon_threshold', $edited_User->ID), 1, T_('Action icon display'), T_('1:more icons ... 5:less icons') ); 225 $Form->text( 'edited_user_action_word_threshold', $UserSettings->get( 'action_word_threshold', $edited_User->ID), 1, T_('Action word display'), T_('1:more action words ... 5:less action words') ); 226 227 // To display or hide icon legend: 228 $Form->checkbox( 'edited_user_legend', $UserSettings->get( 'display_icon_legend', $edited_User->ID ), T_('Display icon legend'), T_('Display a legend at the bottom of every page including all action icons used on that page.') ); 229 230 // To activate or deactivate bozo validator: 231 $Form->checkbox( 'edited_user_bozo', $UserSettings->get( 'control_form_abortions', $edited_User->ID ), T_('Control form closing'), T_('This will alert you if you fill in data into a form and try to leave the form before submitting the data.') ); 232 233 // To activate focus on first form input text 234 $Form->checkbox( 'edited_user_focusonfirst', $UserSettings->get( 'focus_on_first_input', $edited_User->ID ), T_('Focus on first field'), T_('The focus will automatically go to the first input text field.') ); 235 236 // Number of results per page 237 $Form->text( 'edited_user_results_per_page', $UserSettings->get( 'results_per_page', $edited_User->ID ), 3, T_('Results per page'), T_('Number of rows displayed in results tables.') ); 238 239 } 240 else 241 { // display only 242 243 $Form->info( T_('Preferred locale'), $edited_User->get('locale'), T_('Preferred locale for admin interface, notifications, etc.') ); 244 245 $Form->info_field( T_('Admin skin'), $value_admin_skin, array( 'note' => T_('The skin defines how the backoffice appears to you.') ) ); 246 247 // fp> TODO: a lot of things will not be displayed in view only mode. Do we want that? 248 249 $Form->info_field( T_('Results per page'), $UserSettings->get( 'results_per_page', $edited_User->ID ), array( 'note' => T_('Number of rows displayed in results tables.') ) ); 250 } 251 252 $Form->end_fieldset(); 253 254 // _____________________________________________________________________ 255 256 if( $action != 'view_user' ) 257 { // We can edit the values: 258 // PluginUserSettings 259 load_funcs('plugins/_plugin.funcs.php'); 260 261 $Plugins->restart(); 262 while( $loop_Plugin = & $Plugins->get_next() ) 263 { 264 if( ! $loop_Plugin->UserSettings /* NOTE: this triggers autoloading in PHP5, which is needed for the "hackish" isset($this->UserSettings)-method to see if the settings are queried for editing (required before 1.9) */ 265 && ! $Plugins->has_event($loop_Plugin->ID, 'PluginSettingsEditDisplayAfter') ) 266 { 267 continue; 268 } 269 270 // We use output buffers here to display the fieldset only, if there's content in there (either from PluginUserSettings or PluginSettingsEditDisplayAfter). 271 ob_start(); 272 $Form->begin_fieldset( $loop_Plugin->name ); 273 274 ob_start(); 275 // UserSettings: 276 $plugin_user_settings = $loop_Plugin->GetDefaultUserSettings( $tmp_params = array('for_editing'=>true) ); 277 if( is_array($plugin_user_settings) ) 278 { 279 foreach( $plugin_user_settings as $l_name => $l_meta ) 280 { 281 // Display form field for this setting: 282 autoform_display_field( $l_name, $l_meta, $Form, 'UserSettings', $loop_Plugin, $edited_User ); 283 } 284 } 285 286 $Plugins->call_method( $loop_Plugin->ID, 'PluginUserSettingsEditDisplayAfter', 287 $tmp_params = array( 'Form' => & $Form, 'User' => $edited_User ) ); 288 $has_contents = strlen( ob_get_contents() ); 289 $Form->end_fieldset(); 290 291 if( $has_contents ) 292 { 293 ob_end_flush(); 294 ob_end_flush(); 295 } 296 else 297 { // No content, discard output buffers: 298 ob_end_clean(); 299 ob_end_clean(); 300 } 301 } 302 } 303 304 // _____________________________________________________________________ 305 306 307 $Form->begin_fieldset( T_('Additional info') ); 308 309 if( ! $creating ) 310 { // We're NOT creating a new user: 311 $Form->info_field( T_('ID'), $edited_User->ID ); 312 313 $Form->info_field( T_('Posts'), $edited_User->get_num_posts() ); 314 315 $Form->info_field( T_('Created on'), $edited_User->dget('datecreated') ); 316 $Form->info_field( T_('From IP'), $edited_User->dget('ip') ); 317 $Form->info_field( T_('From Domain'), $edited_User->dget('domain') ); 318 $Form->info_field( T_('With Browser'), $edited_User->dget('browser') ); 319 } 320 321 322 if( ($url = $edited_User->get('url')) != '' ) 323 { 324 if( !preg_match('#://#', $url) ) 325 { 326 $url = 'http://'.$url; 327 } 328 $url_fieldnote = '<a href="'.$url.'" target="_blank">'.get_icon( 'play', 'imgtag', array('title'=>T_('Visit the site')) ).'</a>'; 329 } 330 else 331 $url_fieldnote = ''; 332 333 if( $edited_User->get('icq') != 0 ) 334 $icq_fieldnote = '<a href="http://wwp.icq.com/scripts/search.dll?to='.$edited_User->get('icq').'" target="_blank">'.get_icon( 'play', 'imgtag', array('title'=>T_('Search on ICQ.com')) ).'</a>'; 335 else 336 $icq_fieldnote = ''; 337 338 if( $edited_User->get('aim') != '' ) 339 $aim_fieldnote = '<a href="aim:goim?screenname='.$edited_User->get('aim').'&message=Hello">'.get_icon( 'play', 'imgtag', array('title'=>T_('Instant Message to user')) ).'</a>'; 340 else 341 $aim_fieldnote = ''; 342 343 344 if( $action != 'view_user' ) 345 { // We can edit the values: 346 347 $Form->text_input( 'edited_user_url', $edited_User->url, 30, T_('URL'), $url_fieldnote, array( 'maxlength' => 100 ) ); 348 $Form->text_input( 'edited_user_icq', $edited_User->icq, 30, T_('ICQ'), $icq_fieldnote, array( 'maxlength' => 10 ) ); 349 $Form->text_input( 'edited_user_aim', $edited_User->aim, 30, T_('AIM'), $aim_fieldnote, array( 'maxlength' => 50 ) ); 350 $Form->text_input( 'edited_user_msn', $edited_User->msn, 30, T_('MSN IM'), '', array( 'maxlength' => 100 ) ); 351 $Form->text_input( 'edited_user_yim', $edited_User->yim, 30, T_('YahooIM'), '', array( 'maxlength' => 50 ) ); 352 353 } 354 else 355 { // display only 356 357 $Form->info( T_('URL'), $edited_User->get('url'), $url_fieldnote ); 358 $Form->info( T_('ICQ'), $edited_User->get('icq', 'formvalue'), $icq_fieldnote ); 359 $Form->info( T_('AIM'), $edited_User->get('aim'), $aim_fieldnote ); 360 $Form->info( T_('MSN IM'), $edited_User->get('msn') ); 361 $Form->info( T_('YahooIM'), $edited_User->get('yim') ); 362 363 } 364 365 $Form->end_fieldset(); 366 367 // _____________________________________________________________________ 368 369 if( $action != 'view_user' ) 370 { // Edit buttons 371 $Form->buttons( array( 372 array( '', 'actionArray[userupdate]', T_('Save !'), 'SaveButton' ), 373 array( 'reset', '', T_('Reset'), 'ResetButton' ), 374 // dh> TODO: Non-Javascript-confirm before trashing all settings with a misplaced click. 375 array( 'type' => 'submit', 'name' => 'actionArray[default_settings]', 'value' => T_('Restore defaults'), 'class' => 'ResetButton', 376 'onclick' => "return confirm('".TS_('This will reset all your user settings.').'\n'.TS_('This cannot be undone.').'\n'.TS_('Are you sure?')."');" ), 377 ) ); 378 } 379 380 381 $Form->end_form(); 382 383 // End payload block: 384 $this->disp_payload_end(); 385 386 387 /* 388 * $Log: _user.form.php,v $ 389 * Revision 1.1 2007/06/25 11:01:51 fplanque 390 * MODULES (refactored MVC) 391 * 392 * Revision 1.53 2007/06/19 20:41:36 fplanque 393 * renamed generic functions to autoform_* 394 * 395 * Revision 1.52 2007/06/19 00:03:26 fplanque 396 * doc / trying to make sense of automatic settings forms generation. 397 * 398 * Revision 1.51 2007/05/27 20:04:41 fplanque 399 * wording 400 * 401 * Revision 1.50 2007/05/26 22:21:32 blueyed 402 * Made $limit for Results configurable per user 403 * 404 * Revision 1.49 2007/05/26 19:06:35 blueyed 405 * Trigger PluginUserSettingsEditDisplayAfter also if there are no UserSettings 406 * 407 * Revision 1.48 2007/04/26 00:11:13 fplanque 408 * (c) 2007 409 * 410 * Revision 1.47 2007/03/04 05:24:52 fplanque 411 * some progress on the toolbar menu 412 * 413 * Revision 1.46 2007/02/25 01:21:58 fplanque 414 * Wording 415 * 416 * Revision 1.45 2007/02/21 22:21:30 blueyed 417 * "Multiple sessions" user setting 418 * 419 * Revision 1.44 2007/02/19 23:17:00 blueyed 420 * Only display Plugin(User)Settings fieldsets if there is content in them. 421 * 422 * Revision 1.43 2007/02/14 01:37:18 blueyed 423 * Fixed E_PARSE 424 * 425 * Revision 1.42 2007/02/11 15:02:30 fplanque 426 * completely removed autocaps on lastname 427 * 428 * Revision 1.40 2007/01/27 16:08:53 blueyed 429 * Pass "User" param to PluginUserSettingsEditDisplayAfter plugin hook 430 * 431 * Revision 1.39 2007/01/23 08:57:36 fplanque 432 * decrap! 433 * 434 * Revision 1.38 2006/12/17 23:42:39 fplanque 435 * Removed special behavior of blog #1. Any blog can now aggregate any other combination of blogs. 436 * Look into Advanced Settings for the aggregating blog. 437 * There may be side effects and new bugs created by this. Please report them :] 438 * 439 * Revision 1.37 2006/12/16 04:07:11 fplanque 440 * visual cleanup 441 * 442 * Revision 1.36 2006/12/16 00:15:51 fplanque 443 * reorganized user profile page/form 444 * 445 * Revision 1.35 2006/12/16 00:12:21 fplanque 446 * reorganized user profile page/form 447 * 448 * Revision 1.34 2006/12/09 01:55:36 fplanque 449 * feel free to fill in some missing notes 450 * hint: "login" does not need a note! :P 451 * 452 * Revision 1.33 2006/12/05 02:54:37 blueyed 453 * Go to user profile after resetting to defaults; fixed handling of action in case of redirecting 454 * 455 * Revision 1.32 2006/12/04 00:08:56 fplanque 456 * minor 457 * 458 * Revision 1.31 2006/12/03 19:09:49 blueyed 459 * Javascript confirm() for resetting user settings 460 * 461 * Revision 1.30 2006/12/03 16:37:15 fplanque 462 * doc 463 * 464 * Revision 1.29 2006/11/28 01:31:23 blueyed 465 * Display fix: user cannot edit "validated", if he has no "edit users" perms 466 * 467 * Revision 1.28 2006/11/24 18:27:26 blueyed 468 * Fixed link to b2evo CVS browsing interface in file docblocks 469 * 470 * Revision 1.27 2006/11/15 21:14:04 blueyed 471 * "Restore defaults" in user profile 472 * 473 * Revision 1.26 2006/11/14 00:26:28 blueyed 474 * Made isset($this->UserSettings)-hack work; fixed call to undefined function 475 * 476 * Revision 1.25 2006/11/05 20:13:57 fplanque 477 * minor 478 * 479 * Revision 1.24 2006/10/30 19:00:36 blueyed 480 * Lazy-loading of Plugin (User)Settings for PHP5 through overloading 481 */ 482 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Thu Nov 29 23:58:50 2007 | par Balluche grâce à PHPXref 0.7 |
|