return FALSE;
}
+ /**
+ * @inheritDoc
+ */
+ public function getAvailablePermissions() {
+ // We want to list *only* Backdrop perms, so we'll *skip* Civi perms.
+ $allCorePerms = \CRM_Core_Permission::basicPermissions(TRUE);
+
+ $permissions = [];
+ $modules = system_get_info('module');
+ foreach ($modules as $moduleName => $module) {
+ $prefix = isset($module['name']) ? ($module['name'] . ': ') : '';
+ foreach (module_invoke($moduleName, 'permission') as $permName => $perm) {
+ if (isset($allCorePerms[$permName])) {
+ continue;
+ }
+
+ $permissions["Drupal:$permName"] = [
+ 'title' => $prefix . strip_tags($perm['title']),
+ 'description' => $perm['description'] ?? NULL,
+ ];
+ }
+ }
+ return $permissions;
+ }
+
/**
* @inheritDoc
*/
return FALSE;
}
+ /**
+ * Get the palette of available permissions in the CMS's user-management system.
+ *
+ * @return array
+ * List of permissions, keyed by symbolic name. Each item may have fields:
+ * - title: string
+ * - description: string
+ *
+ * The permission-name should correspond to the Civi notation used by
+ * 'CRM_Core_Permission::check()'. For CMS-specific permissions, these are
+ * translated names (eg "WordPress:list_users" or "Drupal:post comments").
+ *
+ * The list should include *only* CMS permissions. Exclude Civi-native permissions.
+ *
+ * @see \CRM_Core_Permission_Base::translatePermission()
+ */
+ public function getAvailablePermissions() {
+ return [];
+ }
+
/**
* Get all the contact emails for users that have a specific permission.
*
return FALSE;
}
+ /**
+ * @inheritDoc
+ */
+ public function getAvailablePermissions() {
+ // We want to list *only* Drupal perms, so we'll *skip* Civi perms.
+ $allCorePerms = \CRM_Core_Permission::basicPermissions(TRUE);
+
+ $permissions = [];
+ $modules = system_get_info('module');
+ foreach ($modules as $moduleName => $module) {
+ $prefix = isset($module['name']) ? ($module['name'] . ': ') : '';
+ foreach (module_invoke($moduleName, 'permission') as $permName => $perm) {
+ if (isset($allCorePerms[$permName])) {
+ continue;
+ }
+
+ $permissions["Drupal:$permName"] = [
+ 'title' => $prefix . strip_tags($perm['title']),
+ 'description' => $perm['description'] ?? NULL,
+ ];
+ }
+ }
+ return $permissions;
+ }
+
/**
* @inheritDoc
*/
return $acct->hasPermission($str);
}
+ /**
+ * Get the palette of available permissions in the CMS's user-management system.
+ *
+ * @return array
+ * List of permissions, keyed by symbolic name. Each item may have fields:
+ * - title: string
+ * - description: string
+ */
+ public function getAvailablePermissions() {
+ // We want to list *only* Drupal perms, so we'll *skip* Civi perms.
+ $allCorePerms = \CRM_Core_Permission::basicPermissions(TRUE);
+
+ $dperms = \Drupal::service('user.permissions')->getPermissions();
+ $modules = system_get_info('module');
+
+ $permissions = [];
+ foreach ($dperms as $permName => $dperm) {
+ if (isset($allCorePerms[$permName])) {
+ continue;
+ }
+
+ $module = $modules[$dperm['provider']] ?? [];
+ $prefix = isset($module['name']) ? ($module['name'] . ': ') : '';
+ $permissions["Drupal:$permName"] = [
+ 'title' => $prefix . strip_tags($dperm['title']),
+ 'description' => $perm['description'] ?? NULL,
+ ];
+ }
+
+ return $permissions;
+ }
+
/**
* Get all the contact emails for users that have a specific permission.
*
return FALSE;
}
+ /**
+ * @inheritDoc
+ */
+ public function getAvailablePermissions() {
+ // We want to list *only* WordPress perms, so we'll *skip* Civi perms.
+ $mungedCorePerms = array_map(
+ function($str) {
+ return CRM_Utils_String::munge(strtolower($str));
+ },
+ array_keys(\CRM_Core_Permission::basicPermissions(TRUE))
+ );
+
+ // WP doesn't have an API to list all capabilities. However, we can discover a
+ // pretty good list by inspecting the (super)admin roles.
+ $wpCaps = [];
+ foreach (wp_roles()->roles as $wpRole) {
+ $wpCaps = array_unique(array_merge(array_keys($wpRole['capabilities']), $wpCaps));
+ }
+
+ $permissions = [];
+ foreach ($wpCaps as $wpCap) {
+ if (!in_array($wpCap, $mungedCorePerms)) {
+ $permissions["WordPress:$wpCap"] = [
+ 'title' => "WordPress: $wpCap",
+ ];
+ }
+ }
+ return $permissions;
+ }
+
/**
* @inheritDoc
*/