Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

civicrm_webtest.install - Backdrop support for adding roles and perms #15571

Merged
merged 1 commit into from
Nov 3, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion tools/drupal/modules/civicrm_webtest/civicrm_webtest.install
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
* Implementation of hook_enable
*/
function civicrm_webtest_enable() {
user_role_grant_permissions(1, [
$anonymous = 1;

// If Backdrop
if (function_exists('config_get')) {
$anonymous = 'Anonymous';
}

user_role_grant_permissions($anonymous, [
'access CiviMail subscribe/unsubscribe pages',
'access all custom data',
'access uploaded files',
Expand All @@ -15,6 +22,7 @@ function civicrm_webtest_enable() {
]);

$roles = user_roles();

if (!in_array('civicrm_webtest_user', $roles)) {
$role = new stdClass();
$role->name = 'civicrm_webtest_user';
Expand All @@ -25,6 +33,17 @@ function civicrm_webtest_enable() {
$rid = array_search('civicrm_webtest_user', $roles);
}

// If Backdrop
if (function_exists('config_get')) {
$rid = 'civicrm_webtest_user';
if (!isset($roles[$rid])) {
$role = new stdClass();
$role->name = $rid;
$role->label = 'CiviCRM Webtest User';
user_role_save($role);
}
}

user_role_grant_permissions($rid, [
// FIXME: whoa, why do we bother with users if both need admin rights?
'access AJAX API',
Expand Down