diff --git a/actions/group_tools/admin/fix_acl.php b/actions/group_tools/admin/fix_acl.php deleted file mode 100644 index 8de582a..0000000 --- a/actions/group_tools/admin/fix_acl.php +++ /dev/null @@ -1,126 +0,0 @@ - acl_id => the acl the user should be added to - * -> group_guid => the group the acl belongs to - * -> user_guid => the user that should be added - */ - $acl = elgg_get_access_collection($user_data->acl_id); - if (!$acl instanceof \ElggAccessCollection) { - continue; - } - - $acl->addMember($user_data->user_guid); - } - }); -}; - -$remove_users = function ($data) { - // make sure we can see all users - elgg_call(ELGG_SHOW_DISABLED_ENTITIES, function() use ($data) { - foreach ($data as $user_data) { - /** - * $user_data = row stdClass - * -> acl_id => the acl the user should be added to - * -> group_guid => the group the acl belongs to - * -> user_guid => the user that should be added - */ - $acl = elgg_get_access_collection($user_data->acl_id); - if (!$acl instanceof \ElggAccessCollection) { - continue; - } - - $acl->removeMember($user_data->user_guid); - } - }); -}; - -switch ($fix) { - case 'missing': - // users without access to group content - $missing_users = group_tools_get_missing_acl_users(); - if (!empty($missing_users)) { - $add_users($missing_users); - - return elgg_ok_response('', elgg_echo('group_tools:action:fix_acl:success:missing', [count($missing_users)])); - } - return elgg_error_response(elgg_echo('group_tools:action:fix_acl:error:missing:nothing')); - - case 'excess': - // users with access to group content, but no longer member - $excess_users = group_tools_get_excess_acl_users(); - if (!empty($excess_users)) { - $remove_users($excess_users); - - return elgg_ok_response('', elgg_echo('group_tools:action:fix_acl:success:excess', [count($excess_users)])); - } - return elgg_error_response(elgg_echo('group_tools:action:fix_acl:error:excess:nothing')); - - case 'without': - // groups without acl - $groups = group_tools_get_groups_without_acl(); - if (!empty($groups)) { - // create the acl's for each group - foreach ($groups as $group) { - groups_create_event_listener('create', 'group', $group); - } - - // now add the group members - $missing_users = group_tools_get_missing_acl_users(); - if (!empty($missing_users)) { - $add_users($missing_users); - } - - return elgg_ok_response('', elgg_echo('group_tools:action:fix_acl:success:without', [count($groups)])); - } - return elgg_error_response(elgg_echo('group_tools:action:fix_acl:error:without:nothing')); - - case 'all': - // fix all problems - - // first: groups without acl - $groups = group_tools_get_groups_without_acl(); - if (!empty($groups)) { - // create the acl's for each group - foreach ($groups as $group) { - groups_create_event_listener('create', 'group', $group); - } - - elgg_register_success_message(elgg_echo('group_tools:action:fix_acl:success:without', [count($groups)])); - } - - // now add the group members - $missing_users = group_tools_get_missing_acl_users(); - if (!empty($missing_users)) { - $add_users($missing_users); - - elgg_register_success_message(elgg_echo('group_tools:action:fix_acl:success:missing', [count($missing_users)])); - } - - // users with access to group content, but no longer member - $excess_users = group_tools_get_excess_acl_users(); - if (!empty($excess_users)) { - $remove_users($excess_users); - - elgg_register_success_message(elgg_echo('group_tools:action:fix_acl:success:excess', [count($excess_users)])); - } - break; - default: - return elgg_error_response(elgg_echo('group_tools:action:fix_acl:error:input', [$fix])); -} - -return elgg_ok_response(); diff --git a/classes/ColdTrick/GroupTools/Menus/AdminHeader.php b/classes/ColdTrick/GroupTools/Menus/AdminHeader.php index b80f437..8d66e37 100644 --- a/classes/ColdTrick/GroupTools/Menus/AdminHeader.php +++ b/classes/ColdTrick/GroupTools/Menus/AdminHeader.php @@ -72,13 +72,6 @@ public static function registerAdminItems(\Elgg\Event $event): ?MenuItems { 'parent_name' => 'groups', ]); - $result[] = \ElggMenuItem::factory([ - 'name' => 'groups:repair', - 'href' => 'admin/groups/repair', - 'text' => elgg_echo('admin:groups:repair'), - 'parent_name' => 'groups', - ]); - return $result; } } diff --git a/classes/ColdTrick/GroupTools/Upgrades/FixGroupAccess.php b/classes/ColdTrick/GroupTools/Upgrades/FixGroupAccess.php deleted file mode 100644 index ecc9dc8..0000000 --- a/classes/ColdTrick/GroupTools/Upgrades/FixGroupAccess.php +++ /dev/null @@ -1,109 +0,0 @@ -countItems()); - } - - /** - * {@inheritdoc} - */ - public function countItems(): int { - return elgg_count_entities($this->getOptions()); - } - - /** - * {@inheritdoc} - */ - public function run(Result $result, $offset): Result { - - $groups = elgg_get_entities($this->getOptions(['offset' => $offset])); - if (empty($groups)) { - $result->markComplete(); - return $result; - } - - /* @var $group \ElggGroup */ - foreach ($groups as $group) { - $group_acl = $group->getOwnedAccessCollection('group_acl'); - if (!$group_acl instanceof \ElggAccessCollection) { - $result->addFailures(); - continue; - } - - if (isset($group->intended_access_id) && ((int) $group->intended_access_id === ACCESS_PRIVATE)) { - $group->intended_access_id = (int) $group_acl->id; - $result->addSuccesses(); - continue; - } - - $group->access_id = (int) $group_acl->id; - $group->save(); - - $result->addSuccesses(); - } - - return $result; - } - - /** - * Get options for elgg_get_entities - * - * @param array $options additional options - * - * @return array - * @see elgg_get_entities() - */ - protected function getOptions(array $options = []): array { - $defaults = [ - 'type' => 'group', - 'access_id' => ACCESS_PRIVATE, - 'limit' => 10, - 'wheres' => [ - function (QueryBuilder $qb, $main_alias) { - $wheres = []; - - // no admin approve - $sub = $qb->subquery('metadata'); - $sub->select('entity_guid') - ->where($qb->compare('name', '=', 'intended_access_id', ELGG_VALUE_STRING)); - - $wheres[] = $qb->compare("{$main_alias}.guid", 'not in', $sub->getSQL()); - - // admin approve, with wrong value - $md = $qb->joinMetadataTable($main_alias, 'guid', 'intended_access_id', 'inner', 'aamd'); - - $wheres[] = $qb->compare("{$md}.value", '=', ACCESS_PRIVATE, ELGG_VALUE_INTEGER); - - return $qb->merge($wheres, 'OR'); - }, - ], - ]; - - return array_merge($defaults, $options); - } -} diff --git a/elgg-plugin.php b/elgg-plugin.php index b141a50..3512f05 100644 --- a/elgg-plugin.php +++ b/elgg-plugin.php @@ -3,7 +3,6 @@ use ColdTrick\GroupTools\Bootstrap; use ColdTrick\GroupTools\Notifications\GroupAdminApprovalNotificationHandler; use ColdTrick\GroupTools\Notifications\GroupMailEnqueueNotificationEventHandler; -use ColdTrick\GroupTools\Upgrades\FixGroupAccess; use Elgg\Router\Middleware\Gatekeeper; use Elgg\Router\Middleware\GroupPageOwnerCanEditGatekeeper; use Elgg\Router\Middleware\GroupPageOwnerGatekeeper; @@ -75,7 +74,6 @@ 'group_tools/order_groups' => ['access' => 'admin'], 'group_tools/admin/toggle_special_state' => ['access' => 'admin'], - 'group_tools/admin/fix_acl' => ['access' => 'admin'], 'group_tools/admin/group_tool_presets' => ['access' => 'admin'], 'group_tools/admin/bulk_delete' => ['access' => 'admin'], 'group_tools/admin/approve' => ['access' => 'admin'], @@ -344,9 +342,6 @@ ], ], ], - 'upgrades' => [ - FixGroupAccess::class, - ], 'view_extensions' => [ 'admin.css' => [ 'group_tools/admin.css' => [], diff --git a/languages/en.php b/languages/en.php index a238286..414cdb6 100644 --- a/languages/en.php +++ b/languages/en.php @@ -33,7 +33,6 @@ 'admin:groups:auto_join' => "Auto join", 'admin:groups:featured' => "Featured", 'admin:groups:suggested' => "Suggested", - 'admin:groups:repair' => "Repair", // plugin settings 'group_tools:settings:default_off' => "Yes, default off", @@ -103,14 +102,6 @@ 'group_tools:settings:special_states:featured:description' => "The site administrators have chosen to feature the following groups.", - 'group_tools:settings:fix:title' => "Fix group access problems", - 'group_tools:settings:fix:missing' => "There are %d users who are a member of a group but don't have access to the content shared with the group.", - 'group_tools:settings:fix:excess' => "There are %d users who have access to group content of groups where they are no longer a member off.", - 'group_tools:settings:fix:without' => "There are %d groups without the possibility to share content with their members.", - 'group_tools:settings:fix:all:description' => "Fix all off the above problems at once.", - 'group_tools:settings:fix_it' => "Fix this", - 'group_tools:settings:fix:all' => "Fix all problems", - 'group_tools:settings:admin_approve' => "Site administrators need to approve new groups", 'group_tools:settings:admin_approve:description' => "Any user can create a group, but a site administrator has to approve the new group", @@ -436,16 +427,6 @@ 'group_tools:action:toggle_special_state:error:suggested' => "An error occurred while saving the new suggested settings", 'group_tools:action:toggle_special_state:error:state' => "Invalid state provided", 'group_tools:action:toggle_special_state:suggested' => "The new suggested settings were saved successfully", - - // fix group problems - 'group_tools:action:fix_acl:error:input' => "Invalid option you can't fix: %s", - 'group_tools:action:fix_acl:error:missing:nothing' => "No missing users found in the group ACLs", - 'group_tools:action:fix_acl:error:excess:nothing' => "No excess users found in the groups ACLs", - 'group_tools:action:fix_acl:error:without:nothing' => "No groups found without an ACL", - - 'group_tools:action:fix_acl:success:missing' => "Successfully added %d users to group ACLs", - 'group_tools:action:fix_acl:success:excess' => "Successfully removed %d users from group ACLs", - 'group_tools:action:fix_acl:success:without' => "Successfully created %d group ACLs", // Widgets // Group River Widget @@ -595,14 +576,4 @@ Please check on the group here: %s", - - // upgrades - 'group_tools:upgrade:2019051000:title' => "Fix group access", - 'group_tools:upgrade:2019051000:description' => "Some group could have been created with the access level 'Private', this will prevent members from accessing the group.", - - 'group_tools:upgrade:2019102501:title' => "Migrate group default content access", - 'group_tools:upgrade:2019102501:description' => "As of Elgg 3.2 group default content access is part of Elgg. This will migrate the group tools settings to the correct place in Elgg.", - - 'group_tools:upgrade:2021071401:title' => "Migrate group plugin settings for Group Tools", - 'group_tools:upgrade:2021071401:description' => "In Elgg 4.0 it's now possible to store specific plugin settings with the group. All old settings need to be migrated.", ]; diff --git a/languages/es.php b/languages/es.php index 51afcf9..e536c5b 100644 --- a/languages/es.php +++ b/languages/es.php @@ -52,12 +52,6 @@ 'group_tools:settings:listing:available' => 'Pestañas de listados de grupos disponibles', 'group_tools:settings:search_index' => 'Permitir que los grupos cerrados sean indexados en los motores de búsqueda', 'group_tools:settings:special_states:featured:description' => 'Los administradores de grupo han elegido esta funcionalidad para los siguientes grupos.', - 'group_tools:settings:fix:title' => 'Corregir problemas de acceso a grupos', - 'group_tools:settings:fix:missing' => 'Hay %d usuarios que son miembros de un grupo pero no tienen acceso al contenido compartido con el grupo.', - 'group_tools:settings:fix:excess' => 'Hay %d usuario que tienen acceso al contenido de un grupo del cual no forman más parte.', - 'group_tools:settings:fix:without' => 'Hay %d grupos sin la posibilidad de compartir contenido con sus miembros.', - 'group_tools:settings:fix:all:description' => 'Corregir todos los problemas seleccionados de una sola vez.', - 'group_tools:settings:fix_it' => 'Corregir esto', 'group_tools:settings:fix:all' => 'Corregir todos los problemas', 'group_tools:settings:admin_approve' => 'Los administradores de usuario necesitan aprobar nuevos grupos', 'group_tools:settings:admin_approve:description' => 'Cualquier usuario puede crear un grupo, pero un administrador del sitio debe aprobarlo', @@ -209,13 +203,6 @@ 'group_tools:action:toggle_special_state:error:suggested' => 'Un error ocurrió mientras se guardaban las nuevas configuraciones sugeridas', 'group_tools:action:toggle_special_state:error:state' => 'Estado inválido', 'group_tools:action:toggle_special_state:suggested' => 'Las nuevas configuraciones sugeridas fueron guardadas exitosamente', - 'group_tools:action:fix_acl:error:input' => 'Opción inválida que no puedes corregir: %s', - 'group_tools:action:fix_acl:error:missing:nothing' => 'No se han encontrado usuarios perdidos en la ACL del grupo', - 'group_tools:action:fix_acl:error:excess:nothing' => 'No se han encontrado usuarios excedentes en la ACL del grupo', - 'group_tools:action:fix_acl:error:without:nothing' => 'No se pueden encontrar grupos sin la ACL', - 'group_tools:action:fix_acl:success:missing' => 'Se han añadido exitosamente %d usuarios a la ACL del grupo', - 'group_tools:action:fix_acl:success:excess' => 'Se han removido exitosamente %d usuarios a la ACL del grupo', - 'group_tools:action:fix_acl:success:without' => 'Se han creado exitosamente %d ACL de grupo', 'widgets:group_river_widget:name' => 'Actividad de Grupo', 'widgets:group_river_widget:description' => 'Muestra la actividad de un grupo en un widget', 'widgets:group_river_widget:edit:group' => 'Elige un grupo', diff --git a/languages/fr.php b/languages/fr.php index 7457474..e1c4e40 100644 --- a/languages/fr.php +++ b/languages/fr.php @@ -109,13 +109,6 @@ 'group_tools:settings:search_index' => 'Autoriser les groupes fermés à être indexé par les moteurs de recherche.', 'group_tools:settings:stale_timeout:help' => 'Si aucun contenu n\'a été créé depuis un certain nombre de jours, le groupe est affiché comme "Périmé". Le propriétaire du groupe recevra une notification le jour où le groupe devient "Périmé". Un propriétaire de groupe/admin peut dire si un groupe est malgré tout toujours d\'actualité. 0 ou vide pour désactiver cette option.', 'group_tools:settings:special_states:featured:description' => 'Les administrateurs du site ont choisi de mettre en avant les groupes suivants', - 'group_tools:settings:fix:title' => 'Réparer les problèmes d\'accés aux groupes', - 'group_tools:settings:fix:missing' => 'Il y a %d utilisateurs qui sont membres d\'un groupe, mais qui n\'ont pas accés au contenu partagé par ce groupe.', - 'group_tools:settings:fix:excess' => 'Il y a %d utilisateurs qui ont accés au contenu d\'un groupe alors qu\'ils n\'en sont plus membre.', - 'group_tools:settings:fix:without' => 'Il y a %d groupes qui ne peuvent pas partager de contenu avec leurs membres', - 'group_tools:settings:fix:all:description' => 'Réparer tout les problémes ci-dessus en une seule fois', - 'group_tools:settings:fix_it' => 'Réparer ceci', - 'group_tools:settings:fix:all' => 'Réparer tous les problèmes', 'group_tools:settings:admin_approve' => 'Les nouveaux groupes doivent être validés par les administrateurs', 'group_tools:settings:admin_approve:description' => 'Tout utilisateur peut crééer un groupe, mais les adminsitrateurs doivent valider la demande', 'group_tools:admin:auto_join:default' => 'Auto adhésion', @@ -187,7 +180,6 @@ 'group_tools:groups:sorting:open' => 'Ouvrir', 'group_tools:groups:sorting:closed' => 'Fermé', 'group_tools:groups:sorting:suggested' => 'Suggéré', - 'group_tools:action:fix_acl:error:without:nothing' => 'Aucun groupe trouvé sans ACL', 'widgets:group_river_widget:edit:group' => 'Sélectionner un groupe', 'widgets:group_members:name' => 'Membres du groupe', 'widgets:group_members:view:no_members' => 'Aucun membre de groupe trouvé', diff --git a/languages/nl.php b/languages/nl.php index c46391a..0701f1b 100644 --- a/languages/nl.php +++ b/languages/nl.php @@ -14,8 +14,6 @@ 'groups:tool:related_groups:description' => 'Toon een lijst met gerelateerde groepen aan de leden van deze groep.', 'group_tools:welcome_message:notifications' => 'Activiteiten binnen deze groep kunnen notificaties versturen. Op dit moment staan je notificatie voorkeuren voor deze groep: %s', - 'group_tools:upgrade:2021071401:title' => 'Migreer de groep plugin instellingen voor Group Tools', - 'group_tools:upgrade:2021071401:description' => 'Sinds Elgg 4.0 is het mogelijk specifieke plugin instellingen op te slaan bij de groep. Alle oude instellingen moeten worden gemigreerd.', 'group_tools:edit:group:notifications:change_settings' => 'Wijzig de notificatie instellingen van alle leden', 'group_tools:edit:group:notifications:change_settings:help' => 'Selecteer de notificatiemethodes welke moeten zijn ingeschakeld voor alle leden, de niet geselecteerde methodes zullen worden uitgeschakeld.', 'group_tools:group:admin_approve:decline:title' => 'Wijs het groepsverzoek af', @@ -70,18 +68,13 @@ 'group_tools:menu:group:invitations:invitations' => 'Uitnodigingen', 'group_tools:menu:group:invitations:email_invitations' => 'E-mail uitnodigingen', 'group_tools:action:notifications:success:disable' => 'Alle notificaties zijn uitgeschakeld', - 'group_tools:upgrade:2019102501:title' => 'MIgreer standaard toegangsniveau voor groepscontent', - 'group_tools:upgrade:2019102501:description' => 'Sinds Elgg 3.2 wordt het standaard toegangsniveau voor nieuwe groepscontent beheerd door Elgg. Deze upgrade migreert de oude instellingen naar de nieuwe correcte locatie in Elgg.', 'group_tools:groups:invite:member' => 'Reeds lid van de groep', - 'group_tools:upgrade:2019051000:title' => 'Repareer groep toegang', - 'group_tools:upgrade:2019051000:description' => 'Sommige groepen kunnen zijn aangemaakt met het toegangsniveau \'Privé\', dit voorkomt dat leden van de groep toegang hebben tot de groep.', 'group_tools:settings:simple_tool_presets' => 'Vereenvoudig groep tools preset selectie', 'group_tools:settings:simple_tool_presets:help' => 'Vereenvoudigd de groep tool preset selectie. Enkel de groep tool preset titel en omschrijving worden getoond. De individuele tools worden niet getoond. Ook kan er in deze eenvoudige modus geen individuele tools worden geselecteerd.', 'group_tools:profile:field:group_tools_preset' => 'Groep tool set', 'group_tools:menu:title:add:preset' => 'Creëer een %s groep', 'admin:groups:featured' => 'Uitgelicht', 'admin:groups:suggested' => 'Aangeraden', - 'admin:groups:repair' => 'Repareer', 'group_tools:settings:create_based_on_preset' => 'Toolsets toevoegen aan \'Maak nieuwe groep\' knop', 'group_tools:settings:create_based_on_preset:help' => 'Indien er groep tool sets zijn geconfigureerd, voeg een optie aan de \'maak nieuwe groep\' knop toe om een groep te maken op basis van deze tool set. Dit zal ook de tool selectie op het formulier verbergen.', @@ -306,20 +299,6 @@ 'group_tools:invite_members:title' => 'Groepsleden mogen uitnodigen', 'group_tools:invite_members:description' => 'Mogen de leden van deze groep nieuwe leden uitnodigen', 'group_tools:invite_members:disclaimer' => 'Let op, voor besloten groepen geldt dat als je leden nieuwe gebruikers mogen uitnodigen deze gebruikers geen goedkeuring nodig hebben van de groepseigenaar/-beheerder(s).', - 'group_tools:settings:fix:title' => 'Los problemen met groep toegang op', - 'group_tools:settings:fix:missing' => 'Er zijn %d gebruikers die lid zijn van een groep maar geen toegang hebben tot de content die gedeeld wordt met de groep.', - 'group_tools:settings:fix:excess' => 'Er zijn %d gebruikers die toegang hebben tot content van een groep waar ze geen lid meer van zijn.', - 'group_tools:settings:fix:without' => 'Er zijn %d groepen die niet de mogelijkheid hebben om content te delen met de leden.', - 'group_tools:settings:fix:all:description' => 'Los alle bovenstaande problemen op.', - 'group_tools:settings:fix_it' => 'Los dit op', - 'group_tools:settings:fix:all' => 'Los alles op', - 'group_tools:action:fix_acl:error:input' => 'Ongeldige optie, je kunt %s niet oplossen', - 'group_tools:action:fix_acl:error:missing:nothing' => 'Er zijn geen ontbrekende gebruikers gevonden in de groep ACLs', - 'group_tools:action:fix_acl:error:excess:nothing' => 'Er zijn geen ongeldige gebruikers gevonden in de groep ACLs', - 'group_tools:action:fix_acl:error:without:nothing' => 'Er zijn geen groepen gevonden zonder ACL', - 'group_tools:action:fix_acl:success:missing' => 'Er zijn %d gebruikers toegevoegd aan de groep ACLs', - 'group_tools:action:fix_acl:success:excess' => 'Er zijn %d gebruikers verwijderd uit de groep ACLs', - 'group_tools:action:fix_acl:success:without' => 'Er zijn %d groep ACLs aangemaakt', 'group_tools:action:groups:decline_email_invitation:error:delete' => 'Er is een fout opgetreden tijdens het verwijderen van de uitnodiging', 'widgets:index_groups:filter:field' => 'Filter de groepen obv een profielveld', 'widgets:index_groups:filter:value' => 'met de waarde', diff --git a/views/default/admin/groups/repair.php b/views/default/admin/groups/repair.php deleted file mode 100644 index 13736f6..0000000 --- a/views/default/admin/groups/repair.php +++ /dev/null @@ -1,69 +0,0 @@ - 'action/group_tools/admin/fix_acl?fix=missing', - 'text' => elgg_echo('group_tools:settings:fix_it'), - 'class' => 'elgg-button elgg-button-action', - 'is_action' => true, - 'style' => 'white-space: nowrap;', - 'confirm' => true, - ]), -]; - -// check excess acl members -$excess_acl_members = group_tools_get_excess_acl_users(); -$rows[] = [ - elgg_echo('group_tools:settings:fix:excess', [count($excess_acl_members)]), - elgg_view('output/url', [ - 'href' => 'action/group_tools/admin/fix_acl?fix=excess', - 'text' => elgg_echo('group_tools:settings:fix_it'), - 'class' => 'elgg-button elgg-button-action', - 'is_action' => true, - 'style' => 'white-space: nowrap;', - 'confirm' => true, - ]), -]; - -// check groups without acl -$wrong_groups = group_tools_get_groups_without_acl(true); -$rows[] = [ - elgg_echo('group_tools:settings:fix:without', [$wrong_groups]), - elgg_view('output/url', [ - 'href' => 'action/group_tools/admin/fix_acl?fix=without', - 'text' => elgg_echo('group_tools:settings:fix_it'), - 'class' => 'elgg-button elgg-button-action', - 'is_action' => true, - 'style' => 'white-space: nowrap;', - 'confirm' => true, - ]), -]; - -// fix everything at once -$rows[] = [ - elgg_echo('group_tools:settings:fix:all:description'), - elgg_view('output/url', [ - 'href' => 'action/group_tools/admin/fix_acl?fix=all', - 'text' => elgg_echo('group_tools:settings:fix:all'), - 'class' => 'elgg-button elgg-button-action', - 'is_action' => true, - 'style' => 'white-space: nowrap;', - 'confirm' => true, - ]), -]; - -$content = ''; - -foreach ($rows as $row) { - $content .= ''; -} - -$content .= '
' . implode('', $row) . '
'; - -echo elgg_view_module('info', elgg_echo('group_tools:settings:fix:title'), $content);