diff --git a/README.adoc b/README.adoc index 0dbbb6ac..feeda61c 100644 --- a/README.adoc +++ b/README.adoc @@ -345,10 +345,19 @@ The file used to import SAGs must be a CSV file with the following columns: .^|`user_rights` .^|User Rights .^a| +Prior to REDCap v14.1.0: * `0` - Not allowed * `1` - Allowed +As of REDCap v14.1.0: + +* `0` - No access +* `2` - Read only +* `1` - View & Edit + +_**Note**: The counterintuitive values here break with the general pattern of this module (in which higher values correspond with more permissions) in order to aid in maintaining backwards compatibility and prevent errors with this very important permission._ + .^|`data_access_groups` .^|Data Access Groups .^a| diff --git a/README.html b/README.html index 07063931..b3ad6f1a 100644 --- a/README.html +++ b/README.html @@ -989,7 +989,10 @@

S

user_rights

User Rights

-
diff --git a/SecurityAccessGroups.php b/SecurityAccessGroups.php index bb40e148..f6de4405 100644 --- a/SecurityAccessGroups.php +++ b/SecurityAccessGroups.php @@ -42,7 +42,7 @@ class SecurityAccessGroups extends AbstractExternalModule public function redcap_every_page_before_render() : void { // Only run on the pages we're interested in - if (!defined('PAGE') || !isset($_SERVER)) { + if ( !defined('PAGE') || !isset($_SERVER) ) { return; } $method = $_SERVER['REQUEST_METHOD'] ?? ''; diff --git a/classes/RightsChecker.php b/classes/RightsChecker.php index 02d01fbc..b7f9e1f2 100644 --- a/classes/RightsChecker.php +++ b/classes/RightsChecker.php @@ -318,7 +318,7 @@ private function checkUserRightsRight($right, $value) if ( $value == '1' && $userRights != 1 ) { $rightName = $mainRight . ($newVersion ? ' - ' . RightsUtilities::getDisplayTextForRight('viewAndEdit') : ''); $this->badRights[] = $rightName; - } elseif ( $value == '2' && $userRights != 2 ) { + } elseif ( $value == '2' && $userRights == 0 ) { $rightName = $mainRight . ($newVersion ? ' - ' . RightsUtilities::getDisplayTextForRight('readOnly') : ''); $this->badRights[] = $rightName; } diff --git a/classes/RightsUtilities.php b/classes/RightsUtilities.php index 4ed460cd..d8f2e3f2 100644 --- a/classes/RightsUtilities.php +++ b/classes/RightsUtilities.php @@ -70,44 +70,6 @@ public static function convertDataEntryRightsStringToArray($fullRightsString) return $result; } - /** - * Converts the User Rights permission values from the SAG user-facing format to the interal format that is also used by REDCap. - * - * This function can be used to convert in either direction. - * - * Prior to REDCap 14.1.0, the user_rights field was: - * 0: No access - * 1: View and edit - * - * Starting with REDCap 14.1.0, the user_rights field is: - * 0: No access - * 2: View only - * 1: View and edit - * - * For user-facing purposes (e.g., CSV Import), we want higher values to always mean more permission, so if REDCap 14.1.0 or later, we need to swap 1 and 2. - * This results in: - * - * 0: No access - * 1: View only - * 2: View and edit - * - * @param array $rights - * @return array $rights - */ - public static function convertUserRights($rights) - { - $redcapVersion = defined('REDCAP_VERSION') ? REDCAP_VERSION : '99.99.99'; - if ( \REDCap::versionCompare($redcapVersion, '14.1.0') >= 0 ) { - if ( $rights['user_rights'] == 1 ) { - $rights['user_rights'] = 2; - } else if ( $rights['user_rights'] == 2 ) { - $rights['user_rights'] = 1; - } - } - return $rights; - } - - private static function convertDoubleData($rights) { // 0: Reviewer @@ -146,7 +108,6 @@ public static function convertPermissions(string $permissions) $rights = json_decode($permissions, true); $rights = self::convertDataQualityResolution($rights); $rights = self::convertDoubleData($rights); - $rights = self::convertUserRights($rights); foreach ( $rights as $key => $value ) { if ( $value === 'on' ) { $rights[$key] = 1; diff --git a/classes/SAGEditForm.php b/classes/SAGEditForm.php index 4f110974..b1411977 100644 --- a/classes/SAGEditForm.php +++ b/classes/SAGEditForm.php @@ -183,16 +183,16 @@ private function getUserRights() for='user_rights_0'>$label2
- + + for='user_rights_2'>$label3
- + + for='user_rights_1'>$label4