Changeset 455
- Timestamp:
- 06/15/07 11:34:34 (2 years ago)
- Files:
-
- trunk/lib/jelix-plugins/auth/auth.plugin.php (modified) (1 diff)
- trunk/lib/jelix-plugins/auth/auth.plugin.php (modified) (1 diff)
- trunk/lib/jelix/auth/jAuth.class.php (modified) (16 diffs)
- trunk/lib/jelix/auth/jAuth.class.php (modified) (16 diffs)
- trunk/lib/jelix/auth/jAuthDriverLDS.class.php (modified) (5 diffs)
- trunk/lib/jelix/auth/jAuthDriverLDS.class.php (modified) (5 diffs)
- trunk/lib/jelix/auth/jAuthUser.class.php (modified) (2 diffs)
- trunk/lib/jelix/auth/jAuthUser.class.php (modified) (2 diffs)
- trunk/lib/jelix/core/response/jResponseJsonrpc.class.php (modified) (1 diff)
- trunk/lib/jelix/core/response/jResponseJsonrpc.class.php (modified) (1 diff)
- trunk/lib/jelix/core/response/jResponseXul.class.php (modified) (1 diff)
- trunk/lib/jelix/core/response/jResponseXul.class.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/jelix-plugins/auth/auth.plugin.php
r386 r455 51 51 if (! isset ($_SESSION['JELIX_USER'])){ 52 52 $notLogged = true; 53 $_SESSION['JELIX_USER'] = new j AuthUser();53 $_SESSION['JELIX_USER'] = new jDummyAuthUser(); 54 54 }else{ 55 55 $notLogged = ! jAuth::isConnected(); trunk/lib/jelix-plugins/auth/auth.plugin.php
r386 r455 51 51 if (! isset ($_SESSION['JELIX_USER'])){ 52 52 $notLogged = true; 53 $_SESSION['JELIX_USER'] = new j AuthUser();53 $_SESSION['JELIX_USER'] = new jDummyAuthUser(); 54 54 }else{ 55 55 $notLogged = ! jAuth::isConnected(); trunk/lib/jelix/auth/jAuth.class.php
r402 r455 5 5 * @author Laurent Jouanneau 6 6 * @contributor 7 * @copyright 2001-2005 CopixTeam, 2005-200 6Laurent Jouanneau7 * @copyright 2001-2005 CopixTeam, 2005-2007 Laurent Jouanneau 8 8 * Classe orginellement issue d'une branche experimentale du 9 9 * framework Copix 2.3dev. http://www.copix.org (jAuth) … … 33 33 * @param string $login the user login 34 34 * @param string $password the user password 35 * @return jAuthUser|object the returned object depends on the driver35 * @return object the returned object depends on the driver 36 36 */ 37 37 public function createUserObject($login, $password); … … 42 42 * It create the user in a database for example 43 43 * should be call after a call of createUser and after setting some of its properties... 44 * @param jAuthUser|object $user the user data container44 * @param object $user the user data container 45 45 */ 46 46 public function saveNewUser($user); … … 55 55 * save updated datas of a user 56 56 * warning : should not save the password ! 57 * @param jAuthUser|object $user the user data container57 * @param object $user the user data container 58 58 */ 59 59 public function updateUser($user); … … 62 62 * return user data corresponding to the given login 63 63 * @param string $login the login of the user 64 * @return jAuthUser|object the user data container64 * @return object the user data container 65 65 */ 66 66 public function getUser($login); … … 69 69 * construct the user list 70 70 * @param string $pattern '' for all users 71 * @return array array of jAuthUser|object71 * @return array array of user object 72 72 */ 73 73 public function getUserList($pattern); … … 85 85 * @param string $login the login of the user 86 86 * @param string $password the password to test 87 * @return jAuthUser|false87 * @return object|false 88 88 */ 89 89 public function verifyPassword($login, $password); … … 109 109 $plugin = $gJCoord->getPlugin('auth'); 110 110 if($plugin === null){ 111 trigger_error(jLocale::get('jelix~jxauth.error.plugin.missing'), E_USER_ERROR); 112 return null; 111 throw new jException('jelix~jxauth.error.plugin.missing'); 113 112 } 114 113 $config = & $plugin->config; … … 133 132 134 133 /** 135 * Save a new user and send the AuthNewUser event 136 * @param jAuthUser $user the user data (can be an other type object, depending on the driver) 137 * @return jAuthUser the user (eventually, with additional datas) 134 * load user datas 135 * 136 * This method returns an object, generated by the driver, and which contains 137 * datas corresponding to the given login. This method should be called if you want 138 * to update datas of a user. see updateUser method. 139 * 140 * @param string $login 141 * @return object the user 142 */ 143 public static function getUser($login){ 144 $dr = self::_getDriver(); 145 return $dr->getUser($login); 146 } 147 148 /** 149 * Create a new user object 150 * 151 * You should call this method if you want to create a new user. It returns an object, 152 * representing a user. Then you should fill its properties and give it to the saveNewUser 153 * method. 154 * 155 * @param string $login the user login 156 * @param string $password the user password (not encrypted) 157 * @return object the returned object depends on the driver 158 * @since 1.0b2 159 */ 160 public static function createUserObject($login,$password){ 161 $dr = self::_getDriver(); 162 return $dr->createUserObject($login,$password); 163 } 164 165 /** 166 * Save a new user 167 * 168 * if the saving has succeed, a AuthNewUser event is sent 169 * The given object should have been created by calling createUserObject method : 170 * 171 * example : 172 * <pre> 173 * $user = jAuth::createUserObject('login','password'); 174 * $user->email ='bla@foo.com'; 175 * jAuth::saveNewUser($user); 176 * </pre> 177 * the type of $user depends of the driver, so it can have other properties. 178 * 179 * @param object $user the user data 180 * @return object the user (eventually, with additional datas) 138 181 */ 139 182 public static function saveNewUser($user){ … … 146 189 147 190 /** 191 * update user datas 192 * 193 * It send a AuthUpdateUser event if the saving has succeed. If you want 194 * to change the user password, you must use jAuth::changePassword method 195 * instead of jAuth::updateUser method. 196 * 197 * The given object should have been created by calling getUser method. 198 * Example : 199 * <pre> 200 * $user = jAuth::getUser('login'); 201 * $user->email ='bla@foo.com'; 202 * jAuth::updateUser($user); 203 * </pre> 204 * the type of $user depends of the driver, so it can have other properties. 205 * 206 * @param object $user user datas 207 */ 208 public static function updateUser($user){ 209 $dr = self::_getDriver(); 210 if($user = $dr->updateUser($user)){ 211 jEvent::notify ('AuthUpdateUser', array('user'=>$user)); 212 } 213 } 214 215 /** 148 216 * remove a user 149 217 * send first AuthCanRemoveUser event, then if ok, send AuthRemoveUser 150 * and then remove the user 218 * and then remove the user. 151 219 * @param string $login the user login 152 220 * @return boolean true if ok … … 165 233 166 234 /** 167 * save user datas and send AuthUpdateUser event168 * @param jAuthUser $user169 */170 public static function updateUser(&$user){171 $dr = self::_getDriver();172 if($user = $dr->updateUser($user)){173 jEvent::notify ('AuthUpdateUser', array('user'=>$user));174 }175 }176 177 178 /**179 * load user data180 * @param string $login181 * @return jAuthUser the user182 */183 public static function getUser($login){184 $dr = self::_getDriver();185 return $dr->getUser($login);186 }187 188 /**189 * deprecated method. see CreateUserObject190 * @param string $login the user login191 * @param string $password the user password192 * @return jAuthUser|object the returned object depends on the driver193 * @deprecated194 */195 public static function createUser($login,$password){196 return self::createUserObject($login,$password);197 }198 199 /**200 * Create a new user object201 * @param string $login the user login202 * @param string $password the user password203 * @return jAuthUser|object the returned object depends on the driver204 * @since 1.0b2205 */206 public static function createUserObject($login,$password){207 $dr = self::_getDriver();208 return $dr->createUserObject($login,$password);209 }210 211 212 /**213 235 * construct the user list 214 236 * @param string $pattern '' for all users 215 * @return array array of jAuthUser|object237 * @return array array of object 216 238 */ 217 239 public static function getUserList($pattern = '%'){ … … 224 246 * 225 247 * @param string $login the login of the user 226 * @param string $newpassword 248 * @param string $newpassword the new password (not encrypted) 249 * @return boolean true if the change succeed 227 250 */ 228 251 public static function changePassword($login, $newpassword){ … … 234 257 * verify that the password correspond to the login 235 258 * @param string $login the login of the user 236 * @param string $password the password to test 237 * @return jAuthUser|false259 * @param string $password the password to test (not encrypted) 260 * @return object|false if ok, returns the user as object 238 261 */ 239 262 public static function verifyPassword($login, $password){ … … 245 268 * authentificate a user, and create a user in the php session 246 269 * @param string $login the login of the user 247 * @param string $password the password to test 270 * @param string $password the password to test (not encrypted) 248 271 * @return boolean true if authentification is ok 249 272 */ … … 272 295 public static function logout(){ 273 296 jEvent::notify ('AuthLogout', array('login'=>$_SESSION['JELIX_USER']->login)); 274 $_SESSION['JELIX_USER'] = new j AuthUser();297 $_SESSION['JELIX_USER'] = new jDummyAuthUser(); 275 298 jAcl::clearCache(); 276 299 } … … 286 309 /** 287 310 * return the user stored in the php session 288 * @return jAuthUserthe user datas311 * @return object the user datas 289 312 */ 290 313 public static function getUserSession (){ 291 314 if (! isset ($_SESSION['JELIX_USER'])){ 292 $_SESSION['JELIX_USER'] = new j AuthUser();315 $_SESSION['JELIX_USER'] = new jDummyAuthUser(); 293 316 } 294 317 return $_SESSION['JELIX_USER']; 295 318 } 296 319 320 /** 321 * deprecated method. see CreateUserObject 322 * @param string $login the user login 323 * @param string $password the user password 324 * @return object the returned object depends on the driver 325 * @deprecated 326 */ 327 public static function createUser($login,$password){ 328 return self::createUserObject($login,$password); 329 } 330 297 331 } 298 332 ?> trunk/lib/jelix/auth/jAuth.class.php
r402 r455 5 5 * @author Laurent Jouanneau 6 6 * @contributor 7 * @copyright 2001-2005 CopixTeam, 2005-200 6Laurent Jouanneau7 * @copyright 2001-2005 CopixTeam, 2005-2007 Laurent Jouanneau 8 8 * Classe orginellement issue d'une branche experimentale du 9 9 * framework Copix 2.3dev. http://www.copix.org (jAuth) … … 33 33 * @param string $login the user login 34 34 * @param string $password the user password 35 * @return jAuthUser|object the returned object depends on the driver35 * @return object the returned object depends on the driver 36 36 */ 37 37 public function createUserObject($login, $password); … … 42 42 * It create the user in a database for example 43 43 * should be call after a call of createUser and after setting some of its properties... 44 * @param jAuthUser|object $user the user data container44 * @param object $user the user data container 45 45 */ 46 46 public function saveNewUser($user); … … 55 55 * save updated datas of a user 56 56 * warning : should not save the password ! 57 * @param jAuthUser|object $user the user data container57 * @param object $user the user data container 58 58 */ 59 59 public function updateUser($user); … … 62 62 * return user data corresponding to the given login 63 63 * @param string $login the login of the user 64 * @return jAuthUser|object the user data container64 * @return object the user data container 65 65 */ 66 66 public function getUser($login); … … 69 69 * construct the user list 70 70 * @param string $pattern '' for all users 71 * @return array array of jAuthUser|object71 * @return array array of user object 72 72 */ 73 73 public function getUserList($pattern); … … 85 85 * @param string $login the login of the user 86 86 * @param string $password the password to test 87 * @return jAuthUser|false87 * @return object|false 88 88 */ 89 89 public function verifyPassword($login, $password); … … 109 109 $plugin = $gJCoord->getPlugin('auth'); 110 110 if($plugin === null){ 111 trigger_error(jLocale::get('jelix~jxauth.error.plugin.missing'), E_USER_ERROR); 112 return null; 111 throw new jException('jelix~jxauth.error.plugin.missing'); 113 112 } 114 113 $config = & $plugin->config; … … 133 132 134 133 /** 135 * Save a new user and send the AuthNewUser event 136 * @param jAuthUser $user the user data (can be an other type object, depending on the driver) 137 * @return jAuthUser the user (eventually, with additional datas) 134 * load user datas 135 * 136 * This method returns an object, generated by the driver, and which contains 137 * datas corresponding to the given login. This method should be called if you want 138 * to update datas of a user. see updateUser method. 139 * 140 * @param string $login 141 * @return object the user 142 */ 143 public static function getUser($login){ 144 $dr = self::_getDriver(); 145 return $dr->getUser($login); 146 } 147 148 /** 149 * Create a new user object 150 * 151 * You should call this method if you want to create a new user. It returns an object, 152 * representing a user. Then you should fill its properties and give it to the saveNewUser 153 * method. 154 * 155 * @param string $login the user login 156 * @param string $password the user password (not encrypted) 157 * @return object the returned object depends on the driver 158 * @since 1.0b2 159 */ 160 public static function createUserObject($login,$password){ 161 $dr = self::_getDriver(); 162 return $dr->createUserObject($login,$password); 163 } 164 165 /** 166 * Save a new user 167 * 168 * if the saving has succeed, a AuthNewUser event is sent 169 * The given object should have been created by calling createUserObject method : 170 * 171 * example : 172 * <pre> 173 * $user = jAuth::createUserObject('login','password'); 174 * $user->email ='bla@foo.com'; 175 * jAuth::saveNewUser($user); 176 * </pre> 177 * the type of $user depends of the driver, so it can have other properties. 178 * 179 * @param object $user the user data 180 * @return object the user (eventually, with additional datas) 138 181 */ 139 182 public static function saveNewUser($user){ … … 146 189 147 190 /** 191 * update user datas 192 * 193 * It send a AuthUpdateUser event if the saving has succeed. If you want 194 * to change the user password, you must use jAuth::changePassword method 195 * instead of jAuth::updateUser method. 196 * 197 * The given object should have been created by calling getUser method. 198 * Example : 199 * <pre> 200 * $user = jAuth::getUser('login'); 201 * $user->email ='bla@foo.com'; 202 * jAuth::updateUser($user); 203 * </pre> 204 * the type of $user depends of the driver, so it can have other properties. 205 * 206 * @param object $user user datas 207 */ 208 public static function updateUser($user){ 209 $dr = self::_getDriver(); 210 if($user = $dr->updateUser($user)){ 211 jEvent::notify ('AuthUpdateUser', array('user'=>$user)); 212 } 213 } 214 215 /** 148 216 * remove a user 149 217 * send first AuthCanRemoveUser event, then if ok, send AuthRemoveUser 150 * and then remove the user 218 * and then remove the user. 151 219 * @param string $login the user login 152 220 * @return boolean true if ok … … 165 233 166 234 /** 167 * save user datas and send AuthUpdateUser event168 * @param jAuthUser $user169 */170 public static function updateUser(&$user){171 $dr = self::_getDriver();172 if($user = $dr->updateUser($user)){173 jEvent::notify ('AuthUpdateUser', array('user'=>$user));174 }175 }176 177 178 /**179 * load user data180 * @param string $login181 * @return jAuthUser the user182 */183 public static function getUser($login){184 $dr = self::_getDriver();185 return $dr->getUser($login);186 }187 188 /**189 * deprecated method. see CreateUserObject190 * @param string $login the user login191 * @param string $password the user password192 * @return jAuthUser|object the returned object depends on the driver193 * @deprecated194 */195 public static function createUser($login,$password){196 return self::createUserObject($login,$password);197 }198 199 /**200 * Create a new user object201 * @param string $login the user login202 * @param string $password the user password203 * @return jAuthUser|object the returned object depends on the driver204 * @since 1.0b2205 */206 public static function createUserObject($login,$password){207 $dr = self::_getDriver();208 return $dr->createUserObject($login,$password);209 }210 211 212 /**213 235 * construct the user list 214 236 * @param string $pattern '' for all users 215 * @return array array of jAuthUser|object237 * @return array array of object 216 238 */ 217 239 public static function getUserList($pattern = '%'){ … … 224 246 * 225 247 * @param string $login the login of the user 226 * @param string $newpassword 248 * @param string $newpassword the new password (not encrypted) 249 * @return boolean true if the change succeed 227 250 */ 228 251 public static function changePassword($login, $newpassword){ … … 234 257 * verify that the password correspond to the login 235 258 * @param string $login the login of the user 236 * @param string $password the password to test 237 * @return jAuthUser|false259 * @param string $password the password to test (not encrypted) 260 * @return object|false if ok, returns the user as object 238 261 */ 239 262 public static function verifyPassword($login, $password){ … … 245 268 * authentificate a user, and create a user in the php session 246 269 * @param string $login the login of the user 247 * @param string $password the password to test 270 * @param string $password the password to test (not encrypted) 248 271 * @return boolean true if authentification is ok 249 272 */ … … 272 295 public static function logout(){ 273 296 jEvent::notify ('AuthLogout', array('login'=>$_SESSION['JELIX_USER']->login)); 274 $_SESSION['JELIX_USER'] = new j AuthUser();297 $_SESSION['JELIX_USER'] = new jDummyAuthUser(); 275 298 jAcl::clearCache(); 276 299 } … … 286 309 /** 287 310 * return the user stored in the php session 288 * @return jAuthUserthe user datas311 * @return object the user datas 289 312 */ 290 313 public static function getUserSession (){ 291 314 if (! isset ($_SESSION['JELIX_USER'])){ 292 $_SESSION['JELIX_USER'] = new j AuthUser();315 $_SESSION['JELIX_USER'] = new jDummyAuthUser(); 293 316 } 294 317 return $_SESSION['JELIX_USER']; 295 318 } 296 319 320 /** 321 * deprecated method. see CreateUserObject 322 * @param string $login the user login 323 * @param string $password the user password 324 * @return object the returned object depends on the driver 325 * @deprecated 326 */ 327 public static function createUser($login,$password){ 328 return self::createUserObject($login,$password); 329 } 330 297 331 } 298 332 ?> trunk/lib/jelix/auth/jAuthDriverLDS.class.php
r360 r455 4 4 * @subpackage auth 5 5 * @author Nicolas JEUDY 6 * @contributor 6 * @contributor Laurent Jouanneau 7 7 * @copyright 2006 Nicolas JEUDY 8 * @copyright 2007 Laurent Jouanneau 8 9 * @licence http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file 9 10 */ 11 12 13 /** 14 * object which represent a user 15 * 16 * @package jelix 17 * @subpackage auth 18 */ 19 class jAuthUserLDS extends jAuthUser { 20 } 21 22 23 10 24 11 25 /** … … 56 70 $login = '*'.$login.'*'; 57 71 $paramsArr = $this->xmlCall('base.getUsersLdap',$login); 58 $user = new jAuthUser ();72 $user = new jAuthUserLDS(); 59 73 $user->login = $paramsArr['uid'][0]; 60 74 $user->password = $paramsArr['userPassword'][0]; … … 63 77 64 78 public function createUserObject($login,$password){ 65 $user = new jAuthUser ();79 $user = new jAuthUserLDS(); 66 80 $user->login = $login; 67 81 $user->password = $password; … … 73 87 $userslist = array(); 74 88 foreach ($users as $userldap) { 75 $user = new jAuthUser ();89 $user = new jAuthUserLDS(); 76 90 $user->login = $userldap['uid']; 77 91 $userslist[] = $user; … … 91 105 $ret= $this->xmlCall("base.ldapAuth",$param); 92 106 if ( $ret == '1') { 93 $user = new jAuthUser ();107 $user = new jAuthUserLDS(); 94 108 $user->login = $login; 95 109 $user->password = $password; trunk/lib/jelix/auth/jAuthDriverLDS.class.php
r360 r455 4 4 * @subpackage auth 5 5 * @author Nicolas JEUDY 6 * @contributor 6 * @contributor Laurent Jouanneau 7 7 * @copyright 2006 Nicolas JEUDY 8 * @copyright 2007 Laurent Jouanneau 8 9 * @licence http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file 9 10 */ 11 12 13 /** 14 * object which represent a user 15 * 16 * @package jelix 17 * @subpackage auth 18 */ 19 class jAuthUserLDS extends jAuthUser { 20 } 21 22 23 10 24 11 25 /** … … 56 70 $login = '*'.$login.'*'; 57 71 $paramsArr = $this->xmlCall('base.getUsersLdap',$login); 58 $user = new jAuthUser ();72 $user = new jAuthUserLDS(); 59 73 $user->login = $paramsArr['uid'][0]; 60 74 $user->password = $paramsArr['userPassword'][0]; … … 63 77 64 78 public function createUserObject($login,$password){ 65 $user = new jAuthUser ();79 $user = new jAuthUserLDS(); 66 80 $user->login = $login; 67 81 $user->password = $password; … … 73 87 $userslist = array(); 74 88 foreach ($users as $userldap) { 75 $user = new jAuthUser ();89 $user = new jAuthUserLDS(); 76 90 $user->login = $userldap['uid']; 77 91 $userslist[] = $user; … … 91 105 $ret= $this->xmlCall("base.ldapAuth",$param); 92 106 if ( $ret == '1') { 93 $user = new jAuthUser ();107 $user = new jAuthUserLDS(); 94 108 $user->login = $login; 95 109 $user->password = $password; trunk/lib/jelix/auth/jAuthUser.class.php
r334 r455 5 5 * @author Laurent Jouanneau 6 6 * @contributor Loic Mathaud 7 * @copyright 2006 Laurent Jouanneau7 * @copyright 2006-2007 Laurent Jouanneau 8 8 * @licence http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file 9 9 */ … … 17 17 * @subpackage auth 18 18 */ 19 class jAuthUser {19 abstract class jAuthUser { 20 20 public $login = ''; 21 21 public $email =''; 22 22 } 23 23 24 25 /** 26 * internal use 27 * @package jelix 28 * @subpackage auth 29 */ 30 class jDummyAuthUser extends jAuthUser { 31 } 32 33 24 34 ?> trunk/lib/jelix/auth/jAuthUser.class.php
r334 r455 5 5 * @author Laurent Jouanneau 6 6 * @contributor Loic Mathaud 7 * @copyright 2006 Laurent Jouanneau7 * @copyright 2006-2007 Laurent Jouanneau 8 8 * @licence http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file 9 9 */ … … 17 17 * @subpackage auth 18 18 */ 19 class jAuthUser {19 abstract class jAuthUser { 20 20 public $login = ''; 21 21 public $email =''; 22 22 } 23 23 24 25 /** 26 * internal use 27 * @package jelix 28 * @subpackage auth 29 */ 30 class jDummyAuthUser extends jAuthUser { 31 } 32 33 24 34 ?> trunk/lib/jelix/core/response/jResponseJsonrpc.class.php
r454 r455 16 16 * @subpackage core_response 17 17 * @see jResponse 18 * @see http://json-rpc.org/ specs.xhtml18 * @see http://json-rpc.org/wiki/specification 19 19 */ 20 20 trunk/lib/jelix/core/response/jResponseJsonrpc.class.php
r454 r455 16 16 * @subpackage core_response 17 17 * @see jResponse 18 * @see http://json-rpc.org/ specs.xhtml18 * @see http://json-rpc.org/wiki/specification 19 19 */ 20 20 trunk/lib/jelix/core/response/jResponseXul.class.php
r454 r455 77 77 */ 78 78 public $bodyTpl = ''; 79 80 /**81 * selector of the template to use for errors82 * @var string83 */84 public $bodyErrorTpl = '';85 79 86 80 /** trunk/lib/jelix/core/response/jResponseXul.class.php
r454 r455 77 77 */ 78 78 public $bodyTpl = ''; 79 80 /**81 * selector of the template to use for errors82 * @var string83 */84 public $bodyErrorTpl = '';85 79 86 80 /**
