did AND panel = '$pane->panel' AND position = $pane->position"); } if ($count) { $ret[] = update_sql("INSERT INTO {sequences} (name, id) VALUES ('{panels_pane}_pid', $count)"); } $ret[] = update_sql(<<did, '$display->layout')"); if ($display->did > $max_did) { $max_did = $display->did; } } $ret[] = update_sql("ALTER TABLE {panels_page} DROP COLUMN layout"); if ($max_did) { $ret[] = update_sql("INSERT INTO {sequences} (name, id) VALUES ('{panels_display}_did', $max_did)"); } return $ret; } function panels_update_1001() { $ret = array(); $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN no_blocks int(1)"); $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu int(1) DEFAULT 0"); $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu_tab int(1)"); $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu_tab_weight int(4)"); $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu_title varchar(255)"); $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu_tab_default int(1)"); $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu_tab_default_parent_type varchar(10)"); $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu_parent_title varchar(255)"); $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu_parent_tab_weight int(4)"); return $ret; } // Create a field for the layout settings function panels_update_1002() { $ret = array(); $ret[] = update_sql("ALTER TABLE {panels_display} ADD COLUMN layout_settings longtext"); $ret[] = update_sql("ALTER TABLE {panels_pane} ADD COLUMN access varchar(128) AFTER type"); $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN css longtext AFTER css_id"); return $ret; } // Create a field for the panel settings. function panels_update_1003() { $ret = array(); $ret[] = update_sql("ALTER TABLE {panels_display} ADD COLUMN panel_settings longtext"); return $ret; } // Create a field for the panel settings. // Renumbering to proper numbering scheme. function panels_update_5204() { $ret = array(); $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN name varchar(255) UNIQUE"); $ret[] = update_sql("ALTER TABLE {panels_display} ADD COLUMN name varchar(255) UNIQUE"); // Give all our panels a name. $ret[] = update_sql("UPDATE {panels_page} SET name = CONCAT('panel_page_', pid)"); $ret[] = update_sql("UPDATE {panels_display} SET name = CONCAT('display_', did)"); return $ret; } // Add the arguments field function panels_update_5205() { $ret = array(); $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN arguments longtext"); return $ret; } // Add a field so that panes can remember their subtype so we can retrieve // context information about it. function panels_update_5206() { $ret = array(); $ret[] = update_sql("ALTER TABLE {panels_pane} ADD COLUMN subtype varchar(64)"); return $ret; } // Add fields for displays and extra contexts function panels_update_5207() { $ret = array(); $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN displays longtext"); $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN contexts longtext"); return $ret; } // Correct the mistaken {panels_display}_id when it should be {panels_display}_did function panels_update_5208() { $ret = array(); $count = db_result(db_query("SELECT MAX(did) FROM {panels_display}")); $ret[] = update_sql("DELETE FROM {sequences} WHERE name = '{panels_display}_did'"); $ret[] = update_sql("DELETE FROM {sequences} WHERE name = '{panels_display}_id'"); if ($count) { $ret[] = update_sql("INSERT INTO {sequences} (name, id) VALUES ('{panels_display}_did', $count)"); } return $ret; } // Update argument, relationship and context code to be more correct. function panels_update_5209() { $ret = array(); $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN relationships longtext"); $result = db_query("SELECT * FROM {panels_page}"); panels_load_include('plugins'); while ($page = db_fetch_object($result)) { $args = unserialize($page->arguments); $arguments = $ids = $keywords = array(); if (!empty($args)) { // Update each argument foreach ($args as $id => $argument) { $name = $argument['name']; $info = panels_get_argument($name); if (!$info) { continue; } // Make sure the id is valid if (empty($argument['id'])) { if (empty($ids[$name])) { $ids[$name] = 1; } else { $ids[$name]++; } $argument['id'] = $ids[$name]; } // Give it an identifier if it doesn't already have one if (empty($argument['identifier'])) { $argument['identifier'] = $info['title'] . ($id > 1 ? ' ' . $id : ''); error_log($argument['identifier']); } // Give it a unique keyword if it doesn't already have one if (empty($argument['keyword'])) { $keyword = $base = $info['keyword']; $count = 0; while (!empty($keywords[$keyword])) { $keyword = $base . '_' . ++$count; } $keywords[$keyword] = TRUE; $argument['keyword'] = $keyword; error_log($argument['keyword']); } $arguments[$id] = $argument; } } // Move old relationships (stored as contexts) to relationships, where // the belong $rels = unserialize($page->contexts); // Not resetting $keywords! $relationships = $ids = array(); if (!empty($rels)) { foreach ($rels as $id => $relationship) { $name = $relationship['name']; $info = panels_get_relationship($name); if (!$info) { continue; } // Make sure the id is valid if (empty($relationship['id'])) { if (empty($ids[$name])) { $ids[$name] = 1; } else { $ids[$name]++; } $relationship['id'] = $ids[$name]; } // Give it an identifier if it doesn't already have one if (empty($relationship['identifier'])) { $relationship['identifier'] = $info['title'] . ($id > 1 ? ' ' . $id : ''); } // Give it a unique keyword if it doesn't already have one if (empty($relationship['keyword'])) { $keyword = $base = $info['keyword']; $count = 0; while (!empty($keywords[$keyword])) { $keyword = $base . '_' . ++$count; } $keywords[$keyword] = TRUE; $relationship['keyword'] = $keyword; } $relationships[$id] = $relationship; } } db_query("UPDATE {panels_page} " . "SET arguments = '%s', " . "relationships = '%s', " . "contexts = '%s' " . "WHERE pid = $page->pid", serialize($arguments), serialize($relationships), serialize(array()), $page->pid ); } return $ret; } function panels_update_5210() { $ret = array(); $ret[] = update_sql("UPDATE {system} SET weight = 10 WHERE name = 'panels'"); return $ret; } /** * Force a menu update */ function panels_update_5211() { menu_rebuild(); return array(); } /** * Add missing index on 'name' field. */ function panels_update_5212() { $ret = array(); $ret[] = update_sql("CREATE INDEX {panels_page}_name_idx ON {panels_page} (name)"); return $ret; } /** * Add a field to store pane caching information. */ function panels_update_5213() { $ret = array(); switch ($GLOBALS['db_type']) { case 'mysql': case 'mysqli': $ret[] = update_sql("ALTER TABLE {panels_pane} ADD COLUMN cache longtext AFTER configuration"); $ret[] = update_sql("ALTER TABLE {panels_display} ADD COLUMN cache longtext AFTER panel_settings"); break; case 'pgsql': db_add_column($ret, 'panels_pane', 'cache', 'text'); db_add_column($ret, 'panels_display', 'cache', 'text'); } return $ret; } /** * Create a new table for object caching. This isn't part of the cache * system. */ function panels_update_5214() { $ret = array(); switch ($GLOBALS['db_type']) { case 'mysql': case 'mysqli': $ret[] = update_sql(<< 1)); db_add_column($ret, 'panels_display', 'title', 'varchar(128)'); db_add_column($ret, 'panels_display', 'hide_title', 'tinyint', array('default' => 0)); $ret = update_sql("ALTER TABLE {panels_display} DROP name"); db_add_column($ret, 'panels_pane', 'visibility', 'text'); } return $ret; } /** * Add the switcher fields to the database */ function panels_update_5217() { $ret = array(); switch ($GLOBALS['db_type']) { case 'mysql': case 'mysqli': $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN switcher_type varchar(128) AFTER no_blocks"); $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN switcher_name varchar(128) AFTER no_blocks"); $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN switcher_options longtext AFTER switcher_type"); break; case 'pgsql': db_add_column($ret, 'panels_page', 'switcher_type', 'varchar(128)'); db_add_column($ret, 'panels_page', 'switcher_name', 'varchar(128)'); db_add_column($ret, 'panels_page', 'switcher_options', 'text'); } return $ret; } /** * Oversight in 5216: 'tinyint' is not a field type in pgsql; the type we wanted * was 'smallint.' */ function panels_update_5218() { $ret = array(); switch ($GLOBALS['db_type']) { case 'mysql': case 'mysqli': $ret[] = array('success' => TRUE, 'query' => t('Update #5218 only has changes for PostgreSQL. There are no updates for MySQL databases - since you\'re running MySQL, you should consider this update successful).')); break; case 'pgsql': db_add_column($ret, 'panels_pane', 'shown', 'smallint', array('default' => 1)); db_add_column($ret, 'panels_display', 'hide_title', 'smallint', array('default' => 0)); $ret[] = array('success' => TRUE, 'query' => t('You can disregard failed attempts to add new columns in update #5216 as long as the two queries preceding this text were successful.')); } return $ret; }