Skip to content

Commit

Permalink
Add in transitional arrangement so that administer CiviCRM is still s…
Browse files Browse the repository at this point in the history
…uffient for the moment to access the status checks as well
  • Loading branch information
seamuslee001 committed Jun 21, 2019
1 parent 0ae0807 commit a1eddd0
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
12 changes: 11 additions & 1 deletion CRM/Core/Invoke.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,17 @@ public static function form($action, $contact_type, $contact_sub_type) {
* @param CRM_Core_Smarty $template
*/
public static function statusCheck($template) {
if (CRM_Core_Config::isUpgradeMode() || !CRM_Core_Permission::check('view status checks')) {
$permissions = [];
// Transitional arrangement until end of 2019, we have added a new permission
// view status checks and if CIVICRM_DISABLE_TRANSITION_STATUS_CHECKS is not defined
// or defined as false fall back to standard administer CiviCRM permission
if (!CRM_Utils_Constant::value('CIVICRM_DISABLE_TRANSITION_STATUS_CHECKS')) {
$permissions[] = ['view status checks', 'administer CiviCRM'];
}
else {
$permissions[0] = 'view status checks';
}
if (CRM_Core_Config::isUpgradeMode() || !CRM_Core_Permission::check($permissions)) {
return;
}
// always use cached results - they will be refreshed by the session timer
Expand Down
5 changes: 4 additions & 1 deletion CRM/Upgrade/Incremental/php/FiveSixteen.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ class CRM_Upgrade_Incremental_php_FiveSixteen extends CRM_Upgrade_Incremental_Ba
*/
public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NULL) {
if ($rev == '5.16.alpha1') {
$preUpgradeMessage .= '<p>' . ts('A new permission, "%1", has been added. This permission is now used to control access to the CiviCRM Status Checks notices.', array(1 => ts('View CiviCRM Status Checks'))) . '</p>';
$preUpgradeMessage .= '<p>' . ts('A new permission, "%1", has been added. For the moment this new permission or %2 permission will be enough to see the status checks. This will change at the end of 2019 when the permissions %1 will be required to access the status checks. We recommend at least one user has that permission granted to them. If System Administrators want to switch to just using the new permission check to control access to the status checks. They can add a define in civicrm.settings.php setting CIVICRM_DISABLE_TRANSITION_STATUS_CHECKS to be TRUE to disable the transitional arrangement .', [
1 => 'View CiviCRM Status Checks',
2 => 'Administer CiviCRM',
]) . '</p>';
}
}

Expand Down
11 changes: 10 additions & 1 deletion CRM/Utils/Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,16 @@ public static function getSeverityList() {
* Display daily system status alerts (admin only).
*/
public function showPeriodicAlerts() {
if (CRM_Core_Permission::check('view status checks')) {
// Transitional arrangement until end of 2019, we have added a new permission
// view status checks and if CIVICRM_DISABLE_TRANSITION_STATUS_CHECKS is not defined
// or defined as false fall back to standard administer CiviCRM permission
if (!CRM_Utils_Constant::value('CIVICRM_DISABLE_TRANSITION_STATUS_CHECKS')) {
$permissions[] = ['view status checks', 'administer CiviCRM'];
}
else {
$permissions[0] = 'view status checks';
}
if (CRM_Core_Permission::check($permissions)) {
$session = CRM_Core_Session::singleton();
if ($session->timer('check_' . __CLASS__, self::CHECK_TIMER)) {

Expand Down
9 changes: 9 additions & 0 deletions templates/CRM/common/civicrm.settings.php.template
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,15 @@ define('CIVICRM_DEADLOCK_RETRIES', 3);
*/
// define('CIVICRM_BAO_CACHE_ADAPTER', 'CRM_Core_BAO_Cache_Psr16');

/**
* Specify if CiviCRM should not translate administer CiviCRM Permission
* to include view status checks permission.
*
* This is a transitional arrangement and if left undefined administer civicrm
* will be treated like view status checks permission
*/
// define('CIVICRM_DISABLE_TRANSITION_STATUS_CHECKS', TRUE);

if (CIVICRM_UF === 'UnitTests') {
if (!defined('CIVICRM_CONTAINER_CACHE')) define('CIVICRM_CONTAINER_CACHE', 'auto');
if (!defined('CIVICRM_MYSQL_STRICT')) define('CIVICRM_MYSQL_STRICT', true);
Expand Down

0 comments on commit a1eddd0

Please sign in to comment.