Skip to content

Commit

Permalink
[SD-418] add validation delete bulk approver (#527)
Browse files Browse the repository at this point in the history
* added validation to current user
  • Loading branch information
yeniatencio authored and Sahil Sharma committed Oct 18, 2024
1 parent 12410bd commit 2c29afd
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ public function viewsForm(&$form, FormStateInterface $form_state) {
'#empty_option' => $this->t('- Select -'),
];
$current_user = \Drupal::currentUser();

// Removed delete option for approver role.
if ($current_user) {
$roles = $current_user->getRoles();
if (
in_array('approver', $roles) &&
isset($form['header']['node_bulk_form']['action']['#options']['node_delete_action'])
) {
unset($form['header']['node_bulk_form']['action']['#options']['node_delete_action']);
}
}
if (!$current_user->hasPermission('tide node bulk update') &&
!\Drupal::service('tide_site_restriction.helper')->canBypassRestriction($current_user)) {
$form['actions']['submit']['#disabled'] = TRUE;
Expand All @@ -86,15 +97,6 @@ public function viewsForm(&$form, FormStateInterface $form_state) {
// Remove the default actions build array.
unset($form['actions']);
}

// Removed delete option for approver role.
$roles = $current_user->getRoles();
if (
in_array('approver', $roles) &&
isset($form['header']['node_bulk_form']['action']['#options']['node_delete_action'])
) {
unset($form['header']['node_bulk_form']['action']['#options']['node_delete_action']);
}
}

}

0 comments on commit 2c29afd

Please sign in to comment.