Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed issue #17422: Survey Deletion view/read permission seems to be …
…granted (#1959)

Dev: Check if forced by minimal read : don't display checkbox in view
Dev: Alt : show checkbox as checked and disable ?
  • Loading branch information
Shnoulle committed Aug 9, 2021
1 parent 66af51e commit beb3cf1
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
6 changes: 0 additions & 6 deletions application/controllers/admin/surveypermission.php
Expand Up @@ -162,7 +162,6 @@ public function index($iSurveyID)
if (
$sPDetailValue
&& Permission::model()->hasSurveyPermission($iSurveyID, $sPKey, $sPDetailKey, $PermissionRow['uid'])
&& !($sPKey == 'survey' && $sPDetailKey == 'read')
) {
$iCount++;
$sTooltip .= $sPDetailKey . ", ";
Expand All @@ -171,11 +170,6 @@ public function index($iSurveyID)
$iPermissionCount++;
}
}

if ($sPKey == 'survey') {
$iPermissionCount--;
}

// Remove last ',' and make first char upper-case
$sTooltip = substr($sTooltip, 0, -2);
$sTooltip = ucfirst($sTooltip);
Expand Down
Expand Up @@ -23,7 +23,7 @@
<td><?= $aCurrentPermissions['title'] ?></td>
<td><?php echo CHtml::checkBox("all_$sPermission",false, array('class' => 'markrow')) ?></td>
<?php foreach ($aCurrentPermissions['current'] as $sKey =>$aValues): ?>
<td class='extended'><?php if($aCurrentPermissions[$sKey]) {
<td class='extended'><?php if($aCurrentPermissions[$sKey] && !$aValues['forced']) {
echo CHtml::checkBox(
"set[{$aCurrentPermissions['entity']}][{$sPermission}][$sKey]",
$aValues['checked'],
Expand Down
7 changes: 4 additions & 3 deletions application/models/Survey.php
Expand Up @@ -2185,12 +2185,13 @@ public static function getPermissionData()
),
'survey' => array(
'create' => false,
'read' => true, /* Minimal : forced to true when edit */
'update' => false,
'import' => false,
'export' => false,
'title' => gT("Survey deletion"),
'description' => gT("Permission to delete a survey"),
'img' => ' fa fa-trash',
'title' => gT("Survey"),
'description' => gT("Permission on survey (delete). Read permission is used to give access to this group."),
'img' => ' fa fa-list', /** Unused, global use icon-list */
),
'surveyactivation' => array(
'create' => false,
Expand Down
2 changes: 1 addition & 1 deletion application/models/SurveysGroups.php
Expand Up @@ -428,7 +428,7 @@ public static function getPermissionData()
$aPermission = array(
'group' => array(
'create' => false,
'read' => false, /* Minimal : forced to true when edit, see survey for Survey model */
'read' => true, /* Minimal : forced to true when edit */
'update' => true,
'delete' => true,
'import' => false,
Expand Down
6 changes: 5 additions & 1 deletion application/models/services/PermissionManager.php
Expand Up @@ -75,7 +75,8 @@ public function getPermissionData($userId = null)
'checked' => false,
/* The checkbox are disable if currentuser don't have permission */
'disabled' => !$this->getCurrentPermission($sPermission, $crud, $this->user->id),
'indeterminate' => false
'indeterminate' => false,
'forced' => false,
);
}
/* If user id is set : update the data with permission of this user */
Expand All @@ -95,6 +96,9 @@ public function getPermissionData($userId = null)
if (!$havePermissionSet) {
$aObjectPermissions[$sPermission]['current'][$crud]['indeterminate'] = $this->getCurrentPermission($sPermission, $crud, $userId);
}
if ($sPermission == $this->model->getMinimalPermissionRead() && $crud == 'read') {
$aObjectPermissions[$sPermission]['current'][$crud]['forced'] = true;
}
}
}
}
Expand Down

0 comments on commit beb3cf1

Please sign in to comment.