Skip to content

Commit 164b7ee

Browse files
committed
fixed: bulk update widget access in groups now show correct access opts
1 parent 3e47907 commit 164b7ee

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

classes/ColdTrick/WidgetManager/Access.php

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,33 @@ class Access {
1717
public static function setWriteAccess(\Elgg\Hook $hook) {
1818

1919
$input_params = $hook->getParam('input_params', []);
20-
21-
$widget = elgg_extract('entity', $input_params);
22-
if (!$widget instanceof \ElggWidget) {
20+
if (elgg_extract('entity_type', $input_params) !== 'object' || elgg_extract('entity_subtype', $input_params) !== 'widget') {
2321
return;
2422
}
2523

26-
$result = $hook->getValue();
27-
28-
$widget_context = $widget->context;
24+
$container = get_entity(elgg_extract('container_guid', $input_params));
25+
if (!$container instanceof \ElggEntity) {
26+
return;
27+
}
2928

30-
if ($widget_context === 'groups') {
31-
$group = $widget->getContainerEntity();
32-
if ($group instanceof \ElggGroup) {
33-
$acl = $group->getOwnedAccessCollection('group_acl');
34-
if ($acl) {
35-
return [
36-
$acl->id => elgg_echo('groups:access:group'),
37-
ACCESS_LOGGED_IN => elgg_echo('access:label:logged_in'),
38-
ACCESS_PUBLIC => elgg_echo('access:label:public')
39-
];
40-
}
29+
if ($container instanceof \ElggGroup) {
30+
$acl = $container->getOwnedAccessCollection('group_acl');
31+
if ($acl) {
32+
return [
33+
$acl->id => elgg_echo('groups:access:group'),
34+
ACCESS_LOGGED_IN => elgg_echo('access:label:logged_in'),
35+
ACCESS_PUBLIC => elgg_echo('access:label:public')
36+
];
4137
}
42-
} elseif ($widget->container_guid === elgg_get_site_entity()->guid) {
38+
} elseif ($container instanceof \ElggSite) {
4339
// sepcial options for index widgets
44-
if (elgg_can_edit_widget_layout($widget_context)) {
40+
41+
$widget = elgg_extract('entity', $input_params);
42+
if (!$widget instanceof \ElggWidget) {
43+
return;
44+
}
45+
46+
if (elgg_can_edit_widget_layout($widget->context)) {
4547
return [
4648
ACCESS_PRIVATE => elgg_echo('access:admin_only'),
4749
ACCESS_LOGGED_IN => elgg_echo('access:label:logged_in'),

views/default/widget_manager/forms/groups_widget_access.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@
2525

2626
$form_body = '<div>' . elgg_echo('widget_manager:forms:groups_widget_access:description') . '</div>';
2727

28-
$form_body .= '<div>' . elgg_view('input/access', ['name' => 'widget_access_level']) . '</div>';
28+
$form_body .= '<div>' . elgg_view('input/access', [
29+
'name' => 'widget_access_level',
30+
'entity_type' => 'object',
31+
'entity_subtype' => 'widget',
32+
'container_guid' => $group->guid,
33+
'purpose' => 'groups_widget_access',
34+
]) . '</div>';
2935

3036
$form_body .= '<div class="elgg-footer">';
3137
$form_body .= elgg_view('input/hidden', ['name' => 'group_guid', 'value' => $group->getGUID()]);

0 commit comments

Comments
 (0)