Afform - Use API for listing/searching available permissions
authorTim Otten <totten@civicrm.org>
Fri, 22 Jan 2021 03:07:41 +0000 (19:07 -0800)
committerTim Otten <totten@civicrm.org>
Fri, 5 Feb 2021 01:28:04 +0000 (17:28 -0800)
ext/afform/admin/Civi/AfformAdmin/AfformAdminMeta.php

index 468d690bdbcdfe6a41f1f9a05f9eb5af749bf48d..c2068cc18983f7a1c8b348b639485a562c53b91f 100644 (file)
@@ -216,11 +216,16 @@ class AfformAdminMeta {
     ];
 
     $data['permissions'] = [];
-    foreach (\CRM_Core_Permission::basicPermissions(TRUE, TRUE) as $name => $perm) {
+    $perms = \Civi\Api4\Permission::get()
+      ->addWhere('group', 'IN', ['afformGeneric', 'const', 'civicrm', 'cms'])
+      ->addWhere('is_active', '=', 1)
+      ->setOrderBy(['group' => 'ASC', 'name' => 'ASC'])
+      ->execute();
+    foreach ($perms as $perm) {
       $data['permissions'][] = [
-        'id' => $name,
-        'text' => $perm[0],
-        'description' => $perm[1] ?? NULL,
+        'id' => $perm['name'],
+        'text' => $perm['title'],
+        'description' => $perm['description'] ?? NULL,
       ];
     }