mirror of
https://github.com/pierre42100/ComunicAPI
synced 2024-11-30 09:16:35 +00:00
Can export user information
This commit is contained in:
parent
21d00c0a00
commit
3f0c64495f
@ -111,6 +111,60 @@ class accountController {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Export all account data
|
||||
*
|
||||
* @url POST /account/export_data
|
||||
*/
|
||||
public function exportData(){
|
||||
|
||||
//Login & valid password required
|
||||
user_login_required();
|
||||
check_post_password(userID, "password");
|
||||
|
||||
//Generate and get data set
|
||||
$data = components()->account->export(userID);
|
||||
|
||||
//Process data set
|
||||
//Advanced user information
|
||||
$data["advanced_info"] = userController::advancedUserToAPI($data["advanced_info"]);
|
||||
|
||||
//Posts
|
||||
foreach($data["posts"] as $num => $post)
|
||||
$data["posts"][$num] = PostsController::PostToAPI($post);
|
||||
|
||||
//Comments
|
||||
foreach($data["comments"] as $num => $comment)
|
||||
$data["comments"][$num] = CommentsController::commentToAPI($comment);
|
||||
|
||||
//Likes
|
||||
foreach($data["likes"] as $num => $like)
|
||||
$data["likes"][$num] = LikesController::UserLikeToAPI($like);
|
||||
|
||||
//Survey responses
|
||||
foreach($data["survey_responses"] as $num => $response)
|
||||
$data["survey_responses"][$num] = SurveysController::SurveyResponseToAPI($response);
|
||||
|
||||
//Movies
|
||||
foreach($data["movies"] as $num => $movie)
|
||||
$data["movies"][$num] = MoviesController::MovieToAPI($movie);
|
||||
|
||||
//Conversations messages
|
||||
foreach($data["conversation_messages"] as $num => $message)
|
||||
$data["conversation_messages"][$num] = ConversationsController::ConvMessageToAPI($message);
|
||||
|
||||
//Conversations list
|
||||
foreach($data["conversations_list"] as $num => $conversation)
|
||||
$data["conversations_list"][$num] = ConversationsController::ConvInfoToAPI($conversation);
|
||||
|
||||
//Friends list
|
||||
foreach($data["friends_list"] as $num => $friend)
|
||||
$data["friends_list"][$num] = friendsController::parseFriendAPI($friend);
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an account
|
||||
*
|
||||
|
@ -277,6 +277,46 @@ class AccountComponent {
|
||||
return crypt(sha1($userPassword), sha1($userPassword));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user account data (full export)
|
||||
*
|
||||
* @param int $userID Target user ID
|
||||
* @return array Information about the user
|
||||
*/
|
||||
public function export(int $userID) : array {
|
||||
|
||||
$data = array();
|
||||
|
||||
//General account information
|
||||
$data["advanced_info"] = components()->user->getUserAdvancedInfo($userID);
|
||||
|
||||
//Posts list (with comments)
|
||||
$data["posts"] = components()->posts->getUserEntirePostsList($userID, TRUE);
|
||||
|
||||
//Comments list
|
||||
$data["comments"] = components()->comments->getAllUser($userID);
|
||||
|
||||
//Likes
|
||||
$data["likes"] = components()->likes->get_all_user($userID);
|
||||
|
||||
//Survey responses
|
||||
$data["survey_responses"] = components()->survey->get_all_responses($userID);
|
||||
|
||||
//User movies
|
||||
$data["movies"] = components()->movies->get_list($userID);
|
||||
|
||||
//Conversation messages
|
||||
$data["conversation_messages"] = components()->conversations->getAllUserMessages($userID);
|
||||
|
||||
//Conversations list
|
||||
$data["conversations_list"] = components()->conversations->getList($userID);
|
||||
|
||||
//Friend list
|
||||
$data["friends_list"] = components()->friends->getList($userID);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete user account
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user