123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650 |
- <?php
- function views_install() {
- if (Database::getConnection()->databaseType() == 'pgsql') {
- db_query('CREATE OR REPLACE FUNCTION first(anyelement, anyelement) RETURNS anyelement AS \'SELECT COALESCE($1, $2);\' LANGUAGE \'sql\';');
- db_query("DROP AGGREGATE IF EXISTS first(anyelement)");
- db_query("CREATE AGGREGATE first(sfunc = first, basetype = anyelement, stype = anyelement);");
- }
- db_query("UPDATE {system} SET weight = 10 WHERE name = 'views'");
- }
- function views_schema($caller_function = NULL) {
-
-
-
-
-
-
-
-
-
-
- static $get_current;
- static $schemas = array();
-
- if (!isset($get_current)) {
- $get_current = $caller_function ? FALSE : TRUE;
- }
-
- if ($get_current || empty($schemas)) {
- $get_current = FALSE;
-
- $start_schema = 6000;
- $end_schema = 7999;
- for ($i = $start_schema; $i <= $end_schema; $i++) {
- if (function_exists('views_schema_' . $i)) {
- $schemas[] = $i;
- }
- }
- if ($schemas) {
- sort($schemas, SORT_NUMERIC);
-
-
- if ($caller_function) {
- do {
- $schema = array_pop($schemas);
- } while ($schemas && $caller_function != 'views_schema_' . $schema);
- }
- }
- }
-
- if ($schema = array_pop($schemas)) {
- $function = 'views_schema_' . $schema;
- return $function();
- }
- return array();
- }
- function views_schema_6000() {
- $schema['views_view'] = array(
- 'description' => 'Stores the general data for a view.',
- 'export' => array(
- 'identifier' => 'view',
- 'bulk export' => TRUE,
- 'primary key' => 'vid',
- 'default hook' => 'views_default_views',
- 'admin_title' => 'human_name',
- 'admin_description' => 'description',
- 'api' => array(
- 'owner' => 'views',
- 'api' => 'views_default',
- 'minimum_version' => '2',
- 'current_version' => '3.0',
- ),
- 'object' => 'view',
-
- 'subrecords callback' => 'views_load_display_records',
-
- 'status' => 'views_defaults',
-
- 'create callback' => 'views_new_view',
- 'save callback' => 'views_save_view',
- 'delete callback' => 'views_delete_view',
- 'export callback' => 'views_export_view',
- 'status callback' => 'views_export_status',
- 'cache defaults' => TRUE,
- 'default cache bin' => 'cache_views',
- ),
- 'fields' => array(
- 'vid' => array(
- 'type' => 'serial',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'description' => 'The view ID of the field, defined by the database.',
- 'no export' => TRUE,
- ),
- 'name' => array(
- 'type' => 'varchar',
- 'length' => '32',
- 'default' => '',
- 'not null' => TRUE,
- 'description' => 'The unique name of the view. This is the primary field views are loaded from, and is used so that views may be internal and not necessarily in the database. May only be alphanumeric characters plus underscores.',
- ),
- 'description' => array(
- 'type' => 'varchar',
- 'length' => '255',
- 'default' => '',
- 'description' => 'A description of the view for the admin interface.',
- ),
- 'tag' => array(
- 'type' => 'varchar',
- 'length' => '255',
- 'default' => '',
- 'description' => 'A tag used to group/sort views in the admin interface',
- ),
- 'view_php' => array(
- 'type' => 'blob',
- 'description' => 'A chunk of PHP code that can be used to provide modifications to the view prior to building.',
- ),
- 'base_table' => array(
- 'type' => 'varchar',
- 'length' => '32',
-
- 'default' => '',
- 'not null' => TRUE,
- 'description' => 'What table this view is based on, such as node, user, comment, or term.',
- ),
- 'is_cacheable' => array(
- 'type' => 'int',
- 'default' => 0,
- 'size' => 'tiny',
- 'description' => 'A boolean to indicate whether or not this view may have its query cached.',
- ),
- ),
- 'primary key' => array('vid'),
- 'unique key' => array('name' => array('name')),
-
- );
- $schema['views_display'] = array(
- 'description' => 'Stores information about each display attached to a view.',
- 'fields' => array(
- 'vid' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => 'The view this display is attached to.',
- 'no export' => TRUE,
- ),
- 'id' => array(
- 'type' => 'varchar',
- 'length' => '64',
- 'default' => '',
- 'not null' => TRUE,
- 'description' => 'An identifier for this display; usually generated from the display_plugin, so should be something like page or page_1 or block_2, etc.',
- ),
- 'display_title' => array(
- 'type' => 'varchar',
- 'length' => '64',
- 'default' => '',
- 'not null' => TRUE,
- 'description' => 'The title of the display, viewable by the administrator.',
- ),
- 'display_plugin' => array(
- 'type' => 'varchar',
- 'length' => '64',
- 'default' => '',
- 'not null' => TRUE,
- 'description' => 'The type of the display. Usually page, block or embed, but is pluggable so may be other things.',
- ),
- 'position' => array(
- 'type' => 'int',
- 'default' => 0,
- 'description' => 'The order in which this display is loaded.',
- ),
- 'display_options' => array(
-
- 'type' => 'blob',
- 'description' => 'A serialized array of options for this display; it contains options that are generally only pertinent to that display plugin type.',
- 'serialize' => TRUE,
- 'serialized default' => 'a:0:{}',
- ),
- ),
-
- 'indexes' => array('vid' => array('vid', 'position')),
- );
- $schema['cache_views'] = drupal_get_schema_unprocessed('system', 'cache');
- $schema['views_object_cache'] = array(
- 'description' => 'A special cache used to store objects that are being edited; it serves to save state in an ordinarily stateless environment.',
- 'fields' => array(
- 'sid' => array(
- 'type' => 'varchar',
- 'length' => '64',
- 'description' => 'The session ID this cache object belongs to.',
- ),
- 'name' => array(
- 'type' => 'varchar',
- 'length' => '32',
- 'description' => 'The name of the view this cache is attached to.',
- ),
- 'obj' => array(
- 'type' => 'varchar',
- 'length' => '32',
- 'description' => 'The name of the object this cache is attached to; this essentially represents the owner so that several sub-systems can use this cache.',
- ),
- 'updated' => array(
- 'type' => 'int',
- 'unsigned' => TRUE,
- 'not null' => TRUE,
- 'default' => 0,
- 'description' => 'The time this cache was created or updated.',
- ),
- 'data' => array(
- 'type' => 'blob',
-
- 'description' => 'Serialized data being stored.',
- 'serialize' => TRUE,
- ),
- ),
- 'indexes' => array(
- 'sid_obj_name' => array('sid', 'obj', 'name'),
- 'updated' => array('updated'),
- ),
- );
-
- return $schema;
- }
- function views_update_6000() {
- if (db_table_exists('views_view')) {
- return;
- }
-
-
- if (db_table_exists('cache_views')) {
- db_drop_table('cache_views');
- }
-
-
-
- $schema = views_schema_6000();
- _drupal_schema_initialize($schema, 'views');
- foreach ($schema as $name => $table) {
- db_create_table($name, $table);
- }
- }
- function views_update_6001() {
- $result = db_query("SELECT * FROM {blocks} WHERE module = 'views' AND delta LIKE '\$exp%'");
- foreach ($result as $block) {
- $new = strtr($block->delta, '$', '-');
- update_sql("UPDATE {blocks} SET delta = '" . db_escape_string($new) . "' WHERE module = 'views' AND delta = '" . db_escape_string($block->delta) . "'");
- }
- update_sql("UPDATE {blocks} SET delta = CONCAT(delta, '-block_1') WHERE module = 'views'");
- }
- function views_schema_6003() {
- $schema = views_schema(__FUNCTION__);
- $schema['views_view']['unique keys'] = array('name' => array('name'));
- unset($schema['views_view']['unique key']);
- return $schema;
- }
- function views_update_6003() {
- db_add_unique_key('views_view', 'name', array('name'));
- }
- function views_schema_6004() {
- $schema = views_schema(__FUNCTION__);
- $schema['views_object_cache']['fields']['data']['type'] = 'text';
- $schema['views_object_cache']['fields']['data']['size'] = 'big';
- return $schema;
- }
- function views_update_6004() {
- $new_field = array(
- 'type' => 'text',
- 'size' => 'big',
- 'description' => 'Serialized data being stored.',
- 'serialize' => TRUE,
- );
-
-
- db_drop_field('views_object_cache', 'data');
- db_add_field('views_object_cache', 'data', $new_field);
- }
- function views_schema_6005() {
- $schema = views_schema(__FUNCTION__);
- $schema['views_view']['fields']['base_table']['length'] = 64;
- return $schema;
- }
- function views_update_6005() {
- $new_field = array(
- 'type' => 'varchar',
- 'length' => '64',
- 'default' => '',
- 'not null' => TRUE,
- 'description' => 'What table this view is based on, such as node, user, comment, or term.',
- );
- db_change_field('views_view', 'base_table', 'base_table', $new_field);
- }
- function views_schema_6006() {
- $schema = views_schema(__FUNCTION__);
- $schema['cache_views_data'] = drupal_get_schema_unprocessed('system', 'cache');
- $schema['cache_views_data']['description'] = 'Cache table for views to store pre-rendered queries, results, and display output.';
- $schema['cache_views_data']['fields']['serialized']['default'] = 1;
- return $schema;
- }
- function views_update_6006() {
- $table = drupal_get_schema_unprocessed('system', 'cache');
- $table['description'] = 'Cache table for views to store pre-rendered queries, results, and display output.';
- $table['fields']['serialized']['default'] = 1;
- db_create_table('cache_views_data', $table);
- }
- function views_update_6007() {
- if (Database::getConnection()->databaseType() == 'pgsql') {
- db_query('CREATE OR REPLACE FUNCTION first(anyelement, anyelement) RETURNS anyelement AS \'SELECT COALESCE($1, $2);\' LANGUAGE \'sql\';');
- db_query("DROP AGGREGATE IF EXISTS first(anyelement)");
- db_query("CREATE AGGREGATE first(sfunc = first, basetype = anyelement, stype = anyelement);");
- }
- }
- function views_schema_6008() {
- $schema = views_schema(__FUNCTION__);
- $schema['views_display']['primary key'] = array('vid', 'id');
- return $schema;
- }
- function views_update_6008() {
- db_add_primary_key('views_display', array('vid', 'id'));
- }
- function views_schema_6009() {
- $schema = views_schema(__FUNCTION__);
- $schema['views_display']['fields']['display_options'] = array(
- 'type' => 'text',
- 'size' => 'big',
- 'description' => 'A serialized array of options for this display; it contains options that are generally only pertinent to that display plugin type.',
- 'serialize' => TRUE,
- 'serialized default' => 'a:0:{}',
- );
- return $schema;
- }
- function views_update_6009() {
- $schema = views_schema_6009();
- if (Database::getConnection()->databaseType() == 'pgsql') {
- db_query('ALTER TABLE {views_display} RENAME "display_options" TO "display_options_old"');
- db_add_field('views_display', 'display_options', $schema['views_display']['fields']['display_options']);
- $sql = "SELECT vid, id, display_options_old FROM {views_display}";
- $result = db_query($sql);
- foreach ($result as $row) {
- $row['display_options_old'] = $row['display_options_old'];
- $sql = "UPDATE {views_display} SET display_options = :display_optons WHERE vid = :vid AND id = :id";
- db_query($sql, array(
- ':display_optons' => $row['display_options_old'],
- ':vid' => $row['vid'],
- ':id' => $row['id'],
- ));
- }
- db_drop_field('views_display', 'display_options_old');
- }
- else {
- db_change_field('views_display', 'display_options', 'display_options', $schema['views_display']['fields']['display_options']);
- }
- }
- function views_schema_6010() {
- $schema = views_schema(__FUNCTION__);
- unset($schema['views_view']['fields']['view_php']);
- unset($schema['views_view']['fields']['is_cacheable']);
- return $schema;
- }
- function views_update_6010() {
- db_drop_field('views_view', 'view_php');
- db_drop_field('views_view', 'is_cacheable');
- }
- function views_schema_6011() {
- $schema = views_schema(__FUNCTION__);
- unset($schema['views_object_cache']);
- return $schema;
- }
- function views_update_6011() {
- $caches = db_query("SELECT * FROM {views_object_cache}");
- foreach ($caches as $item) {
- drupal_write_record('ctools_object_cache', $item);
- }
- db_drop_table('views_object_cache');
- }
- function views_update_6012() {
-
- db_update('blocks')
- ->condition('module', 'views')
- ->condition('delta', db_like('-exp-') . '%', 'LIKE')
- ->fields(array('cache' => DRUPAL_NO_CACHE));
- }
- function views_schema_6013() {
- $schema = views_schema(__FUNCTION__);
- $schema['views_view']['fields']['human_name'] = array(
- 'type' => 'varchar',
- 'length' => '255',
- 'default' => '',
- 'description' => 'A human readable name used to be displayed in the admin interface',
- );
- return $schema;
- }
- function views_update_6013() {
-
- if (!db_field_exists('views_view', 'human_name')) {
- $new_field = array(
- 'type' => 'varchar',
- 'length' => '255',
- 'default' => '',
- 'description' => 'A human readable name used to be displayed in the admin interface',
- );
- db_add_field('views_view', 'human_name', $new_field);
- }
- }
- function views_schema_6014() {
- $schema = views_schema(__FUNCTION__);
- $schema['views_view']['fields']['core'] = array(
- 'type' => 'int',
- 'default' => 0,
- 'description' => 'Stores the drupal core version of the view.',
- );
- return $schema;
- }
- function views_update_6014() {
-
- if (!db_field_exists('views_view', 'core')) {
- $new_field = array(
- 'type' => 'int',
- 'default' => 0,
- 'description' => 'Stores the drupal core version of the view.',
- );
- db_add_field('views_view', 'core', $new_field);
- }
- }
- function views_update_7000() {
-
- $query_on_top = variable_get('views_ui_query_on_top');
- if (isset($query_on_top)) {
- variable_set('views_ui_show_sql_query', TRUE);
- if ($query_on_top) {
- variable_set('views_ui_show_sql_query_where', 'above');
- }
- else {
- variable_set('views_ui_show_sql_query_where', 'below');
- }
- variable_del('views_ui_query_on_top');
- }
-
- $hide_help = variable_get('views_hide_help_message');
- if (isset($hide_help)) {
- variable_set('views_ui_show_advanced_help_warning', !$hide_help);
- variable_del('views_hide_help_message');
- }
-
- variable_del('views_no_hover_links');
- }
- function views_update_7001() {
- $depth = db_select('menu_links')
- ->fields('menu_links', array('depth'))
- ->condition('link_path', 'admin/structure/views/view/%')
- ->execute()
- ->fetchField();
- if ($depth == 3) {
- db_delete('menu_links')
- ->condition('link_path', 'admin/structure/views/%', 'LIKE')
- ->execute();
- cache_clear_all(NULL, 'cache_menu');
- menu_rebuild();
- }
- }
- function views_schema_7300() {
- return views_schema_6013();
- }
- function views_update_7300() {
- views_update_6013();
- }
- function views_schema_7301() {
- $schema = views_schema(__FUNCTION__);
- $schema['views_view']['fields']['name']['length'] = 128;
- return $schema;
- }
- function views_update_7301() {
- $new_field = array(
- 'type' => 'varchar',
- 'length' => '128',
- 'default' => '',
- 'not null' => TRUE,
- 'description' => 'The unique name of the view. This is the primary field views are loaded from, and is used so that views may be internal and not necessarily in the database. May only be alphanumeric characters plus underscores.',
- );
- db_change_field('views_view', 'name', 'name', $new_field);
- }
- function views_update_7302() {
- if (db_field_exists('cache_views', 'headers')) {
- db_drop_field('cache_views', 'headers');
- }
- if (db_field_exists('cache_views_data', 'headers')) {
- db_drop_field('cache_views_data', 'headers');
- }
- }
|