Action Type as variable
authorAlice Frumin <alice@aghstrategies.com>
Thu, 15 Dec 2022 16:41:27 +0000 (11:41 -0500)
committerAlice Frumin <alice@aghstrategies.com>
Thu, 15 Dec 2022 16:41:27 +0000 (11:41 -0500)
ext/search_kit/Civi/Api4/Action/SearchDisplay/GetSearchTasks.php

index e5164cbc54cc65b30fc20a56682af67ab749fa8e..9879c9289bde521db14c4fc447cf914b519169ee 100644 (file)
@@ -139,29 +139,18 @@ class GetSearchTasks extends \Civi\Api4\Generic\AbstractAction {
           }
           $key = \CRM_Core_Key::get(\CRM_Utils_Array::first((array) $task['class']), TRUE);
 
-          //break out mailing labels for redirect instead of crmPopup
-          if ($id == CRM_Core_Task::LABEL_CONTACTS) {
-            $tasks[$entity['name']]['contact.' . $id] = [
-              'title' => $task['title'],
-              'icon' => $task['icon'] ?? 'fa-gear',
-              'redirect' => [
-                'path' => "'{$task['url']}'",
-                'query' => "{reset: 1}",
-                'data' => "{cids: ids.join(','), qfKey: '$key'}",
-              ],
-            ];
-          }
-          else {
-            $tasks[$entity['name']]['contact.' . $id] = [
-              'title' => $task['title'],
-              'icon' => $task['icon'] ?? 'fa-gear',
-              'crmPopup' => [
-                'path' => "'{$task['url']}'",
-                'query' => "{reset: 1}",
-                'data' => "{cids: ids.join(','), qfKey: '$key'}",
-              ],
-            ];
-          }
+          // Print Labels action does not support popups, open full-screen
+          $actionType = $id == \CRM_Core_Task::LABEL_CONTACTS ? 'redirect' : 'crmPopup';
+
+          $tasks[$entity['name']]['contact.' . $id] = [
+            'title' => $task['title'],
+            'icon' => $task['icon'] ?? 'fa-gear',
+            $actionType => [
+              'path' => "'{$task['url']}'",
+              'query' => "{reset: 1}",
+              'data' => "{cids: ids.join(','), qfKey: '$key'}",
+            ],
+          ];
         }
       }
       if (!$this->checkPermissions || \CRM_Core_Permission::check(['merge duplicate contacts', 'delete contacts'])) {