diff --git a/plugins/views_plugin_query_default.inc b/plugins/views_plugin_query_default.inc index 2911a56033947fcfc217c13b1ea76377bccffb7b..27ed30e571cba31ee98569f77ee31cccad48cbdd 100644 --- a/plugins/views_plugin_query_default.inc +++ b/plugins/views_plugin_query_default.inc @@ -248,15 +248,25 @@ class views_plugin_query_default extends views_plugin_query { public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); - $form['disable_sql_rewrite'] = array( - '#title' => t('Disable SQL rewriting'), - '#description' => t('Disabling SQL rewriting will disable node_access checks as well as other modules that implement hook_query_alter().'), - '#type' => 'checkbox', - '#default_value' => !empty($this->options['disable_sql_rewrite']), - '#suffix' => '
', - ); + // Establish which query tag will be affected by disable_sql_rewrite. + // This 'access query tag' is defined by hook_views_data() for the base table. + // e.g. node_views_data() + if (!empty($form_state['view']->base_table)) { + $base_table = $form_state['view']->base_table; + $base_table_data = views_fetch_data($base_table); + if (!empty($base_table_data['table']['base']['access query tag'])) { + $access_tag = $base_table_data['table']['base']['access query tag']; + $form['disable_sql_rewrite'] = array( + '#title' => t('Disable access checks'), + '#description' => t('Do not apply %access_tag checks to this query. Selecting this option omits that tag from the alterable query.', array('%access_tag' => $access_tag)), + '#type' => 'checkbox', + '#default_value' => !empty($this->options['disable_sql_rewrite']), + '#suffix' => ' ', + ); + } + } $form['distinct'] = array( '#type' => 'checkbox', '#title' => t('Distinct'),