PageRenderTime 40ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/mantisbt-1.2.8/manage_user_edit_page.php

#
PHP | 279 lines | 217 code | 34 blank | 28 comment | 25 complexity | 10b0894008bcaf348e12f8dfa9226af7 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0
  1. <?php
  2. # MantisBT - a php based bugtracking system
  3. # MantisBT is free software: you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation, either version 2 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # MantisBT is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with MantisBT. If not, see <http://www.gnu.org/licenses/>.
  15. /**
  16. * @package MantisBT
  17. * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
  18. * @copyright Copyright (C) 2002 - 2011 MantisBT Team - mantisbt-dev@lists.sourceforge.net
  19. * @link http://www.mantisbt.org
  20. */
  21. /**
  22. * MantisBT Core API's
  23. */
  24. require_once( 'core.php' );
  25. auth_reauthenticate();
  26. access_ensure_global_level( config_get( 'manage_user_threshold' ) );
  27. $f_username = gpc_get_string( 'username', '' );
  28. if ( is_blank( $f_username ) ) {
  29. $t_user_id = gpc_get_int( 'user_id' );
  30. } else {
  31. $t_user_id = user_get_id_by_name( $f_username );
  32. if ( $t_user_id === false ) {
  33. error_parameters( $f_username );
  34. trigger_error( ERROR_USER_BY_NAME_NOT_FOUND, ERROR );
  35. }
  36. }
  37. $t_user = user_get_row( $t_user_id );
  38. # Ensure that the account to be updated is of equal or lower access to the
  39. # current user.
  40. access_ensure_global_level( $t_user['access_level'] );
  41. $t_ldap = ( LDAP == config_get( 'login_method' ) );
  42. html_page_top();
  43. print_manage_menu();
  44. ?>
  45. <br />
  46. <!-- USER INFO -->
  47. <div align="center">
  48. <form method="post" action="manage_user_update.php">
  49. <?php echo form_security_field( 'manage_user_update' ) ?>
  50. <table class="width75" cellspacing="1">
  51. <!-- Title -->
  52. <tr>
  53. <td class="form-title" colspan="2">
  54. <input type="hidden" name="user_id" value="<?php echo $t_user['id'] ?>" />
  55. <?php echo lang_get( 'edit_user_title' ) ?>
  56. </td>
  57. </tr>
  58. <!-- Username -->
  59. <tr <?php echo helper_alternate_class( 1 ) ?>>
  60. <td class="category" width="30%">
  61. <?php echo lang_get( 'username' ) ?>
  62. </td>
  63. <td width="70%">
  64. <input type="text" size="32" maxlength="<?php echo DB_FIELD_SIZE_USERNAME;?>" name="username" value="<?php echo string_attribute( $t_user['username'] ) ?>" />
  65. </td>
  66. </tr>
  67. <!-- Realname -->
  68. <tr <?php echo helper_alternate_class( 1 ) ?>>
  69. <td class="category" width="30%">
  70. <?php echo lang_get( 'realname' ) ?>
  71. </td>
  72. <td width="70%">
  73. <?php
  74. // With LDAP
  75. if ( $t_ldap && ON == config_get( 'use_ldap_realname' ) ) {
  76. echo string_display_line( user_get_realname( $t_user_id ) );
  77. }
  78. // Without LDAP
  79. else {
  80. ?>
  81. <input type="text" size="32" maxlength="<?php echo DB_FIELD_SIZE_REALNAME;?>" name="realname" value="<?php echo string_attribute( $t_user['realname'] ) ?>" />
  82. <?php
  83. }
  84. ?>
  85. </td>
  86. </tr>
  87. <!-- Email -->
  88. <tr <?php echo helper_alternate_class() ?>>
  89. <td class="category">
  90. <?php echo lang_get( 'email' ) ?>
  91. </td>
  92. <td>
  93. <?php
  94. // With LDAP
  95. if ( $t_ldap && ON == config_get( 'use_ldap_email' ) ) {
  96. echo string_display_line( user_get_email( $t_user_id ) );
  97. }
  98. // Without LDAP
  99. else {
  100. print_email_input( 'email', $t_user['email'] );
  101. }
  102. ?>
  103. </td>
  104. </tr>
  105. <!-- Access Level -->
  106. <tr <?php echo helper_alternate_class() ?>>
  107. <td class="category">
  108. <?php echo lang_get( 'access_level' ) ?>
  109. </td>
  110. <td>
  111. <select name="access_level">
  112. <?php
  113. $t_access_level = $t_user['access_level'];
  114. if ( !MantisEnum::hasValue( config_get( 'access_levels_enum_string' ), $t_access_level ) ) {
  115. $t_access_level = config_get( 'default_new_account_access_level' );
  116. }
  117. print_project_access_levels_option_list( $t_access_level )
  118. ?>
  119. </select>
  120. </td>
  121. </tr>
  122. <!-- Enabled Checkbox -->
  123. <tr <?php echo helper_alternate_class() ?>>
  124. <td class="category">
  125. <?php echo lang_get( 'enabled' ) ?>
  126. </td>
  127. <td>
  128. <input type="checkbox" name="enabled" <?php check_checked( $t_user['enabled'], ON ); ?> />
  129. </td>
  130. </tr>
  131. <!-- Protected Checkbox -->
  132. <tr <?php echo helper_alternate_class() ?>>
  133. <td class="category">
  134. <?php echo lang_get( 'protected' ) ?>
  135. </td>
  136. <td>
  137. <input type="checkbox" name="protected" <?php check_checked( $t_user['protected'], ON ); ?> />
  138. </td>
  139. </tr>
  140. <!-- Submit Button -->
  141. <tr>
  142. <td colspan="2" class="center">
  143. <?php if ( config_get( 'enable_email_notification' ) == ON ) {
  144. echo lang_get( 'notify_user' ); ?>
  145. <input type="checkbox" name="send_email_notification" checked />
  146. <?php } ?>
  147. <input type="submit" class="button" value="<?php echo lang_get( 'update_user_button' ) ?>" />
  148. </td>
  149. </tr>
  150. </table>
  151. </form>
  152. </div>
  153. <br />
  154. <!-- RESET AND DELETE -->
  155. <div class="border center">
  156. <!-- Reset Button -->
  157. <?php if( helper_call_custom_function( 'auth_can_change_password', array() ) ) { ?>
  158. <form method="post" action="manage_user_reset.php">
  159. <?php echo form_security_field( 'manage_user_reset' ) ?>
  160. <input type="hidden" name="user_id" value="<?php echo $t_user['id'] ?>" />
  161. <input type="submit" class="button" value="<?php echo lang_get( 'reset_password_button' ) ?>" />
  162. </form>
  163. <?php } ?>
  164. <!-- Delete Button -->
  165. <?php if ( !( ( user_is_administrator( $t_user_id ) && ( user_count_level( config_get_global( 'admin_site_threshold' ) ) <= 1 ) ) ) ) { ?>
  166. <form method="post" action="manage_user_delete.php">
  167. <?php echo form_security_field( 'manage_user_delete' ) ?>
  168. <input type="hidden" name="user_id" value="<?php echo $t_user['id'] ?>" />
  169. <input type="submit" class="button" value="<?php echo lang_get( 'delete_user_button' ) ?>" />
  170. </form>
  171. <?php } ?>
  172. </div>
  173. <br />
  174. <?php if( !$t_ldap ) { ?>
  175. <div align="center">
  176. <?php
  177. if ( ( ON == config_get( 'send_reset_password' ) ) && ( ON == config_get( 'enable_email_notification' ) ) ) {
  178. echo lang_get( 'reset_password_msg' );
  179. } else {
  180. echo lang_get( 'reset_password_msg2' );
  181. }
  182. ?>
  183. </div>
  184. <?php } ?>
  185. <!-- PROJECT ACCESS (if permissions allow) and user is not ADMINISTRATOR -->
  186. <?php if ( access_has_global_level( config_get( 'manage_user_threshold' ) ) &&
  187. !user_is_administrator( $t_user_id ) ) {
  188. ?>
  189. <br />
  190. <div align="center">
  191. <table class="width75" cellspacing="1">
  192. <!-- Title -->
  193. <tr>
  194. <td class="form-title" colspan="2">
  195. <?php echo lang_get( 'add_user_title' ) ?>
  196. </td>
  197. </tr>
  198. <!-- Assigned Projects -->
  199. <tr <?php echo helper_alternate_class( 1 ) ?> valign="top">
  200. <td class="category" width="30%">
  201. <?php echo lang_get( 'assigned_projects' ) ?>
  202. </td>
  203. <td width="70%">
  204. <?php print_project_user_list( $t_user['id'] ) ?>
  205. </td>
  206. </tr>
  207. <form method="post" action="manage_user_proj_add.php">
  208. <?php echo form_security_field( 'manage_user_proj_add' ) ?>
  209. <input type="hidden" name="user_id" value="<?php echo $t_user['id'] ?>" />
  210. <!-- Unassigned Project Selection -->
  211. <tr <?php echo helper_alternate_class() ?> valign="top">
  212. <td class="category">
  213. <?php echo lang_get( 'unassigned_projects' ) ?>
  214. </td>
  215. <td>
  216. <select name="project_id[]" multiple="multiple" size="5">
  217. <?php print_project_user_list_option_list2( $t_user['id'] ) ?>
  218. </select>
  219. </td>
  220. </tr>
  221. <!-- New Access Level -->
  222. <tr <?php echo helper_alternate_class() ?> valign="top">
  223. <td class="category">
  224. <?php echo lang_get( 'access_level' ) ?>
  225. </td>
  226. <td>
  227. <select name="access_level">
  228. <?php print_project_access_levels_option_list( config_get( 'default_new_account_access_level' ) ) ?>
  229. </select>
  230. </td>
  231. </tr>
  232. <!-- Submit Buttom -->
  233. <tr>
  234. <td class="center" colspan="2">
  235. <input type="submit" class="button" value="<?php echo lang_get( 'add_user_button' ) ?>" />
  236. </td>
  237. </tr>
  238. </form>
  239. </table>
  240. </div>
  241. <?php
  242. } # End of PROJECT ACCESS conditional section
  243. include ( 'account_prefs_inc.php' );
  244. edit_account_prefs( $t_user['id'], false, false, 'manage_user_edit_page.php?user_id=' . $t_user_id );
  245. html_page_bottom();