From: Tim Otten Date: Fri, 22 Jan 2021 03:07:41 +0000 (-0800) Subject: Afform - Use API for listing/searching available permissions X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f1de39ec1217db1360500384c92a64b99779244b;p=civicrm-core.git Afform - Use API for listing/searching available permissions --- diff --git a/ext/afform/admin/Civi/AfformAdmin/AfformAdminMeta.php b/ext/afform/admin/Civi/AfformAdmin/AfformAdminMeta.php index 468d690bdb..c2068cc189 100644 --- a/ext/afform/admin/Civi/AfformAdmin/AfformAdminMeta.php +++ b/ext/afform/admin/Civi/AfformAdmin/AfformAdminMeta.php @@ -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, ]; }