Commit 915450db authored by slashrsm's avatar slashrsm Committed by tim.plunkett

Issue #1315578 by slashrsm, paranojik, dawehner: Added Ability to save exposed...

Issue #1315578 by slashrsm, paranojik, dawehner: Added Ability to save exposed filters state only for registered users?.
parent 0efb93b7
......@@ -109,6 +109,9 @@ function option_definition() {
'required' => array('default' => FALSE, 'bool' => TRUE),
'remember' => array('default' => FALSE, 'bool' => TRUE),
'multiple' => array('default' => FALSE, 'bool' => TRUE),
'remember_roles' => array('default' => array(
DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID,
)),
),
);
......@@ -387,6 +390,20 @@ function expose_form(&$form, &$form_state) {
'#default_value' => $this->options['expose']['remember'],
);
$role_options = array_map('check_plain', user_roles());
$form['expose']['remember_roles'] = array(
'#type' => 'checkboxes',
'#title' => t('User roles'),
'#description' => t('Remember exposed selection only for the selected user role(s). If you select no roles, the exposed data will never be stored.'),
'#default_value' => $this->options['expose']['remember_roles'],
'#options' => $role_options,
'#states' => array(
'invisible' => array(
':input[name="options[expose][remember]"]' => array('checked' => FALSE),
),
),
);
$form['expose']['identifier'] = array(
'#type' => 'textfield',
'#default_value' => $this->options['expose']['identifier'],
......@@ -626,6 +643,14 @@ function store_exposed_input($input, $status) {
return;
}
// Check if we store exposed value for current user.
global $user;
$allowed_rids = empty($this->options['expose']['remember_roles']) ? array() : array_filter($this->options['expose']['remember_roles']);
$intersect_rids = array_intersect_key($allowed_rids, $user->roles);
if (empty($intersect_rids)) {
return;
}
// Figure out which display id is responsible for the filters, so we
// know where to look for session stored values.
$display_id = ($this->view->display_handler->is_defaulted('filters')) ? 'default' : $this->view->current_display;
......
......@@ -309,7 +309,7 @@ function options_form(&$form, &$form_state) {
'#type' => 'textfield',
'#description' => t('This view will be displayed by visiting this path on your site. You may use "%" in your URL to represent values that will be used for contextual filters: For example, "node/%/feed".'),
'#default_value' => $this->get_option('path'),
'#field_prefix' => '<span dir="ltr">' . url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
'#field_prefix' => '<span dir="ltr">' . url(NULL, array('absolute' => TRUE)),
'#field_suffix' => '</span>&lrm;',
'#attributes' => array('dir'=>'ltr'),
);
......
......@@ -81,7 +81,7 @@ function __construct($plugin) {
function build_form($form, &$form_state) {
$style_options = views_fetch_plugin_names('style', 'normal', array($this->base_table));
$feed_row_options = views_fetch_plugin_names('row', 'feed', array($this->base_table));
$path_prefix = url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q=');
$path_prefix = url(NULL, array('absolute' => TRUE));
// Add filters and sorts which apply to the view as a whole.
$this->build_filters($form, $form_state);
......
......@@ -1980,13 +1980,6 @@ function views_exposed_form($form, &$form_state) {
$form['#info'] = array();
if (!variable_get('clean_url', FALSE)) {
$form['q'] = array(
'#type' => 'hidden',
'#value' => $view->get_url(),
);
}
// Go through each handler and let it generate its exposed widget.
foreach ($view->display_handler->handlers as $type => $value) {
foreach ($view->$type as $id => $handler) {
......@@ -2066,7 +2059,7 @@ function views_exposed_form_submit(&$form, &$form_state) {
$form_state['view']->exposed_raw_input = array();
$exclude = array('q', 'submit', 'form_build_id', 'form_id', 'form_token', 'exposed_form_plugin', '', 'reset');
$exclude = array('submit', 'form_build_id', 'form_id', 'form_token', 'exposed_form_plugin', '', 'reset');
$exposed_form_plugin = $form_state['exposed_form_plugin'];
$exposed_form_plugin->exposed_form_submit($form, $form_state, $exclude);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment