[ Index ]

PHP Cross Reference of MantisBT

title

Body

[close]

/ -> account_page.php (source)

   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   * CALLERS
  19   * This page is called from:
  20   * - print_menu()
  21   * - print_account_menu()
  22   * - header redirects from account_*.php
  23   * - included by verify.php to allow user to change their password
  24   *
  25   * EXPECTED BEHAVIOUR
  26   * - Display the user's current settings
  27   * - Allow the user to edit their settings
  28   * - Allow the user to save their changes
  29   * - Allow the user to delete their account if account deletion is enabled
  30   *
  31   * CALLS
  32   * This page calls the following pages:
  33   * - account_update.php  (to save changes)
  34   * - account_delete.php  (to delete the user's account)
  35   *
  36   * RESTRICTIONS & PERMISSIONS
  37   * - User must be authenticated
  38   * - The user's account must not be protected
  39   *
  40   * @package MantisBT
  41   * @copyright Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
  42   * @copyright Copyright (C) 2002 - 2010  MantisBT Team - mantisbt-dev@lists.sourceforge.net
  43   * @link http://www.mantisbt.org
  44   *
  45   * @uses core.php
  46   * @uses authentication_api.php
  47   * @uses config_api.php
  48   * @uses constant_inc.php
  49   * @uses current_user_api.php
  50   * @uses form_api.php
  51   * @uses helper_api.php
  52   * @uses html_api.php
  53   * @uses lang_api.php
  54   * @uses ldap_api.php
  55   * @uses print_api.php
  56   * @uses string_api.php
  57   * @uses user_api.php
  58   * @uses utility_api.php
  59   */
  60  
  61  require_once ( 'core.php' );
  62  require_api( 'authentication_api.php' );
  63  require_api( 'config_api.php' );
  64  require_api( 'constant_inc.php' );
  65  require_api( 'current_user_api.php' );
  66  require_api( 'form_api.php' );
  67  require_api( 'helper_api.php' );
  68  require_api( 'html_api.php' );
  69  require_api( 'lang_api.php' );
  70  require_api( 'ldap_api.php' );
  71  require_api( 'print_api.php' );
  72  require_api( 'string_api.php' );
  73  require_api( 'user_api.php' );
  74  require_api( 'utility_api.php' );
  75  
  76  #============ Parameters ============
  77  # (none)
  78  
  79  #============ Permissions ============
  80  auth_ensure_user_authenticated();
  81  
  82  current_user_ensure_unprotected();
  83  
  84  # extracts the user information for the currently logged in user
  85  # and prefixes it with u_
  86  $row = user_get_row( auth_get_current_user_id() );
  87  extract( $row, EXTR_PREFIX_ALL, 'u' );
  88  
  89  $t_ldap = ( LDAP == config_get( 'login_method' ) );
  90  
  91  # In case we're using LDAP to get the email address... this will pull out
  92  #  that version instead of the one in the DB
  93  $u_email = user_get_email( $u_id, $u_username );
  94  
  95  # note if we are being included by a script of a different name, if so,
  96  #  this is a mandatory password change request
  97  $t_force_pw_reset = is_page_name( 'verify.php' );
  98  
  99  # Only show the update button if there is something to update.
 100  $t_show_update_button = false;
 101  
 102  html_page_top( lang_get( 'account_link' ) );
 103  ?>
 104  
 105  <!-- # Edit Account Form BEGIN -->
 106  <br />
 107  <?php if ( $t_force_pw_reset ) { ?>
 108  <center><div style="color:red; width:75%">
 109      <?php
 110          echo lang_get( 'verify_warning' );
 111          if ( helper_call_custom_function( 'auth_can_change_password', array() ) ) {
 112              echo '<br />' . lang_get( 'verify_change_password' );
 113          }
 114      ?>
 115  </div></center>
 116  <br />
 117  <?php } ?>
 118  <div align="center">
 119  <form method="post" action="account_update.php">
 120  <?php echo form_security_field( 'account_update' ); ?>
 121  <table class="width75" cellspacing="1">
 122      <!-- Headings -->
 123      <tr>
 124          <td class="form-title">
 125              <?php echo lang_get( 'edit_account_title' ) ?>
 126          </td>
 127          <td class="right">
 128              <?php print_account_menu( 'account_page.php' ) ?>
 129          </td>
 130      </tr>
 131  
 132  <?php if ( !helper_call_custom_function( 'auth_can_change_password', array() ) ) { ?> <!-- With LDAP -->
 133  
 134      <!-- Username -->
 135      <tr <?php echo helper_alternate_class() ?>>
 136          <td class="category" width="25%">
 137              <?php echo lang_get( 'username' ) ?>
 138          </td>
 139          <td width="75%">
 140              <?php echo $u_username ?>
 141          </td>
 142      </tr>
 143  
 144      <!-- Password -->
 145      <tr <?php echo helper_alternate_class() ?>>
 146          <td class="category">
 147              <?php echo lang_get( 'password' ) ?>
 148          </td>
 149          <td>
 150              <?php echo lang_get( 'no_password_change' ) ?>
 151          </td>
 152      </tr>
 153  
 154  <!-- Without LDAP -->
 155  <?php } else {
 156      $t_show_update_button = true;
 157  ?>
 158  
 159      <!-- Username -->
 160      <tr <?php echo helper_alternate_class() ?>>
 161          <td class="category" width="25%">
 162              <?php echo lang_get( 'username' ) ?>
 163          </td>
 164          <td width="75%">
 165              <?php echo $u_username ?>
 166          </td>
 167      </tr>
 168  
 169      <!-- Password -->
 170      <tr <?php echo helper_alternate_class() ?>>
 171          <td class="category">
 172              <?php 
 173                  echo lang_get( 'password' );
 174                  if ( $t_force_pw_reset ) { 
 175              ?>
 176              <span class="required">*</span>
 177              <?php } ?>
 178          </td>
 179          <td>
 180              <input type="password" size="32" maxlength="<?php echo PASSLEN;?>" name="password" />
 181          </td>
 182      </tr>
 183  
 184      <!-- Password confirmation -->
 185      <tr <?php echo helper_alternate_class() ?>>
 186          <td class="category">
 187              <?php 
 188                  echo lang_get( 'confirm_password' );
 189                  if ( $t_force_pw_reset ) { 
 190              ?>
 191              <span class="required">*</span>
 192              <?php } ?>
 193          </td>
 194          <td>
 195              <input type="password" size="32" maxlength="<?php echo PASSLEN;?>" name="password_confirm" />
 196          </td>
 197      </tr>
 198  
 199  <?php
 200  } // End LDAP conditional
 201  
 202  if ( $t_ldap && ON == config_get( 'use_ldap_email' ) ) { ?> <!-- With LDAP Email-->
 203  
 204      <!-- Email -->
 205      <tr <?php echo helper_alternate_class() ?>>
 206          <td class="category">
 207              <?php echo lang_get( 'email' ) ?>
 208          </td>
 209          <td>
 210              <?php echo $u_email ?>
 211          </td>
 212      </tr>
 213  
 214  <?php } else { ?> <!-- Without LDAP Email -->
 215  
 216      <!-- Email -->
 217      <tr <?php echo helper_alternate_class() ?>>
 218          <td class="category">
 219              <?php echo lang_get( 'email' ) ?>
 220          </td>
 221          <td>
 222              <?php
 223                  $t_show_update_button = true;
 224                  print_email_input( 'email', $u_email );
 225              ?>
 226          </td>
 227      </tr>
 228  
 229  <?php } ?> <!-- End LDAP Email conditional -->
 230  
 231      <!-- Realname -->
 232      <tr <?php echo helper_alternate_class() ?> valign="top">
 233          <td class="category">
 234              <?php echo lang_get( 'realname' ) ?>
 235          </td>
 236          <td>
 237  <?php
 238  if ( $t_ldap && ON == config_get( 'use_ldap_realname' ) ) {
 239      echo string_display( ldap_realname_from_username( $u_username ) );
 240  } else {
 241      $t_show_update_button = true;
 242  ?>
 243              <input type="text" size="32" maxlength="<?php echo REALLEN;?>" name="realname" value="<?php echo string_attribute( $u_realname ) ?>" />
 244  <?php } ?>
 245          </td>
 246      </tr>
 247  
 248      <!-- Access level -->
 249      <tr <?php echo helper_alternate_class() ?>>
 250          <td class="category">
 251              <?php echo lang_get( 'access_level' ) ?>
 252          </td>
 253          <td>
 254              <?php echo get_enum_element( 'access_levels', $u_access_level ) ?>
 255          </td>
 256      </tr>
 257  
 258      <!-- Project access level -->
 259      <tr <?php echo helper_alternate_class() ?>>
 260          <td class="category">
 261              <?php echo lang_get( 'access_level_project' ) ?>
 262          </td>
 263          <td>
 264              <?php echo get_enum_element( 'access_levels', current_user_get_access_level() ) ?>
 265          </td>
 266      </tr>
 267  
 268      <!-- Assigned project list -->
 269      <tr <?php echo helper_alternate_class() ?> valign="top">
 270          <td class="category">
 271              <?php echo lang_get( 'assigned_projects' ) ?>
 272          </td>
 273          <td>
 274              <?php print_project_user_list( auth_get_current_user_id(), false ) ?>
 275          </td>
 276      </tr>
 277  
 278      <?php if ( $t_show_update_button ) { ?>
 279      <!-- BUTTONS -->
 280      <tr>
 281          <td class="left">
 282              <?php if ( $t_force_pw_reset ) { ?>
 283              <span class="required"> * <?php echo lang_get( 'required' ) ?></span>
 284              <?php } ?>
 285          </td>
 286          <!-- Update Button -->
 287          <td>
 288              <input type="submit" class="button" value="<?php echo lang_get( 'update_user_button' ) ?>" />
 289          </td>
 290      </tr>
 291      <?php } ?>
 292  </table>
 293  </form>
 294  </div>
 295  
 296  <br />
 297  <?php # Delete Account Form BEGIN ?>
 298  <?php
 299      # check if users can't delete their own accounts
 300      if ( ON == config_get( 'allow_account_delete' ) ) {
 301  ?>
 302  
 303  <!-- Delete Button -->
 304  <div class="border center">
 305      <form method="post" action="account_delete.php">
 306      <?php echo form_security_field( 'account_delete' ) ?>
 307      <input type="submit" class="button" value="<?php echo lang_get( 'delete_account_button' ) ?>" />
 308      </form>
 309  </div>
 310  
 311  <?php 
 312  } 
 313  # Delete Account Form END
 314  
 315  html_page_bottom();


Generated: Sat Mar 6 17:17:35 2010 Cross-referenced by PHPXref 0.7