humhub / legal

3 stars 9 forks source link

User data export #77

Closed yurabakhtin closed 6 days ago

yurabakhtin commented 1 month ago

https://github.com/humhub/humhub-internal/issues/167

luke- commented 1 month ago

@yurabakhtin Thanks, looks already quite good!

luke- commented 1 month ago

@yurabakhtin Thanks, looks very good.

What do you think of the following API for modules? (I would prefer when the Legal module triggers the event).

We should also document this API in the Legal module under docs/DEVELOPER.md.

config.php

['class' => 'humhub\modules\legal\services\ExportService', 'event' => 'collectUserData', 'callback' => ['humhub\modules\wiki\Events', 'onLegalUserDataCollect']],

Events.php

  use humhub\modules\legal\events\UserDataCollectionEvent;

  public static function onLegalUserDataCollect(UserDataCollectionEvent $event)
    {
        $event->addData('wiki', array_map(function ($page) {
                return RestDefinitions::getWikiPage($page);
            }, WikiPage::find()
                ->joinWith('content')
                ->andWhere(['content.created_by' => $event->user->id])
                ->all());
       );
       # $event->addFile()         //?
    }
yurabakhtin commented 1 month ago

@luke-

What do you think of the following API for modules? (I would prefer when the Legal module triggers the event).

I have implemened your solution in the commits https://github.com/humhub-contrib/legal/pull/77/commits/4bd8b8db079b40ec781b925cc75c7da340e47528 and https://github.com/humhub/wiki/pull/348/commits/7319a0d3e5aba4d7188d799fa90b7647fd96f4e9.

yurabakhtin commented 1 month ago

What do you think about introducing a class like events/UserDataCollectionEvent (maybe based on UserEvent), which is only responsible for collecting and holding the data. Then we could remove this part from the ExportService.

@luke- Done in the commits https://github.com/humhub-contrib/legal/pull/77/commits/e5c0316d75462b0bd6a7e2f420dea0fd51ed25dc and https://github.com/humhub/wiki/pull/348/commits/dfa00e0e440e73b77686f145588f7d3d55652cc6.