X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=ext%2Fafform%2Fcore%2Fafform.php;h=49b3ba9f9977a3ed085f98e7e5e955a7fc2baff8;hb=69be62073c1e99c5a52db4fcb4d5415dcaac5d79;hp=b73043d1fb7bdb082a30121a27ba0850f5e76a70;hpb=521b232a706cb95b6ef14ab16802de2a4a13c3b1;p=civicrm-core.git diff --git a/ext/afform/core/afform.php b/ext/afform/core/afform.php index b73043d1fb..49b3ba9f99 100644 --- a/ext/afform/core/afform.php +++ b/ext/afform/core/afform.php @@ -392,8 +392,9 @@ function _af_fill_field_metadata($entityType, DOMElement $afField) { $params['values'] = ['contact_type' => $entityType]; $entityType = 'Contact'; } - $getFields = civicrm_api4($entityType, 'getFields', $params); - // Merge field definition data with whatever's already in the markup + // Merge field definition data with whatever's already in the markup. + // If the admin has chosen to include this field on the form, then it's OK for us to get metadata about the field - regardless of user's other permissions. + $getFields = civicrm_api4($entityType, 'getFields', $params + ['checkPermissions' => FALSE]); $deep = ['input_attrs']; foreach ($getFields as $fieldInfo) { $existingFieldDefn = trim(pq($afField)->attr('defn') ?: ''); @@ -541,6 +542,23 @@ function afform_civicrm_permission_check($permission, &$granted, $contactId) { } } +/** + * Implements hook_civicrm_permissionList(). + * + * @see CRM_Utils_Hook::permissionList() + */ +function afform_civicrm_permissionList(&$permissions) { + $scanner = Civi::service('afform_scanner'); + foreach ($scanner->getMetas() as $name => $meta) { + $permissions['@afform:' . $name] = [ + 'group' => 'afform', + 'title' => ts('Afform: Inherit permission of %1', [ + 1 => $name, + ]), + ]; + } +} + /** * Clear any local/in-memory caches based on afform data. */