[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Created on: <01-Aug-2002 09:58:09 bf> 4 // 5 // SOFTWARE NAME: eZ publish 6 // SOFTWARE RELEASE: 3.9.0 7 // BUILD VERSION: 17785 8 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 9 // SOFTWARE LICENSE: GNU General Public License v2.0 10 // NOTICE: > 11 // This program is free software; you can redistribute it and/or 12 // modify it under the terms of version 2.0 of the GNU General 13 // Public License as published by the Free Software Foundation. 14 // 15 // This program is distributed in the hope that it will be useful, 16 // but WITHOUT ANY WARRANTY; without even the implied warranty of 17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 // GNU General Public License for more details. 19 // 20 // You should have received a copy of version 2.0 of the GNU General 21 // Public License along with this program; if not, write to the Free 22 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 23 // MA 02110-1301, USA. 24 // 25 // 26 27 include_once ( "kernel/classes/datatypes/ezuser/ezuser.php" ); 28 include_once ( "lib/ezutils/classes/ezhttptool.php" ); 29 include_once ( 'lib/ezutils/classes/ezini.php' ); 30 31 $ini =& eZINI::instance(); 32 $currentUser =& eZUser::currentUser(); 33 $currentUserID = $currentUser->attribute( "contentobject_id" ); 34 $http =& eZHTTPTool::instance(); 35 $Module =& $Params["Module"]; 36 $message = 0; 37 $oldPasswordNotValid = 0; 38 $newPasswordNotMatch = 0; 39 $newPasswordTooShort = 0; 40 $userRedirectURI = ''; 41 42 $userRedirectURI = $Module->actionParameter( 'UserRedirectURI' ); 43 44 if ( $http->hasSessionVariable( "LastAccessesURI" ) ) 45 $userRedirectURI = $http->sessionVariable( "LastAccessesURI" ); 46 47 $redirectionURI = $userRedirectURI; 48 if ( $redirectionURI == '' ) 49 $redirectionURI = $ini->variable( 'SiteSettings', 'DefaultPage' ); 50 51 if( !isset( $oldPassword ) ) 52 $oldPassword = ''; 53 54 if( !isset( $newPassword ) ) 55 $newPassword = ''; 56 57 if( !isset( $confirmPassword ) ) 58 $confirmPassword = ''; 59 60 if ( is_numeric( $Params["UserID"] ) ) 61 $UserID = $Params["UserID"]; 62 else 63 $UserID = $currentUserID; 64 65 $user = eZUser::fetch( $UserID ); 66 if ( !$user ) 67 return $Module->handleError( EZ_ERROR_KERNEL_NOT_AVAILABLE, 'kernel' ); 68 $currentUser =& eZUser::currentUser(); 69 if ( $currentUser->attribute( 'contentobject_id' ) != $user->attribute( 'contentobject_id' ) or 70 !$currentUser->isLoggedIn() ) 71 return $Module->handleError( EZ_ERROR_KERNEL_ACCESS_DENIED, 'kernel' ); 72 73 if ( $http->hasPostVariable( "OKButton" ) ) 74 { 75 if ( $http->hasPostVariable( "oldPassword" ) ) 76 { 77 $oldPassword = $http->postVariable( "oldPassword" ); 78 } 79 if ( $http->hasPostVariable( "newPassword" ) ) 80 { 81 $newPassword = $http->postVariable( "newPassword" ); 82 } 83 if ( $http->hasPostVariable( "confirmPassword" ) ) 84 { 85 $confirmPassword = $http->postVariable( "confirmPassword" ); 86 } 87 88 $login = $user->attribute( "login" ); 89 $type = $user->attribute( "password_hash_type" ); 90 $hash = $user->attribute( "password_hash" ); 91 $site = $user->site(); 92 if ( $user->authenticateHash( $login, $oldPassword, $site, $type, $hash ) ) 93 { 94 if ( $newPassword == $confirmPassword ) 95 { 96 if ( strlen( $newPassword ) < 3 ) 97 { 98 $newPasswordTooShort = 1; 99 } 100 else 101 { 102 $newHash = $user->createHash( $login, $newPassword, $site, $type ); 103 $user->setAttribute( "password_hash", $newHash ); 104 $user->store(); 105 } 106 $message = true; 107 $newPassword = ''; 108 $oldPassword = ''; 109 $confirmPassword = ''; 110 111 } 112 else 113 { 114 $newPassword = ""; 115 $confirmPassword = ""; 116 $newPasswordNotMatch = 1; 117 $message = true; 118 } 119 } 120 else 121 { 122 $oldPassword = ""; 123 $oldPasswordNotValid = 1; 124 $message = true; 125 } 126 } 127 128 if ( $http->hasPostVariable( "CancelButton" ) ) 129 { 130 if ( $http->hasPostVariable( "RedirectOnCancel" ) ) 131 { 132 return $Module->redirectTo( $http->postVariable( "RedirectOnCancel" ) ); 133 } 134 include_once ( 'kernel/classes/ezredirectmanager.php' ); 135 eZRedirectManager::redirectTo( $Module, $redirectionURI ); 136 return; 137 } 138 139 $Module->setTitle( "Edit user information" ); 140 // Template handling 141 include_once ( "kernel/common/template.php" ); 142 $tpl =& templateInit(); 143 $tpl->setVariable( "module", $Module ); 144 $tpl->setVariable( "http", $http ); 145 $tpl->setVariable( "userID", $UserID ); 146 $tpl->setVariable( "userAccount", $user ); 147 $tpl->setVariable( "oldPassword", $oldPassword ); 148 $tpl->setVariable( "newPassword", $newPassword ); 149 $tpl->setVariable( "confirmPassword", $confirmPassword ); 150 $tpl->setVariable( "oldPasswordNotValid", $oldPasswordNotValid ); 151 $tpl->setVariable( "newPasswordNotMatch", $newPasswordNotMatch ); 152 $tpl->setVariable( "newPasswordTooShort", $newPasswordTooShort ); 153 $tpl->setVariable( "message", $message ); 154 155 $Result = array(); 156 $Result['path'] = array( array( 'text' => ezi18n( 'kernel/user', 'User' ), 157 'url' => false ), 158 array( 'text' => ezi18n( 'kernel/user', 'Change password' ), 159 'url' => false ) ); 160 $Result['content'] =& $tpl->fetch( "design:user/password.tpl" ); 161 162 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |