Skip to content
Snippets Groups Projects

Add proposed code to check remember setting when fetching exposed input from session.

Open catch requested to merge issue/drupal-3506696:3506696-viewexecutable-should-not into 11.x
1 unresolved thread
1 file
+ 28
1
Compare changes
  • Side-by-side
  • Inline
@@ -753,7 +753,7 @@ public function getExposedInput() {
}
// If we have no input at all, check for remembered input via session.
if (empty($this->exposed_input)) {
if (empty($this->exposed_input) && $this->isFilterRememberEnabled()) {
$session = $this->request->getSession();
// If filters are not overridden, store the 'remember' settings on the
// default display. If they are, store them on this display. This way,
@@ -769,6 +769,33 @@ public function getExposedInput() {
return $this->exposed_input;
}
/**
* Check the view for remember configuration for current user role.
*
* @return bool
* Returns TRUE if the "Remember" setting is enabled for any
* of the user's roles, FALSE otherwise.
*/
public function isFilterRememberEnabled() {
// Loop through the exposed input filters.
foreach ($this->exposed_input as $filter_name => $input) {
// Check if the filter exists in the display handler's filter options.
if (isset($this->display_handler->getOption('filters')[$filter_name])) {
// Retrieve the configuration for the current filter.
$filter_config = $this->display_handler->getOption('filters')[$filter_name];
// Check if the "Remember" setting is enabled.
if ($filter_config['expose']['remember']) {
foreach ($filter_config['expose']['remember_roles'] as $role => $remember_roles) {
if ($remember_roles != 0 && $this->getUser()->hasRole($role)) {
return TRUE;
}
}
}
}
}
return FALSE;
}
/**
* Sets the display for this view and initializes the display handler.
*
Loading