@@ -20,7 +20,7 @@ final class LinkDatabaseExporter extends AbstractExporter
2020 'dev.hanashi.wsdb.links ' => 'Database ' ,
2121 'dev.hanashi.wsdb.links.permission ' => 'Permissions ' ,
2222 'dev.hanashi.wsdb.links.category ' => 'Categories ' ,
23- 'dev.hanashi.wsdb.links.category.acl ' => 'CategoryACL ' ,
23+ 'dev.hanashi.wsdb.links.category.acl ' => 'CategoryACLs ' ,
2424 'dev.hanashi.wsdb.links.option ' => 'Option ' ,
2525 'dev.hanashi.wsdb.links.links ' => 'Links ' ,
2626 'dev.hanashi.wsdb.links.comment ' => 'Comment ' ,
@@ -69,8 +69,12 @@ public function getQueue()
6969 if (\in_array ('dev.hanashi.wsdb.links.permission ' , $ this ->selectedData )) {
7070 $ queue [] = 'dev.hanashi.wsdb.links.permission ' ;
7171 }
72+
7273 if (\in_array ('dev.hanashi.wsdb.links.category ' , $ this ->selectedData )) {
7374 $ queue [] = 'dev.hanashi.wsdb.links.category ' ;
75+ if (\in_array ('dev.hanashi.wsdb.links.category.acl ' , $ this ->selectedData )) {
76+ $ queue [] = 'dev.hanashi.wsdb.links.category.acl ' ;
77+ }
7478 }
7579 }
7680
@@ -292,6 +296,100 @@ public function exportCategories(int $offset, int $limit): void
292296 }
293297 }
294298
299+ public function countCategoryACLs (): int
300+ {
301+ $ objectType = ObjectTypeCache::getInstance ()->getObjectTypeByName (
302+ 'com.woltlab.wcf.acl ' ,
303+ 'de.pehbeh.links.category '
304+ );
305+ if ($ objectType === null ) {
306+ return 0 ;
307+ }
308+
309+ $ sql = "SELECT (
310+ SELECT COUNT(*)
311+ FROM wcf1_acl_option_to_group acl_option_to_group
312+ INNER JOIN wcf1_acl_option acl_option
313+ ON acl_option.optionID = acl_option_to_group.optionID
314+ WHERE acl_option.objectTypeID = ?
315+ ) + (
316+ SELECT COUNT(*)
317+ FROM wcf1_acl_option_to_user acl_option_to_user
318+ INNER JOIN wcf1_acl_option acl_option
319+ ON acl_option.optionID = acl_option_to_user.optionID
320+ WHERE acl_option.objectTypeID = ?
321+ ) AS count " ;
322+ $ statement = $ this ->database ->prepare ($ sql );
323+ $ statement ->execute ([$ objectType ->objectTypeID , $ objectType ->objectTypeID ]);
324+
325+ return $ statement ->fetchSingleColumn ();
326+ }
327+
328+ public function exportCategoryACLs (int $ offset , int $ limit ): void
329+ {
330+ $ objectType = ObjectTypeCache::getInstance ()->getObjectTypeByName (
331+ 'com.woltlab.wcf.acl ' ,
332+ 'de.pehbeh.links.category '
333+ );
334+ if ($ objectType === null ) {
335+ return ;
336+ }
337+
338+ $ aclMap = [
339+ 'canViewCategory ' => [
340+ 'canViewCategory ' ,
341+ 'canViewRecord ' ,
342+ ],
343+ 'canAddLinkEntry ' => [
344+ 'canAddRecord ' ,
345+ ],
346+ ];
347+
348+ $ sql = "(
349+ SELECT acl_option.optionName, acl_option.optionID,
350+ option_to_group.objectID, option_to_group.optionValue, 0 AS userID, option_to_group.groupID
351+ FROM wcf1_acl_option_to_group option_to_group,
352+ wcf1_acl_option acl_option
353+ WHERE acl_option.optionID = option_to_group.optionID
354+ AND acl_option.objectTypeID = ?
355+ )
356+ UNION
357+ (
358+ SELECT acl_option.optionName, acl_option.optionID,
359+ option_to_user.objectID, option_to_user.optionValue, option_to_user.userID, 0 AS groupID
360+ FROM wcf1_acl_option_to_user option_to_user,
361+ wcf1_acl_option acl_option
362+ WHERE acl_option.optionID = option_to_user.optionID
363+ AND acl_option.objectTypeID = ?
364+ )
365+ ORDER BY optionID, objectID, userID, groupID " ;
366+ $ statement = $ this ->database ->prepareUnmanaged ($ sql , $ limit , $ offset );
367+ $ statement ->execute ([$ objectType ->objectTypeID , $ objectType ->objectTypeID ]);
368+ while ($ row = $ statement ->fetchArray ()) {
369+ $ acls = $ aclMap [$ row ['optionName ' ]] ?? [];
370+ foreach ($ acls as $ acl ) {
371+ $ data = [
372+ 'objectID ' => $ row ['objectID ' ],
373+ 'optionValue ' => $ row ['optionValue ' ],
374+ ];
375+ if ($ row ['userID ' ]) {
376+ $ data ['userID ' ] = $ row ['userID ' ];
377+ }
378+ if ($ row ['groupID ' ]) {
379+ $ data ['groupID ' ] = $ row ['groupID ' ];
380+ }
381+
382+ ImportHandler::getInstance ()
383+ ->getImporter ('dev.hanashi.wsdb.links.category.acl ' )
384+ ->import (
385+ 0 ,
386+ $ data ,
387+ ['optionName ' => $ acl ]
388+ );
389+ }
390+ }
391+ }
392+
295393 /**
296394 * @param string[] $i18nValues
297395 * @return string[][][]
0 commit comments