| [ Index ] |
PHP Cross Reference of MantisBT |
[Summary view] [Print] [Text view]
1 <?php 2 # MantisBT - A PHP based bugtracking system 3 4 # MantisBT is free software: you can redistribute it and/or modify 5 # it under the terms of the GNU General Public License as published by 6 # the Free Software Foundation, either version 2 of the License, or 7 # (at your option) any later version. 8 # 9 # MantisBT is distributed in the hope that it will be useful, 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 # GNU General Public License for more details. 13 # 14 # You should have received a copy of the GNU General Public License 15 # along with MantisBT. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * @package MantisBT 19 * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org 20 * @copyright Copyright (C) 2002 - 2011 MantisBT Team - mantisbt-dev@lists.sourceforge.net 21 * @link http://www.mantisbt.org 22 * 23 * @uses core.php 24 * @uses access_api.php 25 * @uses authentication_api.php 26 * @uses config_api.php 27 * @uses constant_inc.php 28 * @uses email_api.php 29 * @uses form_api.php 30 * @uses gpc_api.php 31 * @uses helper_api.php 32 * @uses html_api.php 33 * @uses lang_api.php 34 * @uses print_api.php 35 * @uses string_api.php 36 * @uses user_api.php 37 * @uses utility_api.php 38 */ 39 40 /** 41 * MantisBT Core API's 42 */ 43 require_once ( 'core.php' ); 44 require_api( 'access_api.php' ); 45 require_api( 'authentication_api.php' ); 46 require_api( 'config_api.php' ); 47 require_api( 'constant_inc.php' ); 48 require_api( 'email_api.php' ); 49 require_api( 'form_api.php' ); 50 require_api( 'gpc_api.php' ); 51 require_api( 'helper_api.php' ); 52 require_api( 'html_api.php' ); 53 require_api( 'lang_api.php' ); 54 require_api( 'print_api.php' ); 55 require_api( 'string_api.php' ); 56 require_api( 'user_api.php' ); 57 require_api( 'utility_api.php' ); 58 59 form_security_validate( 'manage_user_create' ); 60 61 auth_reauthenticate(); 62 access_ensure_global_level( config_get( 'manage_user_threshold' ) ); 63 64 $f_username = gpc_get_string( 'username' ); 65 $f_realname = gpc_get_string( 'realname', '' ); 66 $f_password = gpc_get_string( 'password', '' ); 67 $f_password_verify = gpc_get_string( 'password_verify', '' ); 68 $f_email = gpc_get_string( 'email', '' ); 69 $f_access_level = gpc_get_string( 'access_level' ); 70 $f_protected = gpc_get_bool( 'protected' ); 71 $f_enabled = gpc_get_bool( 'enabled' ); 72 73 # check for empty username 74 $f_username = trim( $f_username ); 75 if ( is_blank( $f_username ) ) { 76 trigger_error( ERROR_EMPTY_FIELD, ERROR ); 77 } 78 79 # Check the name for validity here so we do it before promting to use a 80 # blank password (don't want to prompt the user if the process will fail 81 # anyway) 82 # strip extra space from real name 83 $t_realname = string_normalize( $f_realname ); 84 user_ensure_name_valid( $f_username ); 85 user_ensure_realname_unique( $f_username, $f_realname ); 86 87 if ( $f_password != $f_password_verify ) { 88 trigger_error( ERROR_USER_CREATE_PASSWORD_MISMATCH, ERROR ); 89 } 90 91 $f_email = email_append_domain( $f_email ); 92 email_ensure_not_disposable( $f_email ); 93 94 if ( ( ON == config_get( 'send_reset_password' ) ) && ( ON == config_get( 'enable_email_notification' ) ) ) { 95 # Check code will be sent to the user directly via email. Dummy password set to random 96 # Create random password 97 $t_seed = $f_email . $f_username; 98 $f_password = auth_generate_random_password( $t_seed ); 99 } else { 100 # Password won't to be sent by email. It entered by the admin 101 # Now, if the password is empty, confirm that that is what we wanted 102 if ( is_blank( $f_password ) ) { 103 helper_ensure_confirmed( lang_get( 'empty_password_sure_msg' ), 104 lang_get( 'empty_password_button' ) ); 105 } 106 } 107 108 # Don't allow the creation of accounts with access levels higher than that of 109 # the user creating the account. 110 access_ensure_global_level( $f_access_level ); 111 112 # Need to send the user creation mail in the tracker language, not in the creating admin's language 113 # Park the current language name until the user has been created 114 lang_push( config_get( 'default_language' ) ); 115 116 # create the user 117 $t_admin_name = user_get_name( auth_get_current_user_id() ); 118 $t_cookie = user_create( $f_username, $f_password, $f_email, $f_access_level, $f_protected, $f_enabled, $t_realname, $t_admin_name ); 119 120 # set language back to user language 121 lang_pop(); 122 123 form_security_purge( 'manage_user_create' ); 124 125 if ( $t_cookie === false ) { 126 $t_redirect_url = 'manage_user_page.php'; 127 } else { 128 # ok, we created the user, get the row again 129 $t_user_id = user_get_id_by_name( $f_username ); 130 $t_redirect_url = 'manage_user_edit_page.php?user_id=' . $t_user_id; 131 } 132 133 html_page_top( null, $t_redirect_url ); 134 ?> 135 136 <br /> 137 <div> 138 <?php 139 $t_access_level = get_enum_element( 'access_levels', $f_access_level ); 140 echo lang_get( 'created_user_part1' ) . ' <span class="bold">' . $f_username . '</span> ' . lang_get( 'created_user_part2' ) . ' <span class="bold">' . $t_access_level . '</span><br />'; 141 142 print_bracket_link( $t_redirect_url, lang_get( 'proceed' ) ); 143 ?> 144 </div> 145 146 <?php html_page_bottom();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Jul 28 15:48:31 2011 | Cross-referenced by PHPXref 0.7 |