mirror of
				https://github.com/pierre42100/ComunicAPI
				synced 2025-10-31 10:14:51 +00:00 
			
		
		
		
	Updated helpers
This commit is contained in:
		| @@ -12,8 +12,14 @@ class accountImage{ | ||||
| 		//Nothing now | ||||
| 	} | ||||
|  | ||||
| 	public function test(){ | ||||
| 		return "test"; | ||||
| 	/** | ||||
| 	 * Returns the path of an account image | ||||
| 	 * | ||||
| 	 * @param Integer $userID The ID of the user on which we perform research | ||||
| 	 * @return String The URL pointing on the avatar | ||||
| 	 */ | ||||
| 	public function getPath($userID){ | ||||
| 		return path_account_image("0Reverse.png"); | ||||
| 	} | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -161,26 +161,38 @@ class User{ | ||||
| 		if(count($userInfos) == 0) | ||||
| 			return array(); //No result | ||||
| 		 | ||||
| 		//Return result | ||||
| 		return $this->generateUserInfosArray($userInfos[0]); | ||||
| 	} | ||||
|  | ||||
| 	/** | ||||
| 	 * Generate and return an array containing informations about a user | ||||
| 	 * given the database entry | ||||
| 	 * | ||||
| 	 * @param Array $userInfos The user entry in the database | ||||
| 	 * @return Array The informations ready to be returned | ||||
| 	 */ | ||||
| 	private function generateUserInfosArray(array $userInfos) : array{ | ||||
| 		//Prepare return | ||||
| 		$return = array(); | ||||
| 		$return['userID'] = $userInfos[0]['ID']; | ||||
| 		$return['firstName'] = $userInfos[0]['prenom']; | ||||
| 		$return['lastName'] = $userInfos[0]['nom']; | ||||
| 		$return['accountCreationDate'] = $userInfos[0]['date_creation']; | ||||
| 		$return['publicPage'] = $userInfos[0]['public']; | ||||
| 		$return['openPage'] = $userInfos[0]['pageouverte']; | ||||
| 		$return['allowPostFromFriendOnHisPage'] = $userInfos[0]['autoriser_post_amis']; | ||||
| 		$return['noCommentOnHisPage'] = $userInfos[0]['bloquecommentaire']; | ||||
| 		$return['virtualDirectory'] = $userInfos[0]['sous_repertoire']; | ||||
| 		$return['personnalWebsite'] = $userInfos[0]['site_web']; | ||||
| 		$return['isPublicFriendList'] = $userInfos[0]['liste_amis_publique']; | ||||
| 		$return['userID'] = $userInfos['ID']; | ||||
| 		$return['firstName'] = $userInfos['prenom']; | ||||
| 		$return['lastName'] = $userInfos['nom']; | ||||
| 		$return['accountCreationDate'] = $userInfos['date_creation']; | ||||
| 		$return['publicPage'] = $userInfos['public']; | ||||
| 		$return['openPage'] = $userInfos['pageouverte']; | ||||
| 		$return['allowPostFromFriendOnHisPage'] = $userInfos['autoriser_post_amis']; | ||||
| 		$return['noCommentOnHisPage'] = $userInfos['bloquecommentaire']; | ||||
| 		$return['virtualDirectory'] = $userInfos['sous_repertoire']; | ||||
| 		$return['personnalWebsite'] = $userInfos['site_web']; | ||||
| 		$return['isPublicFriendList'] = $userInfos['liste_amis_publique']; | ||||
|  | ||||
| 		//Add account image url | ||||
| 		$return['accountImage'] = path_account_image("0Reverse.png"); | ||||
| 		$return['accountImage'] = CS::get()->components->accountImage->getPath($return['userID']); | ||||
|  | ||||
| 		//Only the user may get its mail address | ||||
| 		if(userID === $userID) | ||||
| 			$return['mailAdress'] = $userInfos[0]['mail']; | ||||
| 		if(userID === $return['userID']) | ||||
| 			$return['mailAdress'] = $userInfos['mail']; | ||||
|  | ||||
| 		//Return result | ||||
| 		return $return; | ||||
|   | ||||
							
								
								
									
										11
									
								
								config/userdata.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								config/userdata.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | ||||
| <?php | ||||
| /** | ||||
|  * User data configuration file | ||||
|  * | ||||
|  * @author Pierre HUBERT | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * The subdirectory (of user_data folder) containing image accounts | ||||
|  */ | ||||
| $config->set("imageAccountPath", "avatars/"); | ||||
| @@ -9,18 +9,23 @@ | ||||
|  * Get and returns the URL path to an userdata file | ||||
|  * | ||||
|  * @param String $fileURI Optionnal, defines the URI pointing on the file | ||||
|  * @param Boolean $systemPath Optionnal, defines if system path is required instead of URL | ||||
|  * @return String The full URL to the userdata file | ||||
|  */ | ||||
| function path_user_data($fileURI = ""){ | ||||
| 	return CS::get()->config->get("storage_url").$fileURI; | ||||
| function path_user_data($fileURI = "", $systemPath = false){ | ||||
| 	if(!$systemPath) | ||||
| 		return CS::get()->config->get("storage_url").$fileURI; | ||||
| 	else | ||||
| 		return CS::get()->config->get("storage_path").$fileURI; | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Get and return the URL path to a specified account image | ||||
|  * | ||||
|  * @param String $imageURI Optionnal, defines URI of the image | ||||
|  * @param Boolean $systemPath Optionnal, defines if system path is required instead of URL | ||||
|  * @return String The full URL to the image account file | ||||
|  */ | ||||
| function path_account_image($imageURI=""){ | ||||
| 	return path_user_data("avatars/".$imageURI); | ||||
| function path_account_image($imageURI="", $systemPath = false){ | ||||
| 	return path_user_data(CS::get()->config->get("imageAccountPath").$imageURI, $systemPath); | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Pierre
					Pierre