From d5c6e7cb5f240941043bbc2802b15bb2c1b809c8 Mon Sep 17 00:00:00 2001 From: Rich Lott / Artful Robot Date: Mon, 3 Jul 2023 12:12:10 +0100 Subject: [PATCH] standalone: add role list and (basic) edit UI --- ext/afform/core/CRM/Afform/ArrayHtml.php | 2 +- .../CRM/Standaloneusers/DAO/Role.php | 8 +- ext/standaloneusers/afformEntities/Role.php | 9 ++ ext/standaloneusers/ang/afformX.aff.html | 10 ++ ext/standaloneusers/ang/afformX.aff.json | 19 ++++ .../ang/afsearchUserRoles.aff.html | 10 ++ .../ang/afsearchUserRoles.aff.json | 23 +++++ .../SavedSearch_Administer_Roles.mgd.php | 97 +++++++++++++++++++ .../xml/schema/CRM/Standaloneusers/Role.xml | 6 ++ 9 files changed, 182 insertions(+), 2 deletions(-) create mode 100644 ext/standaloneusers/afformEntities/Role.php create mode 100644 ext/standaloneusers/ang/afformX.aff.html create mode 100644 ext/standaloneusers/ang/afformX.aff.json create mode 100644 ext/standaloneusers/ang/afsearchUserRoles.aff.html create mode 100644 ext/standaloneusers/ang/afsearchUserRoles.aff.json create mode 100644 ext/standaloneusers/managed/SavedSearch_Administer_Roles.mgd.php diff --git a/ext/afform/core/CRM/Afform/ArrayHtml.php b/ext/afform/core/CRM/Afform/ArrayHtml.php index 2425de090a..92a2caca84 100644 --- a/ext/afform/core/CRM/Afform/ArrayHtml.php +++ b/ext/afform/core/CRM/Afform/ArrayHtml.php @@ -111,7 +111,7 @@ class CRM_Afform_ArrayHtml { continue; } if (!preg_match('/^[a-zA-Z0-9\-]+$/', $attrName)) { - throw new \RuntimeException("Malformed HTML attribute"); + throw new \RuntimeException("Malformed HTML attribute $attrName → $attrValue"); } $type = $this->pickAttrType($tag, $attrName); diff --git a/ext/standaloneusers/CRM/Standaloneusers/DAO/Role.php b/ext/standaloneusers/CRM/Standaloneusers/DAO/Role.php index f673ef5494..585f241f2f 100644 --- a/ext/standaloneusers/CRM/Standaloneusers/DAO/Role.php +++ b/ext/standaloneusers/CRM/Standaloneusers/DAO/Role.php @@ -6,7 +6,7 @@ * * Generated from standaloneusers/xml/schema/CRM/Standaloneusers/Role.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:d28fa09f872be30740de728c9e344a6d) + * (GenCodeChecksum:d5053ae97fba22b13adecdce76ebb30f) */ use CRM_Standaloneusers_ExtensionUtil as E; @@ -151,6 +151,9 @@ class CRM_Standaloneusers_DAO_Role extends CRM_Core_DAO { 'entity' => 'Role', 'bao' => 'CRM_Standaloneusers_DAO_Role', 'localizable' => 0, + 'html' => [ + 'type' => 'Text', + ], 'add' => NULL, ], 'label' => [ @@ -172,6 +175,9 @@ class CRM_Standaloneusers_DAO_Role extends CRM_Core_DAO { 'entity' => 'Role', 'bao' => 'CRM_Standaloneusers_DAO_Role', 'localizable' => 0, + 'html' => [ + 'type' => 'Text', + ], 'add' => NULL, ], 'permissions' => [ diff --git a/ext/standaloneusers/afformEntities/Role.php b/ext/standaloneusers/afformEntities/Role.php new file mode 100644 index 0000000000..7c59603a55 --- /dev/null +++ b/ext/standaloneusers/afformEntities/Role.php @@ -0,0 +1,9 @@ + 'primary', + 'entity' => 'Role', + 'label' => 'Role', + 'defaults' => '{}', + 'icon' => 'fa-graduation-cap', + 'unique_fields' => ['name'], +]; diff --git a/ext/standaloneusers/ang/afformX.aff.html b/ext/standaloneusers/ang/afformX.aff.html new file mode 100644 index 0000000000..0af704bf35 --- /dev/null +++ b/ext/standaloneusers/ang/afformX.aff.html @@ -0,0 +1,10 @@ + + +
+ + + + +
+ +
diff --git a/ext/standaloneusers/ang/afformX.aff.json b/ext/standaloneusers/ang/afformX.aff.json new file mode 100644 index 0000000000..d7979beb90 --- /dev/null +++ b/ext/standaloneusers/ang/afformX.aff.json @@ -0,0 +1,19 @@ +{ + "type": "form", + "title": "Edit Role", + "icon": "fa-list-alt", + "server_route": "civicrm/admin/role", + "permission": "access CiviCRM", + "redirect": "civicrm/admin/roles", + "create_submission": true, + "requires": [], + "description": "", + "is_dashlet": false, + "is_public": false, + "is_token": false, + "entity_type": null, + "join_entity": null, + "contact_summary": null, + "summary_contact_type": null, + "navigation": null +} diff --git a/ext/standaloneusers/ang/afsearchUserRoles.aff.html b/ext/standaloneusers/ang/afsearchUserRoles.aff.html new file mode 100644 index 0000000000..15ecb4796e --- /dev/null +++ b/ext/standaloneusers/ang/afsearchUserRoles.aff.html @@ -0,0 +1,10 @@ +

Enter text

+
+
+

{{:: ts('Roles define sets of permissions for different types of users. You can give users roles to grant them permissions appropriate to their needs.') }}

+
+ +
+
+ +
diff --git a/ext/standaloneusers/ang/afsearchUserRoles.aff.json b/ext/standaloneusers/ang/afsearchUserRoles.aff.json new file mode 100644 index 0000000000..cc62bb4a7e --- /dev/null +++ b/ext/standaloneusers/ang/afsearchUserRoles.aff.json @@ -0,0 +1,23 @@ +{ + "type": "search", + "title": "User Roles", + "description": "List of roles defined on the system.", + "icon": "fa-graduation-cap", + "server_route": "civicrm/admin/roles", + "permission": "cms:administer users", + "navigation": { + "parent": "Administer", + "label": "User Roles", + "weight": 0 + }, + "requires": [], + "is_dashlet": false, + "is_public": false, + "is_token": false, + "entity_type": null, + "join_entity": null, + "contact_summary": null, + "summary_contact_type": null, + "redirect": null, + "create_submission": null +} diff --git a/ext/standaloneusers/managed/SavedSearch_Administer_Roles.mgd.php b/ext/standaloneusers/managed/SavedSearch_Administer_Roles.mgd.php new file mode 100644 index 0000000000..692ea568bd --- /dev/null +++ b/ext/standaloneusers/managed/SavedSearch_Administer_Roles.mgd.php @@ -0,0 +1,97 @@ + 'SavedSearch_Roles', + 'entity' => 'SavedSearch', + 'cleanup' => 'always', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'name' => 'Roles', + 'label' => E::ts('Roles'), + 'form_values' => NULL, + 'mapping_id' => NULL, + 'search_custom_id' => NULL, + 'api_entity' => 'Role', + 'api_params' => [ + 'version' => 4, + 'select' => [ + 'id', + 'label', + 'is_active', + ], + 'orderBy' => [], + 'where' => [], + 'groupBy' => [], + 'join' => [], + 'having' => [], + ], + 'expires_date' => NULL, + 'description' => NULL, + ], + 'match' => [ + 'name', + ], + ], + ], + [ + 'name' => 'SavedSearch_Roles_SearchDisplay_Roles_Table_1', + 'entity' => 'SearchDisplay', + 'cleanup' => 'always', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'name' => 'Roles_Table_1', + 'label' => E::ts('Roles Table 1'), + 'saved_search_id.name' => 'Roles', + 'type' => 'table', + 'settings' => [ + 'description' => NULL, + 'sort' => [], + 'limit' => 50, + 'pager' => [], + 'placeholder' => 5, + 'columns' => [ + [ + 'type' => 'field', + 'key' => 'label', + 'dataType' => 'String', + 'label' => E::ts('Label'), + 'sortable' => TRUE, + 'link' => [ + 'path' => '/civicrm/admin/role#?Role1=[id]', + 'entity' => '', + 'action' => '', + 'join' => '', + 'target' => '', + ], + ], + [ + 'type' => 'field', + 'key' => 'is_active', + 'dataType' => 'Boolean', + 'label' => E::ts('Active'), + 'sortable' => TRUE, + 'rewrite' => '', + 'alignment' => '', + ], + ], + 'actions' => TRUE, + 'classes' => [ + 'table', + 'table-striped', + ], + ], + 'acl_bypass' => FALSE, + ], + 'match' => [ + 'name', + 'saved_search_id', + ], + ], + ], +]; diff --git a/ext/standaloneusers/xml/schema/CRM/Standaloneusers/Role.xml b/ext/standaloneusers/xml/schema/CRM/Standaloneusers/Role.xml index 35a3b2c994..4c0e0d0abc 100644 --- a/ext/standaloneusers/xml/schema/CRM/Standaloneusers/Role.xml +++ b/ext/standaloneusers/xml/schema/CRM/Standaloneusers/Role.xml @@ -27,6 +27,9 @@ varchar 60 true + + Text + @@ -35,6 +38,9 @@ varchar 128 true + + Text + -- 2.25.1