Skip to content

Commit

Permalink
CiviGrant - Migrate navigation menu to extension
Browse files Browse the repository at this point in the history
  • Loading branch information
colemanw committed Jan 3, 2022
1 parent be654b7 commit 04d8dd3
Show file tree
Hide file tree
Showing 4 changed files with 235 additions and 14 deletions.
57 changes: 57 additions & 0 deletions CRM/Upgrade/Incremental/php/FiveFortySix.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,63 @@ public static function migrateCiviGrant(CRM_Queue_TaskContext $ctx): bool {
'name' => 'CRM_Report_Form_Grant_Statistics',
],
],
'Navigation_Grants' => [
'entity' => 'Navigation',
'values' => [
'name' => 'Grants',
'domain_id' => 'current_domain',
],
],
'Navigation_Grants_Navigation_Dashboard' => [
'entity' => 'Navigation',
'values' => [
'name' => 'Dashboard',
'url' => 'civicrm/grant?reset=1',
'domain_id' => 'current_domain',
],
],
'Navigation_Grants_Navigation_New_Grant' => [
'entity' => 'Navigation',
'values' => [
'name' => 'New Grant',
'domain_id' => 'current_domain',
],
],
'Navigation_Grants_Navigation_Find_Grants' => [
'entity' => 'Navigation',
'values' => [
'name' => 'Find Grants',
'domain_id' => 'current_domain',
],
],
'Navigation_CiviGrant' => [
'entity' => 'Navigation',
'values' => [
'name' => 'Grants',
'domain_id' => 'current_domain',
],
],
'Navigation_CiviGrant_Navigation_Grant_Types' => [
'entity' => 'Navigation',
'values' => [
'name' => 'Grant Types',
'domain_id' => 'current_domain',
],
],
'Navigation_CiviGrant_Navigation_Grant_Status' => [
'entity' => 'Navigation',
'values' => [
'name' => 'Grant Status',
'domain_id' => 'current_domain',
],
],
'Navigation_Grants_Navigation_Grant_Reports' => [
'entity' => 'Navigation',
'values' => [
'name' => 'Grant Reports',
'domain_id' => 'current_domain',
],
],
];
// Create an entry in civicrm_managed for each existing record that will be managed by the extension
foreach ($managedItems as $name => $item) {
Expand Down
3 changes: 3 additions & 0 deletions Civi/Api4/Navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
* @package Civi\Api4
*/
class Navigation extends Generic\DAOEntity {
<<<<<<< HEAD
use Generic\Traits\SortableEntity;
=======
>>>>>>> CiviGrant - Migrate navigation menu to extension
use Generic\Traits\ManagedEntity;

}
175 changes: 175 additions & 0 deletions ext/civigrant/managed/Navigation_Grants.mgd.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
<?php
return [
[
'name' => 'Navigation_Grants',
'entity' => 'Navigation',
'cleanup' => 'unused',
'update' => 'unmodified',
'params' => [
'version' => 4,
'values' => [
'label' => 'Grants',
'name' => 'Grants',
'url' => NULL,
'icon' => 'crm-i fa-money',
'permission' => 'access CiviGrant',
'permission_operator' => '',
'is_active' => TRUE,
'weight' => 90,
'parent_id' => NULL,
'has_separator' => NULL,
'domain_id' => 'current_domain',
],
],
],
[
'name' => 'Navigation_Grants_Navigation_Dashboard',
'entity' => 'Navigation',
'cleanup' => 'unused',
'update' => 'unmodified',
'params' => [
'version' => 4,
'values' => [
'label' => 'Dashboard',
'name' => 'Dashboard',
'url' => 'civicrm/grant?reset=1',
'icon' => NULL,
'permission' => 'access CiviGrant',
'permission_operator' => '',
'parent_id.name' => 'Grants',
'is_active' => TRUE,
'has_separator' => NULL,
'domain_id' => 'current_domain',
],
],
],
[
'name' => 'Navigation_Grants_Navigation_New_Grant',
'entity' => 'Navigation',
'cleanup' => 'unused',
'update' => 'unmodified',
'params' => [
'version' => 4,
'values' => [
'label' => 'New Grant',
'name' => 'New Grant',
'url' => 'civicrm/grant/add?reset=1&action=add&context=standalone',
'icon' => NULL,
'permission' => 'access CiviGrant,edit grants',
'permission_operator' => 'AND',
'parent_id.name' => 'Grants',
'is_active' => TRUE,
'has_separator' => NULL,
'domain_id' => 'current_domain',
],
],
],
[
'name' => 'Navigation_Grants_Navigation_Find_Grants',
'entity' => 'Navigation',
'cleanup' => 'unused',
'update' => 'unmodified',
'params' => [
'version' => 4,
'values' => [
'label' => 'Find Grants',
'name' => 'Find Grants',
'url' => 'civicrm/grant/search?reset=1',
'icon' => NULL,
'permission' => 'access CiviGrant',
'permission_operator' => '',
'parent_id.name' => 'Grants',
'is_active' => TRUE,
'has_separator' => '1',
'domain_id' => 'current_domain',
],
],
],
[
'name' => 'Navigation_CiviGrant',
'entity' => 'Navigation',
'cleanup' => 'unused',
'update' => 'unmodified',
'params' => [
'version' => 4,
'values' => [
'label' => 'CiviGrant',
'name' => 'CiviGrant',
'url' => NULL,
'icon' => NULL,
'permission' => 'access CiviGrant,administer CiviCRM',
'permission_operator' => 'AND',
'parent_id.name' => 'Administer',
'is_active' => TRUE,
'weight' => 13,
'has_separator' => NULL,
'domain_id' => 'current_domain',
],
],
],
[
'name' => 'Navigation_CiviGrant_Navigation_Grant_Types',
'entity' => 'Navigation',
'cleanup' => 'unused',
'update' => 'unmodified',
'params' => [
'version' => 4,
'values' => [
'label' => 'Grant Types',
'name' => 'Grant Types',
'url' => 'civicrm/admin/options/grant_type?reset=1',
'icon' => NULL,
'permission' => 'access CiviGrant,administer CiviCRM',
'permission_operator' => 'AND',
'parent_id.name' => 'CiviGrant',
'is_active' => TRUE,
'weight' => 1,
'has_separator' => NULL,
'domain_id' => 'current_domain',
],
],
],
[
'name' => 'Navigation_CiviGrant_Navigation_Grant_Status',
'entity' => 'Navigation',
'cleanup' => 'unused',
'update' => 'unmodified',
'params' => [
'version' => 4,
'values' => [
'label' => 'Grant Status',
'name' => 'Grant Status',
'url' => 'civicrm/admin/options/grant_status?reset=1',
'icon' => NULL,
'permission' => 'access CiviGrant,administer CiviCRM',
'permission_operator' => 'AND',
'parent_id.name' => 'CiviGrant',
'is_active' => TRUE,
'weight' => 2,
'has_separator' => NULL,
'domain_id' => 'current_domain',
],
],
],
[
'name' => 'Navigation_Grants_Navigation_Grant_Reports',
'entity' => 'Navigation',
'cleanup' => 'unused',
'update' => 'unmodified',
'params' => [
'version' => 4,
'values' => [
'label' => 'Grant Reports',
'name' => 'Grant Reports',
'url' => 'civicrm/report/list?compid=5&reset=1',
'icon' => NULL,
'permission' => 'access CiviGrant',
'permission_operator' => '',
'parent_id.name' => 'Grants',
'is_active' => TRUE,
'has_separator' => NULL,
'domain_id' => 'current_domain',
],
],
],
];
14 changes: 0 additions & 14 deletions xml/templates/civicrm_navigation.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -248,20 +248,6 @@ VALUES
( @domainID, 'civicrm/case/search?reset=1', '{ts escape="sql" skip="true"}Find Cases{/ts}', 'Find Cases', 'access my cases and activities,access all cases and activities', 'OR', @caselastID, '1', 1, 3 ),
( @domainID, 'civicrm/report/list?compid=7&reset=1', '{ts escape="sql" skip="true"}Case Reports{/ts}', 'Case Reports', 'access my cases and activities,access all cases and activities,administer CiviCase', 'OR', @caselastID, '1', 0, 4 );

INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight, icon )
VALUES
( @domainID, NULL, '{ts escape="sql" skip="true"}Grants{/ts}', 'Grants', 'access CiviGrant', '', NULL, '1', NULL, 90, 'crm-i fa-money' );

SET @grantlastID:=LAST_INSERT_ID();
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( @domainID, 'civicrm/grant?reset=1', '{ts escape="sql" skip="true"}Dashboard{/ts}', 'Dashboard', 'access CiviGrant', '', @grantlastID, '1', NULL, 1 ),
( @domainID, 'civicrm/grant/add?reset=1&action=add&context=standalone', '{ts escape="sql" skip="true"}New Grant{/ts}', 'New Grant', 'access CiviGrant,edit grants', 'AND', @grantlastID, '1', NULL, 2 ),
( @domainID, 'civicrm/grant/search?reset=1', '{ts escape="sql" skip="true"}Find Grants{/ts}', 'Find Grants', 'access CiviGrant', '', @grantlastID, '1', 1, 3 ),
( @domainID, 'civicrm/report/list?compid=5&reset=1', '{ts escape="sql" skip="true"}Grant Reports{/ts}', 'Grant Reports', 'access CiviGrant', '', @grantlastID, '1', 0, 4 );

INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight, icon )
VALUES
Expand Down

0 comments on commit 04d8dd3

Please sign in to comment.