Skip to content

Commit

Permalink
Export additional user data
Browse files Browse the repository at this point in the history
  • Loading branch information
yurabakhtin committed Sep 11, 2024
1 parent ab92cb2 commit 2ed2eae
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,24 @@
namespace humhub\modules\rest;

use humhub\components\Event;
use humhub\modules\activity\models\Activity;
use humhub\modules\comment\models\Comment;
use humhub\modules\file\models\File;
use humhub\modules\legal\events\UserDataCollectionEvent;
use humhub\modules\like\models\Like;
use humhub\modules\notification\models\Notification;
use humhub\modules\post\models\Post;
use humhub\modules\rest\definitions\ActivityDefinitions;
use humhub\modules\rest\definitions\CommentDefinitions;
use humhub\modules\rest\definitions\FileDefinitions;
use humhub\modules\rest\definitions\InviteDefinitions;
use humhub\modules\rest\definitions\LikeDefinitions;
use humhub\modules\rest\definitions\NotificationDefinitions;
use humhub\modules\rest\definitions\PostDefinitions;
use humhub\modules\rest\definitions\SpaceDefinitions;
use humhub\modules\rest\definitions\UserDefinitions;
use humhub\modules\rest\models\Invite;
use humhub\modules\space\models\Space;
use Yii;

class Events
Expand Down Expand Up @@ -184,6 +192,25 @@ public static function onLegalModuleUserDataExport(UserDataCollectionEvent $even
return LikeDefinitions::getLike($like);
}, Like::findAll(['created_by' => $event->user->id])));

$event->addExportData('activity', array_map(function ($activity) {
return ActivityDefinitions::getActivity($activity);
}, Activity::find()
->innerJoin('content', 'activity.id = content.object_id and content.object_model = :activityClass', ['activityClass' => Activity::class])
->where(['created_by' => $event->user->id])
->all()));

$event->addExportData('invite', array_map(function ($invite) {
return InviteDefinitions::getInvite($invite);
}, Invite::findAll(['created_by' => $event->user->id])));

$event->addExportData('notification', array_map(function ($notification) {
return NotificationDefinitions::getNotification($notification);
}, Notification::findAll(['user_id' => $event->user->id])));

$event->addExportData('space', array_map(function ($space) {
return SpaceDefinitions::getSpace($space);
}, Space::findAll(['created_by' => $event->user->id])));

$files = File::findAll(['created_by' => $event->user->id]);
$event->addExportData('file', array_map(function ($file) {
return FileDefinitions::getFile($file);
Expand Down

0 comments on commit 2ed2eae

Please sign in to comment.