Skip to content

Commit

Permalink
chore: support Elgg 6
Browse files Browse the repository at this point in the history
  • Loading branch information
jeabakker committed Jun 3, 2024
1 parent 664149f commit c2955cd
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ name: PHPUnit Plugin Tests
on: [push, pull_request]

jobs:
lint:
name: Run PHPUnit test suites
phpunit5:
name: Run PHPUnit test suites - Elgg 5
uses: ColdTrick/.github/.github/workflows/phpunit.yml@master
phpunit6:
name: Run PHPUnit test suites - Elgg 6
uses: ColdTrick/.github/.github/workflows/phpunit.yml@master
with:
elgg_major_version: 6
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Test Panel
==========

![Elgg 5.0](https://img.shields.io/badge/Elgg-5.0-green.svg)
![Elgg 6.0](https://img.shields.io/badge/Elgg-6.0-green.svg)
![Lint Checks](https://github.com/ColdTrick/test_panel/actions/workflows/lint.yml/badge.svg?event=push)
[![Latest Stable Version](https://poser.pugx.org/coldtrick/test_panel/v/stable.svg)](https://packagist.org/packages/coldtrick/test_panel)
[![License](https://poser.pugx.org/coldtrick/test_panel/license.svg)](https://packagist.org/packages/coldtrick/test_panel)
Expand Down
2 changes: 1 addition & 1 deletion classes/ColdTrick/TestPanel/EmailHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static function validate(\Elgg\Event $event): ?bool {
}

$allowed_emails = test_panel_get_panel_members_email_addresses();
if (empty($allowed_emails) || !is_array($allowed_emails)) {
if (empty($allowed_emails)) {
// nobody is allowed (shouldn't happen)
return false;
}
Expand Down
14 changes: 8 additions & 6 deletions lib/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* All helper functions are bundled here
*/

use Elgg\Database\MetadataTable;
use Elgg\Database\RelationshipsTable;
use Elgg\Database\Select;

/**
Expand Down Expand Up @@ -41,12 +43,12 @@ function test_panel_get_panel_members_email_addresses(): array {

$result = [];

$select = Select::fromTable('metadata', 'md');
$select->select('md.value');
$select->joinEntitiesTable('md', 'entity_guid', 'inner', 'e');
$select = Select::fromTable(MetadataTable::TABLE_NAME, 'md');
$select->select("{$select->getTableAlias()}.value");
$select->joinEntitiesTable($select->getTableAlias(), 'entity_guid', 'inner', 'e');
$select->joinMetadataTable('e', 'guid', null, 'inner', 'mda');
$select->andWhere($select->compare('e.type', '=', 'user', ELGG_VALUE_STRING));
$select->andWhere($select->compare('md.name', '=', 'email', ELGG_VALUE_STRING));
$select->andWhere($select->compare("{$select->getTableAlias()}.name", '=', 'email', ELGG_VALUE_STRING));

// admins
$ands = $select->merge([
Expand All @@ -57,12 +59,12 @@ function test_panel_get_panel_members_email_addresses(): array {
// or group member
$group_guids = test_panel_get_group_guids();
if (!empty($group_guids)) {
$group_members = $select->subquery('entity_relationships');
$group_members = $select->subquery(RelationshipsTable::TABLE_NAME);
$group_members->select('guid_one')
->where($select->compare('relationship', '=', 'member', ELGG_VALUE_STRING))
->andWhere($select->compare('guid_two', 'in', $group_guids, ELGG_VALUE_GUID));

$or = $select->compare('md.entity_guid', 'in', $group_members->getSQL());
$or = $select->compare("{$select->getTableAlias()}.entity_guid", 'in', $group_members->getSQL());

$ands = $select->merge([$ands, $or], 'OR');
}
Expand Down
5 changes: 2 additions & 3 deletions views/default/plugins/test_panel/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
'switch' => true,
]);

$title = elgg_echo('test_panel:settings:message');

// message to non-test members
$content = elgg_view_field([
'#type' => 'text',
'#label' => elgg_echo('test_panel:settings:message_title'),
Expand All @@ -42,4 +41,4 @@
'value' => $plugin->message_content ?? elgg_echo('limited_access'),
]);

echo elgg_view_module('info', $title, $content);
echo elgg_view_module('info', elgg_echo('test_panel:settings:message'), $content);

0 comments on commit c2955cd

Please sign in to comment.