diff --git a/includes/admin.inc b/includes/admin.inc index 79b9e8d88feb7072285fd1d0835bd0929576e926..0e5e89c18be602cc2f05d804c865857f9069ec86 100644 --- a/includes/admin.inc +++ b/includes/admin.inc @@ -2062,7 +2062,14 @@ function views_ui_disable_page($view) { * Page callback for the tools - other page */ function views_ui_admin_tools() { - return t('This page is not yet implemented. But try the convert tool.'); + $form['views_sql_signature'] = array( + '#type' => 'checkbox', + '#title' => t('Add Views signature to all SQL queries'), + '#description' => t("All Views-generated queries will include a special 'VIEWS' = 'VIEWS' string in the WHERE clause. This makes identifying Views queries in database server logs simpler, but should only be used when troubleshooting."), + '#default_value' => variable_get('views_sql_signature', FALSE), + ); + + return system_settings_form($form); } /** diff --git a/includes/view.inc b/includes/view.inc index 7e2f026a9fd2389dcc1df0c584041d34c08838a8..b2baf0ee09fcd32fd23add96d87ec521bd286cd8 100644 --- a/includes/view.inc +++ b/includes/view.inc @@ -472,6 +472,10 @@ class view extends views_db_object { $this->style_handler->query(); + if (variable_get('views_sql_signature', FALSE)) { + $this->query->add_field(NULL, "'". $this->name .':'. $this->current_display ."'", 'view_name'); + } + $this->build_info['query'] = $this->query->query(); $this->build_info['count_query'] = $this->query->query(TRUE); $this->build_info['query_args'] = $this->query->get_where_args(); diff --git a/views_ui.module b/views_ui.module index 15b57082693e19c7fb41cf3e5cce0732cc85de7b..1b1f7ac1d20275377ed338c595098081845220d9 100644 --- a/views_ui.module +++ b/views_ui.module @@ -46,7 +46,8 @@ function views_ui_menu() { ); $items['admin/build/views/tools'] = $base + array( 'title' => t('Tools'), - 'page callback' => 'views_ui_admin_tools', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('views_ui_admin_tools'), 'type' => MENU_LOCAL_TASK ); $items['admin/build/views/tools/basic'] = $base + array(