├── .github
└── workflows
│ ├── create-zip-release.yml
│ ├── lint.yml
│ ├── phpunit.yml
│ └── tweet-release.yml
├── .gitignore
├── CHANGES.txt
├── README.md
├── actions
├── group_tools
│ ├── admin
│ │ ├── approve.php
│ │ ├── auto_join
│ │ │ ├── additional.php
│ │ │ ├── default.php
│ │ │ └── delete.php
│ │ ├── bulk_delete.php
│ │ ├── decline.php
│ │ ├── disable_notifications.php
│ │ ├── group_tool_presets.php
│ │ ├── notifications.php
│ │ └── toggle_special_state.php
│ ├── join_motivation.php
│ ├── mail.php
│ ├── mark_not_stale.php
│ ├── order_groups.php
│ ├── related_groups.php
│ ├── remove_concept_status.php
│ ├── remove_related_groups.php
│ ├── revoke_email_invitation.php
│ ├── toggle_admin.php
│ └── toggle_notifications.php
└── groups
│ ├── decline_email_invitation.php
│ ├── edit.php
│ ├── email_invitation.php
│ └── invite.php
├── classes
├── ColdTrick
│ └── GroupTools
│ │ ├── AutoJoin.php
│ │ ├── Bootstrap.php
│ │ ├── Cron.php
│ │ ├── GroupAdmins.php
│ │ ├── GroupMail.php
│ │ ├── Membership.php
│ │ ├── Menus
│ │ ├── AdminHeader.php
│ │ ├── Annotation.php
│ │ ├── Entity.php
│ │ ├── Filter.php
│ │ ├── Filter
│ │ │ ├── GroupsAll.php
│ │ │ └── GroupsMembers.php
│ │ ├── OwnerBlock.php
│ │ ├── Page.php
│ │ ├── Relationship.php
│ │ └── Title.php
│ │ ├── Notifications.php
│ │ ├── Notifications
│ │ ├── GroupAdminApprovalNotificationHandler.php
│ │ └── GroupMailEnqueueNotificationEventHandler.php
│ │ ├── PageLayout.php
│ │ ├── Permissions.php
│ │ ├── PluginSettings.php
│ │ ├── Plugins
│ │ ├── CSVExporter.php
│ │ ├── Groups.php
│ │ ├── ProfileManager.php
│ │ └── WidgetManager.php
│ │ ├── Router
│ │ └── GroupInviteRegistrationGatekeeper.php
│ │ ├── StaleInfo.php
│ │ ├── Upgrades
│ │ └── MigrateNotificationSettings.php
│ │ ├── Views.php
│ │ └── Widgets.php
└── GroupMail.php
├── composer.json
├── composer.lock
├── elgg-plugin.php
├── languages
├── en.php
├── es.php
├── fr.php
├── nl.php
└── pt_br.php
├── lib
└── functions.php
└── views
└── default
├── admin
└── groups
│ ├── admin_approval.php
│ ├── auto_join.php
│ ├── auto_join
│ ├── additional.php
│ ├── default.php
│ └── exclusive.php
│ ├── bulk_delete.mjs
│ ├── bulk_delete.php
│ ├── featured.php
│ ├── suggested.php
│ └── tool_presets.php
├── annotation
├── approval_reason.php
└── email_invitation.php
├── forms
├── group_tools
│ ├── admin
│ │ ├── auto_join
│ │ │ ├── additional.mjs
│ │ │ ├── additional.php
│ │ │ └── default.php
│ │ └── decline.php
│ ├── group_tool_presets.mjs
│ ├── group_tool_presets.php
│ ├── join_motivation.php
│ ├── mail.mjs
│ ├── mail.php
│ ├── members_search.mjs
│ ├── members_search.php
│ └── related_groups.php
└── groups
│ ├── edit.mjs
│ ├── edit.php
│ ├── email_invitation.php
│ ├── invite.php
│ ├── killrequest.mjs
│ └── killrequest.php
├── group_tools
├── admin.css
├── elements
│ ├── auto_join_configuration.php
│ ├── auto_join_match_pattern.php
│ └── group_tool_preset.php
├── extends
│ └── groups
│ │ ├── edit
│ │ ├── admin_approve.php
│ │ └── settings
│ │ │ ├── domain_based.php
│ │ │ ├── notifications.mjs
│ │ │ ├── notifications.php
│ │ │ └── welcome_message.php
│ │ └── profile
│ │ ├── concept.php
│ │ ├── stale_message.mjs
│ │ └── stale_message.php
├── forms
│ ├── admin_transfer.php
│ └── motivation.php
├── group
│ ├── admin_approve.php
│ ├── reasons.php
│ ├── suggested.php
│ └── suggested
│ │ └── entity.php
├── group_admins.php
├── invitationrequests
│ ├── emailinvitations.php
│ └── emailinviteform.php
├── invite
│ ├── csv.php
│ ├── email.mjs
│ ├── email.php
│ └── users.php
├── notifications
│ └── settings.php
├── register_extend.php
└── site.css
├── groups
├── edit
│ ├── access.php
│ ├── access_simplified.mjs
│ ├── access_simplified.php
│ ├── reason.php
│ ├── tool.php
│ ├── tools.php
│ └── tools
│ │ ├── default.php
│ │ ├── normal.mjs
│ │ ├── normal.php
│ │ ├── simple.mjs
│ │ └── simple.php
├── listing
│ ├── closed.php
│ ├── managed.php
│ ├── member.php
│ ├── open.php
│ ├── preset.php
│ ├── suggested.php
│ └── yours.php
└── profile
│ └── module
│ └── related_groups.php
├── input
└── group_tools_preset.php
├── output
└── group_tools_preset.php
├── plugins
└── group_tools
│ └── settings.php
├── resources
└── groups
│ ├── all.php
│ ├── email_invitations.php
│ ├── invite.php
│ ├── mail.php
│ ├── members.php
│ ├── related.php
│ └── user
│ └── email_invitations.php
└── widgets
├── a_users_groups
├── content.php
└── edit.php
├── featured_groups
├── content.php
└── edit.php
├── group_invitations
└── content.php
├── group_members
├── content.php
└── edit.php
├── group_related
├── content.php
└── edit.php
├── group_river_widget
├── content.php
└── edit.php
└── index_groups
├── content.php
└── edit.php
/.github/workflows/create-zip-release.yml:
--------------------------------------------------------------------------------
1 | name: Create ZIP Release
2 |
3 | on:
4 | release:
5 | types: [created, edited]
6 |
7 | jobs:
8 | build:
9 | name: Build release
10 | uses: ColdTrick/.github/.github/workflows/create-zip-release.yml@master
11 |
--------------------------------------------------------------------------------
/.github/workflows/lint.yml:
--------------------------------------------------------------------------------
1 | name: Lint checks
2 |
3 | on: [push, pull_request]
4 |
5 | jobs:
6 | lint:
7 | name: Lint checks
8 | uses: ColdTrick/.github/.github/workflows/lint.yml@master
9 |
--------------------------------------------------------------------------------
/.github/workflows/phpunit.yml:
--------------------------------------------------------------------------------
1 | name: PHPUnit Plugin Tests
2 |
3 | on: [push, pull_request]
4 |
5 | jobs:
6 | phpunit:
7 | name: Run PHPUnit test suites
8 | uses: ColdTrick/.github/.github/workflows/phpunit.yml@master
9 | with:
10 | elgg_major_version: 6
11 |
--------------------------------------------------------------------------------
/.github/workflows/tweet-release.yml:
--------------------------------------------------------------------------------
1 | name: Tweet about a new release
2 |
3 | on:
4 | release:
5 | types: [created]
6 |
7 | jobs:
8 | tweet:
9 | name: Send a Tweet
10 | uses: ColdTrick/.github/.github/workflows/tweet-release.yml@master
11 | secrets: inherit
12 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /vendor/
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Group Tools
2 | ===========
3 |
4 | 
5 | 
6 | [](https://packagist.org/packages/coldtrick/group_tools)
7 | [](https://packagist.org/packages/coldtrick/group_tools)
8 |
9 | Combines different group additions into one plugin
10 |
11 | Features
12 | --------
13 |
14 | - group multiple admin
15 | - group activity (profile,dashboard,index,group widget)
16 | - can show more than one group activity
17 | - has support for river_comments and like
18 | - group members widget (group only)
19 | - group invitations widget (index, dashboard)
20 | - group mail (requires a working Elgg cron setup)
21 | - group invite
22 | - better error messages
23 | - free text with invite
24 | - listing of outstanding invitations
25 | - personal invitation revoke
26 | - add users to group
27 | - all users (admin option)
28 | - import users from csv
29 | - group listing
30 | - alphabetical
31 |
--------------------------------------------------------------------------------
/actions/group_tools/admin/approve.php:
--------------------------------------------------------------------------------
1 | intended_access_id;
17 | if ($intended_access_id !== null) {
18 | $access_id = (int) $intended_access_id;
19 | }
20 |
21 | if ($access_id === ACCESS_PRIVATE) {
22 | $group_acl = $group->getOwnedAccessCollection('group_acl');
23 |
24 | $access_id = ($group_acl instanceof \ElggAccessCollection) ? (int) $group_acl->id : ACCESS_LOGGED_IN;
25 | }
26 | }
27 |
28 | // save access
29 | $group->access_id = $access_id;
30 | $group->save();
31 |
32 | // unset temp access
33 | unset($group->intended_access_id);
34 |
35 | // notify owner
36 | /* @var $owner \ElggUser */
37 | $owner = $group->getOwnerEntity();
38 |
39 | $subject = elgg_echo('group_tools:group:admin_approve:approve:subject', [$group->getDisplayName()], $owner->getLanguage());
40 | $summary = elgg_echo('group_tools:group:admin_approve:approve:summary', [$group->getDisplayName()], $owner->getLanguage());
41 | $message = elgg_echo('group_tools:group:admin_approve:approve:message', [
42 | $group->getDisplayName(),
43 | $group->getURL(),
44 | ], $owner->getLanguage());
45 |
46 | $params = [
47 | 'object' => $group,
48 | 'action' => 'approve',
49 | 'summary' => $summary,
50 | ];
51 | notify_user($owner->guid, elgg_get_logged_in_user_guid(), $subject, $message, $params);
52 |
53 | // report success
54 | return elgg_ok_response('', elgg_echo('group_tools:group:admin_approve:approve:success'));
55 |
--------------------------------------------------------------------------------
/actions/group_tools/admin/auto_join/additional.php:
--------------------------------------------------------------------------------
1 | $value) {
18 | if (!isset($value) || $value === '') {
19 | continue;
20 | }
21 |
22 | $operand = elgg_extract($index, $operands);
23 | if ($operand === 'pregmatch') {
24 | $valid = @preg_match('/' . $value . '/', '');
25 | if ($valid === false) {
26 | return elgg_error_response(elgg_echo('group_tools:action:admin:auto_join:additional:error:pregmatch'));
27 | }
28 | }
29 |
30 | $patterns[] = [
31 | 'field' => elgg_extract($index, $fields),
32 | 'operand' => $operand,
33 | 'value' => $value,
34 | ];
35 | }
36 |
37 | $config = [
38 | 'id' => $id,
39 | 'type' => $type,
40 | 'title' => $title,
41 | 'group_guids' => (array) get_input('group_guids', []),
42 | 'patterns' => $patterns,
43 | ];
44 |
45 | if (group_tools_save_auto_join_configuration($config)) {
46 | return elgg_ok_response('', elgg_echo('save:success'), REFERRER);
47 | }
48 |
49 | return elgg_error_response(elgg_echo('save:fail'));
50 |
--------------------------------------------------------------------------------
/actions/group_tools/admin/auto_join/default.php:
--------------------------------------------------------------------------------
1 | unsetSetting('auto_join');
19 | } else {
20 | $plugin->setSetting('auto_join', implode(',', $group_guids));
21 | }
22 |
23 | return elgg_ok_response('', elgg_echo('save:success'));
24 |
--------------------------------------------------------------------------------
/actions/group_tools/admin/auto_join/delete.php:
--------------------------------------------------------------------------------
1 | 'group',
14 | 'guids' => $group_guids,
15 | 'limit' => false,
16 | 'batch' => true,
17 | 'batch_inc_offset' => false,
18 | ]);
19 |
20 | $failure = false;
21 | /* @var $group \ElggGroup */
22 | foreach ($batch as $group) {
23 | if (!$group->delete()) {
24 | $failure = true;
25 | $batch->reportFailure();
26 | }
27 | }
28 |
29 | if ($failure) {
30 | return elgg_error_response(elgg_echo('group_tools:action:bulk_delete:error'));
31 | }
32 |
33 | return elgg_ok_response('', elgg_echo('group_tools:action:bulk_delete:success'));
34 |
--------------------------------------------------------------------------------
/actions/group_tools/admin/decline.php:
--------------------------------------------------------------------------------
1 | getOwnerEntity();
16 |
17 | $subject = elgg_echo('group_tools:group:admin_approve:decline:subject', [$group->getDisplayName()], $owner->getLanguage());
18 | $summary = elgg_echo('group_tools:group:admin_approve:decline:summary', [$group->getDisplayName()], $owner->getLanguage());
19 | $message = elgg_echo('group_tools:group:admin_approve:decline:message', [
20 | $group->getDisplayName(),
21 | $reason,
22 | ], $owner->getLanguage());
23 |
24 | $params = [
25 | 'summary' => $summary,
26 | ];
27 | notify_user($owner->guid, elgg_get_logged_in_user_guid(), $subject, $message, $params);
28 |
29 | // correct forward url
30 | $forward_url = REFERRER;
31 | if (stristr($_SERVER['HTTP_REFERER'], $group->getURL()) !== false) {
32 | $forward_url = elgg_generate_url('default:group:group');
33 | }
34 |
35 | // delete group
36 | $group->delete();
37 |
38 | // report success
39 | return elgg_ok_response('', elgg_echo('group_tools:group:admin_approve:decline:success'), $forward_url);
40 |
--------------------------------------------------------------------------------
/actions/group_tools/admin/disable_notifications.php:
--------------------------------------------------------------------------------
1 | getMembers(['count' => true]);
18 | if (empty($members_count)) {
19 | return elgg_ok_response('', '', $group->getURL());
20 | }
21 |
22 | /* @var $members \ElggBatch */
23 | $members = $group->getMembers(['limit' => false, 'batch' => true]);
24 |
25 | // disable notification for everyone
26 | /* @var $member \ElggUser */
27 | foreach ($members as $member) {
28 | $group->removeSubscriptions($member->guid);
29 | }
30 |
31 | return elgg_ok_response('', elgg_echo('group_tools:action:notifications:success:disable'), $group->getURL());
32 |
--------------------------------------------------------------------------------
/actions/group_tools/admin/group_tool_presets.php:
--------------------------------------------------------------------------------
1 | $values) {
7 | if (!is_numeric($index)) {
8 | // the placeholder for cloning
9 | unset($presets[$index]);
10 | } elseif (!elgg_extract('title', $values)) {
11 | // title is required
12 | unset($presets[$index]);
13 | }
14 | }
15 |
16 | // reset array keys
17 | if (!empty($presets)) {
18 | $presets = array_values($presets);
19 | }
20 |
21 | $plugin = elgg_get_plugin_from_id('group_tools');
22 | $plugin->setSetting('group_tool_presets', json_encode($presets));
23 |
24 | return elgg_ok_response('', elgg_echo('group_tools:action:group_tool:presets:saved'));
25 |
--------------------------------------------------------------------------------
/actions/group_tools/admin/notifications.php:
--------------------------------------------------------------------------------
1 | canEdit()) {
13 | return elgg_error_response(elgg_echo('actionunauthorized'));
14 | }
15 |
16 | // also apply the new settings to all group members
17 | /* @var $members \ElggBatch */
18 | $members = $entity->getMembers([
19 | 'limit' => false,
20 | 'batch' => true,
21 | ]);
22 | $methods = elgg_get_notification_methods();
23 | $selected_methods = (array) get_input('group_tools_change_notification_settings', []);
24 |
25 | /* @var $member \ElggUser */
26 | foreach ($members as $member) {
27 | foreach ($methods as $method) {
28 | if (in_array($method, $selected_methods)) {
29 | $entity->addSubscription($member->guid, $method);
30 | } else {
31 | $entity->removeSubscription($member->guid, $method);
32 | }
33 | }
34 | }
35 |
36 | return elgg_ok_response('', elgg_echo('save:success'), $entity->getURL());
37 |
--------------------------------------------------------------------------------
/actions/group_tools/admin/toggle_special_state.php:
--------------------------------------------------------------------------------
1 | canEdit()) {
15 | return elgg_error_response(elgg_echo('actionunauthorized'));
16 | }
17 |
18 | $plugin = elgg_get_plugin_from_id('group_tools');
19 |
20 | $result = false;
21 | $success_message = '';
22 | $error_message = '';
23 |
24 | switch ($state) {
25 | case 'suggested':
26 | $suggested_groups = [];
27 | $suggested_setting = $plugin->getSetting('suggested_groups');
28 | if (!empty($suggested_setting)) {
29 | $suggested_groups = elgg_string_to_array($suggested_setting);
30 | }
31 |
32 | $key = array_search($group_guid, $suggested_groups);
33 | if ($key !== false) {
34 | unset($suggested_groups[$key]);
35 | } else {
36 | $suggested_groups[] = $group_guid;
37 | }
38 |
39 | if (!empty($suggested_groups)) {
40 | $result = $plugin->setSetting('suggested_groups', implode(',', $suggested_groups));
41 | } else {
42 | $result = $plugin->unsetSetting('suggested_groups');
43 | }
44 |
45 | $success_message = elgg_echo('group_tools:action:toggle_special_state:suggested');
46 | $error_message = elgg_echo('group_tools:action:toggle_special_state:error:suggested');
47 |
48 | break;
49 | default:
50 | $error_message = elgg_echo('group_tools:action:toggle_special_state:error:state');
51 | break;
52 | }
53 |
54 | if (!$result) {
55 | return elgg_error_response($error_message);
56 | }
57 |
58 | return elgg_ok_response('', $success_message);
59 |
--------------------------------------------------------------------------------
/actions/group_tools/join_motivation.php:
--------------------------------------------------------------------------------
1 | addRelationship($group->guid, 'membership_request');
23 |
24 | // add motivation
25 | $group_acl = $group->getOwnedAccessCollection('group_acl');
26 | $access_id = ($group_acl instanceof \ElggAccessCollection) ? (int) $group_acl->id : ACCESS_LOGGED_IN;
27 | $group->annotate('join_motivation', $motivation, $access_id, $user->guid);
28 |
29 | // notify owner
30 | /* @var $owner \ElggUser */
31 | $owner = $group->getOwnerEntity();
32 |
33 | $url = elgg_generate_url('requests:group:group', [
34 | 'guid' => $group->guid,
35 | ]);
36 |
37 | $subject = elgg_echo('group_tools:join_motivation:notification:subject', [
38 | $user->getDisplayName(),
39 | $group->getDisplayName(),
40 | ], $owner->getLanguage());
41 | $summary = elgg_echo('group_tools:join_motivation:notification:summary', [
42 | $user->getDisplayName(),
43 | $group->getDisplayName(),
44 | ], $owner->getLanguage());
45 |
46 | $body = elgg_echo('group_tools:join_motivation:notification:body', [
47 | $user->getDisplayName(),
48 | $group->getDisplayName(),
49 | $motivation,
50 | $user->getURL(),
51 | $url,
52 | ], $owner->getLanguage());
53 |
54 | $params = [
55 | 'action' => 'membership_request',
56 | 'object' => $group,
57 | 'summary' => $summary,
58 | ];
59 |
60 | // Notify group owner
61 | notify_user($owner->guid, $user->guid, $subject, $body, $params);
62 |
63 | return elgg_ok_response('', elgg_echo('groups:joinrequestmade'));
64 |
--------------------------------------------------------------------------------
/actions/group_tools/mail.php:
--------------------------------------------------------------------------------
1 | getMembers([
28 | 'callback' => function($row) {
29 | return (int) $row->guid;
30 | },
31 | 'limit' => false,
32 | ]);
33 | } else {
34 | foreach ($user_guids as $index => $user_guid) {
35 | $user_guids[$index] = (int) $user_guid;
36 | }
37 |
38 | $user_guids = array_filter(array_unique($user_guids));
39 | }
40 |
41 | $group_mail = new \GroupMail();
42 | $group_mail->container_guid = $group_guid;
43 |
44 | $group_mail->title = $subject;
45 | $group_mail->description = $body;
46 |
47 | $group_mail->setRecipients($user_guids);
48 |
49 | $group_mail->enqueue();
50 |
51 | return elgg_ok_response('', elgg_echo('group_tools:action:mail:success'), $group->getURL());
52 |
--------------------------------------------------------------------------------
/actions/group_tools/mark_not_stale.php:
--------------------------------------------------------------------------------
1 | canEdit()) {
10 | return elgg_error_response(elgg_echo('actionunauthorized'));
11 | }
12 |
13 | $group->group_tools_stale_touch_ts = time();
14 |
15 | return elgg_ok_response('', elgg_echo('save:success'));
16 |
--------------------------------------------------------------------------------
/actions/group_tools/order_groups.php:
--------------------------------------------------------------------------------
1 | order = $order;
20 | $order++;
21 | }
22 |
23 | return elgg_ok_response();
24 |
--------------------------------------------------------------------------------
/actions/group_tools/related_groups.php:
--------------------------------------------------------------------------------
1 | canEdit()) {
24 | return elgg_error_response(elgg_echo('actionunauthorized'));
25 | }
26 |
27 | if ($group->guid === $related->guid) {
28 | return elgg_error_response(elgg_echo('group_tools:action:related_groups:error:same'));
29 | }
30 |
31 | // not already related?
32 | if ($group->hasRelationship($related->guid, 'related_group')) {
33 | return elgg_error_response(elgg_echo('group_tools:action:related_groups:error:already'));
34 | }
35 |
36 | if (!$group->addRelationship($related->guid, 'related_group')) {
37 | return elgg_error_response(elgg_echo('group_tools:action:related_groups:error:add'));
38 | }
39 |
40 | $logged_in_user = elgg_get_logged_in_user_entity();
41 |
42 | // notify the other owner about this
43 | if ($group->owner_guid !== $related->owner_guid && $related->owner_guid !== $logged_in_user->guid) {
44 | /* @var $related_owner \ElggUser */
45 | $related_owner = $related->getOwnerEntity();
46 |
47 | $subject = elgg_echo('group_tools:related_groups:notify:owner:subject', [], $related_owner->getLanguage());
48 | $message = elgg_echo('group_tools:related_groups:notify:owner:message', [
49 | $logged_in_user->getDisplayName(),
50 | $related->getDisplayName(),
51 | $group->getDisplayName(),
52 | ], $related_owner->getLanguage());
53 |
54 | $params = [
55 | 'action' => 'relate',
56 | 'object' => $related,
57 | ];
58 |
59 | notify_user($related_owner->guid, $logged_in_user->guid, $subject, $message, $params);
60 | }
61 |
62 | return elgg_ok_response('', elgg_echo('group_tools:action:related_groups:success'));
63 |
--------------------------------------------------------------------------------
/actions/group_tools/remove_concept_status.php:
--------------------------------------------------------------------------------
1 | is_concept) {
6 | return elgg_error_response(elgg_echo('error:missing_data'));
7 | }
8 |
9 | if (!$group->canEdit()) {
10 | return elgg_error_response(elgg_echo('actionunauthorized'));
11 | }
12 |
13 | // should the group be approved by and admin?
14 | 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');
20 |
21 | elgg_trigger_event('admin_approval', 'group', $group);
22 |
23 | return elgg_ok_response('', elgg_echo('group_tools:action:remove_concept_status:success:approval'));
24 | }
25 |
26 | // make visible
27 | $access_id = ACCESS_PUBLIC;
28 | if (group_tools_allow_hidden_groups()) {
29 | $intended_access_id = $group->intended_access_id;
30 | if ($intended_access_id !== null) {
31 | $access_id = (int) $intended_access_id;
32 | }
33 |
34 | if ($access_id === ACCESS_PRIVATE) {
35 | $group_acl = $group->getOwnedAccessCollection('group_acl');
36 |
37 | $access_id = ($group_acl instanceof \ElggAccessCollection) ? (int) $group_acl->id : ACCESS_LOGGED_IN;
38 | }
39 | }
40 |
41 | // save access
42 | $group->access_id = $access_id;
43 | $group->save();
44 |
45 | // unset temp access
46 | unset($group->intended_access_id);
47 |
48 | return elgg_ok_response('', elgg_echo('group_tools:action:remove_concept_status:success:published'));
49 |
--------------------------------------------------------------------------------
/actions/group_tools/remove_related_groups.php:
--------------------------------------------------------------------------------
1 | canEdit()) {
21 | return elgg_error_response(elgg_echo('actionunauthorized'));
22 | }
23 |
24 | // related?
25 | if (!$group->hasRelationship($related->guid, 'related_group')) {
26 | return elgg_error_response(elgg_echo('group_tools:action:remove_related_groups:error:not_related'));
27 | }
28 |
29 | if (!$group->removeRelationship($related->guid, 'related_group')) {
30 | return elgg_error_response(elgg_echo('group_tools:action:remove_related_groups:error:remove'));
31 | }
32 |
33 | return elgg_ok_response('', elgg_echo('group_tools:action:remove_related_groups:success'));
34 |
--------------------------------------------------------------------------------
/actions/group_tools/revoke_email_invitation.php:
--------------------------------------------------------------------------------
1 | name !== 'email_invitation') {
16 | return elgg_error_response(elgg_echo('error:missing_data'));
17 | }
18 |
19 | if (!$group->canEdit()) {
20 | return elgg_error_response(elgg_echo('actionunauthorized'));
21 | }
22 |
23 | if (!$annotation->delete()) {
24 | return elgg_error_response(elgg_echo('group_tools:action:revoke_email_invitation:error'));
25 | }
26 |
27 | return elgg_ok_response('', elgg_echo('group_tools:action:revoke_email_invitation:success'));
28 |
--------------------------------------------------------------------------------
/actions/group_tools/toggle_admin.php:
--------------------------------------------------------------------------------
1 | canEdit()) {
17 | return elgg_error_response(elgg_echo('actionunauthorized'));
18 | }
19 |
20 | if (!$group->isMember($user) || ($group->owner_guid === $user->guid)) {
21 | return elgg_error_response(elgg_echo('group_tools:action:toggle_admin:error:group'));
22 | }
23 |
24 | if (!$user->hasRelationship($group->guid, 'group_admin')) {
25 | // user is admin, so remove
26 | if ($user->addRelationship($group->guid, 'group_admin')) {
27 | return elgg_ok_response('', elgg_echo('group_tools:action:toggle_admin:success:add'));
28 | }
29 |
30 | return elgg_error_response(elgg_echo('group_tools:action:toggle_admin:error:add'));
31 | }
32 |
33 | // user is not admin, so add
34 | if ($user->removeRelationship($group->guid, 'group_admin')) {
35 | return elgg_ok_response('', elgg_echo('group_tools:action:toggle_admin:success:remove'));
36 | }
37 |
38 | return elgg_error_response(elgg_echo('group_tools:action:toggle_admin:error:remove'));
39 |
--------------------------------------------------------------------------------
/actions/group_tools/toggle_notifications.php:
--------------------------------------------------------------------------------
1 | removeSubscriptions($user->guid, $methods);
17 |
18 | return elgg_ok_response('', elgg_echo('group_tools:action:toggle_notifications:disabled', [$group->getDisplayName()]));
19 | }
20 |
21 | // user has no notification settings for this group and wishes to enable this
22 | $user_settings = $user->getNotificationSettings();
23 |
24 | $supported_notifications = elgg_get_notification_methods();
25 | $found = [];
26 | if (!empty($user_settings)) {
27 | // check current user settings
28 | foreach ($user_settings as $method => $value) {
29 | if (!in_array($method, $supported_notifications)) {
30 | continue;
31 | }
32 |
33 | if (!empty($value)) {
34 | $found[] = $method;
35 | }
36 | }
37 | }
38 |
39 | // user has no base notification settings
40 | if (empty($found)) {
41 | $found = $supported_notifications;
42 | }
43 |
44 | $group->addSubscription($user->guid, $found);
45 |
46 | return elgg_ok_response('', elgg_echo('group_tools:action:toggle_notifications:enabled', [$group->getDisplayName()]));
47 |
--------------------------------------------------------------------------------
/actions/groups/decline_email_invitation.php:
--------------------------------------------------------------------------------
1 | 'email_invitation',
17 | 'wheres' => [
18 | function(QueryBuilder $qb, $main_alias) use ($invitecode) {
19 | $ors = [
20 | $qb->compare("{$main_alias}.value", '=', $invitecode, ELGG_VALUE_STRING),
21 | $qb->compare("{$main_alias}.value", 'like', "{$invitecode}|%", ELGG_VALUE_STRING),
22 | ];
23 |
24 | return $qb->merge($ors, 'OR');
25 | },
26 | ],
27 | 'limit' => false,
28 | ]);
29 | });
30 |
31 | $forward_url = elgg_generate_url('collection:annotation:email_invitation:user', [
32 | 'username' => elgg_get_logged_in_user_entity()->username,
33 | ]);
34 |
35 | //forwarding to groups invitations page to remove invitecode query string
36 | if (!$deleted) {
37 | return elgg_error_response(elgg_echo('group_tools:action:groups:decline_email_invitation:error:delete'), $forward_url);
38 | }
39 |
40 | return elgg_ok_response('', elgg_echo('groups:invitekilled'), $forward_url);
41 |
--------------------------------------------------------------------------------
/actions/groups/email_invitation.php:
--------------------------------------------------------------------------------
1 | join($user)) {
20 | return elgg_error_response(elgg_echo('group_tools:action:groups:email_invitation:error:join', [$group->getDisplayName()]));
21 | }
22 |
23 | elgg_call(ELGG_IGNORE_ACCESS, function() use ($group, $invitecode) {
24 | elgg_delete_annotations([
25 | 'guid' => $group->guid,
26 | 'annotation_name' => 'email_invitation',
27 | 'wheres' => [
28 | function(QueryBuilder $qb, $main_alias) use ($invitecode) {
29 | $ors = [
30 | $qb->compare("{$main_alias}.value", '=', $invitecode, ELGG_VALUE_STRING),
31 | $qb->compare("{$main_alias}.value", 'like', "{$invitecode}|%", ELGG_VALUE_STRING),
32 | ];
33 |
34 | return $qb->merge($ors, 'OR');
35 | },
36 | ],
37 | 'annotation_owner_guid' => $group->guid,
38 | 'limit' => false,
39 | ]);
40 | });
41 |
42 | return elgg_ok_response('', elgg_echo('group_tools:action:groups:email_invitation:success'), $group->getURL());
43 |
--------------------------------------------------------------------------------
/actions/groups/invite.php:
--------------------------------------------------------------------------------
1 | 'user',
21 | 'limit' => false,
22 | 'callback' => function ($row) {
23 | return (int) $row->guid;
24 | },
25 | 'batch' => true,
26 | ]);
27 | }
28 |
29 | // add users directly?
30 | $adding = (bool) get_input('submit');
31 | }
32 |
33 | $group_guid = (int) get_input('group_guid');
34 | $text = get_input('comment', '');
35 |
36 | $emails = (array) get_input('user_guid_email');
37 | $emails = array_filter($emails);
38 |
39 | $csv = elgg_get_uploaded_file('csv');
40 |
41 | $resend = false;
42 | if (get_input('resend') === 'yes') {
43 | $resend = true;
44 | }
45 |
46 | $group = get_entity($group_guid);
47 | if (!$group instanceof \ElggGroup) {
48 | return elgg_error_response(elgg_echo('error:missing_data'));
49 | }
50 |
51 | if (empty($user_guids) && empty($emails) && empty($csv)) {
52 | return elgg_error_response(elgg_echo('error:missing_data'));
53 | }
54 |
55 | if (!$group->canEdit()) {
56 | return elgg_error_response(elgg_echo('actionunauthorized'));
57 | }
58 |
59 | // counters
60 | $already_invited = 0;
61 | $invited = 0;
62 | $member = 0;
63 | $join = 0;
64 |
65 | // show hidden (unvalidated) users
66 | elgg_call(ELGG_SHOW_DISABLED_ENTITIES, function() use ($text, $group, $user_guids, $adding, $emails, $csv, $resend, &$already_invited, &$invited, &$member, &$join) {
67 | // invite existing users
68 | if (!empty($user_guids)) {
69 | if (!$adding) {
70 | // invite users
71 | foreach ($user_guids as $u_id) {
72 | $user = get_user((int) $u_id);
73 | if (empty($user)) {
74 | continue;
75 | }
76 |
77 | if ($group->isMember($user)) {
78 | $member++;
79 | continue;
80 | }
81 |
82 | if ($group->hasRelationship($user->guid, 'invited') && !$resend) {
83 | // user was already invited
84 | $already_invited++;
85 | continue;
86 | }
87 |
88 | if (group_tools_invite_user($group, $user, $text, $resend)) {
89 | $invited++;
90 | }
91 | }
92 | } else {
93 | // add users directly
94 | foreach ($user_guids as $u_id) {
95 | $user = get_user((int) $u_id);
96 | if (empty($user)) {
97 | continue;
98 | }
99 |
100 | if ($group->isMember($user)) {
101 | $member++;
102 | continue;
103 | }
104 |
105 | if (group_tools_add_user($group, $user, $text)) {
106 | $join++;
107 | }
108 | }
109 | }
110 | }
111 |
112 | // Invite member by e-mail address
113 | if (!empty($emails)) {
114 | foreach ($emails as $email) {
115 | $invite_result = group_tools_invite_email($group, $email, $text, $resend);
116 | if ($invite_result === true) {
117 | $invited++;
118 | } elseif ($invite_result === null) {
119 | $already_invited++;
120 | }
121 | }
122 | }
123 |
124 | // invite from csv
125 | if ($csv instanceof UploadedFile) {
126 | // this could take a while
127 | set_time_limit(0);
128 |
129 | $fh = $csv->openFile('r');
130 | while (!$fh->eof()) {
131 | /*
132 | * data structure
133 | * data[0] => e-mail address
134 | */
135 | $data = $fh->fgetcsv(';');
136 |
137 | $email = '';
138 | if (isset($data[0])) {
139 | $email = trim($data[0]);
140 | }
141 |
142 | if (empty($email) || !elgg_is_valid_email($email)) {
143 | continue;
144 | }
145 |
146 | $user = elgg_get_user_by_email($email);
147 | if ($user instanceof \ElggUser) {
148 | // found a user with this email on the site, so invite (or add)
149 | if ($group->isMember($user)) {
150 | $member++;
151 | continue;
152 | }
153 |
154 | if ($adding) {
155 | if (group_tools_add_user($group, $user, $text)) {
156 | $join++;
157 | }
158 |
159 | continue;
160 | }
161 |
162 | if ($group->hasRelationship($user->guid, 'invited') && !$resend) {
163 | // user was already invited
164 | $already_invited++;
165 | continue;
166 | }
167 |
168 | // invite user
169 | if (group_tools_invite_user($group, $user, $text, $resend)) {
170 | $invited++;
171 | }
172 | } else {
173 | // user not found so invite based on email address
174 | $invite_result = group_tools_invite_email($group, $email, $text, $resend);
175 | if ($invite_result === true) {
176 | $invited++;
177 | } elseif ($invite_result === null) {
178 | $already_invited++;
179 | }
180 | }
181 | }
182 | }
183 | });
184 |
185 | // which message to show
186 | if (!empty($invited) || !empty($join)) {
187 | if (!$adding) {
188 | return elgg_ok_response('', elgg_echo('group_tools:action:invite:success:invite', [$invited, $already_invited, $member]));
189 | } else {
190 | return elgg_ok_response('', elgg_echo('group_tools:action:invite:success:add', [$join, $already_invited, $member]));
191 | }
192 | } else {
193 | if (!$adding) {
194 | return elgg_error_response(elgg_echo('group_tools:action:invite:error:invite', [$already_invited, $member]));
195 | } else {
196 | return elgg_error_response(elgg_echo('group_tools:action:invite:error:add', [$already_invited, $member]));
197 | }
198 | }
199 |
--------------------------------------------------------------------------------
/classes/ColdTrick/GroupTools/Bootstrap.php:
--------------------------------------------------------------------------------
1 | elgg()->events;
17 | $events->registerHandler('route:config', 'account:register', __NAMESPACE__ . '\Router\GroupInviteRegistrationGatekeeper::register');
18 | $events->registerHandler('route:config', 'action:register', __NAMESPACE__ . '\Router\GroupInviteRegistrationGatekeeper::register');
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/classes/ColdTrick/GroupTools/GroupAdmins.php:
--------------------------------------------------------------------------------
1 | getParam('event');
23 | if (!$notification_event instanceof NotificationEvent) {
24 | return null;
25 | }
26 |
27 | $action = $notification_event->getAction();
28 | $entity = $notification_event->getObject();
29 | if ($action !== 'membership_request' || !$entity instanceof \ElggGroup) {
30 | return null;
31 | }
32 |
33 | // only send a message if group admins are allowed
34 | if (!group_tools_multiple_admin_enabled()) {
35 | return null;
36 | }
37 |
38 | $group_subscriptions = elgg_get_subscriptions_for_container($entity->guid);
39 | if (empty($group_subscriptions)) {
40 | return null;
41 | }
42 |
43 | $return = $event->getValue();
44 |
45 | // get group admins
46 | $group_admins = elgg_get_entities([
47 | 'type' => 'user',
48 | 'relationship' => 'group_admin',
49 | 'relationship_guid' => $entity->guid,
50 | 'inverse_relationship' => true,
51 | 'limit' => false,
52 | 'wheres' => [
53 | function (QueryBuilder $qb, $main_alias) use ($entity) {
54 | return $qb->compare("{$main_alias}.guid", '!=', $entity->owner_guid, ELGG_VALUE_GUID);
55 | },
56 | ],
57 | 'batch' => true,
58 | ]);
59 | /* @var $group_admin \ElggUser */
60 | foreach ($group_admins as $group_admin) {
61 | if (!isset($group_subscriptions[$group_admin->guid])) {
62 | // group admin has no notification settings for this group
63 | continue;
64 | }
65 |
66 | if (isset($return[$group_admin->guid])) {
67 | // already in the subscribers, don't override settings
68 | continue;
69 | }
70 |
71 | $return[$group_admin->guid] = $group_subscriptions[$group_admin->guid];
72 | }
73 |
74 | return $return;
75 | }
76 |
77 | /**
78 | * Prepare the notification message to group admins when a membershiprequest is made
79 | *
80 | * @param \Elgg\Event $event 'prepare', 'notification:membership_request:group:group'
81 | *
82 | * @return null|Notification
83 | */
84 | public static function prepareMembershipRequestMessage(\Elgg\Event $event): ?Notification {
85 | $entity = $event->getParam('object');
86 | $recipient = $event->getParam('recipient'); // group admin (or owner)
87 | if (!$entity instanceof \ElggGroup || !$recipient instanceof \ElggUser) {
88 | return null;
89 | }
90 |
91 | if ($entity->owner_guid === $recipient->guid) {
92 | // owner, message already correct
93 | return null;
94 | }
95 |
96 | $sender = $event->getParam('sender'); // user requesting membership
97 |
98 | /* @var $return Notification */
99 | $return = $event->getValue();
100 |
101 | $return->body = elgg_echo('groups:request:body', [
102 | $sender->getDisplayName(),
103 | $entity->getDisplayName(),
104 | $sender->getURL(),
105 | $event->getParam('url'),
106 | ], $event->getParam('language'));
107 |
108 | return $return;
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/classes/ColdTrick/GroupTools/GroupMail.php:
--------------------------------------------------------------------------------
1 | getParam('event');
21 | if (!$notification_event instanceof SubscriptionNotificationEvent) {
22 | return;
23 | }
24 |
25 | if ($notification_event->getAction() !== 'enqueue') {
26 | return;
27 | }
28 |
29 | $object = $notification_event->getObject();
30 | if (!$object instanceof \GroupMail) {
31 | return;
32 | }
33 |
34 | // remove the mail from the database
35 | $object->delete();
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/classes/ColdTrick/GroupTools/Menus/AdminHeader.php:
--------------------------------------------------------------------------------
1 | getValue();
26 |
27 | $result[] = \ElggMenuItem::factory([
28 | 'name' => 'groups',
29 | 'text' => elgg_echo('admin:groups'),
30 | 'href' => false,
31 | ]);
32 |
33 | $result[] = \ElggMenuItem::factory([
34 | 'name' => 'groups:tool_presets',
35 | 'href' => 'admin/groups/tool_presets',
36 | 'text' => elgg_echo('admin:groups:tool_presets'),
37 | 'parent_name' => 'groups',
38 | ]);
39 |
40 | $result[] = \ElggMenuItem::factory([
41 | 'name' => 'groups:bulk_delete',
42 | 'href' => 'admin/groups/bulk_delete',
43 | 'text' => elgg_echo('admin:groups:bulk_delete'),
44 | 'parent_name' => 'groups',
45 | ]);
46 |
47 | $result[] = \ElggMenuItem::factory([
48 | 'name' => 'groups:auto_join',
49 | 'href' => 'admin/groups/auto_join',
50 | 'text' => elgg_echo('admin:groups:auto_join'),
51 | 'parent_name' => 'groups',
52 | ]);
53 |
54 | $result[] = \ElggMenuItem::factory([
55 | 'name' => 'groups:featured',
56 | 'href' => 'admin/groups/featured',
57 | 'text' => elgg_echo('admin:groups:featured'),
58 | 'parent_name' => 'groups',
59 | ]);
60 |
61 | $result[] = \ElggMenuItem::factory([
62 | 'name' => 'groups:suggested',
63 | 'href' => 'admin/groups/suggested',
64 | 'text' => elgg_echo('admin:groups:suggested'),
65 | 'parent_name' => 'groups',
66 | ]);
67 |
68 | $result[] = \ElggMenuItem::factory([
69 | 'name' => 'groups:admin_approval',
70 | 'href' => 'admin/groups/admin_approval',
71 | 'text' => elgg_echo('admin:groups:admin_approval'),
72 | 'parent_name' => 'groups',
73 | ]);
74 |
75 | return $result;
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/classes/ColdTrick/GroupTools/Menus/Annotation.php:
--------------------------------------------------------------------------------
1 | getParam('annotation');
21 | if (!$annotation instanceof \ElggAnnotation || $annotation->name !== 'email_invitation') {
22 | return null;
23 | }
24 |
25 | $group = $annotation->getOwnerEntity();
26 | if (!$group instanceof \ElggGroup || !$group->canEdit()) {
27 | return null;
28 | }
29 |
30 | /* @var $result MenuItems */
31 | $result = $event->getValue();
32 |
33 | $result->remove('delete');
34 |
35 | $result[] = \ElggMenuItem::factory([
36 | 'name' => 'revoke',
37 | 'text' => elgg_echo('revoke'),
38 | 'href' => elgg_generate_action_url('group_tools/revoke_email_invitation', [
39 | 'annotation_id' => $annotation->id,
40 | 'group_guid' => $group->guid,
41 | ]),
42 | 'confirm' => elgg_echo('group_tools:groups:membershipreq:invitations:revoke:confirm'),
43 | 'link_class' => 'elgg-button elgg-button-delete',
44 | ]);
45 |
46 | return $result;
47 | }
48 |
49 | /**
50 | * Add menu items to the email invitation annotation menu
51 | *
52 | * @param \Elgg\Event $event 'register', 'menu:annotation'
53 | *
54 | * @return null|MenuItems
55 | */
56 | public static function registerEmailInvitationUser(\Elgg\Event $event): ?MenuItems {
57 | $annotation = $event->getParam('annotation');
58 | if (!$annotation instanceof \ElggAnnotation || $annotation->name !== 'email_invitation') {
59 | return null;
60 | }
61 |
62 | $user = elgg_get_logged_in_user_entity();
63 | if (!$user instanceof \ElggUser) {
64 | return null;
65 | }
66 |
67 | list($secret, $email) = explode('|', $annotation->value);
68 |
69 | if ($email !== $user->email) {
70 | return null;
71 | }
72 |
73 | /* @var $result MenuItems */
74 | $result = $event->getValue();
75 |
76 | $result[] = \ElggMenuItem::factory([
77 | 'name' => 'accept',
78 | 'text' => elgg_echo('accept'),
79 | 'href' => elgg_generate_action_url('groups/email_invitation', [
80 | 'invitecode' => $secret,
81 | ]),
82 | 'link_class' => 'elgg-button elgg-button-submit',
83 | ]);
84 |
85 | $result[] = \ElggMenuItem::factory([
86 | 'name' => 'decline',
87 | 'text' => elgg_echo('delete'),
88 | 'href' => elgg_generate_action_url('groups/decline_email_invitation', [
89 | 'invitecode' => $secret,
90 | ]),
91 | 'confirm' => elgg_echo('groups:invite:remove:check'),
92 | 'link_class' => 'elgg-button elgg-button-delete',
93 | ]);
94 |
95 | return $result;
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/classes/ColdTrick/GroupTools/Menus/Filter.php:
--------------------------------------------------------------------------------
1 | canEdit()) {
26 | return null;
27 | }
28 |
29 | /* @var $result MenuItems */
30 | $result = $event->getValue();
31 |
32 | $result[] = \ElggMenuItem::factory([
33 | 'name' => 'invitations',
34 | 'text' => elgg_echo('group_tools:menu:group:invitations:invitations'),
35 | 'href' => elgg_generate_url('collection:group:group:invitations', [
36 | 'username' => $page_owner->username,
37 | ]),
38 | ]);
39 |
40 | $result[] = \ElggMenuItem::factory([
41 | 'name' => 'email_invitations',
42 | 'text' => elgg_echo('group_tools:menu:group:invitations:email_invitations'),
43 | 'href' => elgg_generate_url('collection:annotation:email_invitation:user', [
44 | 'username' => $page_owner->username,
45 | ]),
46 | ]);
47 |
48 | return $result;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/classes/ColdTrick/GroupTools/Menus/Filter/GroupsAll.php:
--------------------------------------------------------------------------------
1 | getValue();
22 |
23 | $return[] = \ElggMenuItem::factory([
24 | 'name' => 'all',
25 | 'text' => elgg_echo('groups:all'),
26 | 'href' => elgg_generate_url('collection:group:group:all', [
27 | 'filter' => 'all',
28 | ]),
29 | 'priority' => 200,
30 | ]);
31 |
32 | if (elgg_is_logged_in()) {
33 | $return[] = \ElggMenuItem::factory([
34 | 'name' => 'yours',
35 | 'text' => elgg_echo('groups:yours'),
36 | 'href' => elgg_generate_url('collection:group:group:all', [
37 | 'filter' => 'yours',
38 | ]),
39 | 'priority' => 250,
40 | ]);
41 |
42 | $return[] = \ElggMenuItem::factory([
43 | 'name' => 'member',
44 | 'text' => elgg_echo('group_tools:groups:sorting:member'),
45 | 'href' => elgg_generate_url('collection:group:group:all', [
46 | 'filter' => 'member',
47 | ]),
48 | 'priority' => 260,
49 | ]);
50 |
51 | if (group_tools_multiple_admin_enabled()) {
52 | $return[] = \ElggMenuItem::factory([
53 | 'name' => 'managed',
54 | 'text' => elgg_echo('group_tools:groups:sorting:managed'),
55 | 'href' => elgg_generate_url('collection:group:group:all', [
56 | 'filter' => 'managed',
57 | ]),
58 | 'priority' => 270,
59 | ]);
60 | }
61 | }
62 |
63 | $return[] = \ElggMenuItem::factory([
64 | 'name' => 'open',
65 | 'text' => elgg_echo('group_tools:groups:sorting:open'),
66 | 'href' => elgg_generate_url('collection:group:group:all', [
67 | 'filter' => 'open',
68 | ]),
69 | 'priority' => 500,
70 | ]);
71 |
72 | $return[] = \ElggMenuItem::factory([
73 | 'name' => 'closed',
74 | 'text' => elgg_echo('group_tools:groups:sorting:closed'),
75 | 'href' => elgg_generate_url('collection:group:group:all', [
76 | 'filter' => 'closed',
77 | ]),
78 | 'priority' => 600,
79 | ]);
80 |
81 | $return[] = \ElggMenuItem::factory([
82 | 'name' => 'suggested',
83 | 'text' => elgg_echo('group_tools:groups:sorting:suggested'),
84 | 'href' => elgg_generate_url('collection:group:group:all', [
85 | 'filter' => 'suggested',
86 | ]),
87 | 'priority' => 900,
88 | ]);
89 |
90 | return $return;
91 | }
92 |
93 | /**
94 | * Clean up the tabs on the group listing page
95 | *
96 | * @param \Elgg\Event $event 'register', 'menu:filter:groups/all'
97 | *
98 | * @return MenuItems
99 | */
100 | public static function cleanupTabs(\Elgg\Event $event): MenuItems {
101 | /* @var $return MenuItems */
102 | $return = $event->getValue();
103 |
104 | $new = [];
105 |
106 | /* @var $menu_item \ElggMenuItem */
107 | foreach ($return as $menu_item) {
108 | $menu_name = $menu_item->getName();
109 |
110 | // check plugin settings for the tabs
111 | if (!self::showTab($menu_name)) {
112 | continue;
113 | }
114 |
115 | $new[] = $menu_item;
116 | }
117 |
118 | $return->fill($new);
119 |
120 | return $return;
121 | }
122 |
123 | /**
124 | * Check plugin settings if the tabs should be shown
125 | *
126 | * @param string $name the (internal) name of the tab
127 | *
128 | * @return bool
129 | */
130 | protected static function showTab(string $name): bool {
131 | $show_tab_setting = elgg_get_plugin_setting("group_listing_{$name}_available", 'group_tools');
132 |
133 | return ($show_tab_setting !== '0');
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/classes/ColdTrick/GroupTools/Menus/Filter/GroupsMembers.php:
--------------------------------------------------------------------------------
1 | getParam('filter_entity');
22 | if (!$entity instanceof \ElggGroup) {
23 | return;
24 | }
25 |
26 | if (!group_tools_multiple_admin_enabled()) {
27 | return;
28 | }
29 |
30 | /* @var $result MenuItems */
31 | $result = $event->getValue();
32 |
33 | $result[] = \ElggMenuItem::factory([
34 | 'name' => 'group_admins',
35 | 'text' => elgg_echo('group_tools:multiple_admin:group_admins'),
36 | 'href' => elgg_generate_url('collection:user:user:group_members', [
37 | 'guid' => $entity->guid,
38 | 'filter' => 'group_admins',
39 | ]),
40 | 'priority' => 250,
41 | ]);
42 |
43 | return $result;
44 | }
45 |
46 | /**
47 | * Add a menu item to the tabs on the group members page
48 | *
49 | * @param \Elgg\Event $event 'register', 'menu:filter:groups/member'
50 | *
51 | * @return void|MenuItems
52 | */
53 | public static function registerEmailInvitations(\Elgg\Event $event) {
54 | $entity = $event->getParam('filter_entity');
55 | if (!$entity instanceof \ElggGroup || !$entity->canEdit()) {
56 | return;
57 | }
58 |
59 | if (elgg_get_plugin_setting('invite_email', 'group_tools') === 'no' && elgg_get_plugin_setting('invite_csv', 'group_tools') === 'no') {
60 | // no way to get e-mail invitations
61 | return;
62 | }
63 |
64 | /* @var $result MenuItems */
65 | $result = $event->getValue();
66 |
67 | $result[] = \ElggMenuItem::factory([
68 | 'name' => 'email_invitations',
69 | 'text' => elgg_echo('group_tools:menu:group_members:email_invitations'),
70 | 'href' => elgg_generate_url('collection:annotation:email_invitation:group', [
71 | 'guid' => $entity->guid,
72 | ]),
73 | 'priority' => 600,
74 | 'badge' => elgg_get_annotations([
75 | 'selects' => [
76 | function(QueryBuilder $qb, $main_alias) {
77 | return "SUBSTRING_INDEX({$main_alias}.value, '|', -1) AS invited_email";
78 | },
79 | ],
80 | 'annotation_name' => 'email_invitation',
81 | 'annotation_owner_guid' => $entity->guid,
82 | 'wheres' => [
83 | function(QueryBuilder $qb, $main_alias) {
84 | return $qb->compare("{$main_alias}.value", 'LIKE', '%|%', ELGG_VALUE_STRING);
85 | },
86 | ],
87 | 'count' => true,
88 | ]),
89 | ]);
90 |
91 | return $result;
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/classes/ColdTrick/GroupTools/Menus/OwnerBlock.php:
--------------------------------------------------------------------------------
1 | getEntityParam();
21 | if (!$entity instanceof \ElggGroup) {
22 | return null;
23 | }
24 |
25 | if (!$entity->isToolEnabled('related_groups')) {
26 | return null;
27 | }
28 |
29 | /* @var $return MenuItems */
30 | $return = $event->getValue();
31 |
32 | $return[] = \ElggMenuItem::factory([
33 | 'name' => 'related_groups',
34 | 'text' => elgg_echo('group_tools:related_groups:title'),
35 | 'href' => elgg_generate_url('collection:group:group:related', [
36 | 'guid' => $entity->guid,
37 | ]),
38 | 'is_trusted' => true,
39 | ]);
40 |
41 | return $return;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/classes/ColdTrick/GroupTools/Menus/Page.php:
--------------------------------------------------------------------------------
1 | getValue();
35 |
36 | $return_value[] = \ElggMenuItem::factory([
37 | 'name' => 'mail',
38 | 'text' => elgg_echo('group_tools:menu:mail'),
39 | 'href' => elgg_generate_url('add:object:group_tools_group_mail', [
40 | 'guid' => $page_owner->guid,
41 | ]),
42 | ]);
43 |
44 | return $return_value;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/classes/ColdTrick/GroupTools/Menus/Relationship.php:
--------------------------------------------------------------------------------
1 | getParam('relationship');
21 | if (!$relationship instanceof \ElggRelationship || $relationship->relationship !== 'membership_request') {
22 | return null;
23 | }
24 |
25 | /* @var $result MenuItems */
26 | $result = $event->getValue();
27 | if (!$result->has('reject')) {
28 | return null;
29 | }
30 |
31 | $user = get_entity($relationship->guid_one);
32 | $group = elgg_call(ELGG_IGNORE_ACCESS, function() use ($relationship) {
33 | return get_entity($relationship->guid_two);
34 | });
35 | if (!$group instanceof \ElggGroup || !$user instanceof \ElggUser) {
36 | return null;
37 | }
38 |
39 | $page_owner = elgg_get_page_owner_entity();
40 | if ($page_owner->guid !== $group->guid || !$group->canEdit()) {
41 | return null;
42 | }
43 |
44 | /* @var $reject \ElggMenuItem */
45 | $reject = $result->get('reject');
46 | $reject->setHref(elgg_http_add_url_query_elements('ajax/form/groups/killrequest', [
47 | 'relationship_id' => $relationship->id,
48 | ]));
49 | $reject->setConfirmText(false);
50 | $reject->addLinkClass('elgg-lightbox');
51 |
52 | return $result;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/classes/ColdTrick/GroupTools/Notifications.php:
--------------------------------------------------------------------------------
1 | getParam('event');
21 | if (!$notification_event instanceof NotificationEvent) {
22 | return;
23 | }
24 |
25 | $object = $notification_event->getObject();
26 | if ($notification_event->getAction() !== 'admin_approval' || !$object instanceof \ElggGroup || $object->access_id !== ACCESS_PRIVATE) {
27 | return;
28 | }
29 |
30 | /* @var $owner \ElggUser */
31 | $owner = $object->getOwnerEntity();
32 |
33 | $subject = elgg_echo('group_tools:group:admin_approve:owner:subject', [$object->getDisplayName()], $owner->getLanguage());
34 | $message = elgg_echo('group_tools:group:admin_approve:owner:message', [
35 | $object->getDisplayName(),
36 | $object->getURL(),
37 | ], $owner->getLanguage());
38 |
39 | notify_user($owner->guid, elgg_get_site_entity()->guid, $subject, $message, [], ['email']);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/classes/ColdTrick/GroupTools/Notifications/GroupAdminApprovalNotificationHandler.php:
--------------------------------------------------------------------------------
1 | 'user',
21 | 'metadata_name_value_pairs' => [
22 | 'name' => 'admin',
23 | 'value' => 'yes',
24 | ],
25 | 'batch' => true,
26 | 'limit' => false,
27 | ]);
28 | /* @var $user \ElggUser */
29 | foreach ($batch as $user) {
30 | $settings = $user->getNotificationSettings('group_tools_group_approval');
31 | $settings = array_keys(array_filter($settings));
32 | if (empty($settings)) {
33 | continue;
34 | }
35 |
36 | $return[$user->guid] = $settings;
37 | }
38 |
39 | return $return;
40 | }
41 |
42 | /**
43 | * {@inheritdoc}
44 | */
45 | protected function getNotificationSubject(\ElggUser $recipient, string $method): string {
46 | $group = $this->getGroup();
47 |
48 | return elgg_echo('group_tools:group:admin_approve:admin:subject', [$group->getDisplayName()], $recipient->getLanguage());
49 | }
50 |
51 | /**
52 | * {@inheritdoc}
53 | */
54 | protected function getNotificationSummary(\ElggUser $recipient, string $method): string {
55 | $group = $this->getGroup();
56 |
57 | return elgg_echo('group_tools:group:admin_approve:admin:summary', [$group->getDisplayName()], $recipient->getLanguage());
58 | }
59 |
60 | /**
61 | * {@inheritdoc}
62 | */
63 | protected function getNotificationBody(\ElggUser $recipient, string $method): string {
64 | $group = $this->getGroup();
65 | $actor = $this->event->getActor();
66 |
67 | return elgg_echo('group_tools:group:admin_approve:admin:message', [
68 | $actor->getDisplayName(),
69 | $group->getDisplayName(),
70 | $group->getURL(),
71 | elgg_normalize_url('admin/groups/admin_approval'),
72 | ], $recipient->getLanguage());
73 | }
74 |
75 | /**
76 | * Get the group from the notification
77 | *
78 | * @return \ElggGroup
79 | */
80 | protected function getGroup(): \ElggGroup {
81 | return $this->event->getObject();
82 | }
83 |
84 | /**
85 | * {@inheritdoc}
86 | */
87 | public static function isConfigurableByUser(): bool {
88 | return false;
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/classes/ColdTrick/GroupTools/Notifications/GroupMailEnqueueNotificationEventHandler.php:
--------------------------------------------------------------------------------
1 | getGroupMail();
17 |
18 | // large group could have a lot of recipients, so increase php time limit
19 | set_time_limit(0);
20 |
21 | return $entity->getRecipients();
22 | }
23 |
24 | /**
25 | * {@inheritdoc}
26 | */
27 | protected function getNotificationSubject(\ElggUser $recipient, string $method): string {
28 | $entity = $this->getGroupMail();
29 |
30 | return $entity->getSubject();
31 | }
32 |
33 | /**
34 | * {@inheritdoc}
35 | */
36 | protected function getNotificationBody(\ElggUser $recipient, string $method): string {
37 | $entity = $this->getGroupMail();
38 |
39 | return $entity->getMessage();
40 | }
41 |
42 | /**
43 | * Get the group mail for this notification
44 | *
45 | * @return \GroupMail
46 | */
47 | protected function getGroupMail(): \GroupMail {
48 | return $this->event->getObject();
49 | }
50 |
51 | /**
52 | * {@inheritdoc}
53 | */
54 | public static function isConfigurableByUser(): bool {
55 | return false;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/classes/ColdTrick/GroupTools/PageLayout.php:
--------------------------------------------------------------------------------
1 | getContentAccessMode() === \ElggGroup::CONTENT_ACCESS_MODE_UNRESTRICTED) {
25 | // public group
26 | return null;
27 | }
28 |
29 | if (elgg_get_plugin_setting('search_index', 'group_tools') === 'yes') {
30 | // indexing is allowed
31 | return null;
32 | }
33 |
34 | $return = $event->getValue();
35 |
36 | $return['metas']['robots'] = [
37 | 'name' => 'robots',
38 | 'content' => 'noindex',
39 | ];
40 |
41 | return $return;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/classes/ColdTrick/GroupTools/Permissions.php:
--------------------------------------------------------------------------------
1 | getValue())) {
19 | // already has access
20 | return null;
21 | }
22 |
23 | $group = $event->getEntityParam();
24 | if (!$group instanceof \ElggGroup) {
25 | return null;
26 | }
27 |
28 | return true;
29 | }
30 |
31 | /**
32 | * Allow group admins (not owners) to also edit group content
33 | *
34 | * @param \Elgg\Event $event 'permissions_check', 'group'
35 | *
36 | * @return null|bool
37 | */
38 | public static function allowGroupAdminsToEdit(\Elgg\Event $event): ?bool {
39 | if ($event->getValue()) {
40 | // already has access
41 | return null;
42 | }
43 |
44 | if (!group_tools_multiple_admin_enabled()) {
45 | // group admins not enabled
46 | return null;
47 | }
48 |
49 | $entity = $event->getEntityParam();
50 | $user = $event->getParam('user');
51 | if (!$entity instanceof \ElggGroup || !$user instanceof \ElggUser) {
52 | return null;
53 | }
54 |
55 | if (!$entity->isMember($user)) {
56 | return null;
57 | }
58 |
59 | return $user->hasRelationship($entity->guid, 'group_admin');
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/classes/ColdTrick/GroupTools/PluginSettings.php:
--------------------------------------------------------------------------------
1 | getParam('plugin_id') !== 'group_tools') {
19 | return null;
20 | }
21 |
22 | $value = $event->getValue();
23 | if (!is_array($value)) {
24 | return null;
25 | }
26 |
27 | return json_encode($value);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/classes/ColdTrick/GroupTools/Plugins/Groups.php:
--------------------------------------------------------------------------------
1 | getEntityParam();
22 | $tools = $event->getValue();
23 |
24 | if (group_tools_multiple_admin_enabled()) {
25 | // multiple admins can only be configured for:
26 | // - new groups
27 | // - by the group owner (not other admins)
28 | // - by a site admin
29 | if (!$entity instanceof \ElggGroup || $entity->owner_guid === elgg_get_logged_in_user_guid() || elgg_is_admin_logged_in()) {
30 | // add group tool option
31 | $tools[] = new Tool('group_multiple_admin_allow', [
32 | 'default_on' => false,
33 | ]);
34 | }
35 | }
36 |
37 | if (group_tools_group_mail_members_enabled()) {
38 | $tools[] = new Tool('mail_members', [
39 | 'default_on' => false,
40 | ]);
41 | }
42 |
43 | // related groups
44 | if (elgg_get_plugin_setting('related_groups', 'group_tools') === 'yes') {
45 | $tools[] = new Tool('related_groups', [
46 | 'default_on' => false,
47 | ]);
48 | }
49 |
50 | return $tools;
51 | }
52 |
53 | /**
54 | * Listen to the groups/edit action and register events
55 | *
56 | * @return void
57 | */
58 | public static function editActionListener(): void {
59 | elgg_register_event_handler('update:after', 'group', self::class . '::acceptMembershipRequests');
60 | }
61 |
62 | /**
63 | * Automatically accept pending membership request for open groups
64 | *
65 | * @param \Elgg\Event $event 'update:after', 'group'
66 | *
67 | * @return void
68 | */
69 | public static function acceptMembershipRequests(\Elgg\Event $event): void {
70 | $entity = $event->getObject();
71 | if (!$entity instanceof \ElggGroup || !$entity->canEdit()) {
72 | return;
73 | }
74 |
75 | if (elgg_get_plugin_setting('auto_accept_membership_requests', 'group_tools') !== 'yes') {
76 | return;
77 | }
78 |
79 | if (!$entity->isPublicMembership()) {
80 | return;
81 | }
82 |
83 | // just in case
84 | set_time_limit(0);
85 |
86 | // get pending requests
87 | /* @var $pending_requests \ElggBatch */
88 | $pending_requests = $entity->getEntitiesFromRelationship([
89 | 'type' => 'user',
90 | 'relationship' => 'membership_request',
91 | 'inverse_relationship' => true,
92 | 'limit' => false,
93 | 'batch' => true,
94 | 'batch_inc_offset' => false,
95 | ]);
96 | /* @var $requesting_user \ElggUser */
97 | foreach ($pending_requests as $requesting_user) {
98 | // join the group
99 | if (!$entity->join($requesting_user)) {
100 | $pending_requests->reportFailure();
101 | }
102 | }
103 | }
104 |
105 | /**
106 | * Cleanup group admin status on group leave
107 | *
108 | * @param \Elgg\Event $event 'leave', 'group'
109 | *
110 | * @return null|bool
111 | */
112 | public static function removeGroupAdminOnLeave(\Elgg\Event $event): ?bool {
113 | $params = $event->getObject();
114 |
115 | $user = elgg_extract('user', $params);
116 | $group = elgg_extract('group', $params);
117 | if (!$user instanceof \ElggUser || !$group instanceof \ElggGroup) {
118 | return null;
119 | }
120 |
121 | // is the user a group admin
122 | if (!$user->hasRelationship($group->guid, 'group_admin')) {
123 | return null;
124 | }
125 |
126 | return $user->removeRelationship($group->guid, 'group_admin');
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/classes/ColdTrick/GroupTools/Plugins/ProfileManager.php:
--------------------------------------------------------------------------------
1 | getValue();
21 |
22 | $result[] = FieldType::factory([
23 | 'type' => 'group_tools_preset',
24 | 'name' => elgg_echo('group_tools:profile:field:group_tools_preset'),
25 | 'options' => [
26 | 'user_editable' => true,
27 | 'output_as_tags' => true,
28 | 'admin_only' => true,
29 | ],
30 | ]);
31 |
32 | return $result;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/classes/ColdTrick/GroupTools/Plugins/WidgetManager.php:
--------------------------------------------------------------------------------
1 | getEntityParam();
19 | if (!$entity instanceof \ElggGroup) {
20 | return null;
21 | }
22 |
23 | $return = $event->getValue();
24 |
25 | // check different group tools for which we supply widgets
26 | if ($entity->isToolEnabled('related_groups')) {
27 | $return['enable'][] = 'group_related';
28 | } else {
29 | $return['disable'][] = 'group_related';
30 | }
31 |
32 | if ($entity->isToolEnabled('activity')) {
33 | $return['enable'][] = 'group_river_widget';
34 | } else {
35 | $return['disable'][] = 'group_river_widget';
36 | }
37 |
38 | return $return;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/classes/ColdTrick/GroupTools/Router/GroupInviteRegistrationGatekeeper.php:
--------------------------------------------------------------------------------
1 | validateGroupInvitecode($request)) {
18 | return;
19 | }
20 |
21 | parent::__invoke($request);
22 | }
23 |
24 | /**
25 | * Validate the group invite code
26 | *
27 | * @param Request $request the request
28 | *
29 | * @return bool
30 | */
31 | protected function validateGroupInvitecode(Request $request): bool {
32 | // check for a group invite code
33 | $group_invitecode = $request->getParam('group_invitecode');
34 | if (empty($group_invitecode)) {
35 | return false;
36 | }
37 |
38 | // check if the code is valid
39 | return group_tools_check_group_email_invitation($group_invitecode) instanceof \ElggGroup;
40 | }
41 |
42 | /**
43 | * Change the middleware of the registration to this gatekeeper
44 | *
45 | * @param \Elgg\Event $event 'route:config', 'account:register'|'action:register'
46 | *
47 | * @return array
48 | */
49 | public static function register(\Elgg\Event $event) {
50 | $route_config = $event->getValue();
51 | $middleware = elgg_extract('middleware', $route_config, []);
52 |
53 | // find the default registration gatekeeper
54 | $key = array_search(RegistrationAllowedGatekeeper::class, $middleware);
55 | if ($key !== false) {
56 | unset($middleware[$key]);
57 | }
58 |
59 | // add this gatekeeper
60 | $middleware[] = static::class;
61 |
62 | $route_config['middleware'] = $middleware;
63 |
64 | return $route_config;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/classes/ColdTrick/GroupTools/StaleInfo.php:
--------------------------------------------------------------------------------
1 | group = $entity;
34 | $this->number_of_days = $days;
35 | }
36 |
37 | /**
38 | * Is the group stale
39 | *
40 | * @return bool
41 | */
42 | public function isStale(): bool {
43 | $compare_ts = Values::normalizeTimestamp("-{$this->number_of_days} days");
44 | if ($this->group->time_created > $compare_ts) {
45 | return false;
46 | }
47 |
48 | $ts = $this->getTouchTimestamp();
49 | if ($ts > $compare_ts) {
50 | return false;
51 | }
52 |
53 | $ts = $this->getContentTimestamp();
54 | if ($ts > $compare_ts) {
55 | return false;
56 | }
57 |
58 | $ts = $this->getCommentTimestamp();
59 | if ($ts > $compare_ts) {
60 | return false;
61 | }
62 |
63 | return true;
64 | }
65 |
66 | /**
67 | * Get the timestamp of the last touch/content created in the group
68 | *
69 | * @return int
70 | */
71 | public function getTimestamp(): int {
72 | return max([
73 | $this->group->time_created,
74 | $this->getTouchTimestamp(),
75 | $this->getContentTimestamp(),
76 | $this->getCommentTimestamp(),
77 | ]);
78 | }
79 |
80 | /**
81 | * Get the timestamp when the group was touched as not stale
82 | *
83 | * @return int
84 | */
85 | protected function getTouchTimestamp(): int {
86 | return (int) $this->group->group_tools_stale_touch_ts;
87 | }
88 |
89 | /**
90 | * Get the timestamp of the last content in the group
91 | *
92 | * This is based of searchable entities
93 | *
94 | * @return int
95 | */
96 | protected function getContentTimestamp(): int {
97 | $object_subtypes = $this::getObjectSubtypes();
98 | if (empty($object_subtypes)) {
99 | return 0;
100 | }
101 |
102 | $entities = elgg_call(ELGG_IGNORE_ACCESS, function() use ($object_subtypes) {
103 | return elgg_get_entities([
104 | 'type' => 'object',
105 | 'subtypes' => $object_subtypes,
106 | 'limit' => 1,
107 | 'container_guid' => $this->group->guid,
108 | 'order_by' => new OrderByClause('time_updated', 'DESC'),
109 | ]);
110 | });
111 |
112 | if (empty($entities)) {
113 | return 0;
114 | }
115 |
116 | return $entities[0]->time_updated;
117 | }
118 |
119 | /**
120 | * Get the timestamp of the last comment/discussion_reply in the group
121 | *
122 | * @return int
123 | */
124 | protected function getCommentTimestamp(): int {
125 | $guid = $this->group->guid;
126 |
127 | $entities = elgg_call(ELGG_IGNORE_ACCESS, function() use ($guid) {
128 | return elgg_get_entities([
129 | 'type' => 'object',
130 | 'subtype' => 'comment',
131 | 'limit' => 1,
132 | 'wheres' => [
133 | function(QueryBuilder $qb, $main_alias) use ($guid) {
134 | $ce = $qb->joinEntitiesTable($main_alias, 'container_guid');
135 |
136 | return $qb->compare("{$ce}.container_guid", '=', $guid, ELGG_VALUE_INTEGER);
137 | },
138 | ],
139 | 'order_by' => new OrderByClause('time_updated', 'DESC'),
140 | ]);
141 | });
142 |
143 | if (empty($entities)) {
144 | return 0;
145 | }
146 |
147 | return $entities[0]->time_updated;
148 | }
149 |
150 | /**
151 | * Get supported subtypes for stale info
152 | *
153 | * @return string[]
154 | */
155 | public static function getObjectSubtypes(): array {
156 | $subtypes = elgg_extract('object', elgg_entity_types_with_capability('searchable'), []);
157 |
158 | return elgg_trigger_event_results('stale_info_object_subtypes', 'group_tools', [
159 | 'subtypes' => $subtypes,
160 | ], $subtypes);
161 | }
162 | }
163 |
--------------------------------------------------------------------------------
/classes/ColdTrick/GroupTools/Upgrades/MigrateNotificationSettings.php:
--------------------------------------------------------------------------------
1 | countItems());
25 | }
26 |
27 | /**
28 | * {@inheritdoc}
29 | */
30 | public function needsIncrementOffset(): bool {
31 | return false;
32 | }
33 |
34 | /**
35 | * {@inheritdoc}
36 | */
37 | public function countItems(): int {
38 | return elgg_count_entities($this->getOptions());
39 | }
40 |
41 | /**
42 | * {@inheritdoc}
43 | */
44 | public function run(Result $result, $offset): Result {
45 | $methods = elgg_get_notification_methods();
46 |
47 | /* @var $users \ElggBatch */
48 | $users = elgg_get_entities($this->getOptions([
49 | 'offset' => $offset,
50 | ]));
51 | /* @var $user \ElggUser */
52 | foreach ($users as $user) {
53 | $notify = (bool) $user->getPluginSetting('group_tools', 'notify_approval');
54 |
55 | foreach ($methods as $method) {
56 | $user->setNotificationSetting($method, $notify, 'group_tools_group_approval');
57 | }
58 |
59 | if ($user->removePluginSetting('group_tools', 'notify_approval')) {
60 | $result->addSuccesses();
61 | } else {
62 | $result->addFailures();
63 | }
64 | }
65 |
66 | return $result;
67 | }
68 |
69 | /**
70 | * Options for fetching admins
71 | *
72 | * @param array $options additional options
73 | *
74 | * @return array
75 | * @see elgg_get_entities()
76 | */
77 | protected function getOptions(array $options = []): array {
78 | $defaults = [
79 | 'type' => 'user',
80 | 'metadata_name_value_pairs' => [
81 | 'name' => 'admin',
82 | 'value' => 'yes',
83 | ],
84 | 'metadata_name' => 'plugin:user_setting:group_tools:notify_approval',
85 | 'limit' => false,
86 | 'batch' => true,
87 | 'batch_inc_offset' => $this->needsIncrementOffset(),
88 | ];
89 |
90 | return array_merge($defaults, $options);
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/classes/ColdTrick/GroupTools/Widgets.php:
--------------------------------------------------------------------------------
1 | getParam('context') !== 'groups') {
19 | return null;
20 | }
21 |
22 | $remove = false;
23 | if (elgg_get_plugin_setting('related_groups', 'group_tools') === 'no') {
24 | // not allowed by plugin setting
25 | $remove = true;
26 | }
27 |
28 | $container = $event->getParam('container');
29 | if (!$remove && $container instanceof \ElggGroup) {
30 | // check if group has tool enabled
31 | if (!$container->isToolEnabled('related_groups')) {
32 | $remove = true;
33 | }
34 | }
35 |
36 | if (!$remove) {
37 | return null;
38 | }
39 |
40 | /* @var $result \Elgg\WidgetDefinition[] */
41 | $result = $event->getValue();
42 | foreach ($result as $index => $definition) {
43 | if ($definition->id !== 'group_related') {
44 | continue;
45 | }
46 |
47 | unset($result[$index]);
48 | break;
49 | }
50 |
51 | return $result;
52 | }
53 |
54 | /**
55 | * Unregister the groups activity widget because our version is better
56 | *
57 | * @param \Elgg\Event $event 'handlers', 'widgets'
58 | *
59 | * @return null|\Elgg\WidgetDefinition[]
60 | */
61 | public static function unregisterGroupActivityWidget(\Elgg\Event $event): ?array {
62 | /* @var $result \Elgg\WidgetDefinition[] */
63 | $result = $event->getValue();
64 | foreach ($result as $index => $definition) {
65 | if ($definition->id !== 'group_activity') {
66 | continue;
67 | }
68 |
69 | unset($result[$index]);
70 | break;
71 | }
72 |
73 | return $result;
74 | }
75 |
76 | /**
77 | * Set the title URL for the group tools widgets
78 | *
79 | * @param \Elgg\Event $event 'entity:url', 'object'
80 | *
81 | * @return null|string
82 | */
83 | public static function widgetURL(\Elgg\Event $event): ?string {
84 | if (!empty($event->getValue())) {
85 | // someone already set an url
86 | return null;
87 | }
88 |
89 | $widget = $event->getEntityParam();
90 | if (!$widget instanceof \ElggWidget) {
91 | return null;
92 | }
93 |
94 | switch ($widget->handler) {
95 | case 'group_members':
96 | return elgg_generate_url('collection:user:user:group_members', [
97 | 'guid' => $widget->owner_guid,
98 | ]);
99 |
100 | case 'group_invitations':
101 | $user = elgg_get_logged_in_user_entity();
102 | if (!empty($user)) {
103 | return elgg_generate_url('collection:group:group:invitations', [
104 | 'username' => $user->username,
105 | ]);
106 | }
107 | break;
108 |
109 | case 'group_river_widget':
110 | if ($widget->context !== 'groups') {
111 | $group_guid = (int) $widget->group_guid;
112 | } else {
113 | $group_guid = $widget->owner_guid;
114 | }
115 |
116 | if (!empty($group_guid)) {
117 | $group = get_entity($group_guid);
118 | if ($group instanceof \ElggGroup) {
119 | return elgg_generate_url('collection:river:group', [
120 | 'guid' => $group->guid,
121 | ]);
122 | }
123 | }
124 | break;
125 |
126 | case 'index_groups':
127 | return elgg_generate_url('collection:group:group:all');
128 |
129 | case 'featured_groups':
130 | return elgg_generate_url('collection:group:group:all', [
131 | 'filter' => 'featured',
132 | ]);
133 |
134 | case 'group_related':
135 | return elgg_generate_url('collection:group:group:related', [
136 | 'guid' => $widget->owner_guid,
137 | ]);
138 | }
139 |
140 | return null;
141 | }
142 | }
143 |
--------------------------------------------------------------------------------
/classes/GroupMail.php:
--------------------------------------------------------------------------------
1 | attributes['subtype'] = self::SUBTYPE;
21 | $this->attributes['access_id'] = ACCESS_PUBLIC;
22 | }
23 |
24 | /**
25 | * Get the mail subject
26 | *
27 | * @return string
28 | */
29 | public function getSubject(): string {
30 | return $this->title ?? elgg_echo('group_tools:mail:message:default_subject', [$this->getContainerEntity()->getDisplayName()]);
31 | }
32 |
33 | /**
34 | * Get the mail message
35 | *
36 | * @return string
37 | */
38 | public function getMessage(): string {
39 | /* @var $group \ElggGroup */
40 | $group = $this->getContainerEntity();
41 |
42 | $message = $this->description;
43 | $message .= PHP_EOL . PHP_EOL;
44 | $message .= elgg_echo('group_tools:mail:message:from');
45 | $message .= ": {$group->getDisplayName()}" . PHP_EOL;
46 | $message .= $group->getURL();
47 |
48 | return $message;
49 | }
50 |
51 | /**
52 | * Save the recipients for this message
53 | *
54 | * @param array $recipients GUID array of group members to receive this message
55 | *
56 | * @return void
57 | */
58 | public function setRecipients(array $recipients): void {
59 | $this->recipients = $recipients;
60 | }
61 |
62 | /**
63 | * Get the recipients for this message in the form [guid => ['email']]
64 | *
65 | * @return array
66 | */
67 | public function getRecipients(): array {
68 | if (empty($this->recipients)) {
69 | return [];
70 | }
71 |
72 | $recipients = (array) $this->recipients;
73 | /* @var $batch \ElggBatch */
74 | $batch = elgg_get_entities([
75 | 'type' => 'user',
76 | 'limit' => false,
77 | 'guids' => $recipients,
78 | 'relationship' => 'member',
79 | 'relationship_guid' => $this->container_guid,
80 | 'inverse_relationship' => true,
81 | 'batch' => true,
82 | ]);
83 |
84 | $formatted_recipients = [];
85 | /* @var $user \ElggUser */
86 | foreach ($batch as $user) {
87 | $formatted_recipients[$user->guid] = ['email'];
88 | }
89 |
90 | return $formatted_recipients;
91 | }
92 |
93 | /**
94 | * Enqueue the mail for delivery
95 | *
96 | * @return bool
97 | */
98 | public function enqueue(): bool {
99 | if (!$this->save()) {
100 | return false;
101 | }
102 |
103 | return elgg_trigger_event('enqueue-mail', 'object', $this);
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "coldtrick/group_tools",
3 | "description": "Combines different group additions into one plugin",
4 | "homepage": "https://www.coldtrick.com",
5 | "type": "elgg-plugin",
6 | "keywords": ["elgg", "plugin", "groups"],
7 | "license": "GPL-2.0-only",
8 | "support": {
9 | "source": "https://github.com/ColdTrick/group_tools",
10 | "issues": "https://github.com/ColdTrick/group_tools/issues"
11 | },
12 | "conflict": {
13 | "elgg/elgg": "<6.2"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/composer.lock:
--------------------------------------------------------------------------------
1 | {
2 | "_readme": [
3 | "This file locks the dependencies of your project to a known state",
4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
5 | "This file is @generated automatically"
6 | ],
7 | "content-hash": "01ed9ffc7472226817a885796d974abe",
8 | "packages": [],
9 | "packages-dev": [],
10 | "aliases": [],
11 | "minimum-stability": "stable",
12 | "stability-flags": {},
13 | "prefer-stable": false,
14 | "prefer-lowest": false,
15 | "platform": {},
16 | "platform-dev": {},
17 | "plugin-api-version": "2.6.0"
18 | }
19 |
--------------------------------------------------------------------------------
/views/default/admin/groups/admin_approval.php:
--------------------------------------------------------------------------------
1 | elgg_echo('group_tools:group:admin_approve:admin:description'),
5 | ]);
6 |
7 | echo elgg_list_entities([
8 | 'type' => 'group',
9 | 'limit' => false,
10 | 'access_id' => ACCESS_PRIVATE,
11 | 'item_view' => 'group_tools/group/admin_approve',
12 | 'no_results' => elgg_echo('groups:none'),
13 | ]);
14 |
--------------------------------------------------------------------------------
/views/default/admin/groups/auto_join.php:
--------------------------------------------------------------------------------
1 | elgg_echo('group_tools:admin:auto_join:additional:description'),
5 | ]);
6 |
7 | $output = '';
8 | $configs = group_tools_get_auto_join_configurations();
9 | foreach ($configs as $id => $config) {
10 | if (elgg_extract('type', $config) !== 'additional') {
11 | continue;
12 | }
13 |
14 | $output .= elgg_view('group_tools/elements/auto_join_configuration', [
15 | 'config' => $config,
16 | ]);
17 | }
18 |
19 | if (empty($output)) {
20 | $output = elgg_echo('group_tools:admin:auto_join:additional:none');
21 | }
22 |
23 | $content .= $output;
24 |
25 | $menu = elgg_view('output/url', [
26 | 'text' => elgg_echo('add'),
27 | 'icon' => 'plus-circle',
28 | 'href' => 'ajax/form/group_tools/admin/auto_join/additional',
29 | 'class' => [
30 | 'elgg-lightbox',
31 | ],
32 | 'data-colorbox-opts' => json_encode([
33 | 'maxWidth' => '650px',
34 | ]),
35 | ]);
36 |
37 | echo elgg_view_module('info', elgg_echo('group_tools:admin:auto_join:additional'), $content, ['menu' => $menu]);
38 |
--------------------------------------------------------------------------------
/views/default/admin/groups/auto_join/default.php:
--------------------------------------------------------------------------------
1 | elgg_echo('group_tools:admin:auto_join:default:description'),
5 | ]);
6 |
7 | $auto_joins = elgg_get_plugin_setting('auto_join', 'group_tools');
8 | if (!empty($auto_joins)) {
9 | $auto_joins = elgg_string_to_array($auto_joins);
10 |
11 | $rows = [];
12 |
13 | // header
14 | $row = [];
15 | $row[] = elgg_format_element('th', ['style' => 'width: 40px;', 'class' => 'center'], ' ');
16 | $row[] = elgg_format_element('th', [], elgg_echo('groups:name'));
17 |
18 | $rows[] = elgg_format_element('thead', [], elgg_format_element('tr', [], implode('', $row)));
19 |
20 | $groups = new \ElggBatch('elgg_get_entities', [
21 | 'type' => 'group',
22 | 'limit' => false,
23 | 'guids' => $auto_joins,
24 | ]);
25 |
26 | foreach ($groups as $group) {
27 | $row = [];
28 |
29 | $row[] = elgg_format_element('td', ['style' => 'width: 40px;', 'class' => 'center'], elgg_view_entity_icon($group, 'tiny'));
30 | $row[] = elgg_format_element('td', [], elgg_view('output/url', [
31 | 'href' => $group->getURL(),
32 | 'text' => $group->getDisplayName(),
33 | ]));
34 |
35 | $rows[] = elgg_format_element('tr', [], implode('', $row));
36 | }
37 |
38 | $content .= elgg_format_element('table', ['class' => 'elgg-table-alt mtm'], implode('', $rows));
39 | } else {
40 | $content .= elgg_echo('group_tools:admin:auto_join:default:none');
41 | }
42 |
43 | $menu = elgg_view('output/url', [
44 | 'text' => elgg_echo('edit'),
45 | 'icon' => 'edit',
46 | 'href' => 'ajax/form/group_tools/admin/auto_join/default',
47 | 'class' => [
48 | 'elgg-lightbox',
49 | ],
50 | 'data-colorbox-opts' => json_encode([
51 | 'maxWidth' => '650px',
52 | ]),
53 | ]);
54 |
55 | echo elgg_view_module('info', elgg_echo('group_tools:admin:auto_join:default'), $content, ['menu' => $menu]);
56 |
--------------------------------------------------------------------------------
/views/default/admin/groups/auto_join/exclusive.php:
--------------------------------------------------------------------------------
1 | elgg_echo('group_tools:admin:auto_join:exclusive:description'),
5 | ]);
6 |
7 | $output = '';
8 | $configs = group_tools_get_auto_join_configurations();
9 | foreach ($configs as $id => $config) {
10 | if (elgg_extract('type', $config) !== 'exclusive') {
11 | continue;
12 | }
13 |
14 | $output .= elgg_view('group_tools/elements/auto_join_configuration', [
15 | 'config' => $config,
16 | ]);
17 | }
18 |
19 | if (empty($output)) {
20 | $output = elgg_echo('group_tools:admin:auto_join:exclusive:none');
21 | }
22 |
23 | $content .= $output;
24 |
25 | $menu = elgg_view('output/url', [
26 | 'icon' => 'plus-circle',
27 | 'text' => elgg_echo('add'),
28 | 'href' => elgg_http_add_url_query_elements('ajax/form/group_tools/admin/auto_join/additional', [
29 | 'type' => 'exclusive',
30 | ]),
31 | 'class' => [
32 | 'elgg-lightbox',
33 | ],
34 | 'data-colorbox-opts' => json_encode([
35 | 'maxWidth' => '650px',
36 | ]),
37 | ]);
38 |
39 | echo elgg_view_module('info', elgg_echo('group_tools:admin:auto_join:exclusive'), $content, ['menu' => $menu]);
40 |
--------------------------------------------------------------------------------
/views/default/admin/groups/bulk_delete.mjs:
--------------------------------------------------------------------------------
1 | import 'jquery';
2 | import spinner from 'elgg/spinner';
3 |
4 | $(document).on('change', 'input[name="checkall"]', function () {
5 | var $form = $(this).closest('form');
6 | var checked = $(this).is(":checked");
7 | $('[name="group_guids[]"]', $form).prop('checked', checked);
8 | });
9 |
10 | $(document).on('submit', '#group-tools-admin-bulk-delete', function() {
11 | spinner.start();
12 | });
13 |
--------------------------------------------------------------------------------
/views/default/admin/groups/bulk_delete.php:
--------------------------------------------------------------------------------
1 | 'group',
15 | 'limit' => $limit,
16 | 'offset' => $offset,
17 | 'sort_by' => [
18 | 'property' => 'name',
19 | 'direction' => 'ASC',
20 | ],
21 | ];
22 |
23 | $group_count = elgg_count_entities($options);
24 | if ($group_count < 1) {
25 | echo elgg_echo('groups:none');
26 | return;
27 | }
28 |
29 | elgg_import_esm('admin/groups/bulk_delete');
30 |
31 | $batch = new ElggBatch('elgg_get_entities', $options);
32 |
33 | $delete_button = elgg_view('input/submit', [
34 | 'text' => elgg_echo('group_tools:delete_selected'),
35 | 'class' => 'elgg-button-submit float-alt mvs',
36 | 'data-confirm' => elgg_echo('deleteconfirm:plural'),
37 | ]);
38 |
39 | $form_data = $delete_button;
40 |
41 | $form_data .= '
';
42 |
43 | $form_data .= '';
44 | $form_data .= '';
45 | $form_data .= elgg_format_element('th', ['class' => 'center'], elgg_view('input/checkbox', ['name' => 'checkall', 'default' => false]));
46 | $form_data .= elgg_format_element('th', [], elgg_echo('groups:group'));
47 | $form_data .= elgg_format_element('th', ['class' => 'center'], elgg_echo('groups:edit'));
48 | $form_data .= elgg_format_element('th', ['class' => 'center'], elgg_echo('delete'));
49 | $form_data .= '
';
50 | $form_data .= '';
51 |
52 | // add group rows
53 | $rows = [];
54 | foreach ($batch as $group) {
55 | $cells = [];
56 |
57 | // brief view
58 | $icon = elgg_view_entity_icon($group, 'tiny');
59 | $params = [
60 | 'entity' => $group,
61 | 'metadata' => '',
62 | 'subtitle' => $group->briefdescription,
63 | ];
64 | $list_body = elgg_view('group/elements/summary', $params);
65 | $group_summary = elgg_view_image_block($icon, $list_body);
66 |
67 | $cells[] = elgg_format_element('td', ['class' => 'center'], elgg_view('input/checkbox', [
68 | 'name' => 'group_guids[]',
69 | 'value' => $group->guid,
70 | 'default' => false,
71 | ]));
72 | $cells[] = elgg_format_element('td', [], $group_summary);
73 | $cells[] = elgg_format_element('td', ['class' => 'center'], elgg_view('output/url', [
74 | 'icon' => 'settings-alt',
75 | 'text' => false,
76 | 'title' => elgg_echo('edit'),
77 | 'href' => elgg_generate_entity_url($group, 'edit'),
78 | ]));
79 | $cells[] = elgg_format_element('td', ['class' => 'center'], elgg_view('output/url', [
80 | 'icon' => 'delete-alt',
81 | 'text' => false,
82 | 'title' => elgg_echo('delete'),
83 | 'confirm' => elgg_echo('deleteconfirm'),
84 | 'href' => elgg_generate_action_url('entity/delete', [
85 | 'guid' => $group->guid,
86 | ]),
87 | ]));
88 |
89 | $rows[] = elgg_format_element('tr', [], implode(PHP_EOL, $cells));
90 | }
91 |
92 | $form_data .= elgg_format_element('tbody', [], implode(PHP_EOL, $rows));
93 |
94 | $form_data .= '
';
95 |
96 | $form_data .= $delete_button;
97 |
98 | // pagination
99 | $form_data .= elgg_view('navigation/pagination', [
100 | 'limit' => $limit,
101 | 'offset' => $offset,
102 | 'count' => $group_count,
103 | ]);
104 |
105 | echo elgg_view('input/form', [
106 | 'id' => 'group-tools-admin-bulk-delete',
107 | 'action' => 'action/group_tools/admin/bulk_delete',
108 | 'body' => $form_data,
109 | ]);
110 |
--------------------------------------------------------------------------------
/views/default/admin/groups/featured.php:
--------------------------------------------------------------------------------
1 | elgg_echo('group_tools:settings:special_states:featured:description'),
5 | ]);
6 |
7 | echo elgg_list_entities([
8 | 'type' => 'group',
9 | 'limit' => false,
10 | 'metadata_name_value_pairs' => [
11 | 'name' => 'featured_group',
12 | 'value' => 'yes',
13 | ],
14 | 'no_results' => true,
15 | ]);
16 |
--------------------------------------------------------------------------------
/views/default/admin/groups/suggested.php:
--------------------------------------------------------------------------------
1 | elgg_echo('notfound')]);
8 | return;
9 | }
10 |
11 | echo elgg_list_entities([
12 | 'type' => 'group',
13 | 'limit' => false,
14 | 'guids' => $suggested_groups,
15 | ]);
16 |
--------------------------------------------------------------------------------
/views/default/admin/groups/tool_presets.php:
--------------------------------------------------------------------------------
1 | elgg_echo('group_tools:admin:group_tool_presets:description'),
6 | ]);
7 |
8 | // build elements
9 | $title = elgg_echo('group_tools:admin:group_tool_presets:header');
10 | $add_button = elgg_view('output/url', [
11 | 'icon' => 'plus',
12 | 'text' => elgg_echo('add'),
13 | 'href' => false,
14 | 'class' => 'elgg-button elgg-button-action group-tools-admin-add-tool-preset',
15 | ]);
16 |
17 | $form = elgg_view_form('group_tools/group_tool_presets', [
18 | 'action' => 'action/group_tools/admin/group_tool_presets',
19 | ], [
20 | 'group_tool_presets' => group_tools_get_tool_presets(),
21 | ]);
22 |
23 | // draw list
24 | echo elgg_view_module('info', $title, $form, ['menu' => $add_button]);
25 |
--------------------------------------------------------------------------------
/views/default/annotation/approval_reason.php:
--------------------------------------------------------------------------------
1 | name, strlen('approval_reason:'));
15 |
16 | if (elgg_language_key_exists("group_tools:group:edit:reason:{$label}")) {
17 | $label = elgg_echo("group_tools:group:edit:reason:{$label}");
18 | }
19 |
20 | echo elgg_format_element('strong', [], $label);
21 | echo elgg_view('output/longtext', [
22 | 'value' => unserialize($annotation->value),
23 | ]);
24 |
--------------------------------------------------------------------------------
/views/default/annotation/email_invitation.php:
--------------------------------------------------------------------------------
1 | getOwnerEntity();
16 | if (!$owner instanceof \ElggGroup) {
17 | return;
18 | }
19 |
20 | $page_owner = elgg_get_page_owner_entity();
21 |
22 | // value of the annotation is in the format 'secret|e-mail address'
23 | list(, $email) = explode('|', $annotation->value);
24 |
25 | $icon = elgg_view_entity_icon($owner, 'tiny');
26 |
27 | $title_text = '';
28 | if ($page_owner->guid !== $owner->guid) {
29 | $title_text = elgg_view('output/url', [
30 | 'text' => $owner->getDisplayName(),
31 | 'href' => $owner->getURL(),
32 | 'is_trusted' => true,
33 | ]);
34 | } else {
35 | $title_text = elgg_view('output/email', [
36 | 'value' => $email,
37 | ]);
38 | }
39 |
40 | $title = elgg_format_element('h4', [], $title_text);
41 |
42 | $menu = elgg_view_menu('annotation', [
43 | 'annotation' => $annotation,
44 | 'class' => 'elgg-menu-hz',
45 | ]);
46 |
47 | $friendlytime = elgg_view_friendly_time($annotation->time_created);
48 | $friendlytime = elgg_format_element('span', ['class' => 'elgg-subtext'], $friendlytime);
49 |
50 | $body = elgg_format_element('div', ['class' => 'mbn'], $title . $friendlytime);
51 |
52 | echo elgg_view_image_block($icon, $body, ['image_alt' => $menu]);
53 |
--------------------------------------------------------------------------------
/views/default/forms/group_tools/admin/auto_join/additional.mjs:
--------------------------------------------------------------------------------
1 | import 'jquery';
2 | import Ajax from 'elgg/Ajax';
3 | import lightbox from 'elgg/lightbox';
4 |
5 | $(document).on('click', '#group-tools-auto-join-add-pattern', function (event){
6 | event.preventDefault();
7 |
8 | var ajax = new Ajax();
9 | ajax.view('group_tools/elements/auto_join_match_pattern', {
10 | success: function(data) {
11 | $('#group-tools-auto-join-add-pattern').before(data);
12 | lightbox.resize();
13 | }
14 | });
15 |
16 | return false;
17 | });
18 |
--------------------------------------------------------------------------------
/views/default/forms/group_tools/admin/auto_join/additional.php:
--------------------------------------------------------------------------------
1 | 'hidden',
16 | 'name' => 'id',
17 | 'value' => $id,
18 | ]);
19 |
20 | echo elgg_view_field([
21 | '#type' => 'hidden',
22 | 'name' => 'type',
23 | 'value' => elgg_extract('type', $config, 'additional'),
24 | ]);
25 |
26 | echo elgg_view_field([
27 | '#type' => 'text',
28 | '#label' => elgg_echo('title'),
29 | 'name' => 'title',
30 | 'value' => elgg_extract('title', $config),
31 | 'required' => true,
32 | ]);
33 |
34 | // matching patterns
35 | $label = elgg_view('elements/forms/label', [
36 | 'label' => elgg_echo('group_tools:form:admin:auto_join:additional:pattern'),
37 | 'required' => true,
38 | ]);
39 | $help = elgg_view('output/url', [
40 | 'text' => elgg_echo('group_tools:form:admin:auto_join:additional:pattern:add'),
41 | 'href' => '#',
42 | 'id' => 'group-tools-auto-join-add-pattern',
43 | ]);
44 | $help .= elgg_view('elements/forms/help', [
45 | 'help' => elgg_echo('group_tools:form:admin:auto_join:additional:pattern:help'),
46 | ]);
47 | $patterns = elgg_extract('patterns', $config);
48 | if (!empty($patterns)) {
49 | $input = '';
50 | foreach ($patterns as $pattern) {
51 | $input .= elgg_view('group_tools/elements/auto_join_match_pattern', [
52 | 'pattern' => $pattern,
53 | ]);
54 | }
55 | } else {
56 | $input = elgg_view('group_tools/elements/auto_join_match_pattern');
57 | }
58 |
59 | echo elgg_view('elements/forms/field', [
60 | 'label' => $label,
61 | 'help' => $help,
62 | 'input' => $input,
63 | 'class' => 'group-tools-auto-join-additional-pattern',
64 | ]);
65 |
66 | echo elgg_view_field([
67 | '#type' => 'grouppicker',
68 | '#label' => elgg_echo('group_tools:form:admin:auto_join:additional:group'),
69 | '#help' => elgg_echo('group_tools:form:admin:auto_join:additional:group:help'),
70 | 'name' => 'group_guids',
71 | 'values' => elgg_extract('group_guids', $config, []),
72 | ]);
73 |
74 | // make form footer
75 | $footer = elgg_view_field([
76 | '#type' => 'submit',
77 | 'text' => elgg_echo('save'),
78 | ]);
79 | elgg_set_form_footer($footer);
80 |
--------------------------------------------------------------------------------
/views/default/forms/group_tools/admin/auto_join/default.php:
--------------------------------------------------------------------------------
1 | 'grouppicker',
12 | '#label' => elgg_echo('group_tools:form:admin:auto_join:group'),
13 | '#help' => elgg_echo('group_tools:form:admin:auto_join:group:help'),
14 | 'name' => 'group_guids',
15 | 'values' => $auto_joins,
16 | ]);
17 |
18 | $footer = elgg_view_field([
19 | '#type' => 'submit',
20 | 'text' => elgg_echo('save'),
21 | ]);
22 | elgg_set_form_footer($footer);
23 |
--------------------------------------------------------------------------------
/views/default/forms/group_tools/admin/decline.php:
--------------------------------------------------------------------------------
1 | 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 = elgg_view_field([
31 | '#type' => 'submit',
32 | 'text' => elgg_echo('decline'),
33 | 'class' => 'elgg-button-delete',
34 | 'data-confirm' => elgg_echo('group_tools:group:admin_approve:decline:confirm'),
35 | ]);
36 |
37 | elgg_set_form_footer($footer);
38 |
--------------------------------------------------------------------------------
/views/default/forms/group_tools/group_tool_presets.mjs:
--------------------------------------------------------------------------------
1 | import 'jquery';
2 |
3 | $(document).on('click', '.group-tools-admin-add-tool-preset', function (e) {
4 | e.preventDefault();
5 |
6 | var $clone_base = $('#group-tools-tool-preset-base');
7 | var $clone = $clone_base.clone();
8 |
9 | $clone.removeAttr('id').removeClass('hidden');
10 | $clone.find('.group-tools-group-preset-edit').removeClass('hidden');
11 |
12 | // find inputs and set correct name
13 | var counter = $clone_base.parent().find('> div.group-tools-group-preset-wrapper').length;
14 | while ($clone_base.parent().find('input[name^="params[' + counter + ']"]').length) {
15 | counter++;
16 | }
17 |
18 | var $inputs = $clone.find(':input');
19 | $.each($inputs, function (index, object) {
20 | var name = $(object).attr('name');
21 | name = name.replace('params[i]', 'params[' + counter + ']');
22 | $(object).attr('name', name);
23 | });
24 |
25 | // insert clone
26 | $clone_base.parent().find('.group-tools-group-preset-edit:visible').addClass('hidden');
27 | $clone.insertBefore($clone_base);
28 | });
29 |
30 | $(document).on('click', '.group-tools-admin-edit-tool-preset', function (e) {
31 | e.preventDefault();
32 |
33 | var $container = $(this).closest('.group-tools-group-preset-wrapper').find('.group-tools-group-preset-edit');
34 | var visible = $container.is(':visible');
35 |
36 | $(this).closest('.elgg-form-body').find('.group-tools-group-preset-edit:visible').addClass('hidden');
37 |
38 | if (!visible) {
39 | $container.removeClass('hidden');
40 | }
41 | });
42 |
43 | $(document).on('click', '.group-tools-admin-delete-tool-preset', function (e) {
44 | e.preventDefault();
45 |
46 | $(this).closest('.elgg-form-body').find('.group-tools-group-preset-edit:visible').addClass('hidden');
47 |
48 | $(this).closest('.group-tools-group-preset-wrapper').remove();
49 | });
50 |
51 | $(document).on('keyup keydown', '.group-tools-admin-change-tool-preset-title', function () {
52 | if (!$(this).val()) {
53 | return;
54 | }
55 |
56 | var $label = $(this).closest('.group-tools-group-preset-wrapper').find('.group-tools-group-preset-title');
57 | $label.html($(this).val());
58 | });
59 |
60 | $(document).on('keyup keydown', '.group-tools-admin-change-tool-preset-description', function () {
61 | if (!$(this).val()) {
62 | return;
63 | }
64 |
65 | var $container = $(this).closest('.group-tools-group-preset-wrapper').find('.group-tools-group-preset-description');
66 | $container.html($(this).val());
67 | });
68 |
--------------------------------------------------------------------------------
/views/default/forms/group_tools/group_tool_presets.php:
--------------------------------------------------------------------------------
1 | group_tools->all();
13 |
14 | // list existing
15 | if (!empty($presets)) {
16 | foreach ($presets as $index => $values) {
17 | echo elgg_view('group_tools/elements/group_tool_preset', [
18 | 'index' => $index,
19 | 'values' => $values,
20 | ]);
21 | }
22 | }
23 |
24 | // hidden wrapper for clone
25 | echo elgg_view('group_tools/elements/group_tool_preset', [
26 | 'wrapper_vars' => [
27 | 'id' => 'group-tools-tool-preset-base',
28 | 'class' => 'hidden',
29 | ],
30 | ]);
31 |
32 | // save button
33 | $footer = elgg_view_field([
34 | '#type' => 'submit',
35 | 'text' => elgg_echo('save'),
36 | ]);
37 | elgg_set_form_footer($footer);
38 |
--------------------------------------------------------------------------------
/views/default/forms/group_tools/join_motivation.php:
--------------------------------------------------------------------------------
1 | 'hidden',
13 | 'name' => 'group_guid',
14 | 'value' => $group->guid,
15 | ]);
16 |
17 | echo elgg_view_field([
18 | '#type' => 'longtext',
19 | '#label' => elgg_echo('group_tools:join_motivation:label'),
20 | 'name' => 'motivation',
21 | 'id' => 'group-tools-join-motivation',
22 | 'required' => true,
23 | ]);
24 |
25 | $footer = elgg_view_field([
26 | '#type' => 'submit',
27 | 'text' => elgg_echo('groups:joinrequest'),
28 | ]);
29 | elgg_set_form_footer($footer);
30 |
--------------------------------------------------------------------------------
/views/default/forms/group_tools/mail.mjs:
--------------------------------------------------------------------------------
1 | import 'jquery';
2 |
3 | $(document).on('click', '#group-tools-mail-clear', function() {
4 | var $form = $(this).closest('form');
5 |
6 | $form.find('div.elgg-user-picker[data-name="user_guids"] > ul.elgg-user-picker-list > li').remove();
7 | });
8 |
9 | $(document).on('change', 'form.elgg-form-group-tools-mail input[type="checkbox"][name="all_members"]', function() {
10 | if ($(this).is(':checked')) {
11 | $('#group-tools-mail-individual').closest('.elgg-field').addClass('hidden');
12 | } else {
13 | $('#group-tools-mail-individual').closest('.elgg-field').removeClass('hidden');
14 | }
15 | });
16 |
--------------------------------------------------------------------------------
/views/default/forms/group_tools/mail.php:
--------------------------------------------------------------------------------
1 | guid;
18 | }
19 | }
20 |
21 | $form_data = elgg_view_field([
22 | '#type' => 'checkbox',
23 | '#label' => elgg_echo('group_tools:all_members', [$group->getMembers(['count' => true])]),
24 | 'name' => 'all_members',
25 | 'value' => 1,
26 | 'checked' => true,
27 | 'switch' => true,
28 | ]);
29 |
30 | $form_data .= elgg_view_field([
31 | '#type' => 'fieldset',
32 | '#class' => 'hidden',
33 | 'id' => 'group-tools-mail-individual',
34 | 'fields' => [
35 | [
36 | '#type' => 'userpicker',
37 | '#label' => elgg_echo('group_tools:mail:form:recipients'),
38 | 'name' => 'user_guids',
39 | 'value' => $user_guids,
40 | 'show_friends' => false,
41 | 'handler' => 'livesearch/group_members',
42 | 'options' => [
43 | 'group_guid' => $group->guid,
44 | ],
45 | ],
46 | [
47 | '#type' => 'button',
48 | 'id' => 'group-tools-mail-clear',
49 | 'text' => elgg_echo('group_tools:clear_selection'),
50 | 'class' => 'elgg-button-action',
51 | ],
52 | ]
53 | ]);
54 |
55 | $form_data .= elgg_view_field([
56 | '#type' => 'text',
57 | '#label' => elgg_echo('group_tools:mail:form:title'),
58 | 'name' => 'title',
59 | ]);
60 |
61 | $form_data .= elgg_view_field([
62 | '#type' => 'longtext',
63 | '#label' => elgg_echo('group_tools:mail:form:description'),
64 | 'name' => 'description',
65 | 'required' => true,
66 | ]);
67 |
68 | $form_data .= elgg_view('input/hidden', [
69 | 'name' => 'group_guid',
70 | 'value' => $group->guid,
71 | ]);
72 |
73 | echo $form_data;
74 |
75 | // footer
76 | $footer = elgg_view_field([
77 | '#type' => 'submit',
78 | 'text' => elgg_echo('send'),
79 | ]);
80 | elgg_set_form_footer($footer);
81 |
--------------------------------------------------------------------------------
/views/default/forms/group_tools/members_search.mjs:
--------------------------------------------------------------------------------
1 | import 'jquery';
2 | import Ajax from 'elgg/Ajax';
3 |
4 | $(document).on('submit.memberSearch', '.elgg-form-group-tools-members-search', function (event) {
5 | event.preventDefault();
6 |
7 | var $form = $(this);
8 |
9 | var ajax = new Ajax();
10 | ajax.path($form.prop('action'), {
11 | data: ajax.objectify($form),
12 | success: function(data) {
13 | $form.siblings().not($form).remove();
14 | $form.after(data);
15 | },
16 | });
17 | });
18 |
--------------------------------------------------------------------------------
/views/default/forms/group_tools/members_search.php:
--------------------------------------------------------------------------------
1 | 'fieldset',
7 | 'align' => 'horizontal',
8 | 'fields' => [
9 | [
10 | '#type' => 'search',
11 | '#class' => 'elgg-field-stretch',
12 | 'name' => 'members_search',
13 | 'value' => get_input('members_search'),
14 | 'placeholder' => elgg_echo('group_tools:forms:members_search:members_search:placeholder'),
15 | ],
16 | [
17 | '#type' => 'submit',
18 | 'icon' => 'search',
19 | 'text' => elgg_echo('search'),
20 | ]
21 | ],
22 | ]);
23 |
--------------------------------------------------------------------------------
/views/default/forms/group_tools/related_groups.php:
--------------------------------------------------------------------------------
1 | 'grouppicker',
11 | '#help' => elgg_echo('group_tools:related_groups:form:description'),
12 | '#class' => 'elgg-field-stretch',
13 | 'name' => 'guid',
14 | 'placeholder' => elgg_echo('group_tools:related_groups:form:placeholder'),
15 | 'limit' => 1,
16 | ],
17 | [
18 | '#type' => 'submit',
19 | 'text' => elgg_echo('add'),
20 | ],
21 | [
22 | '#type' => 'hidden',
23 | 'name' => 'group_guid',
24 | 'value' => $group->guid,
25 | ],
26 | ];
27 |
28 | echo elgg_view_field([
29 | '#type' => 'fieldset',
30 | 'fields' => $fields,
31 | 'align' => 'horizontal',
32 | ]);
33 |
--------------------------------------------------------------------------------
/views/default/forms/groups/edit.mjs:
--------------------------------------------------------------------------------
1 | import 'jquery';
2 | import Ajax from 'elgg/Ajax';
3 |
4 | function add_group_suggestions() {
5 | var $input = $('form.elgg-form-groups-edit input[name="name"]');
6 | if ($input.closest('form').find('input[name="group_guid"]').length) {
7 | // edit
8 | return;
9 | }
10 |
11 | var ajax = new Ajax();
12 | ajax.view('group_tools/group/suggested', {
13 | data: {
14 | q: $input.val()
15 | },
16 | success: function (data) {
17 | $('#group-tools-edit-group-suggestions').remove();
18 |
19 | $input.closest('.elgg-field').after(data);
20 | }
21 | });
22 | }
23 |
24 | var inputTimeout;
25 | $(document).on('input', 'form.elgg-form-groups-edit input[name="name"]', function(event) {
26 | clearTimeout(inputTimeout);
27 | if ($(this).val().length < 3) {
28 | // not enough characters (yet)
29 | return;
30 | }
31 |
32 | inputTimeout = setTimeout(add_group_suggestions, 400);
33 | });
34 |
35 | $(document).on('change', '#groups-membership', function() {
36 | if ($(this).val() === '0') {
37 | $('#group-tools-join-motivation').show();
38 | } else {
39 | $('#group-tools-join-motivation').hide();
40 | }
41 | });
42 |
--------------------------------------------------------------------------------
/views/default/forms/groups/edit.php:
--------------------------------------------------------------------------------
1 | 'profile',
15 | 150 => 'images',
16 | 175 => 'reason',
17 | 200 => 'access',
18 | 300 => 'tools',
19 | 400 => 'settings',
20 | ];
21 |
22 | // build group edit tabs
23 | $tabs = [];
24 |
25 | foreach ($sections as $priority => $name) {
26 | $content = elgg_view("groups/edit/{$name}", $vars);
27 | if (empty($content)) {
28 | continue;
29 | }
30 |
31 | $tabs[] = [
32 | 'name' => $name,
33 | 'priority' => $priority,
34 | 'text' => elgg_echo("groups:edit:{$name}"),
35 | 'content' => $content,
36 | ];
37 | }
38 |
39 | // show tabs
40 | echo elgg_view('page/components/tabs', [
41 | 'id' => 'groups-edit',
42 | 'tabs' => $tabs,
43 | ]);
44 |
45 | // display the save button and some additional form data
46 | $footer = '';
47 | $submit_classes = ['elgg-groups-edit-footer-submit'];
48 | if ($entity instanceof \ElggGroup) {
49 | echo elgg_view('input/hidden', [
50 | 'name' => 'group_guid',
51 | 'value' => $entity->guid,
52 | ]);
53 | } else {
54 | elgg_import_esm('forms/groups/create_navigation');
55 |
56 | $footer .= elgg_view_field([
57 | '#type' => 'fieldset',
58 | '#class' => 'elgg-groups-edit-footer-navigate',
59 | 'fields' => [
60 | [
61 | '#type' => 'button',
62 | 'id' => 'elgg-groups-edit-footer-navigate-next',
63 | 'icon_alt' => 'chevron-right',
64 | 'text' => elgg_echo('next'),
65 | 'class' => 'elgg-button-action',
66 | ],
67 | ],
68 | 'align' => 'horizontal',
69 | ]);
70 |
71 | $submit_classes[] = 'hidden';
72 | }
73 |
74 | // build form footer
75 | $admin_approve = elgg_get_plugin_setting('admin_approve', 'group_tools') === 'yes';
76 | $admin_approve = $admin_approve && !elgg_is_admin_logged_in();
77 |
78 | // display the save button and some additional form data
79 | $buttons = [];
80 | if ($admin_approve && (!$entity instanceof \ElggGroup || $entity->access_id === ACCESS_PRIVATE)) {
81 | $buttons[] = [
82 | '#type' => 'submit',
83 | 'text' => elgg_echo('group_tools:group:edit:save:approve'),
84 | ];
85 | } else {
86 | $buttons[] = [
87 | '#type' => 'submit',
88 | 'text' => elgg_echo('save'),
89 | ];
90 | }
91 |
92 | if ((bool) elgg_get_plugin_setting('concept_groups', 'group_tools') && (!$entity instanceof \ElggGroup || (bool) $entity->is_concept)) {
93 | if ($entity instanceof \ElggGroup) {
94 | $buttons = [];
95 | }
96 |
97 | $buttons[] = [
98 | '#type' => 'submit',
99 | 'name' => 'concept_group',
100 | 'value' => 1,
101 | 'text' => elgg_echo('group_tools:group:edit:save:concept'),
102 | ];
103 | }
104 |
105 | $footer .= elgg_view_field([
106 | '#type' => 'fieldset',
107 | '#class' => $submit_classes,
108 | 'fields' => $buttons,
109 | 'align' => 'horizontal',
110 | ]);
111 |
112 | elgg_set_form_footer($footer);
113 |
--------------------------------------------------------------------------------
/views/default/forms/groups/email_invitation.php:
--------------------------------------------------------------------------------
1 | elgg_echo('group_tools:groups:invitation:code:description'),
8 | ]);
9 |
10 | echo elgg_view_field([
11 | '#type' => 'text',
12 | 'name' => 'invitecode',
13 | 'value' => get_input('invitecode'),
14 | ]);
15 |
16 | $footer = elgg_view_field([
17 | '#type' => 'submit',
18 | 'text' => elgg_echo('submit'),
19 | ]);
20 | elgg_set_form_footer($footer);
21 |
--------------------------------------------------------------------------------
/views/default/forms/groups/invite.php:
--------------------------------------------------------------------------------
1 | 'hidden',
13 | 'name' => 'group_guid',
14 | 'value' => $group->guid,
15 | ]);
16 |
17 | // invite friends
18 | $tabs = [];
19 |
20 | // invite site members
21 | $tabs[] = [
22 | 'text' => elgg_echo('group_tools:group:invite:users'),
23 | 'content' => elgg_view('group_tools/invite/users', $vars),
24 | ];
25 |
26 | // invite email
27 | if ((bool) elgg_extract('invite_email', $vars)) {
28 | $tabs[] = [
29 | 'text' => elgg_echo('group_tools:group:invite:email'),
30 | 'content' => elgg_view('group_tools/invite/email', $vars),
31 | ];
32 | }
33 |
34 | // invite csv
35 | if ((bool) elgg_extract('invite_csv', $vars)) {
36 | $tabs[] = [
37 | 'text' => elgg_echo('group_tools:group:invite:csv'),
38 | 'content' => elgg_view('group_tools/invite/csv', $vars),
39 | ];
40 | }
41 |
42 | if (count($tabs) === 1) {
43 | echo $tabs[0]['content'];
44 | } else {
45 | echo elgg_view('page/components/tabs', [
46 | 'tabs' => $tabs,
47 | ]);
48 | }
49 |
50 | // optional text
51 | echo elgg_view_field([
52 | '#type' => 'longtext',
53 | '#label' => elgg_echo('group_tools:group:invite:text'),
54 | 'name' => 'comment',
55 | 'value' => elgg_extract('comment', $vars),
56 | ]);
57 |
58 | // renotify existing invites
59 | if ($group->canEdit()) {
60 | echo elgg_view_field([
61 | '#type' => 'switch',
62 | '#label' => elgg_echo('groups:invite:resend'),
63 | 'name' => 'resend',
64 | ]);
65 | }
66 |
67 | // show buttons
68 | $footer_fields = [
69 | [
70 | '#type' => 'submit',
71 | 'name' => 'submit',
72 | 'value' => 0,
73 | 'icon' => 'envelope',
74 | 'text' => elgg_echo('invite'),
75 | ],
76 | ];
77 | if (elgg_is_admin_logged_in()) {
78 | $footer_fields[] = [
79 | '#type' => 'submit',
80 | 'name' => 'submit',
81 | 'value' => 1,
82 | 'icon' => 'plus',
83 | 'text' => elgg_echo('group_tools:add_users'),
84 | 'data-confirm' => elgg_echo('group_tools:group:invite:add:confirm'),
85 | ];
86 | }
87 |
88 | $footer = elgg_view_field([
89 | '#type' => 'fieldset',
90 | 'align' => 'horizontal',
91 | 'fields' => $footer_fields,
92 | ]);
93 | elgg_set_form_footer($footer);
94 |
--------------------------------------------------------------------------------
/views/default/forms/groups/killrequest.mjs:
--------------------------------------------------------------------------------
1 | import 'jquery';
2 | import Ajax from 'elgg/Ajax';
3 | import lightbox from 'elgg/lightbox';
4 |
5 | $(document).on('submit', '.elgg-form-groups-killrequest', function () {
6 | var id = $(this).find('input[name="relationship_id"]').val();
7 |
8 | var ajax = new Ajax();
9 | ajax.action($(this).attr('action'), {
10 | data: ajax.objectify(this),
11 | success: function() {
12 | var $wrapper = $('#elgg-relationship-' + id);
13 | if ($wrapper.length) {
14 | $wrapper.remove();
15 | }
16 | },
17 | complete: function() {
18 | lightbox.close();
19 | }
20 | });
21 |
22 | return false;
23 | });
24 |
--------------------------------------------------------------------------------
/views/default/forms/groups/killrequest.php:
--------------------------------------------------------------------------------
1 | relationship !== 'membership_request') {
11 | throw new BadRequestException();
12 | }
13 |
14 | $user = get_entity($relationship->guid_one);
15 | $group = elgg_call(ELGG_IGNORE_ACCESS, function() use ($relationship) {
16 | return get_entity($relationship->guid_two);
17 | });
18 | if (!$group instanceof \ElggGroup || !$user instanceof \ElggUser) {
19 | throw new BadRequestException();
20 | }
21 |
22 | echo elgg_view_field([
23 | '#type' => 'hidden',
24 | 'name' => 'group_guid',
25 | 'value' => $group->guid,
26 | ]);
27 |
28 | echo elgg_view_field([
29 | '#type' => 'hidden',
30 | 'name' => 'user_guid',
31 | 'value' => $user->guid,
32 | ]);
33 |
34 | echo elgg_view_field([
35 | '#type' => 'hidden',
36 | 'name' => 'relationship_id',
37 | 'value' => $relationship->id,
38 | ]);
39 |
40 | $content = elgg_view_field([
41 | '#type' => 'plaintext',
42 | '#label' => elgg_echo('group_tools:groups:membershipreq:kill_request:prompt'),
43 | 'name' => 'reason',
44 | 'rows' => '3',
45 | ]);
46 |
47 | echo elgg_view_module('info', elgg_echo('groups:joinrequest:remove:check'), $content);
48 |
49 | $footer = elgg_view_field([
50 | '#type' => 'fieldset',
51 | 'align' => 'horizontal',
52 | 'fields' => [
53 | [
54 | '#type' => 'submit',
55 | 'text' => elgg_echo('decline'),
56 | ],
57 | [
58 | '#type' => 'button',
59 | 'text' => elgg_echo('cancel'),
60 | 'onclick' => 'import("elgg/lightbox").then((lightbox) => {lightbox.default.close();});',
61 | ],
62 | ],
63 | ]);
64 |
65 | elgg_set_form_footer($footer);
66 |
--------------------------------------------------------------------------------
/views/default/group_tools/admin.css:
--------------------------------------------------------------------------------
1 | /* Group Tools admin css */
2 | .group-tools-auto-join-config .group-tools-auto-join-title a {
3 | display: none;
4 | }
5 | .group-tools-auto-join-config:hover .group-tools-auto-join-title a {
6 | display: inline-block;
7 | }
8 |
9 | .group-tools-auto-join-match-pattern {
10 | display: flex;
11 | }
12 | .group-tools-auto-join-match-pattern-field {
13 | flex: 2;
14 | }
15 | .group-tools-auto-join-match-pattern-operand {
16 | flex: 1;
17 | }
18 | .group-tools-auto-join-match-pattern-value {
19 | flex: 3;
20 | }
21 | .elgg-form-group-tools-admin-auto-join-default .elgg-input-group-picker,
22 | .elgg-form-group-tools-admin-auto-join-additional .elgg-input-group-picker {
23 | width: 100%;
24 | }
25 |
--------------------------------------------------------------------------------
/views/default/group_tools/elements/auto_join_configuration.php:
--------------------------------------------------------------------------------
1 | 'edit',
11 | 'text' => false,
12 | 'title' => elgg_echo('edit'),
13 | 'href' => elgg_http_add_url_query_elements('ajax/form/group_tools/admin/auto_join/additional', [
14 | 'id' => elgg_extract('id', $config),
15 | ]),
16 | 'class' => [
17 | 'mlm',
18 | 'elgg-lightbox',
19 | ],
20 | 'data-colorbox-opts' => json_encode([
21 | 'maxWidth' => '650px',
22 | ]),
23 | ]);
24 | $title .= elgg_view('output/url', [
25 | 'icon' => 'delete-alt',
26 | 'text' => false,
27 | 'title' => elgg_echo('delete'),
28 | 'href' => elgg_generate_action_url('group_tools/admin/auto_join/delete', [
29 | 'id' => elgg_extract('id', $config),
30 | ]),
31 | 'confirm' => elgg_echo('deleteconfirm'),
32 | 'class' => [
33 | 'mls',
34 | ],
35 | ]);
36 |
37 | $content = elgg_format_element('h4', ['class' => 'group-tools-auto-join-title'], $title);
38 |
39 | $group_guids = (array) elgg_extract('group_guids', $config, []);
40 | foreach ($group_guids as $guid) {
41 | $group = get_entity((int) $guid);
42 | if (!$group instanceof \ElggGroup) {
43 | continue;
44 | }
45 |
46 | $content .= elgg_view_image_block(elgg_view_entity_icon($group, 'tiny'), elgg_view_entity_url($group));
47 | }
48 |
49 | echo elgg_format_element('div', ['class' => 'group-tools-auto-join-config'], $content);
50 |
--------------------------------------------------------------------------------
/views/default/group_tools/elements/auto_join_match_pattern.php:
--------------------------------------------------------------------------------
1 | 'fieldset',
15 | 'align' => 'horizontal',
16 | 'fields' => [
17 | [
18 | '#type' => 'select',
19 | 'name' => 'field[]',
20 | 'value' => $field_name,
21 | 'options_values' => $user_options,
22 | 'class' => [
23 | 'group-tools-auto-join-match-pattern-field',
24 | ]
25 | ],
26 | [
27 | '#type' => 'select',
28 | 'name' => 'operand[]',
29 | 'value' => elgg_extract('operand', $pattern),
30 | 'options_values' => [
31 | 'equals' => elgg_echo('group_tools:auto_join:pattern:operand:equals'),
32 | 'not_equals' => elgg_echo('group_tools:auto_join:pattern:operand:not_equals'),
33 | 'contains' => elgg_echo('group_tools:auto_join:pattern:operand:contains'),
34 | 'not_contains' => elgg_echo('group_tools:auto_join:pattern:operand:not_contains'),
35 | 'pregmatch' => elgg_echo('group_tools:auto_join:pattern:operand:pregmatch'),
36 | ],
37 | 'class' => [
38 | 'group-tools-auto-join-match-pattern-operand',
39 | ],
40 | ],
41 | [
42 | '#type' => 'text',
43 | 'name' => 'value[]',
44 | 'value' => elgg_extract('value', $pattern),
45 | 'placeholder' => elgg_echo('group_tools:auto_join:pattern:value:placeholder'),
46 | 'class' => [
47 | 'group-tools-auto-join-match-pattern-value',
48 | ],
49 | ],
50 | ],
51 | ]);
52 |
53 | echo elgg_format_element('div', ['class' => 'group-tools-auto-join-match-pattern'], $field);
54 |
--------------------------------------------------------------------------------
/views/default/group_tools/elements/group_tool_preset.php:
--------------------------------------------------------------------------------
1 | group_tools->all();
15 |
16 | $title = elgg_format_element('div', ['class' => 'group-tools-group-preset-title'], elgg_extract('title', $values, elgg_echo('title')));
17 |
18 | $menu = elgg_view('output/url', [
19 | 'icon' => 'edit',
20 | 'text' => elgg_echo('edit'),
21 | 'href' => false,
22 | 'class' => ['group-tools-admin-edit-tool-preset', 'mrm'],
23 | ]);
24 | $menu .= elgg_view('output/url', [
25 | 'icon' => 'delete',
26 | 'text' => elgg_echo('delete'),
27 | 'href' => false,
28 | 'class' => 'group-tools-admin-delete-tool-preset',
29 | ]);
30 |
31 | $description = elgg_view('output/longtext', [
32 | 'class' => ['elgg-quiet', 'mtn', 'group-tools-group-preset-description'],
33 | 'value' => elgg_extract('description', $values, elgg_echo('description')),
34 | ]);
35 |
36 | $edit = elgg_view_field([
37 | '#type' => 'text',
38 | '#label' => elgg_echo('title'),
39 | 'name' => "params[{$index}][title]",
40 | 'value' => elgg_extract('title', $values),
41 | 'class' => 'group-tools-admin-change-tool-preset-title',
42 | ]);
43 |
44 | $edit .= elgg_view_field([
45 | '#type' => 'plaintext',
46 | '#label' => elgg_echo('description'),
47 | 'name' => "params[{$index}][description]",
48 | 'value' => elgg_extract('description', $values),
49 | 'class' => 'group-tools-admin-change-tool-preset-description',
50 | ]);
51 |
52 | /* @var $group_tool \Elgg\Groups\Tool */
53 | foreach ($group_tools as $group_tool) {
54 | $metadata_name = $group_tool->mapMetadataName();
55 |
56 | $edit .= elgg_view('groups/edit/tool', [
57 | 'tool' => $group_tool,
58 | 'value' => $values ? elgg_extract($metadata_name, $values['tools']) : null,
59 | 'name' => "params[{$index}][tools][{$metadata_name}]",
60 | 'class' => 'mbs',
61 | ]);
62 | }
63 |
64 | $edit = elgg_format_element('div', ['class' => ['group-tools-group-preset-edit', 'hidden']], $edit);
65 |
66 | $wrapper_vars['class'] = elgg_extract_class($wrapper_vars, ['group-tools-group-preset-wrapper']);
67 | $wrapper_vars['image_alt'] = $menu;
68 |
69 | echo elgg_view_image_block('', $title . $description . $edit, $wrapper_vars);
70 |
--------------------------------------------------------------------------------
/views/default/group_tools/extends/groups/edit/admin_approve.php:
--------------------------------------------------------------------------------
1 | guid) && elgg_is_admin_logged_in()) {
8 | // group create form
9 | return;
10 | }
11 |
12 | if (elgg_get_plugin_setting('admin_approve', 'group_tools') !== 'yes') {
13 | return;
14 | }
15 |
16 | if (empty($entity->guid)) {
17 | // create form
18 | echo elgg_view_message('notice', elgg_echo('group_tools:group:admin_approve:notice'));
19 | } elseif ($entity->access_id === ACCESS_PRIVATE && !(bool) $entity->is_concept) {
20 | // group profile / edit form
21 | $message = elgg_echo('group_tools:group:admin_approve:notice:profile');
22 | $link = '';
23 |
24 | if ($entity->canEdit() && (bool) elgg_get_plugin_setting('creation_reason', 'group_tools')) {
25 | $count = $entity->getAnnotations([
26 | 'count' => true,
27 | 'wheres' => [
28 | function(QueryBuilder $qb, $main_alias) {
29 | return $qb->compare("{$main_alias}.name", 'like', 'approval_reason:%', ELGG_VALUE_STRING);
30 | },
31 | ],
32 | ]);
33 | if (!empty($count)) {
34 | $link = elgg_view('output/url', [
35 | 'text' => elgg_echo('group_tools:group:admin_approve:reasons'),
36 | 'href' => elgg_http_add_url_query_elements('ajax/view/group_tools/group/reasons', [
37 | 'guid' => $entity->guid,
38 | ]),
39 | 'class' => 'elgg-lightbox',
40 | ]);
41 | }
42 | }
43 |
44 | echo elgg_view_message('notice', $message, ['link' => $link]);
45 |
46 | if (elgg_is_admin_logged_in()) {
47 | $form = elgg_view_form('group_tools/admin/decline', [], [
48 | 'entity' => $entity,
49 | ]);
50 | $module = elgg_view_module('info', elgg_echo('group_tools:group:admin_approve:decline:title'), $form, [
51 | 'id' => "group-tools-admin-approve-decline-{$entity->guid}",
52 | ]);
53 |
54 | echo elgg_format_element('div', ['class' => 'hidden'], $module);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/views/default/group_tools/extends/groups/edit/settings/domain_based.php:
--------------------------------------------------------------------------------
1 | 'mbm'], elgg_echo('group_tools:domain_based:description'));
8 |
9 | $domains = '';
10 | $group = elgg_extract('entity', $vars);
11 | if ($group instanceof \ElggGroup) {
12 | $domains = (string) $group->getPluginSetting('group_tools', 'domain_based');
13 | if (!empty($domains)) {
14 | $domains = elgg_string_to_array($domains);
15 | }
16 | }
17 |
18 | $content .= elgg_view_field([
19 | '#type' => 'tags',
20 | 'name' => 'settings[group_tools][domain_based]',
21 | 'value' => $domains,
22 | ]);
23 |
24 | // show content
25 | echo elgg_view_module('info', elgg_echo('group_tools:domain_based:title'), $content);
26 |
--------------------------------------------------------------------------------
/views/default/group_tools/extends/groups/edit/settings/notifications.mjs:
--------------------------------------------------------------------------------
1 | import 'jquery';
2 | import elgg from 'elgg';
3 | import spinner from 'elgg/spinner';
4 |
5 | $(document).on('click', '#group-tools-edit-notifications', function (event) {
6 | var $form = $(this).closest('form');
7 | $form.prop('action', elgg.normalize_url('action/group_tools/admin/notifications'));
8 | spinner.start();
9 | $form.submit();
10 | });
11 |
--------------------------------------------------------------------------------
/views/default/group_tools/extends/groups/edit/settings/notifications.php:
--------------------------------------------------------------------------------
1 | getMembers([
29 | 'count' => true,
30 | ]);
31 |
32 | $notification_count = 0;
33 |
34 | $options = [];
35 | foreach ($methods as $method) {
36 | // make correct label
37 | $label = $method;
38 | if (elgg_language_key_exists("notification:method:{$method}")) {
39 | $label = elgg_echo("notification:method:{$method}");
40 | }
41 |
42 | // add counters (can't use $entity->getSubscribers() because of OOM errors on large groups)
43 | $count = elgg_count_entities([
44 | 'wheres' => [
45 | function(QueryBuilder $qb, $main_alias) use ($entity) {
46 | $rel = $qb->joinRelationshipTable($main_alias, 'guid', null, true);
47 |
48 | return $qb->compare("{$rel}.guid_two", '=', $entity->guid, ELGG_VALUE_GUID);
49 | },
50 | function(QueryBuilder $qb, $main_alias) use ($method) {
51 | $rel = $qb->joinRelationshipTable($main_alias, 'guid', null, true);
52 |
53 | $ors = [
54 | $qb->compare("{$rel}.relationship", '=', SubscriptionsService::RELATIONSHIP_PREFIX . ':' . $method, ELGG_VALUE_STRING),
55 | $qb->compare("{$rel}.relationship", 'like', SubscriptionsService::RELATIONSHIP_PREFIX . ':%:' . $method, ELGG_VALUE_STRING),
56 | ];
57 |
58 | return $qb->merge($ors, 'OR');
59 | },
60 | ],
61 | ]);
62 | $notification_count += $count;
63 |
64 | // append counters to label
65 | $label .= ' ' . elgg_echo('group_tools:edit:group:notifications:counter', [$count, $members_count]);
66 |
67 | $options[$label] = $method;
68 | }
69 |
70 | $content .= elgg_view_field([
71 | '#type' => 'checkboxes',
72 | '#label' => elgg_echo('group_tools:edit:group:notifications:change_settings'),
73 | '#help' => elgg_echo('group_tools:edit:group:notifications:change_settings:help'),
74 | 'name' => 'group_tools_change_notification_settings',
75 | 'options' => $options,
76 | 'align' => 'horizontal',
77 | ]);
78 |
79 | // buttons
80 | $buttons = [];
81 | if ($notification_count > 0) {
82 | $buttons[] = [
83 | '#html' => elgg_view('output/url', [
84 | 'text' => elgg_echo('group_tools:notifications:disable'),
85 | 'title' => elgg_echo('group_tools:notifications:disclaimer'),
86 | 'href' => elgg_generate_action_url('group_tools/admin/disable_notifications', [
87 | 'guid' => $entity->guid,
88 | ]),
89 | 'class' => [
90 | 'elgg-button',
91 | 'elgg-button-delete',
92 | 'mrm',
93 | ],
94 | 'confirm' => true,
95 | ]),
96 | ];
97 | }
98 |
99 | $buttons[] = [
100 | '#type' => 'button',
101 | 'id' => 'group-tools-edit-notifications',
102 | 'text' => elgg_echo('group_tools:notifications:enable'),
103 | 'title' => elgg_echo('group_tools:notifications:disclaimer'),
104 | 'confirm' => true,
105 | 'class' => 'elgg-button-action',
106 | ];
107 |
108 | $content .= elgg_view_field([
109 | '#type' => 'fieldset',
110 | 'fields' => $buttons,
111 | 'align' => 'horizontal',
112 | ]);
113 |
114 | echo elgg_view_module('info', elgg_echo('group_tools:notifications:title'), $content);
115 |
--------------------------------------------------------------------------------
/views/default/group_tools/extends/groups/edit/settings/welcome_message.php:
--------------------------------------------------------------------------------
1 | elgg_echo('group_tools:welcome_message:description'),
8 | ]);
9 |
10 | $help = null;
11 | $value = '';
12 |
13 | $group = elgg_extract('entity', $vars);
14 | if ($group instanceof \ElggGroup) {
15 | $help = elgg_echo('group_tools:welcome_message:explain', [
16 | elgg_get_logged_in_user_entity()->getDisplayName(),
17 | $group->getDisplayName(),
18 | $group->getURL(),
19 | ]);
20 |
21 | $value = $group->getPluginSetting('group_tools', 'welcome_message');
22 | }
23 |
24 | $content .= elgg_view_field([
25 | '#type' => 'longtext',
26 | '#help' => $help,
27 | 'name' => 'settings[group_tools][welcome_message]',
28 | 'value' => $value,
29 | ]);
30 |
31 | echo elgg_view_module('info', elgg_echo('group_tools:welcome_message:title'), $content);
32 |
--------------------------------------------------------------------------------
/views/default/group_tools/extends/groups/profile/concept.php:
--------------------------------------------------------------------------------
1 | canEdit()) {
12 | return;
13 | }
14 |
15 | if ($entity->access_id !== ACCESS_PRIVATE || !(bool) $entity->is_concept) {
16 | return;
17 | }
18 |
19 | $content = elgg_echo('group_tools:group:concept:profile:description');
20 |
21 | $retention = (int) elgg_get_plugin_setting('concept_groups_retention', 'group_tools');
22 | if ($retention > 0) {
23 | $retention_ts = Values::normalizeTime($entity->time_created);
24 | $retention_ts->modify("+{$retention} days");
25 |
26 | $friendly_ts = elgg_get_friendly_time($retention_ts->getTimestamp());
27 |
28 | $content .= ' ' . elgg_echo('group_tools:group:concept:profile:retention', [$friendly_ts]);
29 | }
30 |
31 | echo elgg_view_message('notice', $content);
32 |
--------------------------------------------------------------------------------
/views/default/group_tools/extends/groups/profile/stale_message.mjs:
--------------------------------------------------------------------------------
1 | import 'jquery';
2 | import Ajax from 'elgg/Ajax';
3 |
4 | $(document).on('click', '#group-tools-stale-touch-link', function(event) {
5 | event.preventDefault();
6 |
7 | if (typeof event.result !== 'undefined' && event.result === false) {
8 | return false;
9 | }
10 |
11 | var $elem = $(this);
12 | var ajax = new Ajax();
13 | ajax.action($elem.attr('href'), {
14 | success: function() {
15 | $elem.closest('.elgg-message').remove();
16 | }
17 | });
18 |
19 | return false;
20 | });
21 |
--------------------------------------------------------------------------------
/views/default/group_tools/extends/groups/profile/stale_message.php:
--------------------------------------------------------------------------------
1 | isStale()) {
14 | return;
15 | }
16 |
17 | $link = '';
18 |
19 | if ($entity->canEdit()) {
20 | $link = elgg_view('output/url', [
21 | 'icon' => 'exclamation-triangle',
22 | 'text' => elgg_echo('group_tools:stale_info:link'),
23 | 'href' => elgg_generate_action_url('group_tools/mark_not_stale', [
24 | 'guid' => $entity->guid,
25 | ]),
26 | 'confirm' => true,
27 | 'id' => 'group-tools-stale-touch-link',
28 | ]);
29 |
30 | elgg_import_esm('group_tools/extends/groups/profile/stale_message');
31 | }
32 |
33 | echo elgg_view_message('warning', elgg_echo('group_tools:stale_info:description'), [
34 | 'id' => 'group-tools-stale-message',
35 | 'title' => false,
36 | 'link' => $link,
37 | ]);
38 |
--------------------------------------------------------------------------------
/views/default/group_tools/forms/admin_transfer.php:
--------------------------------------------------------------------------------
1 | owner_guid !== $user->guid && !$user->isAdmin()) {
19 | return;
20 | }
21 |
22 | // transfer owner
23 | $owner_guid_options = [
24 | '#type' => 'userpicker',
25 | '#label' => elgg_echo('groups:owner'),
26 | 'name' => 'owner_guid',
27 | 'value' => $group->owner_guid,
28 | 'placeholder' => elgg_echo('groups:owner:placeholder'),
29 | 'limit' => 1,
30 | 'match_on' => 'group_members',
31 | 'show_friends' => false,
32 | 'options' => [
33 | 'group_guid' => $group->guid,
34 | ],
35 | ];
36 |
37 | if ($group->owner_guid === $user->guid) {
38 | $owner_guid_options['#help'] = elgg_echo('groups:owner:warning');
39 | }
40 |
41 | echo elgg_view_field($owner_guid_options);
42 |
43 | // stay admin
44 | if (group_tools_multiple_admin_enabled() && $group->owner_guid === $user->guid) {
45 | echo elgg_view_field([
46 | '#type' => 'checkbox',
47 | '#label' => elgg_echo('group_tools:admin_transfer:remain_admin'),
48 | '#help' => elgg_echo('group_tools:admin_transfer:remain_admin:help'),
49 | '#class' => 'elgg-divide-left plm',
50 | 'name' => 'admin_transfer_remain',
51 | 'value' => 1,
52 | 'checked' => true,
53 | 'switch' => true,
54 | ]);
55 | }
56 |
--------------------------------------------------------------------------------
/views/default/group_tools/forms/motivation.php:
--------------------------------------------------------------------------------
1 | getDisplayName()]);
15 |
16 | $content = elgg_view('output/longtext', [
17 | 'value' => elgg_echo('group_tools:join_motivation:description', [$group->getDisplayName()]),
18 | ]);
19 | $content .= elgg_view_form('group_tools/join_motivation', ['class' => 'mtm'], ['entity' => $group]);
20 |
21 | echo elgg_view_module('info', $title, $content);
22 |
--------------------------------------------------------------------------------
/views/default/group_tools/group/admin_approve.php:
--------------------------------------------------------------------------------
1 | is_concept) {
20 | // awaiting approval
21 | $buttons[] = elgg_view('output/url', [
22 | 'text' => elgg_echo('approve'),
23 | 'href' => elgg_generate_action_url('group_tools/admin/approve', [
24 | 'guid' => $group->guid,
25 | ]),
26 | 'confirm' => true,
27 | 'class' => 'elgg-button elgg-button-submit',
28 | ]);
29 | $buttons[] = elgg_view('output/url', [
30 | 'text' => elgg_echo('decline'),
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}",
44 | ]);
45 | $content .= elgg_format_element('div', ['class' => 'hidden'], $module);
46 |
47 | $count = $group->getAnnotations([
48 | 'count' => true,
49 | 'wheres' => [
50 | function(QueryBuilder $qb, $main_alias) {
51 | return $qb->compare("{$main_alias}.name", 'like', 'approval_reason:%', ELGG_VALUE_STRING);
52 | },
53 | ],
54 | ]);
55 | if (!empty($count)) {
56 | $buttons[] = elgg_view('output/url', [
57 | 'text' => elgg_echo('group_tools:group:admin_approve:reasons'),
58 | 'href' => elgg_http_add_url_query_elements('ajax/view/group_tools/group/reasons', [
59 | 'guid' => $group->guid,
60 | ]),
61 | 'class' => 'elgg-button elgg-button-action elgg-lightbox',
62 | ]);
63 | }
64 | } else {
65 | // concept group
66 | $buttons[] = elgg_format_element('span', ['class' => 'mls'], elgg_echo('status:draft'));
67 |
68 | $retention = (int) elgg_get_plugin_setting('concept_groups_retention', 'group_tools');
69 | if ($retention > 0) {
70 | $remove_ts = Values::normalizeTime($group->time_created);
71 | $remove_ts->modify("+{$retention} days");
72 |
73 | $friendly_time = elgg_get_friendly_time($remove_ts->getTimestamp());
74 | $buttons[] = elgg_format_element('span', ['class' => 'mls'], elgg_echo('group_tools:group:concept:remaining', [$friendly_time]));
75 | }
76 | }
77 |
78 | echo elgg_view('group/elements/summary', [
79 | 'entity' => $group,
80 | 'icon' => true,
81 | 'icon_entity' => $group,
82 | 'access' => false,
83 | 'metadata' => false,
84 | 'image_block_vars' => [
85 | 'image_alt' => implode('', $buttons) . $content,
86 | ],
87 | ]);
88 |
--------------------------------------------------------------------------------
/views/default/group_tools/group/reasons.php:
--------------------------------------------------------------------------------
1 | canEdit()) {
10 | return;
11 | }
12 |
13 | $content = elgg_list_annotations([
14 | 'limit' => false,
15 | 'guid' => $entity->guid,
16 | 'wheres' => [
17 | function (QueryBuilder $qb, $main_alias) {
18 | return $qb->compare("{$main_alias}.name", 'like', 'approval_reason:%', ELGG_VALUE_STRING);
19 | }
20 | ],
21 | 'item_view' => 'annotation/approval_reason',
22 | ]);
23 |
24 | echo elgg_view_module('info', elgg_echo('group_tools:group:admin_approve:reasons:details'), $content);
25 |
--------------------------------------------------------------------------------
/views/default/group_tools/group/suggested.php:
--------------------------------------------------------------------------------
1 | 'group',
14 | 'query' => $q,
15 | 'limit' => 3,
16 | 'pagination' => false,
17 | 'item_view' => 'group_tools/group/suggested/entity',
18 | ], 'elgg_search');
19 |
20 | if (empty($result)) {
21 | return;
22 | }
23 |
24 | echo elgg_view_module('info', elgg_echo('group_tools:group:edit:suggested'), $result, [
25 | 'id' => 'group-tools-edit-group-suggestions'
26 | ]);
27 |
--------------------------------------------------------------------------------
/views/default/group_tools/group/suggested/entity.php:
--------------------------------------------------------------------------------
1 | $entity,
15 | 'title' => elgg_view_entity_url($entity),
16 | 'content' => elgg_get_excerpt((string) $entity->description),
17 | 'byline' => false,
18 | 'time' => false,
19 | 'access' => false,
20 | 'metadata' => false,
21 | 'icon' => elgg_view_entity_icon($entity, 'small'),
22 | ];
23 | $params = $params + $vars;
24 | echo elgg_view('group/elements/summary', $params);
25 |
--------------------------------------------------------------------------------
/views/default/group_tools/group_admins.php:
--------------------------------------------------------------------------------
1 | 'group_admin',
19 | 'relationship_guid' => $group->guid,
20 | 'inverse_relationship' => true,
21 | 'type' => 'user',
22 | 'limit' => false,
23 | 'list_type' => 'gallery',
24 | 'gallery_class' => 'elgg-gallery-users',
25 | 'wheres' => [
26 | function (QueryBuilder $qb, $main_alias) use ($group) {
27 | return $qb->compare("{$main_alias}.guid", '!=', $group->owner_guid, ELGG_VALUE_GUID);
28 | },
29 | ],
30 | ];
31 |
32 | $users = elgg_get_entities($options);
33 | if (empty($users)) {
34 | return;
35 | }
36 |
37 | // add owner to the beginning of the list
38 | array_unshift($users, $group->getOwnerEntity());
39 |
40 | $body = elgg_view_entity_list($users, $options);
41 |
42 | echo elgg_view_module('aside', elgg_echo('group_tools:multiple_admin:group_admins'), $body);
43 |
--------------------------------------------------------------------------------
/views/default/group_tools/invitationrequests/emailinvitations.php:
--------------------------------------------------------------------------------
1 | canEdit()) {
8 | return;
9 | }
10 |
11 | if (elgg_get_plugin_setting('invite_email', 'group_tools') !== 'yes') {
12 | return;
13 | }
14 |
15 | echo elgg_list_annotations([
16 | 'type' => 'group',
17 | 'annotation_name_value_pairs' => [
18 | [
19 | 'name' => 'email_invitation',
20 | 'value' => "%|{$user->email}",
21 | 'operand' => 'LIKE',
22 | 'type' => ELGG_VALUE_STRING,
23 | ],
24 | ],
25 | 'no_results' => elgg_echo('groups:invitations:none'),
26 | ]);
27 |
--------------------------------------------------------------------------------
/views/default/group_tools/invitationrequests/emailinviteform.php:
--------------------------------------------------------------------------------
1 | guid !== elgg_get_logged_in_user_guid()) {
9 | // only show this form on the current user's page (only applies to admins)
10 | return;
11 | }
12 |
13 | if (elgg_get_plugin_setting('invite_email', 'group_tools') !== 'yes') {
14 | return;
15 | }
16 |
17 | echo elgg_view_module('info', elgg_echo('group_tools:groups:invitation:code:title'), elgg_view_form('groups/email_invitation'));
18 |
--------------------------------------------------------------------------------
/views/default/group_tools/invite/csv.php:
--------------------------------------------------------------------------------
1 | elgg_echo('group_tools:group:invite:csv:description'),
10 | ]);
11 |
12 | echo elgg_view_field([
13 | '#type' => 'file',
14 | 'name' => 'csv',
15 | ]);
16 |
--------------------------------------------------------------------------------
/views/default/group_tools/invite/email.mjs:
--------------------------------------------------------------------------------
1 | import 'jquery';
2 | import system_messages from 'elgg/system_messages';
3 |
4 | $(document).on('keydown', '#group-tools-invite-email .elgg-input-email', function (event) {
5 | if (event.keyCode === 10 || event.keyCode === 13) {
6 | event.preventDefault();
7 | event.stopPropagation();
8 | $('#group-tools-invite-email .elgg-button-action').click();
9 | }
10 | });
11 |
12 | $(document).on('click', '#group-tools-invite-email .elgg-list-email .elgg-icon-delete', function (event) {
13 | $(this).closest('li').remove();
14 | });
15 |
16 | $(document).on('click', '#group-tools-invite-email .elgg-button-action', function (event) {
17 | event.preventDefault();
18 | event.stopPropagation();
19 |
20 | var $form = $('#group-tools-invite-email');
21 | var $email_input = $form.find('.elgg-input-email');
22 |
23 | if (!$email_input[0].checkValidity()) {
24 | system_messages.error($email_input[0].validationMessage);
25 |
26 | return;
27 | }
28 |
29 | var mail = $email_input.val();
30 | if (!mail) {
31 | return;
32 | }
33 |
34 | var $list = $form.find('.elgg-list-email');
35 |
36 | $list.append('' + mail + '');
37 |
38 | $email_input.val('');
39 | });
40 |
--------------------------------------------------------------------------------
/views/default/group_tools/invite/email.php:
--------------------------------------------------------------------------------
1 | 'fieldset',
17 | 'align' => 'horizontal',
18 | 'fields' => [
19 | [
20 | '#type' => 'email',
21 | '#label' => elgg_echo('group_tools:group:invite:email:description'),
22 | '#class' => 'elgg-field-stretch',
23 | 'name' => 'user_guid_email[]',
24 | 'group_guid' => $group->guid,
25 | ],
26 | [
27 | '#type' => 'button',
28 | 'icon' => 'plus',
29 | 'text' => elgg_echo('add'),
30 | 'class' => [
31 | 'elgg-button-action',
32 | ],
33 | ],
34 | ],
35 | ]);
36 |
37 | $contents .= elgg_format_element('ul', ['class' => ['elgg-list', 'elgg-list-email']]);
38 |
39 | echo elgg_format_element('div', ['id' => 'group-tools-invite-email'], $contents);
40 |
--------------------------------------------------------------------------------
/views/default/group_tools/invite/users.php:
--------------------------------------------------------------------------------
1 | 'userpicker',
15 | '#label' => elgg_echo('groups:invite:friends:help'),
16 | 'name' => 'user_guid',
17 | 'options' => [
18 | 'item_view' => 'livesearch/user/group_invite',
19 | 'group_guid' => $group->guid,
20 | ],
21 | ]);
22 |
23 | if (elgg_is_admin_logged_in()) {
24 | echo elgg_view_field([
25 | '#type' => 'checkbox',
26 | '#label' => elgg_echo('group_tools:group:invite:users:all'),
27 | 'name' => 'all_users',
28 | 'value' => 'yes',
29 | 'switch' => true,
30 | ]);
31 | }
32 |
--------------------------------------------------------------------------------
/views/default/group_tools/notifications/settings.php:
--------------------------------------------------------------------------------
1 | isAdmin()) {
10 | return;
11 | }
12 |
13 | if (elgg_get_plugin_setting('admin_approve', 'group_tools') !== 'yes') {
14 | return;
15 | }
16 |
17 | $params = $vars;
18 | $params['description'] = elgg_echo('group_tools:notifications::admin:notify_approval');
19 | $params['purpose'] = 'group_tools_group_approval';
20 |
21 | echo elgg_view('notifications/settings/record', $params);
22 |
--------------------------------------------------------------------------------
/views/default/group_tools/register_extend.php:
--------------------------------------------------------------------------------
1 | 'group_invitecode',
13 | 'value' => $group_invitecode,
14 | ]);
15 |
--------------------------------------------------------------------------------
/views/default/group_tools/site.css:
--------------------------------------------------------------------------------
1 | /** Group tools CSS */
2 | #invite_to_group .ui-helper-hidden-accessible {
3 | display: none;
4 | }
5 |
6 | /* groups simplified options */
7 | .group-tools-simplified-options {
8 | display: flex;
9 | flex-wrap: wrap;
10 |
11 | > div {
12 | flex-basis: 45%;
13 | flex-grow: 1;
14 | }
15 | }
16 |
17 | .group-tools-simplified-option {
18 | background: $(background-color-soft);
19 | border: 1px solid rgba(0, 0, 0, 0.2);
20 | color: $(text-color-mild);
21 | padding: 1rem;
22 | margin: 1rem;
23 | cursor: pointer;
24 |
25 | border-radius: 3px;
26 | box-shadow: inset 0 0 1px rgba(255, 255, 255, 0.6);
27 |
28 | > h2 {
29 | display: block;
30 | color: inherit;
31 | }
32 |
33 | &.elgg-state-active {
34 | color: $(button-action-font-color);
35 | background: $(button-action-background-color);
36 | }
37 | }
38 |
39 | #group-tools-stale-message.elgg-message {
40 | cursor: default;
41 | }
42 |
43 | #group-tools-invite-email {
44 | .elgg-fieldset-horizontal {
45 | align-items: flex-end;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/views/default/groups/edit/access.php:
--------------------------------------------------------------------------------
1 | guid) || ($entity->access_id !== ACCESS_PRIVATE)));
22 |
23 | $show_motivation_option = group_tools_join_motivation_required();
24 | $motivation_plugin_setting = elgg_get_plugin_setting('join_motivation', 'group_tools', 'no');
25 | $show_motivation_option = ($show_motivation_option && str_starts_with($motivation_plugin_setting, 'yes'));
26 |
27 | // group membership
28 | echo elgg_view_field([
29 | '#type' => 'select',
30 | '#label' => elgg_echo('groups:membership'),
31 | 'name' => 'membership',
32 | 'id' => 'groups-membership',
33 | 'value' => $membership,
34 | 'options_values' => [
35 | ACCESS_PRIVATE => elgg_echo('groups:access:private'),
36 | ACCESS_PUBLIC => elgg_echo('groups:access:public'),
37 | ],
38 | ]);
39 |
40 | if ($show_motivation_option) {
41 | $checked = ($motivation_plugin_setting === 'yes_on');
42 | if ($entity instanceof \ElggGroup) {
43 | $group_setting = $entity->join_motivation;
44 | if (!empty($group_setting)) {
45 | $checked = ($group_setting === 'yes');
46 | }
47 | }
48 |
49 | $join_motivation = elgg_view_field([
50 | '#type' => 'checkbox',
51 | '#label' => elgg_echo('group_tools:join_motivation:edit:option:label'),
52 | '#help' => elgg_echo('group_tools:join_motivation:edit:option:description'),
53 | 'name' => 'join_motivation',
54 | 'default' => 'no',
55 | 'value' => 'yes',
56 | 'checked' => $checked,
57 | ]);
58 |
59 | echo elgg_format_element('div', [
60 | 'id' => 'group-tools-join-motivation',
61 | 'class' => ($membership === ACCESS_PRIVATE) ? '' : 'hidden',
62 | ], $join_motivation);
63 | }
64 |
65 | // group access (hidden groups)
66 | if ($show_visibility) {
67 | $visibility_options = [
68 | ACCESS_PRIVATE => elgg_echo('groups:access:group'),
69 | ACCESS_LOGGED_IN => elgg_echo('access:label:logged_in'),
70 | ACCESS_PUBLIC => elgg_echo('access:label:public'),
71 | ];
72 |
73 | if (elgg_get_config('walled_garden')) {
74 | unset($visibility_options[ACCESS_PUBLIC]);
75 |
76 | if ($visibility == ACCESS_PUBLIC) {
77 | $visibility = ACCESS_LOGGED_IN;
78 | }
79 | }
80 |
81 | echo elgg_view_field([
82 | '#type' => 'access',
83 | '#label' => elgg_echo('groups:visibility'),
84 | 'name' => 'vis',
85 | 'id' => 'groups-vis',
86 | 'value' => $visibility,
87 | 'options_values' => $visibility_options,
88 | 'entity' => $entity,
89 | 'entity_type' => 'group',
90 | 'entity_subtype' => '',
91 | ]);
92 | }
93 |
94 | // group content access mode
95 | $access_mode_params = [
96 | '#type' => 'select',
97 | '#label' => elgg_echo('groups:content_access_mode'),
98 | 'name' => 'content_access_mode',
99 | 'id' => 'groups-content-access-mode',
100 | 'value' => $content_access_mode,
101 | 'options_values' => [
102 | \ElggGroup::CONTENT_ACCESS_MODE_UNRESTRICTED => elgg_echo('groups:content_access_mode:unrestricted'),
103 | \ElggGroup::CONTENT_ACCESS_MODE_MEMBERS_ONLY => elgg_echo('groups:content_access_mode:membersonly'),
104 | ],
105 | ];
106 |
107 | if ($entity instanceof \ElggGroup) {
108 | // Disable content_access_mode field for hidden groups because the setting
109 | // will be forced to members_only regardless of the entered value
110 | $acl = $entity->getOwnedAccessCollection('group_acl');
111 | if ($acl instanceof \ElggAccessCollection && ($entity->access_id === $acl->id)) {
112 | $access_mode_params['disabled'] = 'disabled';
113 | }
114 |
115 | if ($entity->getContentAccessMode() == ElggGroup::CONTENT_ACCESS_MODE_UNRESTRICTED) {
116 | // Warn the user that changing the content access mode to more
117 | // restrictive will not affect the existing group content
118 | $access_mode_params['#help'] = elgg_echo('groups:content_access_mode:warning');
119 | }
120 | }
121 |
122 | echo elgg_view_field($access_mode_params);
123 |
124 | // group default access
125 | if ($show_content_default_access) {
126 | $content_default_access_options = [
127 | '' => elgg_echo('groups:content_default_access:not_configured'),
128 | ACCESS_PRIVATE => elgg_echo('groups:access:group'),
129 | ACCESS_LOGGED_IN => elgg_echo('access:label:logged_in'),
130 | ];
131 | if (!elgg_get_config('walled_garden')) {
132 | $content_default_access_options[ACCESS_PUBLIC] = elgg_echo('access:label:public');
133 | }
134 |
135 | echo elgg_view_field([
136 | '#type' => 'select',
137 | '#label' => elgg_echo('groups:content_default_access'),
138 | '#help' => elgg_echo('groups:content_default_access:help'),
139 | 'name' => 'content_default_access',
140 | 'value' => $content_default_access,
141 | 'options_values' => $content_default_access_options,
142 | ]);
143 | }
144 |
145 | // next stuff only when entity exists
146 | if (!$entity) {
147 | return;
148 | }
149 |
150 | // transfer owner
151 | echo elgg_view('group_tools/forms/admin_transfer', $vars);
152 |
--------------------------------------------------------------------------------
/views/default/groups/edit/access_simplified.mjs:
--------------------------------------------------------------------------------
1 | import 'jquery';
2 |
3 | function update_access_values(group_type) {
4 | var $form = $('.elgg-form-groups-edit');
5 | var $membership = $form.find('[name="membership"]');
6 | var $content_access_mode = $form.find('[name="content_access_mode"]');
7 | var $group_default_access = $form.find('[name="content_default_access"]');
8 |
9 | if (group_type === 'open') {
10 | $membership.val('2');
11 | $content_access_mode.val('unrestricted');
12 | $group_default_access.prop('disabled', false);
13 | } else {
14 | // closed
15 | $membership.val('0');
16 | $content_access_mode.val('members_only');
17 | $group_default_access.prop('disabled', true);
18 | }
19 | }
20 |
21 | $('.group-tools-edit-access-simple .group-tools-simplified-option').on('click', function() {
22 | $(this).siblings().removeClass('elgg-state-active');
23 |
24 | $(this).addClass('elgg-state-active');
25 |
26 | update_access_values($(this).data('groupType'));
27 | });
28 |
29 | $('.group-tools-edit-access-simple .group-tools-simplified-option:first').click();
30 |
--------------------------------------------------------------------------------
/views/default/groups/edit/access_simplified.php:
--------------------------------------------------------------------------------
1 | elgg_echo('group_tools:edit:access_simplified:open:description'),
8 | ]);
9 |
10 | $closed_text = elgg_format_element('h2', [], elgg_echo('group_tools:edit:access_simplified:closed'));
11 | $closed_text .= elgg_view('output/longtext', [
12 | 'value' => elgg_echo('group_tools:edit:access_simplified:closed:description'),
13 | ]);
14 |
15 | $open_text = elgg_format_element('div', [
16 | 'class' => 'group-tools-simplified-option elgg-state-active',
17 | 'data-group-type' => 'open',
18 | ], $open_text);
19 |
20 | $closed_text = elgg_format_element('div', [
21 | 'class' => 'group-tools-simplified-option',
22 | 'data-group-type' => 'closed',
23 | ], $closed_text);
24 |
25 | echo elgg_format_element('div', ['class' => ['group-tools-edit-access-simple', 'group-tools-simplified-options']], $open_text . $closed_text);
26 |
27 | $params = [
28 | '_group_tools_simplified_deadloop' => true,
29 | ];
30 | $params = $params + $vars;
31 | echo elgg_format_element('div', ['class' => 'hidden'], elgg_view('groups/edit/access', $params));
32 |
--------------------------------------------------------------------------------
/views/default/groups/edit/reason.php:
--------------------------------------------------------------------------------
1 | '
7 | */
8 |
9 | $entity = elgg_extract('entity', $vars);
10 | if ($entity instanceof \ElggGroup) {
11 | return;
12 | }
13 |
14 | $admin_approve = elgg_get_plugin_setting('admin_approve', 'group_tools') === 'yes';
15 | $admin_approve = $admin_approve && !elgg_is_admin_logged_in();
16 | $ask_reason = (bool) elgg_get_plugin_setting('creation_reason', 'group_tools');
17 | if (!$admin_approve || !$ask_reason) {
18 | return;
19 | }
20 |
21 | echo elgg_view('output/longtext', [
22 | 'value' => elgg_echo('group_tools:group:edit:reason:description'),
23 | ]);
24 |
25 | echo elgg_view_field([
26 | '#type' => 'longtext',
27 | '#label' => elgg_echo('group_tools:group:edit:reason:question'),
28 | 'name' => 'reasons[question]',
29 | 'value' => elgg_extract('question', elgg_extract('reasons', $vars, [])),
30 | 'required' => true,
31 | ]);
32 |
--------------------------------------------------------------------------------
/views/default/groups/edit/tool.php:
--------------------------------------------------------------------------------
1 | 'checkbox',
19 | '#label' => $tool->getLabel(),
20 | '#help' => $tool->getDescription(),
21 | '#class' => elgg_extract_class($vars),
22 | 'name' => elgg_extract('name', $vars, $tool->mapMetadataName()),
23 | 'value' => 'yes',
24 | 'default' => 'no',
25 | 'switch' => true,
26 | 'checked' => elgg_extract('value', $vars) === 'yes',
27 | ]);
28 |
--------------------------------------------------------------------------------
/views/default/groups/edit/tools.php:
--------------------------------------------------------------------------------
1 | group_tools->group($entity);
12 | } else {
13 | $tools = elgg()->group_tools->all();
14 | }
15 |
16 | /* @var $tools \Elgg\Groups\Tool[] */
17 | $tools = $tools->sort(function (\Elgg\Groups\Tool $a, \Elgg\Groups\Tool $b) {
18 | return strcmp($a->getLabel(), $b->getLabel());
19 | })->all();
20 |
21 | if (empty($tools)) {
22 | return;
23 | }
24 |
25 | $vars['tools'] = $tools;
26 |
27 | // if the form comes back from a failed save we can't use the presets
28 | $sticky_form = (bool) elgg_extract('group_tools_presets', $vars, false);
29 | $presets = false;
30 | if (!$sticky_form) {
31 | $presets = group_tools_get_tool_presets();
32 | }
33 |
34 | $vars['presets'] = $presets;
35 |
36 | // we need to be able to tell if we came from a sticky form
37 | echo elgg_view_field([
38 | '#type' => 'hidden',
39 | 'name' => 'group_tools_presets',
40 | 'value' => '1',
41 | ]);
42 |
43 | if (!$entity instanceof \ElggGroup) {
44 | echo elgg_view_field([
45 | '#type' => 'hidden',
46 | 'id' => 'group-tools-preset',
47 | 'name' => 'group_tools_preset',
48 | 'value' => elgg_extract('group_tool_preset', $vars),
49 | ]);
50 | }
51 |
52 | // new group can choose from preset (if any)
53 | if (empty($entity) && !empty($presets)) {
54 | if (elgg_get_plugin_setting('simple_tool_presets', 'group_tools') === 'yes') {
55 | echo elgg_view('groups/edit/tools/simple', $vars);
56 | } else {
57 | echo elgg_view('groups/edit/tools/normal', $vars);
58 | }
59 | } else {
60 | echo elgg_view('groups/edit/tools/default', $vars);
61 | }
62 |
--------------------------------------------------------------------------------
/views/default/groups/edit/tools/default.php:
--------------------------------------------------------------------------------
1 | elgg_extract('entity', $vars),
9 | 'tool' => $tool,
10 | 'value' => elgg_extract($tool->mapMetadataName(), $vars),
11 | ]);
12 | }
13 |
--------------------------------------------------------------------------------
/views/default/groups/edit/tools/normal.mjs:
--------------------------------------------------------------------------------
1 | import 'jquery';
2 |
3 | function ToolsPreset(wrapper) {
4 | var self = this;
5 |
6 | $('#group-tools-preset-selector a', wrapper).on('click', function() {
7 | self.changePreset(this);
8 |
9 | return false;
10 | });
11 |
12 | self.autoDetect(wrapper);
13 | }
14 |
15 | ToolsPreset.prototype = {
16 | changePreset: function(elem) {
17 | var rel = $(elem).attr('rel');
18 |
19 | $('#group-tools-preset-descriptions div').hide();
20 | $('#group-tools-preset-description-' + rel).show();
21 |
22 | this.resetTools();
23 | this.presetTools(rel);
24 |
25 | $('#group-tools-preset-more').hide();
26 | $('#group-tools-preset-active').show();
27 |
28 | },
29 | resetTools: function() {
30 | $('#group-tools-preset-active .elgg-field').each(function(index, elm) {
31 | $(elm).appendTo('#group-tools-preset-more div.elgg-body');
32 | });
33 |
34 | $('#group-tools-preset-more .elgg-input-checkbox[value="yes"]:checked').click();
35 | $('#group-tools-preset-more-link').show();
36 | },
37 | presetTools: function(preset_id) {
38 | if (preset_id === 'blank') {
39 | $('#group-tools-preset-more .elgg-body > .elgg-field').each(function() {
40 | $(this).prependTo('#group-tools-preset-active div.elgg-body');
41 | });
42 | } else {
43 | $('#group-tools-preset-more .elgg-field.group-tools-preset-' + preset_id).each(function() {
44 | $(this).prependTo('#group-tools-preset-active div.elgg-body');
45 | });
46 |
47 | $('#group-tools-preset-active .elgg-input-checkbox[value="yes"]').not(':checked').click();
48 | }
49 |
50 | $('#group-tools-preset').val($('#group-tools-preset-description-' + preset_id + ' input[name="group_tools_preset"]').val());
51 |
52 | if ($('#group-tools-preset-more .elgg-body > .elgg-field').length === 0) {
53 | $('#group-tools-preset-more-link').hide();
54 | }
55 | },
56 | autoDetect: function(wrapper) {
57 | var $input = $(wrapper).find('input[name="group_tools_auto_select"]');
58 | if (!$input.length) {
59 | return;
60 | }
61 |
62 | var $preset = $('#group-tools-preset-selector .elgg-anchor-label').filter(function(index, elem) {
63 | return $input.val() === $(elem).text();
64 | });
65 | if (!$preset.length) {
66 | return;
67 | }
68 |
69 | $preset.closest('a').click();
70 | }
71 | };
72 |
73 | ToolsPreset.init = function(selector) {
74 | new ToolsPreset(selector);
75 | };
76 |
77 | ToolsPreset.init('.elgg-form-groups-edit');
78 |
--------------------------------------------------------------------------------
/views/default/groups/edit/tools/normal.php:
--------------------------------------------------------------------------------
1 | elgg_echo('group_tools:create_group:tool_presets:description'),
10 | ]);
11 |
12 | $preset_selectors = '';
13 | $preset_descriptions = '';
14 |
15 | $presets_tools = [];
16 |
17 | foreach ($presets as $index => $values) {
18 | $preset_selectors .= elgg_view('output/url', [
19 | 'text' => elgg_extract('title', $values),
20 | 'href' => false,
21 | 'class' => 'elgg-button elgg-button-action mrm',
22 | 'rel' => $index,
23 | 'title' => elgg_strip_tags(elgg_extract('description', $values)),
24 | ]);
25 |
26 | $preset_tools = (array) elgg_extract('tools', $values, []);
27 | foreach ($preset_tools as $tool_name => $tool) {
28 | if ($tool == 'yes') {
29 | $presets_tools[$tool_name][] = "group-tools-preset-{$index}";
30 | }
31 | }
32 |
33 | $tool_description = elgg_extract('description', $values);
34 | $tool_description .= elgg_view_field([
35 | '#type' => 'hidden',
36 | 'name' => 'group_tools_preset',
37 | 'value' => elgg_extract('title', $values),
38 | 'disabled' => true,
39 | ]);
40 |
41 | $preset_descriptions .= elgg_format_element('div', [
42 | 'id' => "group-tools-preset-description-{$index}",
43 | 'class' => 'hidden'
44 | ], $tool_description);
45 | }
46 |
47 | // blank preset
48 | $preset_selectors .= elgg_view('output/url', [
49 | 'text' => elgg_echo('group_tools:create_group:tool_presets:blank:title'),
50 | 'href' => '#',
51 | 'class' => 'elgg-button elgg-button-action mrm',
52 | 'rel' => 'blank',
53 | ]);
54 |
55 | $tool_description = elgg_echo('group_tools:create_group:tool_presets:blank:description');
56 | $tool_description .= elgg_view_field([
57 | '#type' => 'hidden',
58 | 'name' => 'group_tools_preset',
59 | 'value' => 'blank',
60 | 'disabled' => true,
61 | ]);
62 | $preset_descriptions .= elgg_format_element('div', [
63 | 'id' => 'group-tools-preset-description-blank',
64 | 'class' => 'hidden'
65 | ], $tool_description);
66 |
67 | echo elgg_format_element('label', ['class' => 'mbs'], elgg_echo('group_tools:create_group:tool_presets:select')) . ':';
68 | echo elgg_format_element('div', ['id' => 'group-tools-preset-selector', 'class' => 'mbs'], $preset_selectors);
69 | echo elgg_format_element('div', ['id' => 'group-tools-preset-descriptions', 'class' => 'mbs'], $preset_descriptions);
70 |
71 | $more_link = elgg_view('output/url', [
72 | 'text' => elgg_echo('group_tools:create_group:tool_presets:show_more'),
73 | 'href' => '#group-tools-preset-more',
74 | 'id' => 'group-tools-preset-more-link',
75 | 'class' => 'elgg-toggle',
76 | ]);
77 |
78 | echo elgg_view_module('info', elgg_echo('group_tools:create_group:tool_presets:active_header'), ' ', [
79 | 'id' => 'group-tools-preset-active',
80 | 'class' => 'hidden',
81 | 'menu' => $more_link,
82 | ]);
83 |
84 | $tools_content = '';
85 | /* @var $tool \Elgg\Groups\Tool */
86 | foreach ($tools as $tool) {
87 | $group_option_toggle_name = $tool->mapMetadataName();
88 |
89 | $options = [
90 | 'tool' => $tool,
91 | 'value' => 'no',
92 | 'class' => ['mbm'],
93 | ];
94 |
95 | if (array_key_exists($group_option_toggle_name, $presets_tools)) {
96 | $options['class'] = elgg_extract_class($options, $presets_tools[$group_option_toggle_name]);
97 | }
98 |
99 | $tools_content .= elgg_view('groups/edit/tool', $options);
100 | }
101 |
102 | echo elgg_view_module('info', elgg_echo('group_tools:create_group:tool_presets:more_header'), $tools_content, ['id' => 'group-tools-preset-more', 'class' => 'hidden']);
103 |
104 | $url_preset = get_input('group_tools_preset');
105 | if (!empty($url_preset)) {
106 | echo elgg_view_field([
107 | '#type' => 'hidden',
108 | 'name' => 'group_tools_auto_select',
109 | 'value' => $url_preset,
110 | ]);
111 | }
112 |
--------------------------------------------------------------------------------
/views/default/groups/edit/tools/simple.mjs:
--------------------------------------------------------------------------------
1 | import 'jquery';
2 |
3 | function update_tools(preset_id) {
4 | var $tool_section = $('.group-tools-edit-tools-simple').parent();
5 | $tool_section.find('.elgg-input-checkbox[value="yes"]:checked').click();
6 |
7 | var $preset_section = $tool_section.find('.group-tools-preset-' + preset_id);
8 | $preset_section.find('.elgg-input-checkbox[value="yes"]').not(':checked').click();
9 | }
10 |
11 | $('.group-tools-edit-tools-simple .group-tools-simplified-option').on('click', function() {
12 | $(this).siblings().removeClass('elgg-state-active');
13 |
14 | $(this).addClass('elgg-state-active');
15 |
16 | $('.elgg-form-groups-edit input[name="group_tools_preset"]').prop('disabled', true);
17 | $(this).find('input[name="group_tools_preset"]').prop('disabled', false);
18 |
19 | update_tools($(this).data('preset'));
20 | });
21 |
22 | var preset = $('.group-tools-simplified-options input[name="preselected_group_tools_preset"]').val();
23 | $('.group-tools-edit-tools-simple .group-tools-simplified-option[data-preset="' + preset + '"]').click();
24 |
--------------------------------------------------------------------------------
/views/default/groups/edit/tools/simple.php:
--------------------------------------------------------------------------------
1 | $preset) {
18 | $title = elgg_extract('title', $preset);
19 | if (!empty($url_preset) && $title === $url_preset) {
20 | $selected_preset = $index;
21 | }
22 |
23 | $preset_content = elgg_format_element('h2', [], $title);
24 | $preset_content .= elgg_view('output/longtext', [
25 | 'value' => elgg_extract('description', $preset),
26 | ]);
27 |
28 | $preset_content .= elgg_view_field([
29 | '#type' => 'hidden',
30 | 'name' => 'group_tools_preset',
31 | 'value' => elgg_extract('title', $preset),
32 | 'disabled' => true,
33 | ]);
34 |
35 | $preset_tools = (array) elgg_extract('tools', $preset, []);
36 | foreach ($preset_tools as $tool_name => $tool) {
37 | if ($tool == 'yes') {
38 | $selected_tools[$tool_name][] = "group-tools-preset-{$index}";
39 | }
40 | }
41 |
42 | $output .= elgg_format_element('div', [
43 | 'class' => 'group-tools-simplified-option',
44 | 'data-preset' => $index,
45 | ], $preset_content);
46 | }
47 |
48 | $output .= elgg_view_field([
49 | '#type' => 'hidden',
50 | 'name' => 'preselected_group_tools_preset',
51 | 'value' => $selected_preset,
52 | ]);
53 |
54 | echo elgg_format_element('div', ['class' => ['group-tools-edit-tools-simple', 'group-tools-simplified-options']], $output);
55 |
56 | /* @var $tool \Elgg\Groups\Tool */
57 | foreach ($tools as $tool) {
58 | $name = $tool->mapMetadataName();
59 |
60 | $options = [
61 | 'tool' => $tool,
62 | 'value' => 'no',
63 | 'class' => ['hidden'],
64 | ];
65 |
66 | if (array_key_exists($name, $selected_tools)) {
67 | $options['class'] = elgg_extract_class($options, $selected_tools[$name]);
68 | }
69 |
70 | echo elgg_view('groups/edit/tool', $options);
71 | }
72 |
--------------------------------------------------------------------------------
/views/default/groups/listing/closed.php:
--------------------------------------------------------------------------------
1 | [
12 | 'name' => 'membership',
13 | 'value' => ACCESS_PUBLIC,
14 | 'operand' => '<>',
15 | ],
16 | ];
17 |
18 | $vars['options'] = array_merge($options, $closed_options);
19 |
20 | echo elgg_view('groups/listing/all', $vars);
21 |
--------------------------------------------------------------------------------
/views/default/groups/listing/managed.php:
--------------------------------------------------------------------------------
1 | [
18 | function(QueryBuilder $qb, $main_alias) use ($user_guid) {
19 | $subquery = $qb->subquery(RelationshipsTable::TABLE_NAME, 'managed');
20 | $subquery->select('guid_two')
21 | ->where($qb->compare("{$subquery->getTableAlias()}.guid_one", '=', $user_guid, ELGG_VALUE_GUID))
22 | ->andWhere($qb->compare("{$subquery->getTableAlias()}.relationship", '=', 'group_admin', ELGG_VALUE_STRING));
23 |
24 | $managed = $qb->compare("{$main_alias}.guid", 'IN', $subquery->getSQL());
25 |
26 | $owner = $qb->compare("{$main_alias}.owner_guid", '=', $user_guid, ELGG_VALUE_GUID);
27 |
28 | return $qb->merge([$managed, $owner], 'OR');
29 | },
30 | ],
31 | ];
32 |
33 | $vars['options'] = array_merge($options, $managed_options);
34 |
35 | echo elgg_view('groups/listing/all', $vars);
36 |
--------------------------------------------------------------------------------
/views/default/groups/listing/member.php:
--------------------------------------------------------------------------------
1 | 'member',
18 | 'relationship_guid' => elgg_get_logged_in_user_guid(),
19 | 'inverse_relationship' => false,
20 | ];
21 |
22 | $vars['options'] = array_merge($options, $member_options);
23 |
24 | echo elgg_view('groups/listing/all', $vars);
25 |
--------------------------------------------------------------------------------
/views/default/groups/listing/open.php:
--------------------------------------------------------------------------------
1 | [
12 | 'name' => 'membership',
13 | 'value' => ACCESS_PUBLIC,
14 | ],
15 | ];
16 |
17 | $vars['options'] = array_merge($options, $open_options);
18 |
19 | echo elgg_view('groups/listing/all', $vars);
20 |
--------------------------------------------------------------------------------
/views/default/groups/listing/preset.php:
--------------------------------------------------------------------------------
1 | in your input to get a list of groups with the preset
6 | * Pass include_undefined=1 to include all groups without a preset configured
7 | */
8 |
9 | use Elgg\Database\MetadataTable;
10 | use Elgg\Database\QueryBuilder;
11 |
12 | $preset = get_input('preset');
13 | if (empty($preset)) {
14 | throw new \Elgg\Exceptions\Http\BadRequestException();
15 | }
16 |
17 | $preset_options = [];
18 | if ((bool) get_input('include_undefined', false)) {
19 | $preset_options['wheres'] = [
20 | function (QueryBuilder $qb, $main_alias) use ($preset) {
21 | $subquery = $qb->subquery(MetadataTable::TABLE_NAME);
22 | $subquery->select('entity_guid')
23 | ->where($qb->compare('name', '=', 'group_tools_preset', ELGG_VALUE_STRING));
24 |
25 | $nothaving = $qb->compare("{$main_alias}.guid", 'NOT IN', $subquery->getSQL());
26 |
27 | $subquery = $qb->subquery(MetadataTable::TABLE_NAME);
28 | $subquery->select('entity_guid')
29 | ->where($qb->compare('name', '=', 'group_tools_preset', ELGG_VALUE_STRING))
30 | ->andWhere($qb->compare('value', '=', $preset, ELGG_VALUE_STRING));
31 |
32 | $having = $qb->compare("{$main_alias}.guid", 'IN', $subquery->getSQL());
33 |
34 | return $qb->merge([$nothaving, $having], 'OR');
35 | },
36 | ];
37 | } else {
38 | $preset_options['metadata_name_value_pairs'] = [
39 | 'group_tools_preset' => $preset,
40 | ];
41 | }
42 |
43 | $options = (array) elgg_extract('options', $vars);
44 | $vars['options'] = array_merge($options, $preset_options);
45 |
46 | echo elgg_view('groups/listing/all', $vars);
47 |
--------------------------------------------------------------------------------
/views/default/groups/listing/suggested.php:
--------------------------------------------------------------------------------
1 | elgg_echo('group_tools:suggested_groups:info'),
13 | ]);
14 |
15 | $vars['full_view'] = false;
16 |
17 | echo elgg_view_entity_list($groups, $vars);
18 |
--------------------------------------------------------------------------------
/views/default/groups/listing/yours.php:
--------------------------------------------------------------------------------
1 | elgg_get_logged_in_user_guid(),
13 | ];
14 |
15 | $vars['options'] = array_merge($options, $yours_options);
16 |
17 | echo elgg_view('groups/listing/all', $vars);
18 |
--------------------------------------------------------------------------------
/views/default/groups/profile/module/related_groups.php:
--------------------------------------------------------------------------------
1 | elgg_generate_url('collection:group:group:related', [
13 | 'guid' => $group->guid,
14 | ]),
15 | 'text' => elgg_echo('link:view:all'),
16 | ]);
17 |
18 | $content = elgg_list_entities([
19 | 'type' => 'group',
20 | 'limit' => 4,
21 | 'relationship' => 'related_group',
22 | 'relationship_guid' => $group->guid,
23 | 'full_view' => false,
24 | 'sort_by' => [
25 | 'property' => 'name',
26 | 'direction' => 'ASC',
27 | ],
28 | 'no_results' => elgg_echo('groups_tools:related_groups:none'),
29 | ]);
30 |
31 | echo elgg_view('groups/profile/module', [
32 | 'title' => elgg_echo('widgets:group_related:name'),
33 | 'content' => $content,
34 | 'all_link' => $all_link,
35 | ]);
36 |
--------------------------------------------------------------------------------
/views/default/input/group_tools_preset.php:
--------------------------------------------------------------------------------
1 | $content,
19 | 'sidebar' => $sidebar,
20 | 'filter_id' => 'groups/all',
21 | 'filter_value' => $selected_tab,
22 | 'filter_sorting' => $selected_tab !== 'suggested',
23 | 'filter_sorting_selected' => elgg_extract('filter_sorting_selected', $vars),
24 | ]);
25 |
--------------------------------------------------------------------------------
/views/default/resources/groups/email_invitations.php:
--------------------------------------------------------------------------------
1 | canEdit()) {
16 | elgg_register_menu_item('title', [
17 | 'name' => 'groups:invite',
18 | 'icon' => 'user-plus',
19 | 'href' => elgg_generate_entity_url($group, 'invite'),
20 | 'text' => elgg_echo('groups:invite'),
21 | 'link_class' => 'elgg-button elgg-button-action',
22 | ]);
23 | }
24 |
25 | $offset = (int) get_input('offset', 0);
26 | $limit = (int) get_input('limit', 25);
27 |
28 | // build page elements
29 | $content = elgg_list_annotations([
30 | 'selects' => [
31 | function(QueryBuilder $qb, $main_alias) {
32 | return "SUBSTRING_INDEX({$main_alias}.value, '|', -1) AS invited_email";
33 | },
34 | ],
35 | 'annotation_name' => 'email_invitation',
36 | 'annotation_owner_guid' => $group->guid,
37 | 'wheres' => [
38 | function(QueryBuilder $qb, $main_alias) {
39 | return $qb->compare("{$main_alias}.value", 'LIKE', '%|%', ELGG_VALUE_STRING);
40 | },
41 | ],
42 | 'offset' => $offset,
43 | 'limit' => $limit,
44 | 'count' => true,
45 | 'order_by' => new OrderByClause('invited_email', 'ASC'),
46 | 'no_results' => elgg_echo('group_tools:groups:membershipreq:email_invitations:none'),
47 | ]);
48 |
49 | // draw page
50 | echo elgg_view_page(elgg_echo('collection:annotation:email_invitation:group'), [
51 | 'content' => $content,
52 | 'filter_id' => 'groups/members',
53 | 'filter_value' => 'email_invitations',
54 | 'filter_entity' => $group,
55 | 'filter_sorting' => false,
56 | ]);
57 |
--------------------------------------------------------------------------------
/views/default/resources/groups/invite.php:
--------------------------------------------------------------------------------
1 | 'invite_to_group',
13 | 'class' => 'mtm',
14 | 'prevent_double_submit' => false,
15 | 'sticky_enabled' => true,
16 | ], [
17 | 'entity' => $group,
18 | 'invite_email' => $invite_email,
19 | 'invite_csv' => $invite_csv,
20 | ]);
21 |
22 | echo elgg_view_page(elgg_echo('groups:invite:title'), [
23 | 'content' => $content,
24 | 'filter_id' => 'groups/invite',
25 | 'filter_value' => 'invite',
26 | ]);
27 |
--------------------------------------------------------------------------------
/views/default/resources/groups/mail.php:
--------------------------------------------------------------------------------
1 | guid);
18 | elgg_set_context('groups');
19 |
20 | // set breadcrumb
21 | elgg_push_entity_breadcrumbs($group);
22 |
23 | // build page elements
24 | $form_vars = [
25 | 'id' => 'group_tools_mail_form',
26 | ];
27 | $body_vars = [
28 | 'entity' => $group,
29 | ];
30 | $form = elgg_view_form('group_tools/mail', $form_vars, $body_vars);
31 |
32 | // draw page
33 | echo elgg_view_page(elgg_echo('group_tools:mail:title'), [
34 | 'content' => $form,
35 | 'filter_id' => 'groups/mail',
36 | 'filter_value' => 'mail',
37 | ]);
38 |
--------------------------------------------------------------------------------
/views/default/resources/groups/members.php:
--------------------------------------------------------------------------------
1 | canEdit()) {
14 | elgg_register_menu_item('title', [
15 | 'name' => 'groups:invite',
16 | 'icon' => 'user-plus',
17 | 'href' => elgg_generate_entity_url($group, 'invite'),
18 | 'text' => elgg_echo('groups:invite'),
19 | 'link_class' => 'elgg-button elgg-button-action',
20 | ]);
21 | }
22 |
23 | $filter = get_input('filter', 'members');
24 |
25 | $options = [
26 | 'type' => 'user',
27 | 'relationship' => 'member',
28 | 'relationship_guid' => $group->guid,
29 | 'inverse_relationship' => true,
30 | 'sort_by' => get_input('sort_by', [
31 | 'property' => 'name',
32 | 'property_type' => 'metadata',
33 | 'direction' => 'asc',
34 | ]),
35 | ];
36 |
37 | if ($filter === 'group_admins') {
38 | $options['wheres'] = [
39 | function (QueryBuilder $qb, $main_alias) use ($group) {
40 | $owner = $qb->compare("{$main_alias}.guid_one", '=', $group->owner_guid, ELGG_VALUE_GUID);
41 |
42 | $admin_query = $qb->subquery(RelationshipsTable::TABLE_NAME)
43 | ->select('guid_one')
44 | ->where($qb->compare('relationship', '=', 'group_admin', ELGG_VALUE_STRING))
45 | ->andWhere($qb->compare('guid_two', '=', $group->guid, ELGG_VALUE_GUID));
46 |
47 | $admins = $qb->compare("{$main_alias}.guid_one", 'IN', $admin_query->getSQL());
48 |
49 | return $qb->merge([$owner, $admins], 'OR');
50 | },
51 | ];
52 | }
53 |
54 | $members_search = get_input('members_search');
55 | if (!elgg_is_empty($members_search)) {
56 | $options['metadata_name_value_pairs'] = [
57 | [
58 | 'name' => 'name',
59 | 'value' => "%{$members_search}%",
60 | 'operand' => 'LIKE',
61 | 'case_sensitive' => false,
62 | ],
63 | [
64 | 'name' => 'username',
65 | 'value' => "%{$members_search}%",
66 | 'operand' => 'LIKE',
67 | 'case_sensitive' => false,
68 | ],
69 | ];
70 | $options['metadata_name_value_pairs_operator'] = 'OR';
71 | }
72 |
73 | $list = elgg_list_relationships($options);
74 |
75 | if (elgg_is_xhr() && isset($members_search)) {
76 | // ajax pagination
77 | echo $list;
78 | return;
79 | }
80 |
81 | $form = elgg_view_form('group_tools/members_search', [
82 | 'action' => elgg_http_add_url_query_elements(elgg_get_current_url(), [
83 | 'guid' => $group->guid,
84 | ]),
85 | 'disable_security' => true,
86 | 'prevent_double_submit' => false,
87 | ]);
88 |
89 | // draw page
90 | echo elgg_view_page(elgg_echo('groups:members:title', [$group->getDisplayName()]), [
91 | 'content' => $form . $list,
92 | 'filter_id' => 'groups/members',
93 | 'filter_value' => $filter,
94 | 'filter_entity' => $group,
95 | ]);
96 |
--------------------------------------------------------------------------------
/views/default/resources/groups/related.php:
--------------------------------------------------------------------------------
1 | canEdit()) {
16 | $content .= elgg_view_form('group_tools/related_groups', [
17 | 'class' => 'mbm',
18 | ], [
19 | 'entity' => $group,
20 | ]);
21 | }
22 |
23 | $content .= elgg_list_entities([
24 | 'type' => 'group',
25 | 'relationship' => 'related_group',
26 | 'relationship_guid' => $group->guid,
27 | 'sort_by' => [
28 | 'property' => 'name',
29 | 'direction' => 'ASC',
30 | ],
31 | 'no_results' => elgg_echo('groups_tools:related_groups:none'),
32 | ]);
33 |
34 | // draw page
35 | echo elgg_view_page(elgg_echo('group_tools:related_groups:title'), [
36 | 'content' => $content,
37 | 'filter_id' => 'groups/related',
38 | 'filter_value' => 'related',
39 | ]);
40 |
--------------------------------------------------------------------------------
/views/default/resources/groups/user/email_invitations.php:
--------------------------------------------------------------------------------
1 | $user]);
13 | $content .= elgg_view('group_tools/invitationrequests/emailinviteform', ['entity' => $user]);
14 |
15 | // draw page
16 | echo elgg_view_page(elgg_echo('collection:annotation:email_invitation:user'), [
17 | 'content' => $content,
18 | 'filter_id' => 'groups/invitations',
19 | 'filter_value' => 'email_invitations',
20 | ]);
21 |
--------------------------------------------------------------------------------
/views/default/widgets/a_users_groups/content.php:
--------------------------------------------------------------------------------
1 | getOwnerEntity();
16 | if (!$owner instanceof \ElggUser) {
17 | $owner = elgg_get_logged_in_user_entity();
18 | }
19 |
20 | if (!$owner instanceof \ElggUser) {
21 | echo elgg_view_message('notice', elgg_echo('loggedinrequired'), ['title' => false]);
22 | return;
23 | }
24 |
25 | $num_display = (int) $widget->num_display ?: 4;
26 | $sort_by = $widget->sort_by ?? 'alpha';
27 |
28 | $params = [
29 | 'type' => 'group',
30 | 'relationship' => 'member',
31 | 'relationship_guid' => $owner->guid,
32 | 'limit' => $num_display,
33 | 'pagination' => false,
34 | 'no_results' => elgg_echo('groups:none'),
35 | 'widget_more' => elgg_view_url($widget->getURL(), elgg_echo('groups:more')),
36 | 'sort_by' => [
37 | 'property_type' => 'metadata',
38 | 'property' => 'name',
39 | ],
40 | ];
41 |
42 | if ($widget->context !== 'profile') {
43 | switch ($sort_by) {
44 | case 'join_date':
45 | $params['sort_by'] = [
46 | 'property_type' => 'relationship',
47 | 'property' => 'member',
48 | 'direction' => 'DESC',
49 | 'relationship_guid' => $owner->guid,
50 | ];
51 | break;
52 |
53 | case 'activity':
54 | unset($params['sort_by']);
55 |
56 | // sort by latest activity
57 | $params['select'][] = function (QueryBuilder $qb, $main_alias) use ($owner) {
58 | $river = $qb->subquery(RiverTable::TABLE_NAME, 'river');
59 | $river->select("{$river->getTableAlias()}.posted");
60 | $river->joinEntitiesTable($river->getTableAlias(), 'object_guid', 'inner', 'ent');
61 | $river->where($qb->compare("{$river->getTableAlias()}.subject_guid", '=', $owner->guid, ELGG_VALUE_GUID));
62 | $river->andWhere($qb->merge([
63 | $qb->compare("{$main_alias}.guid", '=', 'ent.container_guid'),
64 | $qb->compare("{$main_alias}.guid", '=', 'river.object_guid'),
65 | ], 'OR'));
66 | $river->orderBy("{$river->getTableAlias()}.posted", 'desc');
67 | $river->setMaxResults(1);
68 |
69 | return '('. $river->getSQL() . ') AS latest_activity';
70 | };
71 |
72 | $params['order_by'][] = new OrderByClause('latest_activity', 'desc');
73 | $params['order_by'][] = new OrderByClause('e.time_created', 'desc');
74 | break;
75 | }
76 | }
77 |
78 | echo elgg_list_entities($params);
79 |
--------------------------------------------------------------------------------
/views/default/widgets/a_users_groups/edit.php:
--------------------------------------------------------------------------------
1 | context !== 'profile') {
12 | echo elgg_view_field([
13 | '#type' => 'select',
14 | '#label' => elgg_echo('widgets:a_users_groups:sort_by'),
15 | 'name' => 'params[sort_by]',
16 | 'value' => $widget->sort_by,
17 | 'options_values' => [
18 | 'alpha' => elgg_echo('sort:alpha'),
19 | 'activity' => elgg_echo('widgets:a_users_groups:sort_by:activity'),
20 | 'join_date' => elgg_echo('widgets:a_users_groups:sort_by:join_date'),
21 | ],
22 | ]);
23 | }
24 |
25 | echo elgg_view('object/widget/edit/num_display', [
26 | 'entity' => $widget,
27 | 'label' => elgg_echo('groups:widget:num_display'),
28 | 'default' => 4,
29 | 'min' => 1,
30 | ]);
31 |
--------------------------------------------------------------------------------
/views/default/widgets/featured_groups/content.php:
--------------------------------------------------------------------------------
1 | num_display ?: 5;
14 |
15 | $show_random = $widget->show_random;
16 |
17 | $entities = elgg_get_entities([
18 | 'type' => 'group',
19 | 'limit' => $num_display,
20 | 'metadata_name_value_pairs' => ['featured_group' => 'yes'],
21 | 'order_by' => new OrderByClause('RAND()'),
22 | ]);
23 |
24 | if ($show_random == 'yes') {
25 | $random = elgg_get_entities([
26 | 'type' => 'group',
27 | 'limit' => 1,
28 | 'order_by' => new OrderByClause('RAND()'),
29 | 'wheres' => [
30 | function (QueryBuilder $qb, $main_alias) {
31 | $subquery = $qb->subquery(MetadataTable::TABLE_NAME, 'featured_md');
32 | $subquery->select('entity_guid')
33 | ->andWhere($qb->compare("{$subquery->getTableAlias()}.name", '=', 'featured_group', ELGG_VALUE_STRING))
34 | ->andWhere($qb->compare("{{$subquery->getTableAlias()}}.value", '=', 'yes', ELGG_VALUE_STRING));
35 |
36 | return $qb->compare("{$main_alias}.guid", 'NOT IN', $subquery->getSQL());
37 | },
38 | ],
39 | ]);
40 |
41 | $entities = array_merge($entities, $random);
42 | }
43 |
44 | echo elgg_view_entity_list($entities, [
45 | 'limit' => count($entities),
46 | 'count' => count($entities),
47 | 'pagination' => false,
48 | 'full_view' => false,
49 | 'no_results' => true,
50 | ]);
51 |
--------------------------------------------------------------------------------
/views/default/widgets/featured_groups/edit.php:
--------------------------------------------------------------------------------
1 | $widget,
11 | 'default' => 5,
12 | 'min' => 1,
13 | 'max' => 10,
14 | ]);
15 |
16 | echo elgg_view_field([
17 | '#type' => 'checkbox',
18 | '#label' => elgg_echo('widgets:featured_groups:edit:show_random_group'),
19 | 'name' => 'params[show_random]',
20 | 'checked' => $widget->show_random === 'yes',
21 | 'default' => 'no',
22 | 'value' => 'yes',
23 | 'switch' => true,
24 | ]);
25 |
--------------------------------------------------------------------------------
/views/default/widgets/group_invitations/content.php:
--------------------------------------------------------------------------------
1 | false]);
9 | return;
10 | }
11 |
12 | echo elgg_call(ELGG_IGNORE_ACCESS, function() use ($user) {
13 | return elgg_list_relationships([
14 | 'relationship' => 'invited',
15 | 'relationship_guid' => $user->guid,
16 | 'inverse_relationship' => true,
17 | 'no_results' => elgg_echo('groups:invitations:none'),
18 | ]);
19 | });
20 |
--------------------------------------------------------------------------------
/views/default/widgets/group_members/content.php:
--------------------------------------------------------------------------------
1 | num_display ?: 5;
10 |
11 | echo elgg_list_entities([
12 | 'type' => 'user',
13 | 'limit' => $count,
14 | 'relationship' => 'member',
15 | 'relationship_guid' => $widget->owner_guid,
16 | 'inverse_relationship' => true,
17 | 'list_type' => 'gallery',
18 | 'gallery_class' => 'elgg-gallery-users',
19 | 'pagination' => false,
20 | 'no_results' => elgg_echo('widgets:group_members:view:no_members'),
21 | ]);
22 |
--------------------------------------------------------------------------------
/views/default/widgets/group_members/edit.php:
--------------------------------------------------------------------------------
1 | $widget,
11 | 'default' => 5,
12 | 'min' => 1,
13 | ]);
14 |
--------------------------------------------------------------------------------
/views/default/widgets/group_related/content.php:
--------------------------------------------------------------------------------
1 | num_display ?: 4;
10 |
11 | echo elgg_list_entities([
12 | 'type' => 'group',
13 | 'limit' => $num_display,
14 | 'relationship' => 'related_group',
15 | 'relationship_guid' => $widget->owner_guid,
16 | 'full_view' => false,
17 | 'pagination' => false,
18 | 'sort_by' => [
19 | 'property' => 'name',
20 | 'direction' => 'ASC',
21 | ],
22 | 'no_results' => elgg_echo('groups_tools:related_groups:none'),
23 | ]);
24 |
--------------------------------------------------------------------------------
/views/default/widgets/group_related/edit.php:
--------------------------------------------------------------------------------
1 | $widget,
11 | 'default' => 4,
12 | 'min' => 1,
13 | ]);
14 |
--------------------------------------------------------------------------------
/views/default/widgets/group_river_widget/content.php:
--------------------------------------------------------------------------------
1 | context == 'groups') {
14 | $group_guid = [$widget->owner_guid];
15 | } else {
16 | $group_guid = $widget->group_guid;
17 | if (!empty($group_guid)) {
18 | if (!is_array($group_guid)) {
19 | $group_guid = [$group_guid];
20 | }
21 | }
22 | }
23 |
24 | if (!empty($group_guid)) {
25 | array_walk($group_guid, function(&$value) {
26 | $value = (int) $value;
27 | });
28 | $group_guid = array_filter($group_guid, function ($value) {
29 | return $value > 0;
30 | });
31 | }
32 |
33 | if (empty($group_guid)) {
34 | echo elgg_echo('widgets:not_configured');
35 | return;
36 | }
37 |
38 | // limit
39 | $limit = (int) $widget->num_display;
40 | if ($limit < 1) {
41 | $limit = 10;
42 | }
43 |
44 | // prepare options
45 | $options = [
46 | 'limit' => $limit,
47 | 'wheres' => [
48 | function (QueryBuilder $qb, $main_alias) use ($group_guid) {
49 | $wheres = [];
50 | $wheres[] = $qb->compare("{$main_alias}.object_guid", 'in', $group_guid, ELGG_VALUE_GUID);
51 | $wheres[] = $qb->compare("{$main_alias}.target_guid", 'in', $group_guid, ELGG_VALUE_GUID);
52 |
53 | $sub = $qb->subquery(EntityTable::TABLE_NAME, 'ce');
54 | $sub->select("{$sub->getTableAlias()}.guid")
55 | ->where($qb->compare("{$sub->getTableAlias()}.container_guid", 'in', $group_guid, ELGG_VALUE_GUID));
56 |
57 | $wheres[] = $qb->compare("{$main_alias}.object_guid", 'in', $sub->getSQL());
58 |
59 | $wheres[] = $qb->compare("{$main_alias}.target_guid", 'in', $sub->getSQL());
60 |
61 | return $qb->merge($wheres, 'OR');
62 | },
63 | ],
64 | 'pagination' => false,
65 | 'no_results' => elgg_echo('widgets:group_river_widget:view:noactivity'),
66 | ];
67 |
68 | // get activity filter
69 | $activity_filter = $widget->activity_filter;
70 | if (!empty($activity_filter) && is_string($activity_filter)) {
71 | list($type, $subtype) = explode(',', $activity_filter);
72 |
73 | if (!empty($type)) {
74 | $options['type'] = $type;
75 | }
76 |
77 | if (!empty($subtype)) {
78 | $options['subtype'] = $subtype;
79 | }
80 | }
81 |
82 | echo elgg_list_river($options);
83 |
--------------------------------------------------------------------------------
/views/default/widgets/group_river_widget/edit.php:
--------------------------------------------------------------------------------
1 | elgg_echo('all'),
13 | ];
14 | $registered_entities = elgg_entity_types_with_capability('searchable');
15 | if (!empty($registered_entities)) {
16 | foreach ($registered_entities as $type => $subtypes) {
17 | if (empty($subtypes)) {
18 | return;
19 | }
20 |
21 | foreach ($subtypes as $subtype) {
22 | $keyname = "collection:{$type}:{$subtype}";
23 | if (!elgg_language_key_exists($keyname)) {
24 | $keyname = "item:{$type}:{$subtype}";
25 | }
26 |
27 | $filter_contents["{$type},{$subtype}"] = elgg_echo($keyname);
28 | }
29 | }
30 | }
31 |
32 | // make options
33 | echo elgg_view('object/widget/edit/num_display', [
34 | 'entity' => $widget,
35 | 'max' => 25,
36 | 'min' => 1,
37 | ]);
38 |
39 | echo elgg_view_field([
40 | '#type' => 'select',
41 | '#label' => elgg_echo('filter'),
42 | 'name' => 'params[activity_filter]',
43 | 'value' => $widget->activity_filter,
44 | 'options_values' => $filter_contents,
45 | ]);
46 |
47 | // only allow a group picker if not in a group already
48 | if ($widget->context !== 'groups') {
49 | $owner = $widget->getOwnerEntity();
50 |
51 | if (elgg_is_active_plugin('widget_manager')) {
52 | $group_picker_options = [
53 | '#type' => 'grouppicker',
54 | '#label' => elgg_echo('widgets:group_river_widget:edit:group'),
55 | 'name' => 'params[group_guid]',
56 | 'value' => $widget->group_guid,
57 | 'options' => [],
58 | ];
59 |
60 | if ($owner instanceof \ElggUser) {
61 | $group_picker_options['options']['match_target'] = $owner->guid;
62 | $group_picker_options['options']['match_owner'] = false;
63 | $group_picker_options['options']['match_membership'] = true;
64 | }
65 |
66 | echo elgg_view_field($group_picker_options);
67 | } else {
68 | // Widget owner might not be a user entity (e.g. on default widgets config page it's an ElggSite entity)
69 | if (!$owner instanceof \ElggUser) {
70 | $owner = elgg_get_logged_in_user_entity();
71 | }
72 |
73 | $groups = $owner->getGroups(['limit' => false]);
74 |
75 | $mygroups = [];
76 | if (!$widget->group_guid) {
77 | $mygroups[0] = '';
78 | }
79 |
80 | foreach ($groups as $group) {
81 | $mygroups[$group->guid] = $group->getDisplayName();
82 | }
83 |
84 | echo elgg_view_field([
85 | '#type' => 'select',
86 | 'name' => 'params[group_guid]',
87 | '#label' => elgg_echo('widgets:group_river_widget:edit:group'),
88 | 'value' => $widget->group_guid,
89 | 'options_values' => $mygroups,
90 | ]);
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/views/default/widgets/index_groups/content.php:
--------------------------------------------------------------------------------
1 | group_count;
11 | if ($count < 1) {
12 | $count = 8;
13 | }
14 |
15 | $options = [
16 | 'type' => 'group',
17 | 'limit' => $count,
18 | 'full_view' => false,
19 | 'pagination' => false,
20 | 'metadata_name_value_pairs' => [],
21 | 'metadata_case_sensitive' => false,
22 | 'no_results' => elgg_echo('groups:none'),
23 | ];
24 |
25 | // limit to featured groups?
26 | if ($widget->featured == 'yes') {
27 | $options['metadata_name_value_pairs'][] = [
28 | 'name' => 'featured_group',
29 | 'value' => 'yes',
30 | ];
31 | }
32 |
33 | // enable advanced filter
34 | $filter_name = $widget->filter_name;
35 | $filter_value = $widget->filter_value;
36 | if (!empty($filter_name) && !empty($filter_value)) {
37 | $profile_fields = elgg()->fields->get('group', 'group');
38 | if (!empty($profile_fields)) {
39 | $found = false;
40 |
41 | foreach ($profile_fields as $field_config) {
42 | if ((elgg_extract('name', $field_config) === $filter_name) && (elgg_extract('#type', $field_config) === 'tags')) {
43 | $found = true;
44 | break;
45 | }
46 | }
47 |
48 | if ($found) {
49 | $filter_value = elgg_string_to_array((string) $filter_value);
50 |
51 | $options['metadata_name_value_pairs'][] = [
52 | 'name' => $filter_name,
53 | 'value' => $filter_value,
54 | ];
55 | }
56 | }
57 | }
58 |
59 | // check if groups should respect a specific order
60 | $gettter = 'elgg_get_entities';
61 | switch ($widget->sorting) {
62 | case 'popular':
63 | $gettter = 'elgg_get_entities_from_relationship_count';
64 |
65 | $options['relationship'] = 'member';
66 | $options['inverse_relationship'] = false;
67 | break;
68 | default:
69 | // just use default time created sorting
70 | break;
71 | }
72 |
73 | // list groups
74 | echo elgg_list_entities($options, $gettter);
75 |
--------------------------------------------------------------------------------
/views/default/widgets/index_groups/edit.php:
--------------------------------------------------------------------------------
1 | fields->get('group', 'group');
12 | if (!empty($profile_fields)) {
13 | foreach ($profile_fields as $field_config) {
14 | if (elgg_extract('#type', $field_config) !== 'tags') {
15 | continue;
16 | }
17 |
18 | $name = elgg_extract('name', $field_config);
19 |
20 | $label = $name;
21 | $lan_key = "groups:{$name}";
22 | if (elgg_language_key_exists($lan_key)) {
23 | $label = elgg_echo($lan_key);
24 | }
25 |
26 | $tag_fields[$name] = $label;
27 | }
28 | }
29 |
30 | echo elgg_view('object/widget/edit/num_display', [
31 | 'entity' => $widget,
32 | 'name' => 'group_count',
33 | 'default' => 8,
34 | 'min' => 1,
35 | ]);
36 |
37 | echo elgg_view_field([
38 | '#type' => 'checkbox',
39 | '#label' => elgg_echo('widgets:index_groups:featured'),
40 | 'name' => 'params[featured]',
41 | 'checked' => $widget->featured === 'yes',
42 | 'default' => 'no',
43 | 'value' => 'yes',
44 | 'switch' => true,
45 | ]);
46 |
47 | if (!empty($tag_fields)) {
48 | $tag_fields = array_reverse($tag_fields);
49 | $tag_fields[''] = elgg_echo('widgets:index_groups:filter:no_filter');
50 | $tag_fields = array_reverse($tag_fields);
51 |
52 | echo elgg_view_field([
53 | '#type' => 'select',
54 | '#label' => elgg_echo('widgets:index_groups:filter:field'),
55 | 'name' => 'params[filter_name]',
56 | 'value' => $widget->filter_name,
57 | 'options_values' => $tag_fields,
58 | ]);
59 |
60 | echo elgg_view_field([
61 | '#type' => 'tags',
62 | '#label' => elgg_echo('widgets:index_groups:filter:value'),
63 | 'name' => 'params[filter_value]',
64 | 'value' => $widget->filter_value,
65 | ]);
66 | }
67 |
68 | echo elgg_view_field([
69 | '#type' => 'select',
70 | '#label' => elgg_echo('widgets:index_groups:sorting'),
71 | 'name' => 'params[sorting]',
72 | 'value' => $widget->sorting,
73 | 'options_values' => [
74 | 'newest' => elgg_echo('sort:newest'),
75 | 'popular' => elgg_echo('sort:popular'),
76 | ],
77 | ]);
78 |
--------------------------------------------------------------------------------