5 * Test requirements for installation and running.
7 function panels_requirements($phase) {
8 $function = "panels_requirements_$phase";
9 return function_exists($function) ?
$function() : array();
13 * Check install-time requirements.
15 function panels_requirements_install() {
16 $requirements = array();
18 // Assume that if the user is running an installation profile that both
19 // Panels and CTools are the same release.
20 if (!(defined('MAINTENANCE_MODE') && MAINTENANCE_MODE
== 'install')) {
21 // apparently the install process doesn't include .module files,
22 // so we need to force the issue in order for our versioning
24 if (!defined('PANELS_REQUIRED_CTOOLS_API')) {
25 include_once
drupal_get_path('module', 'panels') .
'/panels.module';
28 // In theory we should check module_exists, but Drupal's gating should
29 // actually prevent us from getting here otherwise.
30 if (!defined('CTOOLS_API_VERSION')) {
31 include_once
drupal_get_path('module', 'ctools') .
'/ctools.module';
33 if (!module_invoke('ctools', 'api_version', PANELS_REQUIRED_CTOOLS_API
)) {
34 $requirements['panels_ctools'] = array(
35 'title' => $t('CTools API Version'),
36 'value' => CTOOLS_API_VERSION
,
37 'severity' => REQUIREMENT_ERROR
,
38 'description' => t('The CTools API version is too old for Panels. Panels needs at least %version.', array('%version' => PANELS_REQUIRED_CTOOLS_API
))
46 * Check runtime requirements (status report).
48 function panels_requirements_runtime() {
49 $requirements = array();
50 $legacy = panels_get_legacy_state();
52 $state = $legacy->getStatus();
54 $requirements['panels_legacy'] = array(
55 'title' => $t('Panels operating normally'),
57 'severity' => REQUIREMENT_OK
,
58 'description' => $t('Panels is operating normally - no out-of-date plugins or modules are forcing it into legacy mode'),
62 $description = $t("Panels is operating in Legacy mode due to the following issues:\n");
64 // Add the reasons why Panels is acting in legacy mode.
66 foreach ($state as
$values) {
68 foreach ($values['modules'] as
$module => $type) {
69 $modules[] = array('data' => check_plain($module) .
' - ' .
$type);
72 $list[] = array('data' => $values['explanation'] .
"\n" .
theme('item_list', array('items' => $modules)));
75 $description .
= theme('item_list', array('items' => $list));
77 $requirements['panels_legacy'] = array(
78 'title' => $t('Panels operating in Legacy mode'),
80 'severity' => REQUIREMENT_WARNING
,
81 'description' => $description,
88 * Implementation of hook_schema().
90 function panels_schema() {
91 // This should always point to our 'current' schema. This makes it relatively easy
92 // to keep a record of schema as we make changes to it.
93 return panels_schema_3();
97 * Schema that adds the panels_layout table.
99 function panels_schema_3() {
100 // Schema 3 is now locked. If you need to make changes, please create
101 // schema 4 and add them.
102 $schema = panels_schema_2();
104 $schema['panels_renderer_pipeline'] = array(
105 'description' => 'Contains renderer pipelines for Panels. Each pipeline contains one or more renderers and access rules to select which renderer gets used.',
107 'identifier' => 'pipeline',
108 'bulk export' => TRUE
,
109 'primary key' => 'rpid',
112 'api' => 'pipelines',
113 'minimum_version' => 1,
114 'current_version' => 1,
120 'description' => 'A database primary key to ensure uniqueness.',
127 'description' => 'Unique ID for this content. Used to identify it programmatically.',
129 'admin_title' => array(
132 'description' => 'Administrative title for this pipeline.',
134 'admin_description' => array(
137 'description' => 'Administrative description for this pipeline.',
138 'object default' => '',
148 'description' => 'Serialized settings for the actual pipeline. The contents of this field are up to the plugin that uses it.',
150 'object default' => array(),
153 'primary key' => array('rpid'),
156 $schema['panels_layout'] = array(
157 'description' => 'Contains exportable customized layouts for this site.',
159 'identifier' => 'layout',
160 'bulk export' => TRUE
,
161 'primary key' => 'lid',
165 'minimum_version' => 1,
166 'current_version' => 1,
172 'description' => 'A database primary key to ensure uniqueness.',
179 'description' => 'Unique ID for this content. Used to identify it programmatically.',
181 'admin_title' => array(
184 'description' => 'Administrative title for this layout.',
186 'admin_description' => array(
189 'description' => 'Administrative description for this layout.',
190 'object default' => '',
195 'description' => 'Administrative category for this layout.',
200 'description' => 'The layout plugin that owns this layout.',
205 'description' => 'Serialized settings for the actual layout. The contents of this field are up to the plugin that uses it.',
207 'object default' => array(),
210 'primary key' => array('lid'),
217 * Schema that adds the title_pane field.
219 function panels_schema_2() {
220 $schema = panels_schema_1();
222 $schema['panels_display']['fields']['title_pane'] = array(
232 * Schema version 1 for Panels in D6.
234 * Schema v1 is now LOCKED; any changes should be done via panels_schema_2.
236 function panels_schema_1() {
239 $schema['panels_display'] = array(
241 'object' => 'panels_display',
242 'bulk export' => FALSE
,
243 'export callback' => 'panels_export_display',
244 'can disable' => FALSE
,
245 'identifier' => 'display',
258 'layout_settings' => array(
262 'object default' => array(),
263 'initial ' => array(),
265 'panel_settings' => array(
269 'object default' => array(),
270 'initial ' => array(),
275 'object default' => array(),
276 'initial ' => array(),
283 'hide_title' => array(
290 'primary key' => array('did'),
293 $schema['panels_pane'] = array(
295 'can disable' => FALSE
,
296 'identifier' => 'pane',
297 'bulk export' => FALSE
,
334 'object default' => array(),
335 'initial ' => array(),
337 'configuration' => array(
341 'object default' => array(),
342 'initial ' => array(),
348 'object default' => array(),
349 'initial ' => array(),
355 'object default' => array(),
356 'initial ' => array(),
362 'object default' => array(),
363 'initial ' => array(),
369 'object default' => array(),
370 'initial ' => array(),
378 'primary key' => array('pid'),
380 'did_idx' => array('did')
387 function panels_update_1000() {
388 // Panels D6 2 had *no* update functions in it, so the schema version is
389 // completely wrong. If we run this update with no schema version, we
390 // were actually that version and we must therefore skip to the proper
392 if (db_table_exists('panels_pane')) {
393 $GLOBALS['SKIP_PANELS_UPDATES'] = TRUE
;
398 $ret[] = update_sql("ALTER TABLE {panels_info} RENAME {panels_page}");
399 $ret[] = update_sql("ALTER TABLE {panels_page} CHANGE COLUMN did pid int(10) NOT NULL DEFAULT 0;");
400 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN did int(10) NOT NULL DEFAULT 0 AFTER pid");
401 $ret[] = update_sql("UPDATE {panels_page} SET did = pid");
403 $max_pid = db_result(db_query("SELECT MAX(pid) FROM {panels_page}"));
405 $ret[] = update_sql("INSERT INTO {sequences} (name, id) VALUES ('{panels_page}_pid', $max_pid)");
408 $ret[] = update_sql("ALTER TABLE {panels_area} RENAME {panels_pane}");
409 $ret[] = update_sql("ALTER TABLE {panels_pane} ADD COLUMN pid int(10) NOT NULL DEFAULT 0 FIRST");
410 $ret[] = update_sql("ALTER TABLE {panels_pane} CHANGE area panel varchar(32)");
411 $result = db_query("SELECT * FROM {panels_pane}");
412 while ($pane = db_fetch_object($result)) {
414 $ret[] = update_sql("UPDATE {panels_pane} SET pid = $count WHERE did = $pane->did AND panel = '$pane->panel' AND position = $pane->position");
417 $ret[] = update_sql("INSERT INTO {sequences} (name, id) VALUES ('{panels_pane}_pid', $count)");
420 $ret[] = update_sql(<<<EOT
421 CREATE TABLE
{panels_display
} (
422 did
INT(10) NOT NULL DEFAULT
0 PRIMARY
KEY,
424 ) /*!40100 DEFAULT CHARACTER SET utf8 */
427 $result = db_query("SELECT did, layout FROM {panels_page}");
429 while ($display = db_fetch_object($result)) {
430 $ret[] = update_sql("INSERT INTO {panels_display} VALUES ($display->did, '$display->layout')");
431 if ($display->did
> $max_did) {
432 $max_did = $display->did
;
435 $ret[] = update_sql("ALTER TABLE {panels_page} DROP COLUMN layout");
437 $ret[] = update_sql("INSERT INTO {sequences} (name, id) VALUES ('{panels_display}_did', $max_did)");
442 function panels_update_1001() {
443 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
447 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN no_blocks int(1)");
448 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu int(1) DEFAULT 0");
449 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu_tab int(1)");
450 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu_tab_weight int(4)");
451 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu_title varchar(255)");
452 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu_tab_default int(1)");
453 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu_tab_default_parent_type varchar(10)");
454 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu_parent_title varchar(255)");
455 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu_parent_tab_weight int(4)");
459 // Create a field for the layout settings
460 function panels_update_1002() {
461 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
465 $ret[] = update_sql("ALTER TABLE {panels_display} ADD COLUMN layout_settings longtext");
466 $ret[] = update_sql("ALTER TABLE {panels_pane} ADD COLUMN access varchar(128) AFTER type");
467 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN css longtext AFTER css_id");
471 // Create a field for the panel settings.
472 function panels_update_1003() {
473 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
477 $ret[] = update_sql("ALTER TABLE {panels_display} ADD COLUMN panel_settings longtext");
481 // Kept up updates from older versions of Panels 2 for D5 to smooth updates.
482 // Create a field for the panel settings.
483 // Renumbering to proper numbering scheme.
484 function panels_update_5204() {
485 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
489 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN name varchar(255) UNIQUE");
490 $ret[] = update_sql("ALTER TABLE {panels_display} ADD COLUMN name varchar(255) UNIQUE");
491 // Give all our panels a name.
492 $ret[] = update_sql("UPDATE {panels_page} SET name = CONCAT('panel_page_', pid)");
493 $ret[] = update_sql("UPDATE {panels_display} SET name = CONCAT('display_', did)");
497 // Add the arguments field
498 function panels_update_5205() {
499 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
503 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN arguments longtext");
507 // Add a field so that panes can remember their subtype so we can retrieve
508 // context information about it.
509 function panels_update_5206() {
510 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
514 $ret[] = update_sql("ALTER TABLE {panels_pane} ADD COLUMN subtype varchar(64)");
518 // Add fields for displays and extra contexts
519 function panels_update_5207() {
520 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
524 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN displays longtext");
525 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN contexts longtext");
529 // Correct the mistaken {panels_display}_id when it should be {panels_display}_did
530 function panels_update_5208() {
531 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
535 $count = db_result(db_query("SELECT MAX(did) FROM {panels_display}"));
536 $ret[] = update_sql("DELETE FROM {sequences} WHERE name = '{panels_display}_did'");
537 $ret[] = update_sql("DELETE FROM {sequences} WHERE name = '{panels_display}_id'");
539 $ret[] = update_sql("INSERT INTO {sequences} (name, id) VALUES ('{panels_display}_did',
546 // Update argument, relationship and context code to be more correct.
547 function panels_update_5209() {
548 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
552 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN relationships longtext");
553 $result = db_query("SELECT * FROM {panels_page}");
555 // This code removed due to call to panels_get_argument(). People with
556 // older versions will just have to suffer.
558 ctools_include('plugins', 'panels');
560 while ($page = db_fetch_object($result)) {
561 $args = unserialize($page->arguments
);
562 $arguments = $ids = $keywords = array();
564 // Update each argument
565 foreach ($args as
$id => $argument) {
566 $name = $argument['name'];
567 $info = panels_get_argument($name);
571 // Make sure the id is valid
572 if (empty($argument['id'])) {
573 if (empty($ids[$name])) {
580 $argument['id'] = $ids[$name];
583 // Give it an identifier if it doesn't already have one
584 if (empty($argument['identifier'])) {
585 $argument['identifier'] = $info['title'] .
($id > 1 ?
' ' .
$id : '');
588 // Give it a unique keyword if it doesn't already have one
589 if (empty($argument['keyword'])) {
590 $keyword = $base = $info['keyword'];
592 while (!empty($keywords[$keyword])) {
593 $keyword = $base .
'_' .
++$count;
595 $keywords[$keyword] = TRUE
;
596 $argument['keyword'] = $keyword;
598 $arguments[$id] = $argument;
601 // Move old relationships (stored as contexts) to relationships, where
603 $rels = unserialize($page->contexts
);
604 // Not resetting $keywords!
605 $relationships = $ids = array();
607 foreach ($rels as
$id => $relationship) {
608 $name = $relationship['name'];
609 $info = panels_get_relationship($name);
613 // Make sure the id is valid
614 if (empty($relationship['id'])) {
615 if (empty($ids[$name])) {
622 $relationship['id'] = $ids[$name];
625 // Give it an identifier if it doesn't already have one
626 if (empty($relationship['identifier'])) {
627 $relationship['identifier'] = $info['title'] .
($id > 1 ?
' ' .
$id : '');
630 // Give it a unique keyword if it doesn't already have one
631 if (empty($relationship['keyword'])) {
632 $keyword = $base = $info['keyword'];
634 while (!empty($keywords[$keyword])) {
635 $keyword = $base .
'_' .
++$count;
637 $keywords[$keyword] = TRUE
;
638 $relationship['keyword'] = $keyword;
640 $relationships[$id] = $relationship;
643 db_query("UPDATE {panels_page} " .
644 "SET arguments = '%s', " .
645 "relationships = '%s', " .
647 "WHERE pid = $page->pid", serialize($arguments), serialize($relationships), serialize(array()), $page->pid
653 function panels_update_5210() {
654 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
658 $ret[] = update_sql("UPDATE {system} SET weight = 10 WHERE name = 'panels'");
663 * Force a menu update
665 function panels_update_5211() {
671 * Add a field to store pane caching information.
673 function panels_update_5213() {
674 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
678 switch ($GLOBALS['db_type']) {
681 $ret[] = update_sql("ALTER TABLE {panels_pane} ADD COLUMN cache longtext AFTER configuration");
682 $ret[] = update_sql("ALTER TABLE {panels_display} ADD COLUMN cache longtext AFTER panel_settings");
686 db_add_column($ret, 'panels_pane', 'cache', 'text');
687 db_add_column($ret, 'panels_display', 'cache', 'text');
693 * Create a new table for object caching. This isn't part of the cache
696 function panels_update_5214() {
697 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
702 switch ($GLOBALS['db_type']) {
705 $ret[] = update_sql(<<<EOT
706 CREATE TABLE
{panels_object_cache
} (
714 ) /*!40100 DEFAULT CHARACTER SET utf8 */
719 return !empty($ret) ?
$ret : $ret;
723 * Increase the size of the data column in the {panels_object_cache} table
726 * Also gets rid of some duplicate indexes resulting the CREATE TABLE queries
727 * in the install() of schema 5214
729 function panels_update_5215() {
730 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
734 switch ($GLOBALS['db_type']) {
737 $ret[] = update_sql("ALTER TABLE {panels_pane} ADD PRIMARY KEY (pid)");
741 $ret[] = update_sql("ALTER TABLE {panels_pane} ADD PRIMARY KEY (pid)");
747 * Adds the 'shown' field to the panels_pane table in order to accomodate
748 * the new show/hide panes feature.
750 function panels_update_5216() {
751 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
755 switch ($GLOBALS['db_type']) {
758 $ret[] = update_sql("ALTER TABLE {panels_pane} ADD COLUMN shown int(1) DEFAULT 1 AFTER subtype");
759 $ret[] = update_sql("ALTER TABLE {panels_display} ADD COLUMN title varchar(128) AFTER cache");
760 $ret[] = update_sql("ALTER TABLE {panels_display} ADD COLUMN hide_title int(1) AFTER title");
761 $ret[] = update_sql("ALTER TABLE {panels_display} DROP COLUMN name");
762 $ret[] = update_sql("ALTER TABLE {panels_pane} ADD COLUMN visibility text AFTER access");
766 db_add_column($ret, 'panels_pane', 'shown', 'tinyint', array('default' => 1));
767 db_add_column($ret, 'panels_display', 'title', 'varchar(128)');
768 db_add_column($ret, 'panels_display', 'hide_title', 'tinyint', array('default' => 0));
769 $ret = update_sql("ALTER TABLE {panels_display} DROP name");
770 db_add_column($ret, 'panels_pane', 'visibility', 'text');
776 * Add the switcher fields to the database
778 function panels_update_5217() {
779 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
783 switch ($GLOBALS['db_type']) {
786 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN switcher_type varchar(128) AFTER no_blocks");
787 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN switcher_name varchar(128) AFTER no_blocks");
788 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN switcher_options longtext AFTER switcher_type");
792 db_add_column($ret, 'panels_page', 'switcher_type', 'varchar(128)');
793 db_add_column($ret, 'panels_page', 'switcher_name', 'varchar(128)');
794 db_add_column($ret, 'panels_page', 'switcher_options', 'text');
801 * Oversight in 5216: 'tinyint' is not a field type in pgsql; the type we wanted
804 function panels_update_5218() {
805 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
809 switch ($GLOBALS['db_type']) {
812 $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.'));
816 db_add_column($ret, 'panels_pane', 'shown', 'smallint', array('default' => 1));
817 db_add_column($ret, 'panels_display', 'hide_title', 'smallint', array('default' => 0));
818 $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.'));
826 function panels_update_5299() {
827 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
831 // Fetch schema version 1.
832 $schema = panels_schema_1();
834 // Certain really old versions of Panels had errors that would cause invalid
835 // panes to be written. This wipes them so that the conversion won't fail:
836 $ret[] = update_sql("DELETE FROM {panels_pane} WHERE pid = 0");
838 // update pid and did to be serial
839 db_drop_primary_key($ret, 'panels_pane');
840 db_change_field($ret, 'panels_pane', 'pid', 'pid', $schema['panels_pane']['fields']['pid'], array('primary key' => array('pid')));
841 db_drop_primary_key($ret, 'panels_display');
842 db_change_field($ret, 'panels_display', 'did', 'did', $schema['panels_display']['fields']['did'], array('primary key' => array('did')));
844 drupal_set_message(t('Please note that the Panels upgrade from Drupal 5 to Drupal 6 is far from perfect, especially where Views and CCK are involved. Please check all your panels carefully and compare them against the originals. You may need to do some rework to regain your original functionality.'));
850 * Update from 6.x v2.
852 function panels_update_6290() {
854 if (!module_exists('panels')) {
855 $ret['#abort'] = array('success' => FALSE
, 'query' => t('The Panels module cannot be updated while disabled. If you wish to update Panels, please enable it. If you do not wish to update Panels, please uninstall it.'));
859 // Fetch schema version 1.
860 $schema = panels_schema_1();
862 // Update size of pane 'access' field.
863 db_change_field($ret, 'panels_pane', 'access', 'access', $schema['panels_pane']['fields']['access']);
865 // Remove the no longer used visibility field
866 if (db_column_exists('panels_pane', 'visibility')) {
867 db_drop_field($ret, 'panels_pane', 'visibility');
870 // Remove panels_object_cache table
871 if (db_table_exists('panels_object_cache')) {
872 db_drop_table($ret, 'panels_object_cache');
875 // Doublecheck that ctools is enabled. If not, automatically disable the module.
876 if (!module_exists('ctools')) {
878 drupal_install_modules(array('ctools'));
880 // If that fails, shut off all Panels.
881 if (!module_exists('ctools')) {
882 drupal_set_message(t('Panels now requires the Chaos Tool Suite (ctools) module to function. Panels has been disabled until you can add this module.'));
883 module_disable(array('panels', 'panels_mini', 'panels_export', 'panels_node', 'panels_simple_cache'));
887 if (!module_exists('page_manager') && db_table_exists('panels_page')) {
888 drupal_set_message('Page manager module has been automatically enabled to replace the Panels pages module.');
889 drupal_install_modules(array('page_manager'));
892 $ret[] = update_sql("DELETE FROM {system} WHERE name IN ('panels_page', 'panels_views')");
898 * Special update function for the alpha2 to alpha3 transition after
901 function panels_update_6291() {
903 if (!module_exists('panels')) {
904 $ret['#abort'] = array('success' => FALSE
, 'query' => t('The Panels module cannot be updated while disabled. If you wish to update Panels, please enable it. If you do not wish to update Panels, please uninstall it.'));
908 // Fetch schema version 1.
909 $schema = panels_schema_1();
912 // Add some new fields
913 db_add_field($ret, 'panels_pane', 'style', $schema['panels_pane']['fields']['style']);
914 db_add_field($ret, 'panels_pane', 'css', $schema['panels_pane']['fields']['css']);
915 db_add_field($ret, 'panels_pane', 'extras', $schema['panels_pane']['fields']['extras']);
921 * Update panels pane fields using batch API.
923 function panels_update_6292(&$sandbox) {
925 if (!module_exists('panels')) {
926 $ret['#abort'] = array('success' => FALSE
, 'query' => t('The Panels module cannot be updated while disabled. If you wish to update Panels, please enable it. If you do not wish to update Panels, please uninstall it.'));
930 if (!isset($sandbox['progress'])) {
931 $sandbox['progress'] = 0;
932 // We'll -1 to disregard the uid 0...
933 $sandbox['max'] = db_result(db_query('SELECT COUNT(*) FROM {panels_pane}'));
937 $result = db_query_range("SELECT pid, access, configuration FROM {panels_pane} ORDER BY pid ASC", $sandbox['progress'], 20);
938 while ($pane = db_fetch_object($result)) {
940 if (!empty($pane->access
)) {
941 $rids = explode(', ', $pane->access
);
942 // For safety, eliminate any non-numeric rids, as we occasionally had
943 // problems with nulls and such getting in here:
944 foreach ($rids as
$id => $rid) {
945 if (!is_numeric($rid)) {
951 $pane->access
= array();
954 // The old access style was just a role based system, so let's convert
956 $pane->access
= array(
960 'context' => 'logged-in-user',
962 'rids' => array_values($rids),
970 $pane->access
= array();
973 // Move style from configuration.
974 $pane->configuration
= unserialize($pane->configuration
);
975 $pane->style
= array();
976 if (!empty($pane->configuration
['style'])) {
977 $pane->style
['style'] = $pane->configuration
['style'];
978 unset($pane->configuration
['style']);
981 $pane->css
= array();
982 // Move css configuration from configuration
983 if (isset($pane->configuration
['css_id'])) {
984 $pane->css
['css_id'] = $pane->configuration
['css_id'];
985 unset($pane->configuration
['css_id']);
988 if (isset($pane->configuration
['css_class'])) {
989 $pane->css
['css_class'] = $pane->configuration
['css_class'];
990 unset($pane->configuration
['css_class']);
993 // Make sure extras is an array. This isn't used by anything in Panels
994 // yet, so an empty array is just fine.
995 $pane->extras
= array();
996 db_query("UPDATE {panels_pane} SET " .
997 "access = '%s', css = '%s', style = '%s', configuration = '%s', extras = '%s'" .
999 serialize($pane->access
),
1000 serialize($pane->css
),
1001 serialize($pane->style
),
1002 serialize($pane->configuration
),
1003 serialize($pane->extras
),
1006 $sandbox['progress']++;
1009 $ret['#finished'] = empty($sandbox['max']) ?
1 : ($sandbox['progress'] / $sandbox['max']);
1010 if ($ret['#finished'] === 1) {
1011 $ret[] = array('success' => TRUE
, 'query' => t('Panel panes were updated'));
1017 * Update panels display fields using batch API.
1019 function panels_update_6293(&$sandbox) {
1021 if (!module_exists('panels')) {
1022 $ret['#abort'] = array('success' => FALSE
, 'query' => t('The Panels module cannot be updated while disabled. If you wish to update Panels, please enable it. If you do not wish to update Panels, please uninstall it.'));
1026 if (!isset($sandbox['progress'])) {
1027 $sandbox['progress'] = 0;
1028 // We'll -1 to disregard the uid 0...
1029 $sandbox['max'] = db_result(db_query('SELECT COUNT(*) FROM {panels_display}'));
1033 $result = db_query_range("SELECT did, panel_settings FROM {panels_display} ORDER BY did ASC", $sandbox['progress'], 20);
1034 while ($display = db_fetch_object($result)) {
1035 if (empty($display->panel_settings
)) {
1036 $display->panel_settings
= array();
1039 $display->panel_settings
= unserialize($display->panel_settings
);
1040 if (!is_array($display->panel_settings
)) {
1041 $display->panel_settings
= array();
1045 if (isset($display->panel_settings
['panel'])) {
1046 foreach ($display->panel_settings
['panel'] as
$key => $settings) {
1047 $display->panel_settings
[$key] = $settings;
1049 unset($display->panel_settings
['panel']);
1052 if (isset($display->panel_settings
['individual'])) {
1053 unset($display->panel_settings
['individual']);
1056 db_query("UPDATE {panels_display} SET " .
1057 "panel_settings = '%s'" .
1059 serialize($display->panel_settings
),
1062 $sandbox['progress']++;
1065 $ret['#finished'] = empty($sandbox['max']) ?
1 : ($sandbox['progress'] / $sandbox['max']);
1066 if ($ret['#finished'] === 1) {
1067 $ret[] = array('success' => TRUE
, 'query' => t('Panel displays were updated'));
1073 * Establish a baseline schema version for 6.x-3.x
1075 function panels_update_6300() {
1079 function panels_update_6302() {
1081 if (!module_exists('panels')) {
1082 $ret['#abort'] = array('success' => FALSE
, 'query' => t('The Panels module cannot be updated while disabled. If you wish to update Panels, please enable it. If you do not wish to update Panels, please uninstall it.'));
1086 if (!module_exists('page_manager') && db_table_exists('panels_page')) {
1087 $ret['#abort'] = array('success' => FALSE
, 'query' => t('Conversion of panels pages cannot be completed without page manager module from CTools installed. Please install CTools, activate page manager, and attempt the update again.'));
1091 if (!db_table_exists('panels_page')) {
1095 // Store the node edit handlers because we merged the edit/add path and we
1096 // need to be able to keep these together to make sure the names work ok.
1097 $node_edit_handlers = array();
1098 page_manager_get_task('page');
1099 $result = db_query("SELECT * FROM {panels_page}");
1100 while ($p = db_fetch_object($result)) {
1101 $page = page_manager_page_new();
1102 $page->default_handlers
= array();
1103 // Should we check for uniqueness here? It doesn't seem really
1104 // plausible that there could be page manager pages already.
1105 $page->name
= $p->name
;
1106 $page->task
= 'page'; // could become custom later.
1107 $page->subtask
= $p->name
;
1108 $page->admin_title
= $p->name
;
1109 $page->path
= $p->path
;
1111 if (!empty($p->access
)) {
1112 $rids = explode(', ', $p->access
);
1113 // For safety, eliminate any non-numeric rids, as we occasionally had
1114 // problems with nulls and such getting in here:
1115 foreach ($rids as
$id => $rid) {
1116 if (!is_numeric($rid)) {
1122 $page->access
= array();
1125 // The old access style was just a role based system, so let's convert
1127 $page->access
= array(
1131 'context' => 'logged-in-user',
1132 'settings' => array(
1133 'rids' => array_values($rids),
1141 // Convert menu stuff.
1142 $page->menu
= array(
1146 'name' => 'navigation',
1151 'name' => 'navigation',
1157 if ($p->menu_tab_default
) {
1158 $page->menu
['type'] = 'default tab';
1159 $page->menu
['parent']['type'] = $p->menu_tab_default_parent_type
;
1160 $page->menu
['parent']['title'] = $p->menu_parent_title
;
1161 $page->menu
['parent']['weight'] = $p->menu_parent_tab_weight
;
1164 $page->menu
['type'] = 'tab';
1168 $page->menu
['type'] = 'normal';
1171 $page->menu
['title'] = $p->menu_title
;
1172 $page->menu
['weight'] = $p->menu_tab_weight
;
1175 $page->conf
= array();
1176 $displays = unserialize($p->displays
);
1177 $arguments = unserialize($p->arguments
);
1179 foreach ($arguments as
$id => $argument) {
1180 $page->arguments
[$argument['keyword']] = array(
1181 'name' => $argument['name'],
1182 'identifier' => $argument['identifier'],
1183 'title' => $argument['title'],
1184 'id' => $argument['id'],
1185 'settings' => isset($argument['argument_settings']) ?
$argument['argument_settings'] : array(),
1189 $bits = explode('/', $page->path
);
1190 foreach ($bits as
$pos => $bit) {
1192 $bits[$pos] = '%' .
$argument['keyword'];
1194 $page->path
= implode('/', $bits);
1200 if ($argument['default'] == '404') {
1201 $page->path .
= '/%' .
$argument['keyword'];
1204 $page->path .
= '/!' .
$argument['keyword'];
1208 // save this for later use.
1209 $arguments[$id]['context'] = 'argument_' .
$argument['name'] .
'_' .
$argument['id'];
1212 // Reset the task type here if it's one of our overrides. This ensures
1213 // that we get the right names.
1216 $page->task
= 'node_view';
1217 $page->subtask
= '';
1218 variable_set('page_manager_node_view_disabled', FALSE
);
1221 // It seems nearly impossible to actually upgrade this properly.
1224 // Could we get conflicts here if they had both?
1225 $page->task
= 'node_edit';
1226 $page->subtask
= '';
1227 variable_set('page_manager_node_edit_disabled', FALSE
);
1229 case
'taxonomy/term':
1230 case
'taxonomy/term/%':
1231 $page->task
= 'term_view';
1232 $page->subtask
= '';
1233 if ($arguments[0]['name'] == 'term') {
1234 variable_set('page_manager_term_view_type', 'single');
1236 variable_set('page_manager_term_view_disabled', FALSE
);
1239 $page->task
= 'user_view';
1240 $page->subtask
= '';
1241 variable_set('page_manager_user_view_disabled', FALSE
);
1243 // There is no default here.
1246 if (empty($displays)) {
1247 // only one display on this panel, mak
1248 $cache = new
stdClass();
1249 if ($page->task
!= 'node_edit') {
1250 $cache->handlers
= array();
1253 $cache->handlers
= $node_edit_handlers;
1255 _panels_update_create_handler($page, $p, NULL
, array('did' => $p->did
, 'title' => t('Panel')), $arguments, 0, $cache);
1256 $page->default_handlers
= $cache->handlers
;
1259 // for each display we need to create a new handler.
1261 $cache = new
stdClass();
1262 if ($page->task
!= 'node_edit') {
1263 $cache->handlers
= array();
1266 $cache->handlers
= $node_edit_handlers;
1267 $weight = count($cache->handlers
) + 1;
1269 foreach ($displays as
$origin => $info) {
1270 if (!isset($info['argument_id'])) {
1271 $info['argument_id'] = 0;
1274 _panels_update_create_handler($page, $p, $origin, $info, $arguments, $weight++, $cache);
1277 // Also add the primary display as a default with no selector.
1278 // _panels_update_create_handler($page, $p, NULL, array('did' => $p->did, 'title' => t('Default')), $arguments, $weight++, $cache);
1279 $page->default_handlers
= $cache->handlers
;
1282 if ($page->task
!= 'page') {
1283 // just save the handlers.
1284 foreach ($cache->handlers as
$name => $handler) {
1285 page_manager_save_task_handler($handler);
1287 // Keep all node edit handlers for later use.
1288 if ($page->task
== 'node_edit') {
1289 $node_edit_handlers[$name] = $handler;
1294 page_manager_page_save($page);
1298 $ret[] = update_sql("DROP TABLE {panels_page}");
1300 // Update a couple of pane types that changed and are easily moved:
1301 switch ($GLOBALS['db_type']) {
1304 $ret[] = update_sql("UPDATE {panels_pane} SET type = CONCAT(type, '_', subtype) WHERE type = 'node_form'");
1308 $ret[] = update_sql("UPDATE {panels_pane} SET type = type || '_' || subtype WHERE type = 'node_form'");
1310 $ret[] = update_sql("UPDATE {panels_pane} SET type = 'node_form_path' WHERE type = 'node_form_url_path'");
1312 if (module_exists('ctools') && !module_exists('views_content') && db_result(db_query("SELECT pid FROM {panels_pane} WHERE type = 'views'"))) {
1313 drupal_install_modules(array('views_content'));
1319 function _panels_update_create_handler($page, $p, $origin, $info, $arguments, $weight, &$cache) {
1320 $task = page_manager_get_task($page->task
);
1321 $task_name = 'page-' .
$page->name
;
1322 $plugin = page_manager_get_task_handler('panel_context');
1323 $handler = page_manager_new_task_handler($plugin);
1325 $handler->weight
= $weight;
1326 $handler->task
= $page->task
;
1327 if ($page->task
== 'page') {
1328 $handler->subtask
= $page->name
;
1330 $handler->export_type
= EXPORT_IN_DATABASE
;
1331 $handler->type
= t('Normal');
1333 $handler->name
= page_manager_handler_get_name($task_name, $cache->handlers
, $handler);
1335 $handler->conf
['css'] = $p->css
;
1336 $handler->conf
['css_id'] = $p->css_id
;
1337 $handler->conf
['no_blocks'] = $p->no_blocks
;
1338 if (!empty($info['did']) && is_numeric($info['did'])) {
1339 $handler->conf
['did'] = $info['did'];
1342 $d = panels_load_display($p->did
);
1344 $display_code = panels_export_display($d);
1345 eval($display_code);
1347 $handler->conf
['did'] = 'new';
1348 $handler->conf
['display'] = $display;
1351 $handler->conf
['title'] = !empty($info['title']) ?
$info['title'] : '';
1352 $handler->conf
['contexts'] = unserialize($p->contexts
);
1353 $handler->conf
['relationships'] = unserialize($p->relationships
);
1355 if ($origin && strpos($origin, '-')) {
1356 $handler->conf
['access'] = array(
1358 'plugins' => array(),
1361 // Only 4 types of arguments supported having their own displays:
1362 // nid, node_add_form, node_edit_form and term. 3 of those simply used
1363 // node type and the last simply used vocabulary.
1364 list($junk, $key) = explode('-', $origin);
1365 if ($key && $key != 'default') {
1366 if ($arguments[$info['argument_id']]['name'] == 'term') {
1367 $handler->conf
['access']['plugins'][] = array(
1368 'name' => 'term_vocabulary',
1369 'context' => $arguments[$info['argument_id']]['context'],
1370 'settings' => array(
1371 'vids' => array($key),
1376 $handler->conf
['access']['plugins'][] = array(
1377 'name' => 'node_type',
1378 'context' => $arguments[$info['argument_id']]['context'],
1379 'settings' => array(
1380 'type' => array($key),
1386 // make sure defaults float to the bottom:
1387 $handler->weight
+= 100;
1390 $cache->handlers
[$handler->name
] = $handler;
1396 * Ensure the panels_simple_cache module does not exist.
1398 function panels_update_6303() {
1400 if (module_exists('panels_simple_cache')) {
1401 drupal_set_message(t('Your installation contains a module that no longer exists. When updating modules, you should always remove the module directory first, then replace it with the new code. The "Panels Simple Cache" module is being automatically disabled for you. Please do not re-enable it as it will cause your system to crash.'));
1402 $ret[] = update_sql("DELETE FROM {system} WHERE name = 'panels_simple_cache'");
1409 * Ensure that users are informed about the page manager module.
1411 function panels_update_6304() {
1412 if (!module_exists('page_manager')) {
1413 drupal_set_message(t('The delegator module has been replaced by the Page Manager module. You should enable the page manager module to ensure that any panel pages you have will not be lost.'));
1420 * Add the title_pane field.
1422 function panels_update_6305() {
1425 // Fetch schema version 2.
1426 $schema = panels_schema_2();
1429 db_add_field($ret, 'panels_display', 'title_pane', $schema['panels_display']['fields']['title_pane']);
1435 * Drop a table that should have been gone long ago.
1437 function panels_update_6306() {
1440 if (db_table_exists('panels_page_router_store')) {
1441 db_drop_table($ret, 'panels_page_router_store');
1448 * This update function does nothing, it was committed in error and is
1449 * left in to prevent update problems.
1451 function panels_update_6307() {
1456 * Add the panels_layout table
1458 function panels_update_6308() {
1461 // Schema 3 is locked and should not be changed.
1462 $schema = panels_schema_3();
1464 db_create_table($ret, 'panels_layout', $schema['panels_layout']);
1469 * Add the panels_renderer_pipeline table
1471 function panels_update_6309() {
1474 // Schema 3 is locked and should not be changed.
1475 $schema = panels_schema_3();
1477 db_create_table($ret, 'panels_renderer_pipeline', $schema['panels_renderer_pipeline']);
1482 * Move stylizer data from Panels to CTools.
1484 function panels_update_6310() {
1486 // load the module files, if possible
1487 if (!defined('PANELS_REQUIRED_CTOOLS_API')) {
1488 include_once
drupal_get_path('module', 'panels') .
'/panels.module';
1490 if (!defined('CTOOLS_API_VERSION')) {
1491 include_once
drupal_get_path('module', 'ctools') .
'/ctools.module';
1493 // Safety: go away if CTools is not at an appropriate version.
1494 if (!module_invoke('ctools', 'api_version', PANELS_REQUIRED_CTOOLS_API
)) {
1495 $ret['#abort'] = array('success' => FALSE
, 'query' => t('Panels cannot be updated because CTools 1.7 (API v1.7.2) is required. Please update CTools and then try update.php again.'));
1499 // Enable the stylizer module to make everything as seamless as possible.
1500 drupal_install_modules(array('stylizer'));