phpDocumentor pond
[ class tree: pond ] [ index: pond ] [ all elements ]

Source for file profile_update.php

Documentation is available at profile_update.php

  1. <?php
  2. /**
  3.  * This file updates the current user's profile!
  4.  *
  5.  * This file is part of Quam Plures - {@link http://quamplures.net/}
  6.  * See also {@link https://launchpad.net/quam-plures}.
  7.  *
  8.  * @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/}
  9.  * @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/}
  10.  *  Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}.
  11.  *
  12.  *  {@internal License choice
  13.  *  - If you have received this file as part of a package, please find the license.txt file in
  14.  *    the same folder or the closest folder above for complete license terms.
  15.  *  - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  16.  *    then you must choose one of the following licenses before using the file:
  17.  *    - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  18.  *    - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  19.  *  }}}
  20.  *
  21.  *  {@internal Open Source relicensing agreement:
  22.  *  Daniel HAHLER grants Francois PLANQUE the right to license
  23.  *  Daniel HAHLER's contributions to this file and the b2evolution project
  24.  *  under any OSI approved OSS license (http://www.opensource.org/licenses/).
  25.  *  }}}
  26.  *
  27.  *  {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  28.  * @author fplanque: Francois PLANQUE
  29.  * @author blueyed: Daniel HAHLER
  30.  *
  31.  *
  32.  * @todo integrate it into the templates to avoid ugly die() on error and confusing redirect on success.
  33.  *
  34.  * @package pond
  35.  */
  36.  
  37. /**
  38.  * Initialize everything:
  39.  */
  40. require_once dirname(__FILE__).'/../qp_config/_config.php';
  41.  
  42. require_once $inc_path.'_main.inc.php';
  43.  
  44. // Getting GET or POST parameters:
  45. param'checkuser_id''integer''' );
  46. param'newuser_firstname''string''' );
  47. param'newuser_lastname''string''' );
  48. param'newuser_nickname''string''' );
  49. param'newuser_idmode''string''' );
  50. param'newuser_locale''string'$default_locale );
  51. param'newuser_url''string''' );
  52. param'newuser_email''string''' );
  53. param'newuser_allow_msgform''integer')// checkbox
  54. param'newuser_notify''integer');        // checkbox
  55. param'newuser_showonline''integer');    // checkbox
  56. param'pass1''string''' );
  57. param'pass2''string''' );
  58.  
  59. /**
  60.  * Basic security checks:
  61.  */
  62. ifis_logged_in() )
  63. // must be logged in!
  64.     bad_request_dieT_('You are not logged in.') );
  65. }
  66.  
  67. if$checkuser_id != $current_User->ID )
  68. // Can only edit your own profile
  69.     bad_request_die'You are not logged in under the same account you are trying to modify.' );
  70. }
  71.  
  72. if$demo_mode && ($current_User->ID == 1
  73.     || $current_User->login == 'demouser'
  74.     || $current_User->login == 'demoblogger'
  75.     || $current_User->login == 'demospecial') )
  76. {
  77.     bad_request_die'Demo mode: you can\'t edit the admin/demouser profile!<br />[<a href="javascript:history.go(-1)">'
  78.         . T_('Back to profile''</a>]' );
  79. }
  80.  
  81. /**
  82.  * Additional checks:
  83.  */
  84.     'nickname' => $newuser_nickname,
  85.     'email' => $newuser_email,
  86.     'url' => $newuser_url,
  87.     'pass1' => $pass1,
  88.     'pass2' => $pass2,
  89.     'pass_required' => false )$current_User );
  90.  
  91.  
  92. if$Messages->count('error') )
  93. {
  94.     header_content_type'text/html' )// sets charset
  95.     // TODO: (legacy) dh> these error should get displayed with the profile form itself, or at least there should be a "real HTML page" here (without JS-backlink)
  96.     $Messages->displayT_('Cannot update profile. Please correct the following errors:'),
  97.         '[<a href="javascript:history.go(-1)">' T_('Back to profile''</a>]' );
  98.     exit(0);
  99. }
  100.  
  101.  
  102. // Do the update:
  103.  
  104. $updatepassword '';
  105. if!empty($pass1) )
  106. {
  107.     $newuser_pass md5($pass1);
  108.     $current_User->set'pass'$newuser_pass );
  109. }
  110.  
  111. $current_User->set'firstname'$newuser_firstname );
  112. $current_User->set'lastname'$newuser_lastname );
  113. $current_User->set'nickname'$newuser_nickname );
  114. $current_User->set_email$newuser_email );
  115. $current_User->set'url'$newuser_url );
  116. $current_User->set'idmode'$newuser_idmode );
  117. $current_User->set'locale'$newuser_locale );
  118. $current_User->set'allow_msgform'$newuser_allow_msgform );
  119. $current_User->set'notify'$newuser_notify );
  120. $current_User->set'showonline'$newuser_showonline );
  121.  
  122.  
  123. // Set Messages into user's session, so they get restored on the next page (after redirect):
  124. if$current_User->dbupdate() )
  125. {
  126.     $Messages->addT_('Your profile has been updated.')'success' );
  127. }
  128. else
  129. {
  130.     $Messages->addT_('Your profile has not been changed.')'note' );
  131. }
  132.  
  133.  
  134. // redirect Will save $Messages into Session:
  135.  
  136. ?>