Skip to content

Commit

Permalink
Add user_dashboard core extension (alpha)
Browse files Browse the repository at this point in the history
  • Loading branch information
colemanw committed Oct 12, 2023
1 parent 3d2eb13 commit d16518f
Show file tree
Hide file tree
Showing 14 changed files with 1,256 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -35,6 +35,7 @@
!/ext/civi_pledge
!/ext/civi_report
!/ext/scheduled_communications
!/ext/user_dashboard
backdrop/
bower_components
CRM/Case/xml/configuration
Expand Down
1 change: 1 addition & 0 deletions distmaker/core-ext.txt
Expand Up @@ -35,3 +35,4 @@ civi_member
civi_pledge
civi_report
scheduled_communications
user_dashboard
32 changes: 32 additions & 0 deletions ext/user_dashboard/ang/afsearchUserDashboard.aff.php
@@ -0,0 +1,32 @@
<?php
use CRM_UserDashboard_ExtensionUtil as E;

$afform = [
'type' => 'search',
'title' => E::ts('User Dashboard'),
'server_route' => 'civicrm/user',
'permission' => ['access Contact Dashboard'],
'layout' => '',
// temporary, remove after merging https://github.com/civicrm/civicrm-core/pull/27783
'requires' => ['af', 'afCore', 'crmSearchDisplayTable'],
];

// Add displays for every SavedSearch tagged "UserDashboard"
$searchDisplays = civicrm_api4('SearchDisplay', 'get', [
'checkPermissions' => FALSE,
'select' => ['name', 'label', 'type:name', 'saved_search_id.name'],
'where' => [
['saved_search_id.is_current', '=', TRUE],
['saved_search_id.tags:name', 'IN', ['UserDashboard']],
],
'orderBy' => ['name' => 'ASC'],
]);
foreach ($searchDisplays as $display) {
$afform['layout'] .= <<<HTML
<div af-fieldset="" class="af-container-style-pane" af-title="$display[label]">
<{$display['type:name']} search-name="{$display['saved_search_id.name']}" display-name="$display[name]"></{$display['type:name']}>
</div>
HTML;
}

return $afform;
36 changes: 36 additions & 0 deletions ext/user_dashboard/info.xml
@@ -0,0 +1,36 @@
<?xml version="1.0"?>
<extension key="user_dashboard" type="module">
<file>user_dashboard</file>
<name>User Dashboard</name>
<description>Adds a page for users to see their contributions, memberships, etc.</description>
<license>AGPL-3.0</license>
<maintainer>
<author>CiviCRM</author>
<email>info@civicrm.org</email>
</maintainer>
<urls>
<url desc="Main Extension Page">http://FIXME</url>
<url desc="Documentation">http://FIXME</url>
<url desc="Support">http://FIXME</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2023-10-07</releaseDate>
<version>1.0</version>
<develStage>alpha</develStage>
<compatibility>
<ver>5.68.alpha1</ver>
</compatibility>
<comments>This extension is still experimental</comments>
<classloader>
<psr0 prefix="CRM_" path="."/>
<psr4 prefix="Civi\" path="Civi"/>
</classloader>
<civix>
<namespace>CRM/UserDashboard</namespace>
<format>23.02.1</format>
<angularModule>crmUserDashboard</angularModule>
</civix>
<mixins>
<mixin>mgd-php@1.0.0</mixin>
</mixins>
</extension>
27 changes: 27 additions & 0 deletions ext/user_dashboard/managed/0Tag_UserDashboard.mgd.php
@@ -0,0 +1,27 @@
<?php
use CRM_UserDashboard_ExtensionUtil as E;

