Skip to content

Commit e0d3bbc

Browse files
committed
added: reason to group approval decline
1 parent 383068f commit e0d3bbc

File tree

9 files changed

+94
-17
lines changed

9 files changed

+94
-17
lines changed

actions/group_tools/admin/decline.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
$group_guid = (int) get_input('guid');
7+
$reason = get_input('reason');
78
$group = get_entity($group_guid);
89
if (!$group instanceof ElggGroup) {
910
return elgg_error_response(elgg_echo('error:missing_data'));
@@ -17,6 +18,7 @@
1718
$message = elgg_echo('group_tools:group:admin_approve:decline:message', [
1819
$owner->getDisplayName(),
1920
$group->getDisplayName(),
21+
$reason,
2022
], $owner->language);
2123

2224
$params = [
@@ -26,8 +28,8 @@
2628

2729
// correct forward url
2830
$forward_url = REFERER;
29-
if ($_SERVER['HTTP_REFERER'] === $group->getURL()) {
30-
$forward_url = 'groups/all';
31+
if (stristr($_SERVER['HTTP_REFERER'], $group->getURL()) !== false) {
32+
$forward_url = elgg_generate_url('default:group:group');
3133
}
3234

3335
// delete group

classes/ColdTrick/GroupTools/TitleMenu.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -332,11 +332,12 @@ public static function pendingApproval(\Elgg\Hook $hook) {
332332
$return[] = \ElggMenuItem::factory([
333333
'name' => 'decline',
334334
'text' => elgg_echo('decline'),
335-
'href' => elgg_generate_action_url('group_tools/admin/decline', [
336-
'guid' => $page_owner->guid,
337-
]),
338-
'confirm' => elgg_echo('group_tools:group:admin_approve:decline:confirm'),
339-
'class' => 'elgg-button elgg-button-delete',
335+
'href' => "#group-tools-admin-approve-decline-{$page_owner->guid}",
336+
'class' => [
337+
'elgg-button',
338+
'elgg-button-delete',
339+
'elgg-lightbox-inline',
340+
],
340341
]);
341342

342343
return $return;

languages/en.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,9 @@
305305
// group admin approve
306306
'group_tools:group:admin_approve:notice' => "New groups need to be approved by a site administrator. You can make/edit the group, but it won't be visible to other users until approved by a site administrator.",
307307
'group_tools:group:admin_approve:notice:profile' => "This group is awaiting approval by a site administrator. You can edit the group, but it won't be visible to other users until approved by a site administrator.",
308+
'group_tools:group:admin_approve:decline:title' => "Decline the group approval request",
309+
'group_tools:group:admin_approve:decline:description' => "Here you can give a reason why the group '%s' isn't being approved. The group owner will receive a notification that the group was declined and the reason why. After the group is declined it'll be removed.",
310+
'group_tools:group:admin_approve:decline:reason' => "Reason for declining the group",
308311
'group_tools:group:admin_approve:decline:confirm' => "Are you sure you wish to decline this group? This will delete the group.",
309312
'group_tools:group:admin_approve:admin:description' => "Here is a list of groups which need to be approved by the site administrators before they can be used.
310313
@@ -346,7 +349,10 @@
346349
'group_tools:group:admin_approve:decline:summary' => "Your group '%s' was declined",
347350
'group_tools:group:admin_approve:decline:message' => "Hi %s,
348351
349-
your group '%s' was declined and removed by a site administrator.",
352+
your group '%s' was declined and removed by a site administrator.
353+
354+
The reason was:
355+
%s",
350356

351357
// group notification
352358
'group_tools:notifications:title' => "Group notifications",

languages/es.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,10 @@
162162
'group_tools:group:admin_approve:decline:summary' => 'Tu grupo \'%s\' ha sido rechazado',
163163
'group_tools:group:admin_approve:decline:message' => 'Hola %s,
164164
165-
tu grupo \'%s\' fue rechazado y eliminado por un administrador del sitio.',
165+
tu grupo \'%s\' fue rechazado y eliminado por un administrador del sitio.
166+
167+
La razón fue:
168+
%s',
166169
'group_tools:notifications:title' => 'Notificaciones de grupo',
167170
'group_tools:notifications:disclaimer' => 'Con grupos numerosos esto puede demorar unos momentos.',
168171
'group_tools:notifications:enable' => 'Activar las notificaciones para todos',

languages/fr.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,10 @@
189189
'group_tools:group:admin_approve:decline:summary' => 'Votre groupe \'%s\' a été refusé',
190190
'group_tools:group:admin_approve:decline:message' => 'Bonjour %s,
191191
192-
Votre groupe \'%s\' a été refusé',
192+
Votre groupe \'%s\' a été refusé`
193+
194+
La raison était:
195+
%s',
193196
'group_tools:notifications:toggle:site:enabled:link' => 'desactive les notifications',
194197
'group_tools:notifications:toggle:site:disabled:link' => 'active les notifications',
195198
'group_tools:mail:message:from' => 'Depuis le groupe',

languages/nl.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,10 @@
209209
'group_tools:group:admin_approve:decline:summary' => 'Je groep \'%s\' is afgewezen',
210210
'group_tools:group:admin_approve:decline:message' => 'Hallo %s,
211211
212-
je groep \'%s\' is afgewezen en verwijderd door een site beheerder.',
212+
je groep \'%s\' is afgewezen en verwijderd door een site beheerder.
213+
214+
De reden was:
215+
%s',
213216
'group_tools:csv_exporter:group_admin:name' => 'Groepsbeheerder(s) naam',
214217
'group_tools:csv_exporter:group_admin:email' => 'Groepsbeheerder(s) e-mail adres',
215218
'group_tools:csv_exporter:group_admin:url' => 'Groepsbeheerder(s) profiel url',
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/**
3+
* Form to add a reason why a group was declined
4+
*
5+
* @use $vars['entity'] the group to decline
6+
*/
7+
8+
$entity = elgg_extract('entity', $vars);
9+
if (!$entity instanceof ElggGroup) {
10+
return;
11+
}
12+
13+
echo elgg_view('output/longtext', [
14+
'value' => elgg_echo('group_tools:group:admin_approve:decline:description', [$entity->getDisplayName()]),
15+
]);
16+
17+
echo elgg_view_field([
18+
'#type' => 'hidden',
19+
'name' => 'guid',
20+
'value' => $entity->guid,
21+
]);
22+
23+
echo elgg_view_field([
24+
'#type' => 'plaintext',
25+
'#label' => elgg_echo('group_tools:group:admin_approve:decline:reason'),
26+
'name' => 'reason',
27+
]);
28+
29+
// form footer
30+
$footer = '';
31+
$footer .= elgg_view_field([
32+
'#type' => 'submit',
33+
'value' => elgg_echo('decline'),
34+
'class' => 'elgg-button-delete',
35+
'data-confirm' => elgg_echo('group_tools:group:admin_approve:decline:confirm'),
36+
]);
37+
38+
elgg_set_form_footer($footer);

views/default/group_tools/extends/groups/edit/admin_approve.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,15 @@ function(QueryBuilder $qb, $main_alias) {
4141
}
4242

4343
echo elgg_view_message('notice', $message);
44+
45+
if (elgg_is_admin_logged_in()) {
46+
$form = elgg_view_form('group_tools/admin/decline', [], [
47+
'entity' => $entity,
48+
]);
49+
$module = elgg_view_module('info', elgg_echo('group_tools:group:admin_approve:decline:title'), $form, [
50+
'id' => "group-tools-admin-approve-decline-{$entity->guid}",
51+
]);
52+
53+
echo elgg_format_element('div', ['class' => 'hidden'], $module);
54+
}
4455
}

views/default/group_tools/group/admin_approve.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
}
1515

1616
$buttons = [];
17+
$content = '';
1718

1819
if (!(bool) $group->is_concept) {
1920
// awaiting approval
@@ -27,12 +28,21 @@
2728
]);
2829
$buttons[] = elgg_view('output/url', [
2930
'text' => elgg_echo('decline'),
30-
'href' => elgg_generate_action_url('group_tools/admin/decline', [
31-
'guid' => $group->guid,
32-
]),
33-
'confirm' => elgg_echo('group_tools:group:admin_approve:decline:confirm'),
34-
'class' => 'elgg-button elgg-button-delete',
31+
'href' => "#group-tools-admin-approve-decline-{$group->guid}",
32+
'class' => [
33+
'elgg-button',
34+
'elgg-button-delete',
35+
'elgg-lightbox-inline',
36+
],
37+
]);
38+
39+
$form = elgg_view_form('group_tools/admin/decline', [], [
40+
'entity' => $group,
41+
]);
42+
$module = elgg_view_module('info', elgg_echo('group_tools:group:admin_approve:decline:title'), $form, [
43+
'id' => "group-tools-admin-approve-decline-{$group->guid}",
3544
]);
45+
$content .= elgg_format_element('div', ['class' => 'hidden'], $module);
3646

3747
$count = $group->getAnnotations([
3848
'count' => true,
@@ -72,7 +82,7 @@ function(QueryBuilder $qb, $main_alias) {
7282
'access' => false,
7383
'metadata' => false,
7484
'image_block_vars' => [
75-
'image_alt' => implode('', $buttons),
85+
'image_alt' => implode('', $buttons) . $content,
7686
],
7787
];
7888

0 commit comments

Comments
 (0)