} if (!empty($tabs)) { $navigation = ""; if (count($tabs) > 1) { $navigation = elgg_view("navigation/tabs", array("tabs" => $tabs, "id" => "group-tools-special-states-tabs")); } echo elgg_view_module("inline", elgg_echo("group_tools:settings:special_states"), $navigation . $content); } // fix some problems with groups $rows = array(); // check missing acl members if ($missing_acl_members = group_tools_get_missing_acl_users()) { $rows[] = array(elgg_echo("group_tools:settings:fix:missing", array(count($missing_acl_members))), elgg_view("output/url", array("href" => "action/group_tools/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 if ($excess_acl_members = group_tools_get_excess_acl_users()) { $rows[] = array(elgg_echo("group_tools:settings:fix:excess", array(count($excess_acl_members))), elgg_view("output/url", array("href" => "action/group_tools/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 if ($wrong_groups = group_tools_get_groups_without_acl()) { $rows[] = array(elgg_echo("group_tools:settings:fix:without", array(count($wrong_groups))), elgg_view("output/url", array("href" => "action/group_tools/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 if (count($rows) > 1) { $rows[] = array(elgg_echo("group_tools:settings:fix:all:description"), elgg_view("output/url", array("href" => "action/group_tools/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))); } if (!empty($rows)) { $content = "<table class='elgg-table'>"; foreach ($rows as $row) { $content .= "<tr><td>" . implode("</td><td>", $row) . "</td></tr>"; }
access_show_hidden_entities(true); foreach ($missing_users 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 */ add_user_to_access_collection($user_data->user_guid, $user_data->acl_id); } // restore hidden settings access_show_hidden_entities($hidden); system_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)) { foreach ($excess_users as $user_data) { /** * $user_data = row stdClass * -> acl_id => the acl the user should be removed from * -> group_guid => the group the acl belongs to * -> user_guid => the user that should be removed */ group_tools_remove_user_from_access_collection($user_data->user_guid, $user_data->acl_id); } system_message(elgg_echo('group_tools:action:fix_acl:success:excess', [count($excess_users)])); } break; default: register_error(elgg_echo('group_tools:action:fix_acl:error:input', [$fix]));