Move creating of nav & menu items to legacycustomsearches extension
authorEileen McNaughton <emcnaughton@wikimedia.org>
Tue, 21 Jun 2022 23:39:42 +0000 (11:39 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Wed, 17 Aug 2022 06:44:18 +0000 (18:44 +1200)
CRM/Core/xml/Menu/Contact.xml
ext/legacycustomsearches/info.xml
ext/legacycustomsearches/legacycustomsearches.php
ext/legacycustomsearches/managed/Navigation.mgd.php [new file with mode: 0644]
ext/legacycustomsearches/xml/Menu/Search.xml
sql/test_data_second_domain.mysql
xml/templates/civicrm_navigation.tpl

index 5f70ed8a3ef2b7c9a301ef49e9fa7b5d9acd02ef..ed81f2bc8273d0f49cb346ff43b55e792143e0a3 100644 (file)
      <page_type>1</page_type>
      <weight>14</weight>
   </item>
-  <item>
-     <path>civicrm/contact/search/custom/list</path>
-     <title>Custom Searches</title>
-     <page_callback>CRM_Contact_Page_CustomSearch</page_callback>
-     <page_type>1</page_type>
-     <weight>16</weight>
-  </item>
   <item>
      <path>civicrm/contact/add</path>
      <title>New Contact</title>
index 0f8a1b4490331f4ee29735fd1890d1935548405d..fdb459aaab5619fda03f401b7044667208b66d8d 100644 (file)
   </classloader>
   <mixins>
     <mixin>menu-xml@1.0.0</mixin>
+    <mixin>mgd-php@1.0.0</mixin>
   </mixins>
   <civix>
     <namespace>CRM/Legacycustomsearches</namespace>
+    <format>22.05.2</format>
   </civix>
 </extension>
index 2213da60d38bdf0a04adbc7a4c07458ea6b4c1af..92c9aa328adf275f0a9b409b2d7f23a2f12498d5 100644 (file)
@@ -78,31 +78,3 @@ function legacycustomsearches_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL
 function legacycustomsearches_civicrm_entityTypes(&$entityTypes) {
   _legacycustomsearches_civix_civicrm_entityTypes($entityTypes);
 }
-
-// --- Functions below this ship commented out. Uncomment as required. ---
-
-/**
- * Implements hook_civicrm_preProcess().
- *
- * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_preProcess
- */
-//function legacycustomsearches_civicrm_preProcess($formName, &$form) {
-//
-//}
-
-/**
- * Implements hook_civicrm_navigationMenu().
- *
- * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_navigationMenu
- */
-//function legacycustomsearches_civicrm_navigationMenu(&$menu) {
-//  _legacycustomsearches_civix_insert_navigation_menu($menu, 'Mailings', array(
-//    'label' => E::ts('New subliminal message'),
-//    'name' => 'mailing_subliminal_message',
-//    'url' => 'civicrm/mailing/subliminal',
-//    'permission' => 'access CiviMail',
-//    'operator' => 'OR',
-//    'separator' => 0,
-//  ));
-//  _legacycustomsearches_civix_navigationMenu($menu);
-//}
diff --git a/ext/legacycustomsearches/managed/Navigation.mgd.php b/ext/legacycustomsearches/managed/Navigation.mgd.php
new file mode 100644 (file)
index 0000000..4175908
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+
+use Civi\Api4\Domain;
+use CRM_Legacycustomsearches_ExtensionUtil as E;
+
+$menuItems = [];
+$domains = Domain::get(FALSE)
+  ->addSelect('id')
+  ->execute();
+foreach ($domains as $domain) {
+  $menuItems[] = [
+    'name' => 'Custom Searches' . $domain['id'],
+    'entity' => 'Navigation',
+    'cleanup' => 'always',
+    'update' => 'unmodified',
+    'params' => [
+      'version' => 4,
+      'values' => [
+        'label' => E::ts('Custom Searches'),
+        'name' => 'Custom Searches',
+        'url' => 'civicrm/contact/search/custom/list?reset=1',
+        'permission' => NULL,
+        'permission_operator' => 'OR',
+        'parent_id.name' => 'Search',
+        'is_active' => TRUE,
+        'has_separator' => 2,
+        'weight' => 15,
+        'domain_id' => $domain['id'],
+      ],
+      'match' => ['domain_id', 'name'],
+    ],
+  ];
+  $menuItems[] = [
+    'name' => 'Manage Custom Searches' . $domain['id'],
+    'entity' => 'Navigation',
+    'cleanup' => 'always',
+    'update' => 'unmodified',
+    'params' => [
+      'version' => 4,
+      'values' => [
+        'label' => E::ts('Manage Custom Searches'),
+        'name' => 'Manage Custom Searches',
+        'url' => 'civicrm/admin/options/custom_search?reset=1',
+        'permission' => 'administer CiviCRM',
+        'permission_operator' => 'OR',
+        'parent_id.name' => 'Customize Data and Screens',
+        'is_active' => TRUE,
+        'weight' => 15,
+        'domain_id' => $domain['id'],
+      ],
+      'match' => ['domain_id', 'name'],
+    ],
+  ];
+}
+return $menuItems;
index f46c9f40f4caf1b36be681c0bd1b3b7b6cad0663..747357a2bd24fd63f186cc508efeb3a1abc137e9 100644 (file)
@@ -9,4 +9,11 @@
     <weight>10</weight>
     <page_type>1</page_type>
   </item>
+  <item>
+    <path>civicrm/contact/search/custom/list</path>
+    <title>Custom Searches</title>
+    <page_callback>CRM_Contact_Page_CustomSearch</page_callback>
+    <page_type>1</page_type>
+    <weight>16</weight>
+  </item>
 </menu>
index 0b356e66bacb0dc885ee6733f690438f8c35b744..81ab693e0d6bae2f4ddda9cf71e99e330befa90d 100644 (file)
@@ -92,11 +92,6 @@ VALUES
     ( @domainID, 'civicrm/pledge/search&reset=1',                           'Find Pledges',       'Find Pledges', 'access CiviPledge', '',        @searchlastID, '1', NULL, 10 ),
     ( @domainID, 'civicrm/activity/search&reset=1',                         'Find Activities',    'Find Activities', NULL,  '',                   @searchlastID, '1', '1',  11 );
 
-INSERT INTO civicrm_navigation
-    ( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
-VALUES
-    ( @domainID, 'civicrm/contact/search/custom/list&reset=1',              'Custom Searches', 'Custom Searches', NULL, '',                 @searchlastID, '1', NULL, 12 );
-
 INSERT INTO civicrm_navigation
     ( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
 VALUES
@@ -287,8 +282,7 @@ VALUES
     ( @domainID, 'civicrm/admin/setting/preferences/display&reset=1',   'Display Preferences', 'Display Preferences',     'administer CiviCRM', '',   @CustomizelastID, '1', NULL, 9 ),
     ( @domainID, 'civicrm/admin/setting/search&reset=1',    'Search Preferences',    'Search Preferences',                'administer CiviCRM', '',   @CustomizelastID, '1', NULL, 10 ),
     ( @domainID, 'civicrm/admin/menu&reset=1',              'Navigation Menu', 'Navigation Menu',                         'administer CiviCRM', '',   @CustomizelastID, '1', NULL, 11 ),
-    ( @domainID, 'civicrm/admin/options/wordreplacements&reset=1','Word Replacements','Word Replacements',                'administer CiviCRM', '',   @CustomizelastID, '1', NULL, 12 ),
-    ( @domainID, 'civicrm/admin/options/custom_search&reset=1&group=custom_search', 'Manage Custom Searches', 'Manage Custom Searches', 'administer CiviCRM', '', @CustomizelastID, '1', NULL, 13 );
+    ( @domainID, 'civicrm/admin/options/wordreplacements&reset=1','Word Replacements','Word Replacements',                'administer CiviCRM', '',   @CustomizelastID, '1', NULL, 12 );
 
 INSERT INTO civicrm_navigation
     ( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
index 3c2dd41e595a06997b293893fac53ee7a36e299b..cd6fe266aecabdf158bbe05bcd331d39c6ec3e6a 100644 (file)
@@ -64,11 +64,6 @@ VALUES
     ( @domainID, 'civicrm/pledge/search?reset=1',                           '{ts escape="sql" skip="true"}Find Pledges{/ts}',       'Find Pledges', 'access CiviPledge', '',        @searchlastID, '1', NULL, 10 ),
     ( @domainID, 'civicrm/activity/search?reset=1',                         '{ts escape="sql" skip="true"}Find Activities{/ts}',    'Find Activities', NULL,  '',                   @searchlastID, '1', '1',  11 );
 
-INSERT INTO civicrm_navigation
-    ( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
-VALUES
-    ( @domainID, 'civicrm/contact/search/custom/list?reset=1',              '{ts escape="sql" skip="true"}Custom Searches{/ts}', 'Custom Searches', NULL, '',                 @searchlastID, '1', NULL, 12 );
-
 INSERT INTO civicrm_navigation
     ( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight, icon )
 VALUES
@@ -285,8 +280,7 @@ VALUES
     ( @domainID, 'civicrm/admin/setting/search?reset=1',    '{ts escape="sql" skip="true"}Search Preferences{/ts}',    'Search Preferences',                'administer CiviCRM', '',   @CustomizelastID, '1', NULL, 10 ),
     ( @domainID, 'civicrm/admin/setting/preferences/date?reset=1', '{ts escape="sql" skip="true"}Date Preferences{/ts}', 'Date Preferences', 'administer CiviCRM', '', @CustomizelastID, '1', NULL, 11 ),
     ( @domainID, 'civicrm/admin/menu?reset=1',              '{ts escape="sql" skip="true"}Navigation Menu{/ts}', 'Navigation Menu',                         'administer CiviCRM', '',   @CustomizelastID, '1', NULL, 12 ),
-    ( @domainID, 'civicrm/admin/options/wordreplacements?reset=1','{ts escape="sql" skip="true"}Word Replacements{/ts}','Word Replacements',                'administer CiviCRM', '',   @CustomizelastID, '1', NULL, 13 ),
-    ( @domainID, 'civicrm/admin/options/custom_search?reset=1', '{ts escape="sql" skip="true"}Manage Custom Searches{/ts}', 'Manage Custom Searches', 'administer CiviCRM', '', @CustomizelastID, '1', NULL, 14 );
+    ( @domainID, 'civicrm/admin/options/wordreplacements?reset=1','{ts escape="sql" skip="true"}Word Replacements{/ts}','Word Replacements',                'administer CiviCRM', '',   @CustomizelastID, '1', NULL, 13 );
 
 INSERT INTO civicrm_navigation
     ( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )