Skip to content

Commit a6c59db

Browse files
committed
changed: concept / admin approval groups have more options
1 parent 5e507f7 commit a6c59db

File tree

20 files changed

+150
-46
lines changed

20 files changed

+150
-46
lines changed

actions/group_tools/admin/approve.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@
3131

3232
// unset temp access
3333
unset($group->intended_access_id);
34+
unset($group->admin_approval);
3435

3536
// notify owner
36-
/* @var $owner \ElggUser */
37+
/** @var \ElggUser $owner */
3738
$owner = $group->getOwnerEntity();
3839

3940
$owner->notify('approve', $group, [], elgg_get_logged_in_user_entity());

actions/group_tools/remove_concept_status.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@
1010
return elgg_error_response(elgg_echo('actionunauthorized'));
1111
}
1212

13+
// remove concept status
14+
unset($group->is_concept);
15+
1316
// should the group be approved by and admin?
1417
if (!elgg_is_admin_logged_in() && (elgg_get_plugin_setting('admin_approve', 'group_tools') === 'yes')) {
15-
// request approval
16-
unset($group->is_concept);
17-
18-
// prevent advanced notifications from preventing the enqueuing of this event
19-
elgg_unregister_event_handler('enqueue', 'notification', '\ColdTrick\AdvancedNotifications\Enqueue::delayPrivateContentNotification');
18+
$group->admin_approval = true;
2019

2120
elgg_trigger_event('admin_approval', 'group', $group);
2221

actions/groups/edit.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@
151151
// new groups get access private, so an admin can validate it
152152
$access_id = (int) $group->access_id;
153153
if ($is_new_group && ($admin_approve || $concept_group)) {
154-
$access_id = ACCESS_PRIVATE;
154+
$acl = $group->getOwnedAccessCollection('group_acl');
155+
$access_id = ($acl instanceof ElggAccessCollection) ? $acl->id : ACCESS_PRIVATE;
155156

156157
if ((bool) elgg_get_plugin_setting('creation_reason', 'group_tools')) {
157158
$reasons = (array) get_input('reasons', []);
@@ -161,6 +162,8 @@
161162
}
162163

163164
if (!$concept_group) {
165+
$group->admin_approval = true;
166+
164167
elgg_trigger_event('admin_approval', 'group', $group);
165168
} else {
166169
$group->is_concept = true;
@@ -185,7 +188,7 @@
185188
$group->setContentAccessMode(ElggGroup::CONTENT_ACCESS_MODE_MEMBERS_ONLY);
186189
}
187190

188-
if (($access_id === ACCESS_PRIVATE) && ($admin_approve || $concept_group)) {
191+
if ($admin_approve || $concept_group) {
189192
// admins has not yet approved the group, store wanted access
190193
$group->intended_access_id = $visibility;
191194
} else {

actions/groups/invite.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@
3838

3939
$csv = elgg_get_uploaded_file('csv');
4040

41-
$resend = false;
42-
if (get_input('resend') === 'yes') {
43-
$resend = true;
44-
}
41+
$resend = (bool) get_input('resend');
4542

4643
$group = get_entity($group_guid);
4744
if (!$group instanceof \ElggGroup) {

classes/ColdTrick/GroupTools/Cron.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -225,20 +225,19 @@ public static function removeExpiredConceptGroups(\Elgg\Event $event): void {
225225
}
226226

227227
elgg_call(ELGG_IGNORE_ACCESS | ELGG_SHOW_DELETED_ENTITIES, function() use ($days) {
228-
/* @var $groups \ElggBatch */
228+
/** @var \ElggBatch $groups */
229229
$groups = elgg_get_entities([
230230
'type' => 'group',
231231
'metadata_name_value_pairs' => [
232232
'name' => 'is_concept',
233233
'value' => true,
234234
],
235-
'access_id' => ACCESS_PRIVATE,
236235
'created_before' => "-{$days} days",
237236
'limit' => false,
238237
'batch' => true,
239238
'batch_inc_offset' => false,
240239
]);
241-
/* @var $group \ElggGroup */
240+
/** @var \ElggGroup $group */
242241
foreach ($groups as $group) {
243242
if (!$group->delete(true, true)) {
244243
$groups->reportFailure();
@@ -262,20 +261,19 @@ public static function notifyConceptGroupOwners(\Elgg\Event $event): void {
262261
$days = (int) elgg_get_plugin_setting('concept_groups_retention', 'group_tools');
263262

264263
elgg_call(ELGG_IGNORE_ACCESS, function() use ($days) {
265-
/* @var $groups \ElggBatch */
264+
/** @var \ElggBatch $groups */
266265
$groups = elgg_get_entities([
267266
'type' => 'group',
268267
'metadata_name_value_pairs' => [
269268
'name' => 'is_concept',
270269
'value' => true,
271270
],
272-
'access_id' => ACCESS_PRIVATE,
273271
'limit' => false,
274272
'batch' => true,
275273
]);
276-
/* @var $group \ElggGroup */
274+
/** @var \ElggGroup $group */
277275
foreach ($groups as $group) {
278-
/* @var $owner \ElggUser */
276+
/** @var \ElggUser $owner */
279277
$owner = $group->getOwnerEntity();
280278

281279
$owner->notify('concept_group_reminder', $group, [

classes/ColdTrick/GroupTools/Menus/Title.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static function groupMembership(\Elgg\Event $event): ?MenuItems {
2727
return null;
2828
}
2929

30-
/* @var $menu_items MenuItems */
30+
/** @var MenuItems $menu_items */
3131
$menu_items = $event->getValue();
3232

3333
$menu_item = $menu_items->get('groups:joinrequest');
@@ -91,7 +91,7 @@ public static function groupAdminStatus(\Elgg\Event $event): ?MenuItems {
9191
return null;
9292
}
9393

94-
/* @var $result MenuItems */
94+
/** @var MenuItems $result */
9595
$result = $event->getValue();
9696

9797
$menu_item = $result->get('group-dropdown');
@@ -123,7 +123,7 @@ public static function pendingApproval(\Elgg\Event $event): ?MenuItems {
123123
}
124124

125125
$page_owner = elgg_get_page_owner_entity();
126-
if (!$page_owner instanceof \ElggGroup || $page_owner->access_id !== ACCESS_PRIVATE) {
126+
if (!$page_owner instanceof \ElggGroup || !(bool) $page_owner->admin_approval) {
127127
return null;
128128
}
129129

@@ -133,7 +133,7 @@ public static function pendingApproval(\Elgg\Event $event): ?MenuItems {
133133
'trash',
134134
];
135135

136-
/* @var $return MenuItems */
136+
/** @var MenuItems $return */
137137
$return = $event->getValue();
138138

139139
// cleanup all items
@@ -203,7 +203,7 @@ public static function conceptGroup(\Elgg\Event $event): ?MenuItems {
203203
}
204204

205205
$page_owner = elgg_get_page_owner_entity();
206-
if (!$page_owner instanceof \ElggGroup || $page_owner->access_id !== ACCESS_PRIVATE || !(bool) $page_owner->is_concept) {
206+
if (!$page_owner instanceof \ElggGroup || !(bool) $page_owner->is_concept) {
207207
return null;
208208
}
209209

@@ -215,7 +215,7 @@ public static function conceptGroup(\Elgg\Event $event): ?MenuItems {
215215
'opensearch_inspect', // OpenSearch
216216
];
217217

218-
/* @var $return MenuItems */
218+
/** @var MenuItems $return */
219219
$return = $event->getValue();
220220

221221
// cleanup all items
@@ -282,7 +282,7 @@ public static function addGroupToolPresets(\Elgg\Event $event): ?MenuItems {
282282
return null;
283283
}
284284

285-
/* @var $return MenuItems */
285+
/** @var MenuItems $return */
286286
$return = $event->getValue();
287287

288288
$add_button = $return->get('add');

classes/ColdTrick/GroupTools/Notifications.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ public static function sendConfirmationOfGroupAdminApprovalToOwner(\Elgg\Event $
2323
}
2424

2525
$object = $notification_event->getObject();
26-
if ($notification_event->getAction() !== 'admin_approval' || !$object instanceof \ElggGroup || $object->access_id !== ACCESS_PRIVATE) {
26+
if ($notification_event->getAction() !== 'admin_approval' || !$object instanceof \ElggGroup || !(bool) $object->admin_approval) {
2727
return;
2828
}
2929

30-
/* @var $owner \ElggUser */
30+
/** @var \ElggUser $owner */
3131
$owner = $object->getOwnerEntity();
3232

3333
$owner->notify('admin_approval:owner', $object);

classes/ColdTrick/GroupTools/Notifications/AddUserHandler.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace ColdTrick\GroupTools\Notifications;
44

5+
use Elgg\Notifications\InstantNotificationEvent;
56
use Elgg\Notifications\InstantNotificationEventHandler;
67

78
/**
@@ -38,7 +39,7 @@ protected function getNotificationSummary(\ElggUser $recipient, string $method):
3839
*/
3940
protected function getNotificationBody(\ElggUser $recipient, string $method): string {
4041
$group = $this->getEventEntity();
41-
$actor = $this->getEventActor();
42+
$actor = ($this->event instanceof InstantNotificationEvent) ? elgg_get_logged_in_user_entity() : $this->getEventActor();
4243
if (!$group instanceof \ElggGroup || !$actor instanceof \ElggUser) {
4344
return parent::getNotificationBody($recipient, $method);
4445
}

classes/ColdTrick/GroupTools/Notifications/GroupOwnerTransferHandler.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace ColdTrick\GroupTools\Notifications;
44

5+
use Elgg\Notifications\InstantNotificationEvent;
56
use Elgg\Notifications\InstantNotificationEventHandler;
67

78
/**
@@ -38,7 +39,7 @@ protected function getNotificationSummary(\ElggUser $recipient, string $method):
3839
*/
3940
protected function getNotificationBody(\ElggUser $recipient, string $method): string {
4041
$group = $this->getEventEntity();
41-
$actor = $this->getEventActor();
42+
$actor = ($this->event instanceof InstantNotificationEvent) ? elgg_get_logged_in_user_entity() : $this->getEventActor();
4243
if (!$group instanceof \ElggGroup || !$actor instanceof \ElggUser) {
4344
return parent::getNotificationBody($recipient, $method);
4445
}

classes/ColdTrick/GroupTools/Notifications/InviteGroupHandler.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace ColdTrick\GroupTools\Notifications;
44

5+
use Elgg\Notifications\InstantNotificationEvent;
56
use Elgg\Notifications\InstantNotificationEventHandler;
67

78
/**
@@ -46,7 +47,8 @@ protected function getNotificationSummary(\ElggUser $recipient, string $method):
4647
*/
4748
protected function getNotificationBody(\ElggUser $recipient, string $method): string {
4849
$group = $this->getEventEntity();
49-
$actor = $this->getEventActor();
50+
$actor = ($this->event instanceof InstantNotificationEvent) ? elgg_get_logged_in_user_entity() : $this->getEventActor();
51+
5052
if (!$group instanceof \ElggGroup || !$actor instanceof \ElggUser) {
5153
return parent::getNotificationBody($recipient, $method);
5254
}

0 commit comments

Comments
 (0)