-
-
Notifications
You must be signed in to change notification settings - Fork 825
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31581 from totten/5.81-upgrade-userdash
(dev/core#5606) user_dashboard - Fix upgrade error
- Loading branch information
Showing
3 changed files
with
41 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,13 @@ | ||
<?php | ||
use CRM_UserDashboard_ExtensionUtil as E; | ||
|
||
$afform = [ | ||
return [ | ||
'type' => 'search', | ||
'title' => E::ts('User Dashboard'), | ||
'server_route' => 'civicrm/user', | ||
'permission' => ['access Contact Dashboard'], | ||
// NOTE: Layout dynamically generated via hook_civicrm_alterAngular | ||
'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; |
26 changes: 26 additions & 0 deletions
26
ext/user_dashboard/ang/afsearchUserDashboard.alterLayout.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
return function (phpQueryObject $doc) { | ||
// 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'], | ||
]); | ||
$layout = ''; | ||
foreach ($searchDisplays as $display) { | ||
$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; | ||
} | ||
|
||
// This naively adds all displays, under the assumption that site-builders never edit `afsearchUserDashboard` layout. | ||
// However, if they do it that, then this could instead do some reconciliation (adding/removing blocks as needed). | ||
$doc->html($layout); | ||
// $doc->append($layout); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters