Skip to content

Commit

Permalink
Add Upgrade step to handle adding of the Everybody option value and m…
Browse files Browse the repository at this point in the history
…odify form appropriately
  • Loading branch information
seamuslee001 committed Jun 23, 2023
1 parent bab8f74 commit c4be24b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CRM/ACL/BAO/ACL.php
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ public static function getObjectIdOptions($context, $params): array {
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'];
Expand Down
1 change: 0 additions & 1 deletion CRM/ACL/Form/ACL.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ public function buildQuickForm() {
$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);

Expand Down
13 changes: 13 additions & 0 deletions CRM/Upgrade/Incremental/php/FiveSixtyFour.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function upgrade_5_64_alpha1($rev): void {
$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 {
Expand All @@ -44,4 +45,16 @@ public static function updateLogging($ctx): bool {
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;
}

}
6 changes: 6 additions & 0 deletions sql/civicrm_data/civicrm_option_group/acl_role.sqldata.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
'title' => ts('ACL Role'),
])
->addValues([
[
'label' => ts('Everyone'),
'value' => 0,
'name' => 'Everyone',
'is_reserved' => 1,
],
[
'label' => ts('Administrator'),
'value' => 1,
Expand Down

0 comments on commit c4be24b

Please sign in to comment.