From 5d5ca570c3628710316a28ae5d1deb81002c3199 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sat, 24 Jun 2023 05:48:34 +1000 Subject: [PATCH] Add Upgrade step to handle adding of the Everybody option value and modify form appropriately --- CRM/ACL/BAO/ACL.php | 2 +- CRM/ACL/Form/ACL.php | 1 - CRM/Upgrade/Incremental/php/FiveSixtyFour.php | 13 +++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CRM/ACL/BAO/ACL.php b/CRM/ACL/BAO/ACL.php index bfd6f9141c..8ab4959f13 100644 --- a/CRM/ACL/BAO/ACL.php +++ b/CRM/ACL/BAO/ACL.php @@ -545,7 +545,7 @@ SELECT g.* return []; } if (!empty($params['values']['object_table:label'])) { - $table_name = array_flip(self::operationTables())[$params['values']['object_table:label']]; + $table_name = array_flip(self::getObjectTableOptions())[$params['values']['object_table:label']]; } else { $table_name = $params['values']['object_table']; diff --git a/CRM/ACL/Form/ACL.php b/CRM/ACL/Form/ACL.php index 3f65d8d7bc..7282113225 100644 --- a/CRM/ACL/Form/ACL.php +++ b/CRM/ACL/Form/ACL.php @@ -132,7 +132,6 @@ class CRM_ACL_Form_ACL extends CRM_Admin_Form { $label = ts('Role'); $role = [ '-1' => ts('- select role -'), - '0' => ts('Everyone'), ] + CRM_Core_OptionGroup::values('acl_role'); $this->add('select', 'entity_id', $label, $role, TRUE); diff --git a/CRM/Upgrade/Incremental/php/FiveSixtyFour.php b/CRM/Upgrade/Incremental/php/FiveSixtyFour.php index fdd22f1757..10d18a85d0 100644 --- a/CRM/Upgrade/Incremental/php/FiveSixtyFour.php +++ b/CRM/Upgrade/Incremental/php/FiveSixtyFour.php @@ -31,6 +31,7 @@ class CRM_Upgrade_Incremental_php_FiveSixtyFour extends CRM_Upgrade_Incremental_ $this->addTask('Add priority column onto ACL table', 'addColumn', 'civicrm_acl', 'priority', 'int NOT NULL DEFAULT 0'); $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); $this->addTask('Update post_URL/cancel_URL in logging tables', 'updateLogging'); + $this->addTask('Add in Everybody ACL Role option value', 'addEveryBodyAclOptionValue'); } public static function updateLogging($ctx): bool { @@ -44,4 +45,16 @@ CHANGE `cancel_URL` `cancel_url` varchar(255) DEFAULT NULL COMMENT 'Redirect to return TRUE; } + public static function addEverybodyAclOptionValue($ctx): bool { + \CRM_Core_BAO_OptionValue::ensureOptionValueExists([ + 'label' => 'Everybody', + 'value' => 0, + 'option_group_id' => 'acl_role', + 'is_active' => 1, + 'name' => 'Everybody', + 'is_reserved' => 1, + ]); + return TRUE; + } + } -- 2.25.1