Add Imports search
authorEileen McNaughton <emcnaughton@wikimedia.org>
Tue, 29 Nov 2022 21:40:21 +0000 (10:40 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Tue, 29 Nov 2022 21:42:53 +0000 (10:42 +1300)
This allows an over-view of a user's searches

ext/civiimport/Managed/ImportSearches.mgd.php
ext/civiimport/Managed/UserJobSearches.mgd.php [new file with mode: 0644]

index e1ce9d4b458f0bace7fef1f4e3de604842eceb20..2f80a3cd380fd767f5e52a67fa0d680901bcca40 100644 (file)
@@ -1,22 +1,8 @@
 <?php
 
-use Civi\Api4\Entity;
 use Civi\BAO\Import;
 use CRM_Civiimport_ExtensionUtil as E;
 
-// Check if SearchKit is enabled before adding SavedSearches.
-try {
-  if (!Entity::get(FALSE)
-    ->addWhere('name', '=', 'SearchDisplay')
-    ->selectRowCount()
-    ->execute()->count()) {
-    return [];
-  }
-}
-catch (CRM_Core_Exception $e) {
-  return [];
-}
-
 $managedEntities = [];
 $importEntities = Import::getImportTables();
 foreach ($importEntities as $importEntity) {
diff --git a/ext/civiimport/Managed/UserJobSearches.mgd.php b/ext/civiimport/Managed/UserJobSearches.mgd.php
new file mode 100644 (file)
index 0000000..8a78511
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+
+use CRM_Civiimport_ExtensionUtil as E;
+
+return [
+  [
+    'name' => 'SavedSearch_My_imports',
+    'entity' => 'SavedSearch',
+    'cleanup' => 'always',
+    'update' => 'unmodified',
+    'params' => [
+      'version' => 4,
+      'values' => [
+        'name' => 'My_imports',
+        'label' => E::ts('My imports'),
+        'form_values' => NULL,
+        'mapping_id' => NULL,
+        'search_custom_id' => NULL,
+        'api_entity' => 'UserJob',
+        'api_params' => [
+          'version' => 4,
+          'select' => [
+            'id',
+            'created_date',
+            'status_id:label',
+            'job_type:label',
+          ],
+          'orderBy' => [],
+          'where' => [
+            [
+              'created_id',
+              '=',
+              'user_contact_id',
+            ],
+            [
+              'is_template',
+              '=',
+              FALSE,
+            ],
+          ],
+          'groupBy' => [],
+          'join' => [],
+          'having' => [],
+        ],
+        'expires_date' => NULL,
+        'description' => NULL,
+      ],
+    ],
+  ],
+];