Skip to content

Commit

Permalink
changed: updated for Elgg 5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jeabakker committed Oct 27, 2023
1 parent e5bf990 commit 26d89da
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 45 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Group Tools
===========

![Elgg 5.0](https://img.shields.io/badge/Elgg-5.0-green.svg)
![Elgg 5.1](https://img.shields.io/badge/Elgg-5.1-green.svg)
![Lint Checks](https://github.com/ColdTrick/group_tools/actions/workflows/lint.yml/badge.svg?event=push)
[![Latest Stable Version](https://poser.pugx.org/coldtrick/group_tools/v/stable.svg)](https://packagist.org/packages/coldtrick/group_tools)
[![License](https://poser.pugx.org/coldtrick/group_tools/license.svg)](https://packagist.org/packages/coldtrick/group_tools)
Expand Down
2 changes: 1 addition & 1 deletion actions/groups/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
// Invisible group support + admin approve check
// @todo this requires save to be called to create the acl for the group. This
// is an odd requirement and should be removed. Either the acl creation happens
// in the action or the visibility moves to a plugin hook
// in the action or the visibility moves to an event handler
$admin_approve = (bool) (elgg_get_plugin_setting('admin_approve', 'group_tools') == 'yes');
$admin_approve = ($admin_approve && !elgg_is_admin_logged_in()); // admins don't need to wait

Expand Down
22 changes: 0 additions & 22 deletions classes/ColdTrick/GroupTools/Cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,13 @@ class Cron {
* @return void
*/
public static function notifyStaleGroupOwners(\Elgg\Event $event): void {
echo 'Starting GroupTools stale group owners' . PHP_EOL;
elgg_log('Starting GroupTools stale group owners', 'NOTICE');

$time = (int) $event->getParam('time', time());

// get stale groups
$groups = elgg_call(ELGG_IGNORE_ACCESS, function() use ($time) {
return self::findStaleGroups($time);
});
if (empty($groups)) {
// non found
echo 'Done with GroupTools stale group owners' . PHP_EOL;
elgg_log('Done with GroupTools stale group owners', 'NOTICE');

return;
}

Expand All @@ -53,9 +46,6 @@ public static function notifyStaleGroupOwners(\Elgg\Event $event): void {
self::notifyStaleGroupOwner($group);
}
});

echo 'Done with GroupTools stale group owners' . PHP_EOL;
elgg_log('Done with GroupTools stale group owners', 'NOTICE');
}

/**
Expand Down Expand Up @@ -249,9 +239,6 @@ public static function removeExpiredConceptGroups(\Elgg\Event $event): void {
return;
}

echo 'Starting concept group cleanup' . PHP_EOL;
elgg_log('Starting concept group cleanup', 'NOTICE');

elgg_call(ELGG_IGNORE_ACCESS, function() use ($days) {
/* @var $groups \ElggBatch */
$groups = elgg_get_entities([
Expand All @@ -273,9 +260,6 @@ public static function removeExpiredConceptGroups(\Elgg\Event $event): void {
}
}
});

echo 'Done with concept group cleanup' . PHP_EOL;
elgg_log('Done with concept group cleanup', 'NOTICE');
}

/**
Expand All @@ -292,9 +276,6 @@ public static function notifyConceptGroupOwners(\Elgg\Event $event): void {

$days = (int) elgg_get_plugin_setting('concept_groups_retention', 'group_tools');

echo 'Starting concept group owner notification' . PHP_EOL;
elgg_log('Starting concept group owner notification', 'NOTICE');

elgg_call(ELGG_IGNORE_ACCESS, function() use ($days) {
$site = elgg_get_site_entity();
$current_language = elgg()->translator->getCurrentLanguage();
Expand Down Expand Up @@ -347,8 +328,5 @@ public static function notifyConceptGroupOwners(\Elgg\Event $event): void {
// restore language
elgg()->translator->setCurrentLanguage($current_language);
});

echo 'Done with concept group owner notification' . PHP_EOL;
elgg_log('Done with concept group owner notification', 'NOTICE');
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"composer/installers": "^1.0.8"
},
"conflict": {
"elgg/elgg": "<5.0"
"elgg/elgg": "<5.1"
},
"config": {
"allow-plugins": {
Expand Down
4 changes: 2 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
function group_tools_check_group_email_invitation(string $invite_code, int $group_guid = 0): ?\ElggGroup {
if (empty($invite_code) || !Base64Url::decode($invite_code)) {
return false;
return null;
}

$options = [
Expand Down
2 changes: 1 addition & 1 deletion views/default/forms/group_tools/mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
'show_friends' => false,
'handler' => 'livesearch/group_members',
'options' => [
'match_target' => $group->guid,
'group_guid' => $group->guid,
],
],
[
Expand Down
3 changes: 1 addition & 2 deletions views/default/resources/groups/email_invitations.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
/* @var $group \ElggGroup */
$group = elgg_get_page_owner_entity();

elgg_push_breadcrumb(elgg_echo('groups'), elgg_generate_url('collection:group:group:all'));
elgg_push_breadcrumb($group->getDisplayName(), $group->getURL());
elgg_push_entity_breadcrumbs($group);

// additional title menu item
if ($group->canEdit() && elgg_is_active_plugin('friends')) {
Expand Down
3 changes: 1 addition & 2 deletions views/default/resources/groups/invite.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
throw $ex;
}

elgg_push_breadcrumb(elgg_echo('groups'), elgg_generate_url('collection:group:group:all'));
elgg_push_breadcrumb($group->getDisplayName(), $group->getURL());
elgg_push_entity_breadcrumbs($group);

$content = elgg_view_form('groups/invite', [
'id' => 'invite_to_group',
Expand Down
3 changes: 1 addition & 2 deletions views/default/resources/groups/mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
elgg_set_context('groups');

// set breadcrumb
elgg_push_breadcrumb(elgg_echo('groups'), elgg_generate_url('collection:group:group:all'));
elgg_push_breadcrumb($group->getDisplayName(), $group->getURL());
elgg_push_entity_breadcrumbs($group);

// build page elements
$form_vars = [
Expand Down
3 changes: 1 addition & 2 deletions views/default/resources/groups/members.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

$group = elgg_get_page_owner_entity();

elgg_push_breadcrumb(elgg_echo('groups'), elgg_generate_url('collection:group:group:all'));
elgg_push_breadcrumb($group->getDisplayName(), $group->getURL());
elgg_push_entity_breadcrumbs($group);

if ($group->canEdit() && elgg_is_active_plugin('friends')) {
elgg_register_menu_item('title', [
Expand Down
3 changes: 1 addition & 2 deletions views/default/resources/groups/related.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
$group = elgg_get_page_owner_entity();

// build breadcrumb
elgg_push_breadcrumb(elgg_echo('groups'), elgg_generate_url('collection:group:group:all'));
elgg_push_breadcrumb($group->getDisplayName(), $group->getURL());
elgg_push_entity_breadcrumbs($group);

// page elements
$content = '';
Expand Down
22 changes: 16 additions & 6 deletions views/json/resources/livesearch/group_members.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
<?php
/**
* Livesearch endpoint to search for users who are a member of the provided group
*
* @uses $vars['limit'] (int) number of results to return
* @uses $vars['term'] (string) search term (for username and displayname)
* @uses $vars['name'] (string) the input name to be used when submitting the selected value
* @uses $vars['group_guid'] (int) the GUID of the group to search members in
*
* @throws Elgg\Exceptions\Http\EntityNotFoundException if the group_guid doesn't match a group
*/

use Elgg\Exceptions\Http\EntityNotFoundException;

Expand All @@ -7,16 +17,19 @@
$limit = (int) elgg_extract('limit', $vars, elgg_get_config('default_limit'));
$query = elgg_extract('term', $vars, elgg_extract('q', $vars));
$input_name = elgg_extract('name', $vars);
$target_guid = (int) elgg_extract('match_target', $vars);
$group_guid = (int) elgg_extract('group_guid', $vars);

$target = get_entity($target_guid);
if (!$target instanceof \ElggGroup) {
$group = get_entity($group_guid);
if (!$group instanceof ElggGroup) {
throw new EntityNotFoundException();
}

$options = [
'query' => $query,
'type' => 'user',
'relationship' => 'member',
'relationship_guid' => $group_guid,
'inverse_relationship' => true,
'limit' => $limit,
'sort_by' => [
'property_type' => 'metadata',
Expand All @@ -26,9 +39,6 @@
'fields' => ['metadata' => ['name', 'username']],
'item_view' => elgg_extract('item_view', $vars, 'search/entity'),
'input_name' => $input_name,
'relationship' => 'member',
'relationship_guid' => $target->guid,
'inverse_relationship' => true,
];

// by default search in all users,
Expand Down

0 comments on commit 26d89da

Please sign in to comment.