return [
[
'name' => 'Tag_UserDashboard',
'entity' => 'Tag',
'cleanup' => 'unused',
'update' => 'unmodified',
'params' => [
'version' => 4,
'values' => [
'label' => E::ts('User Dashboard'),
'name' => 'UserDashboard',
'description' => E::ts('Search will appear on the User Dashboard page'),
'is_reserved' => TRUE,
'used_for' => [
'civicrm_saved_search',
],
'color' => '#5d677b',
],
'match' => [
'name',
],
],
],
];
157 changes: 157 additions & 0 deletions ext/user_dashboard/managed/SavedSearch_UserDashboard_Groups.mgd.php
@@ -0,0 +1,157 @@
<?php
use CRM_UserDashboard_ExtensionUtil as E;

return [
[
'name' => 'SavedSearch_UserDashboard_Groups',
'entity' => 'SavedSearch',
'cleanup' => 'unused',
'update' => 'unmodified',
'params' => [
'version' => 4,
'values' => [
'name' => 'UserDashboard_Groups',
'label' => E::ts('User Dashboard - Groups'),
'api_entity' => 'Group',
'api_params' => [
'version' => 4,
'select' => [
'frontend_title',
'Group_GroupContact_Contact_01.status:label',
'MAX(Group_SubscriptionHistory_group_id_01.date) AS MAX_Group_SubscriptionHistory_group_id_01_date',
],
'orderBy' => [],
'where' => [
[
'Group_GroupContact_Contact_01.id',
'=',
'user_contact_id',
],
[
'visibility:name',
'=',
'Public Pages',
],
[
'is_active',
'=',
TRUE,
],
],
'groupBy' => [
'id',
'Group_GroupContact_Contact_01.id',
],
'join' => [
[
'Contact AS Group_GroupContact_Contact_01',
'LEFT',
'GroupContact',
[
'id',
'=',
'Group_GroupContact_Contact_01.group_id',
],
],
[
'SubscriptionHistory AS Group_SubscriptionHistory_group_id_01',
'LEFT',
[
'id',
'=',
'Group_SubscriptionHistory_group_id_01.group_id',
],
[
'Group_SubscriptionHistory_group_id_01.contact_id',
'=',
'"user_contact_id"',
],
],
],
'having' => [],
],
],
'match' => [
'name',
],
'chain' => [
'tag' => [
'EntityTag', 'save', [
'records' => [['entity_table' => 'civicrm_saved_search', 'entity_id' => '$id', 'tag_id:name' => 'UserDashboard']],
'match' => ['entity_id', 'tag_id'],
],
],
],
],
],
[
'name' => 'SavedSearch_UserDashboard_Groups_SearchDisplay_UserDashboard_Groups',
'entity' => 'SearchDisplay',
'cleanup' => 'unused',
'update' => 'unmodified',
'params' => [
'version' => 4,
'values' => [
'name' => 'UserDashboard_Groups',
'label' => E::ts('Your Group(s)'),
'saved_search_id.name' => 'UserDashboard_Groups',
'type' => 'table',
'settings' => [
'description' => NULL,
'sort' => [
[
'Group_GroupContact_Contact_01.status',
'ASC',
],
],
'limit' => 50,
'pager' => [
'expose_limit' => TRUE,
'hide_single' => TRUE,
],
'placeholder' => 1,
'columns' => [
[
'type' => 'field',
'key' => 'frontend_title',
'dataType' => 'String',
'label' => E::ts('Group'),
'sortable' => TRUE,
],
[
'type' => 'field',
'key' => 'Group_GroupContact_Contact_01.status:label',
'dataType' => 'String',
'label' => E::ts('Status'),
'sortable' => TRUE,
],
[
'type' => 'field',
'key' => 'MAX_Group_SubscriptionHistory_group_id_01_date',
'dataType' => 'Timestamp',
'label' => E::ts('Since'),
'sortable' => TRUE,
],
],
'actions' => FALSE,
'classes' => [
'table',
'table-striped',
],
'cssRules' => [
[
'disabled',
'Group_GroupContact_Contact_01.status',
'=',
'Removed',
],
],
],
],
'match' => [
'name',
'saved_search_id',
],
],
],
];

0 comments on commit d16518f

Please sign in to comment.