5441e1a25f3bf52a2264642690e102d84cfaccc3
[project/panels.git] / panels.install
1 <?php
2 // $Id$
3
4 /**
5 * Test requirements for installation and running.
6 */
7 function panels_requirements($phase) {
8 $function = "panels_requirements_$phase";
9 return function_exists($function) ? $function() : array();
10 }
11
12 /**
13 * Check install-time requirements.
14 */
15 function panels_requirements_install() {
16 $requirements = array();
17 $t = get_t();
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
23 // check to work.
24 if (!defined('PANELS_REQUIRED_CTOOLS_API')) {
25 include_once drupal_get_path('module', 'panels') . '/panels.module';
26 }
27
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';
32 }
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))
39 );
40 }
41 }
42 return $requirements;
43 }
44
45 /**
46 * Check runtime requirements (status report).
47 */
48 function panels_requirements_runtime() {
49 $requirements = array();
50 $legacy = panels_get_legacy_state();
51 $t = get_t();
52 $state = $legacy->getStatus();
53 if (empty($state)) {
54 $requirements['panels_legacy'] = array(
55 'title' => $t('Panels operating normally'),
56 'value' => NULL,
57 'severity' => REQUIREMENT_OK,
58 'description' => $t('Panels is operating normally - no out-of-date plugins or modules are forcing it into legacy mode'),
59 );
60 }
61 else {
62 $description = $t("Panels is operating in Legacy mode due to the following issues:\n");
63
64 // Add the reasons why Panels is acting in legacy mode.
65 $list = array();
66 foreach ($state as $values) {
67 $modules = array();
68 foreach ($values['modules'] as $module => $type) {
69 $modules[] = array('data' => check_plain($module) . ' - ' . $type);
70 }
71
72 $list[] = array('data' => $values['explanation'] ."\n" . theme('item_list', array('items' => $modules)));
73 }
74
75 $description .= theme('item_list', array('items' => $list));
76
77 $requirements['panels_legacy'] = array(
78 'title' => $t('Panels operating in Legacy mode'),
79 'value' => NULL,
80 'severity' => REQUIREMENT_WARNING,
81 'description' => $description,
82 );
83 }
84 return $requirements;
85 }
86
87 /**
88 * Implementation of hook_schema().
89 */
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();
94 }
95
96 /**
97 * Schema that adds the panels_layout table.
98 */
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();
103
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.',
106 'export' => array(
107 'identifier' => 'pipeline',
108 'bulk export' => TRUE,
109 'primary key' => 'rpid',
110 'api' => array(
111 'owner' => 'panels',
112 'api' => 'pipelines',
113 'minimum_version' => 1,
114 'current_version' => 1,
115 ),
116 ),
117 'fields' => array(
118 'rpid' => array(
119 'type' => 'serial',
120 'description' => 'A database primary key to ensure uniqueness.',
121 'not null' => TRUE,
122 'no export' => TRUE,
123 ),
124 'name' => array(
125 'type' => 'varchar',
126 'length' => '255',
127 'description' => 'Unique ID for this content. Used to identify it programmatically.',
128 ),
129 'admin_title' => array(
130 'type' => 'varchar',
131 'length' => '255',
132 'description' => 'Administrative title for this pipeline.',
133 ),
134 'admin_description' => array(
135 'type' => 'text',
136 'size' => 'big',
137 'description' => 'Administrative description for this pipeline.',
138 'object default' => '',
139 ),
140 'weight' => array(
141 'type' => 'int',
142 'size' => 'small',
143 'default' => 0,
144 ),
145 'settings' => array(
146 'type' => 'text',
147 'size' => 'big',
148 'description' => 'Serialized settings for the actual pipeline. The contents of this field are up to the plugin that uses it.',
149 'serialize' => TRUE,
150 'object default' => array(),
151 ),
152 ),
153 'primary key' => array('rpid'),
154 );
155
156 $schema['panels_layout'] = array(
157 'description' => 'Contains exportable customized layouts for this site.',
158 'export' => array(
159 'identifier' => 'layout',
160 'bulk export' => TRUE,
161 'primary key' => 'lid',
162 'api' => array(
163 'owner' => 'panels',
164 'api' => 'layouts',
165 'minimum_version' => 1,
166 'current_version' => 1,
167 ),
168 ),
169 'fields' => array(
170 'lid' => array(
171 'type' => 'serial',
172 'description' => 'A database primary key to ensure uniqueness.',
173 'not null' => TRUE,
174 'no export' => TRUE,
175 ),
176 'name' => array(
177 'type' => 'varchar',
178 'length' => '255',
179 'description' => 'Unique ID for this content. Used to identify it programmatically.',
180 ),
181 'admin_title' => array(
182 'type' => 'varchar',
183 'length' => '255',
184 'description' => 'Administrative title for this layout.',
185 ),
186 'admin_description' => array(
187 'type' => 'text',
188 'size' => 'big',
189 'description' => 'Administrative description for this layout.',
190 'object default' => '',
191 ),
192 'category' => array(
193 'type' => 'varchar',
194 'length' => '255',
195 'description' => 'Administrative category for this layout.',
196 ),
197 'plugin' => array(
198 'type' => 'varchar',
199 'length' => '255',
200 'description' => 'The layout plugin that owns this layout.',
201 ),
202 'settings' => array(
203 'type' => 'text',
204 'size' => 'big',
205 'description' => 'Serialized settings for the actual layout. The contents of this field are up to the plugin that uses it.',
206 'serialize' => TRUE,
207 'object default' => array(),
208 ),
209 ),
210 'primary key' => array('lid'),
211 );
212
213 return $schema;
214 }
215
216 /**
217 * Schema that adds the title_pane field.
218 */
219 function panels_schema_2() {
220 $schema = panels_schema_1();
221
222 $schema['panels_display']['fields']['title_pane'] = array(
223 'type' => 'int',
224 'default' => 0,
225 'no export' => TRUE,
226 );
227
228 return $schema;
229 }
230
231 /**
232 * Schema version 1 for Panels in D6.
233 *
234 * Schema v1 is now LOCKED; any changes should be done via panels_schema_2.
235 */
236 function panels_schema_1() {
237 $schema = array();
238
239 $schema['panels_display'] = array(
240 'export' => array(
241 'object' => 'panels_display',
242 'bulk export' => FALSE,
243 'export callback' => 'panels_export_display',
244 'can disable' => FALSE,
245 'identifier' => 'display',
246 ),
247 'fields' => array(
248 'did' => array(
249 'type' => 'serial',
250 'not null' => TRUE,
251 'no export' => TRUE,
252 ),
253 'layout' => array(
254 'type' => 'varchar',
255 'length' => '32',
256 'default' => '',
257 ),
258 'layout_settings' => array(
259 'type' => 'text',
260 'size' => 'big',
261 'serialize' => TRUE,
262 'object default' => array(),
263 'initial ' => array(),
264 ),
265 'panel_settings' => array(
266 'type' => 'text',
267 'size' => 'big',
268 'serialize' => TRUE,
269 'object default' => array(),
270 'initial ' => array(),
271 ),
272 'cache' => array(
273 'type' => 'text',
274 'serialize' => TRUE,
275 'object default' => array(),
276 'initial ' => array(),
277 ),
278 'title' => array(
279 'type' => 'varchar',
280 'length' => '255',
281 'default' => '',
282 ),
283 'hide_title' => array(
284 'type' => 'int',
285 'size' => 'tiny',
286 'default' => 0,
287 'no export' => TRUE,
288 ),
289 ),
290 'primary key' => array('did'),
291 );
292
293 $schema['panels_pane'] = array(
294 'export' => array(
295 'can disable' => FALSE,
296 'identifier' => 'pane',
297 'bulk export' => FALSE,
298 ),
299 'fields' => array(
300 'pid' => array(
301 'type' => 'serial',
302 'not null' => TRUE,
303 ),
304 'did' => array(
305 'type' => 'int',
306 'not null' => TRUE,
307 'default' => 0,
308 'no export' => TRUE,
309 ),
310 'panel' => array(
311 'type' => 'varchar',
312 'length' => '32',
313 'default' => '',
314 ),
315 'type' => array(
316 'type' => 'varchar',
317 'length' => '32',
318 'default' => '',
319 ),
320 'subtype' => array(
321 'type' => 'varchar',
322 'length' => '64',
323 'default' => '',
324 ),
325 'shown' => array(
326 'type' => 'int',
327 'size' => 'tiny',
328 'default' => 1,
329 ),
330 'access' => array(
331 'type' => 'text',
332 'size' => 'big',
333 'serialize' => TRUE,
334 'object default' => array(),
335 'initial ' => array(),
336 ),
337 'configuration' => array(
338 'type' => 'text',
339 'size' => 'big',
340 'serialize' => TRUE,
341 'object default' => array(),
342 'initial ' => array(),
343 ),
344 'cache' => array(
345 'type' => 'text',
346 'size' => 'big',
347 'serialize' => TRUE,
348 'object default' => array(),
349 'initial ' => array(),
350 ),
351 'style' => array(
352 'type' => 'text',
353 'size' => 'big',
354 'serialize' => TRUE,
355 'object default' => array(),
356 'initial ' => array(),
357 ),
358 'css' => array(
359 'type' => 'text',
360 'size' => 'big',
361 'serialize' => TRUE,
362 'object default' => array(),
363 'initial ' => array(),
364 ),
365 'extras' => array(
366 'type' => 'text',
367 'size' => 'big',
368 'serialize' => TRUE,
369 'object default' => array(),
370 'initial ' => array(),
371 ),
372 'position' => array(
373 'type' => 'int',
374 'size' => 'small',
375 'default' => 0,
376 ),
377 ),
378 'primary key' => array('pid'),
379 'indexes' => array(
380 'did_idx' => array('did')
381 ),
382 );
383
384 return $schema;
385 }
386
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
391 // update.
392 if (db_table_exists('panels_pane')) {
393 $GLOBALS['SKIP_PANELS_UPDATES'] = TRUE;
394 return array();
395 }
396 $ret = array();
397
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");
402
403 $max_pid = db_result(db_query("SELECT MAX(pid) FROM {panels_page}"));
404 if ($max_pid) {
405 $ret[] = update_sql("INSERT INTO {sequences} (name, id) VALUES ('{panels_page}_pid', $max_pid)");
406 }
407
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)) {
413 $count++;
414 $ret[] = update_sql("UPDATE {panels_pane} SET pid = $count WHERE did = $pane->did AND panel = '$pane->panel' AND position = $pane->position");
415 }
416 if ($count) {
417 $ret[] = update_sql("INSERT INTO {sequences} (name, id) VALUES ('{panels_pane}_pid', $count)");
418 }
419
420 $ret[] = update_sql(<<<EOT
421 CREATE TABLE {panels_display} (
422 did INT(10) NOT NULL DEFAULT 0 PRIMARY KEY,
423 layout VARCHAR(32)
424 ) /*!40100 DEFAULT CHARACTER SET utf8 */
425 EOT
426 );
427 $result = db_query("SELECT did, layout FROM {panels_page}");
428 $max_did = 0;
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;
433 }
434 }
435 $ret[] = update_sql("ALTER TABLE {panels_page} DROP COLUMN layout");
436 if ($max_did) {
437 $ret[] = update_sql("INSERT INTO {sequences} (name, id) VALUES ('{panels_display}_did', $max_did)");
438 }
439 return $ret;
440 }
441
442 function panels_update_1001() {
443 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
444 return array();
445 }
446 $ret = array();
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)");
456 return $ret;
457 }
458
459 // Create a field for the layout settings
460 function panels_update_1002() {
461 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
462 return array();
463 }
464 $ret = array();
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");
468 return $ret;
469 }
470
471 // Create a field for the panel settings.
472 function panels_update_1003() {
473 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
474 return array();
475 }
476 $ret = array();
477 $ret[] = update_sql("ALTER TABLE {panels_display} ADD COLUMN panel_settings longtext");
478 return $ret;
479 }
480
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'])) {
486 return array();
487 }
488 $ret = array();
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)");
494 return $ret;
495 }
496
497 // Add the arguments field
498 function panels_update_5205() {
499 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
500 return array();
501 }
502 $ret = array();
503 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN arguments longtext");
504 return $ret;
505 }
506
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'])) {
511 return array();
512 }
513 $ret = array();
514 $ret[] = update_sql("ALTER TABLE {panels_pane} ADD COLUMN subtype varchar(64)");
515 return $ret;
516 }
517
518 // Add fields for displays and extra contexts
519 function panels_update_5207() {
520 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
521 return array();
522 }
523 $ret = array();
524 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN displays longtext");
525 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN contexts longtext");
526 return $ret;
527 }
528
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'])) {
532 return array();
533 }
534 $ret = array();
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'");
538 if ($count) {
539 $ret[] = update_sql("INSERT INTO {sequences} (name, id) VALUES ('{panels_display}_did',
540 $count)");
541 }
542
543 return $ret;
544 }
545
546 // Update argument, relationship and context code to be more correct.
547 function panels_update_5209() {
548 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
549 return array();
550 }
551 $ret = array();
552 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN relationships longtext");
553 $result = db_query("SELECT * FROM {panels_page}");
554
555 // This code removed due to call to panels_get_argument(). People with
556 // older versions will just have to suffer.
557 return $ret;
558 ctools_include('plugins', 'panels');
559
560 while ($page = db_fetch_object($result)) {
561 $args = unserialize($page->arguments);
562 $arguments = $ids = $keywords = array();
563 if (!empty($args)) {
564 // Update each argument
565 foreach ($args as $id => $argument) {
566 $name = $argument['name'];
567 $info = panels_get_argument($name);
568 if (!$info) {
569 continue;
570 }
571 // Make sure the id is valid
572 if (empty($argument['id'])) {
573 if (empty($ids[$name])) {
574 $ids[$name] = 1;
575 }
576 else {
577 $ids[$name]++;
578 }
579
580 $argument['id'] = $ids[$name];
581 }
582
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 : '');
586 }
587
588 // Give it a unique keyword if it doesn't already have one
589 if (empty($argument['keyword'])) {
590 $keyword = $base = $info['keyword'];
591 $count = 0;
592 while (!empty($keywords[$keyword])) {
593 $keyword = $base . '_' . ++$count;
594 }
595 $keywords[$keyword] = TRUE;
596 $argument['keyword'] = $keyword;
597 }
598 $arguments[$id] = $argument;
599 }
600 }
601 // Move old relationships (stored as contexts) to relationships, where
602 // the belong
603 $rels = unserialize($page->contexts);
604 // Not resetting $keywords!
605 $relationships = $ids = array();
606 if (!empty($rels)) {
607 foreach ($rels as $id => $relationship) {
608 $name = $relationship['name'];
609 $info = panels_get_relationship($name);
610 if (!$info) {
611 continue;
612 }
613 // Make sure the id is valid
614 if (empty($relationship['id'])) {
615 if (empty($ids[$name])) {
616 $ids[$name] = 1;
617 }
618 else {
619 $ids[$name]++;
620 }
621
622 $relationship['id'] = $ids[$name];
623 }
624
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 : '');
628 }
629
630 // Give it a unique keyword if it doesn't already have one
631 if (empty($relationship['keyword'])) {
632 $keyword = $base = $info['keyword'];
633 $count = 0;
634 while (!empty($keywords[$keyword])) {
635 $keyword = $base . '_' . ++$count;
636 }
637 $keywords[$keyword] = TRUE;
638 $relationship['keyword'] = $keyword;
639 }
640 $relationships[$id] = $relationship;
641 }
642 }
643 db_query("UPDATE {panels_page} " .
644 "SET arguments = '%s', " .
645 "relationships = '%s', " .
646 "contexts = '%s' " .
647 "WHERE pid = $page->pid", serialize($arguments), serialize($relationships), serialize(array()), $page->pid
648 );
649 }
650 return $ret;
651 }
652
653 function panels_update_5210() {
654 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
655 return array();
656 }
657 $ret = array();
658 $ret[] = update_sql("UPDATE {system} SET weight = 10 WHERE name = 'panels'");
659 return $ret;
660 }
661
662 /**
663 * Force a menu update
664 */
665 function panels_update_5211() {
666 // menu_rebuild();
667 return array();
668 }
669
670 /**
671 * Add a field to store pane caching information.
672 */
673 function panels_update_5213() {
674 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
675 return array();
676 }
677 $ret = array();
678 switch ($GLOBALS['db_type']) {
679 case 'mysql':
680 case 'mysqli':
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");
683 break;
684
685 case 'pgsql':
686 db_add_column($ret, 'panels_pane', 'cache', 'text');
687 db_add_column($ret, 'panels_display', 'cache', 'text');
688 }
689 return $ret;
690 }
691
692 /**
693 * Create a new table for object caching. This isn't part of the cache
694 * system.
695 */
696 function panels_update_5214() {
697 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
698 return array();
699 }
700 $ret = array();
701 return $ret;
702 switch ($GLOBALS['db_type']) {
703 case 'mysql':
704 case 'mysqli':
705 $ret[] = update_sql(<<<EOT
706 CREATE TABLE {panels_object_cache} (
707 sid varchar(64),
708 did integer,
709 obj varchar(255),
710 timestamp integer,
711 data text,
712 KEY (sid, obj, did),
713 KEY (timestamp)
714 ) /*!40100 DEFAULT CHARACTER SET utf8 */
715 EOT
716 );
717 case 'pgsql':
718 }
719 return !empty($ret) ? $ret : $ret;
720 }
721
722 /**
723 * Increase the size of the data column in the {panels_object_cache} table
724 * on MySQL.
725 *
726 * Also gets rid of some duplicate indexes resulting the CREATE TABLE queries
727 * in the install() of schema 5214
728 */
729 function panels_update_5215() {
730 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
731 return array();
732 }
733 $ret = array();
734 switch ($GLOBALS['db_type']) {
735 case 'mysql':
736 case 'mysqli':
737 $ret[] = update_sql("ALTER TABLE {panels_pane} ADD PRIMARY KEY (pid)");
738 break;
739
740 case 'pgsql':
741 $ret[] = update_sql("ALTER TABLE {panels_pane} ADD PRIMARY KEY (pid)");
742 }
743 return $ret;
744 }
745
746 /**
747 * Adds the 'shown' field to the panels_pane table in order to accomodate
748 * the new show/hide panes feature.
749 */
750 function panels_update_5216() {
751 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
752 return array();
753 }
754 $ret = array();
755 switch ($GLOBALS['db_type']) {
756 case 'mysql':
757 case 'mysqli':
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");
763 break;
764
765 case 'pgsql':
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');
771 }
772 return $ret;
773 }
774
775 /**
776 * Add the switcher fields to the database
777 */
778 function panels_update_5217() {
779 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
780 return array();
781 }
782 $ret = array();
783 switch ($GLOBALS['db_type']) {
784 case 'mysql':
785 case 'mysqli':
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");
789 break;
790
791 case 'pgsql':
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');
795 }
796 return $ret;
797 }
798
799
800 /**
801 * Oversight in 5216: 'tinyint' is not a field type in pgsql; the type we wanted
802 * was 'smallint.'
803 */
804 function panels_update_5218() {
805 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
806 return array();
807 }
808 $ret = array();
809 switch ($GLOBALS['db_type']) {
810 case 'mysql':
811 case 'mysqli':
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.'));
813 break;
814
815 case 'pgsql':
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.'));
819 }
820 return $ret;
821 }
822
823 /**
824 * Update from 5.x v2
825 */
826 function panels_update_5299() {
827 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
828 return array();
829 }
830 $ret = array();
831 // Fetch schema version 1.
832 $schema = panels_schema_1();
833
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");
837
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')));
843
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.'));
845
846 return $ret;
847 }
848
849 /**
850 * Update from 6.x v2.
851 */
852 function panels_update_6290() {
853 $ret = array();
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.'));
856 return $ret;
857 }
858
859 // Fetch schema version 1.
860 $schema = panels_schema_1();
861
862 // Update size of pane 'access' field.
863 db_change_field($ret, 'panels_pane', 'access', 'access', $schema['panels_pane']['fields']['access']);
864
865 // Remove the no longer used visibility field
866 if (db_column_exists('panels_pane', 'visibility')) {
867 db_drop_field($ret, 'panels_pane', 'visibility');
868 }
869
870 // Remove panels_object_cache table
871 if (db_table_exists('panels_object_cache')) {
872 db_drop_table($ret, 'panels_object_cache');
873 }
874
875 // Doublecheck that ctools is enabled. If not, automatically disable the module.
876 if (!module_exists('ctools')) {
877 // Try to enable it:
878 drupal_install_modules(array('ctools'));
879
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'));
884 }
885 }
886
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'));
890 }
891
892 $ret[] = update_sql("DELETE FROM {system} WHERE name IN ('panels_page', 'panels_views')");
893
894 return $ret;
895 }
896
897 /**
898 * Special update function for the alpha2 to alpha3 transition after
899 * I messed it up.
900 */
901 function panels_update_6291() {
902 $ret = array();
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.'));
905 return $ret;
906 }
907
908 // Fetch schema version 1.
909 $schema = panels_schema_1();
910
911
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']);
916
917 return $ret;
918 }
919
920 /**
921 * Update panels pane fields using batch API.
922 */
923 function panels_update_6292(&$sandbox) {
924 $ret = array();
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.'));
927 return $ret;
928 }
929
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}'));
934 }
935
936 // configuration
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)) {
939 // access
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)) {
946 unset($rids[$id]);
947 }
948 }
949
950 if (empty($rids)) {
951 $pane->access = array();
952 }
953 else {
954 // The old access style was just a role based system, so let's convert
955 // it to that.
956 $pane->access = array(
957 'plugins' => array(
958 array(
959 'name' => 'role',
960 'context' => 'logged-in-user',
961 'settings' => array(
962 'rids' => array_values($rids),
963 )
964 ),
965 ),
966 );
967 }
968 }
969 else {
970 $pane->access = array();
971 }
972
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']);
979 }
980
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']);
986 }
987
988 if (isset($pane->configuration['css_class'])) {
989 $pane->css['css_class'] = $pane->configuration['css_class'];
990 unset($pane->configuration['css_class']);
991 }
992
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'" .
998 " WHERE pid = %d",
999 serialize($pane->access),
1000 serialize($pane->css),
1001 serialize($pane->style),
1002 serialize($pane->configuration),
1003 serialize($pane->extras),
1004 $pane->pid);
1005
1006 $sandbox['progress']++;
1007 }
1008
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'));
1012 }
1013 return $ret;
1014 }
1015
1016 /**
1017 * Update panels display fields using batch API.
1018 */
1019 function panels_update_6293(&$sandbox) {
1020 $ret = array();
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.'));
1023 return $ret;
1024 }
1025
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}'));
1030 }
1031
1032 // configuration
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();
1037 }
1038 else {
1039 $display->panel_settings = unserialize($display->panel_settings);
1040 if (!is_array($display->panel_settings)) {
1041 $display->panel_settings = array();
1042 }
1043 }
1044
1045 if (isset($display->panel_settings['panel'])) {
1046 foreach ($display->panel_settings['panel'] as $key => $settings) {
1047 $display->panel_settings[$key] = $settings;
1048 }
1049 unset($display->panel_settings['panel']);
1050 }
1051
1052 if (isset($display->panel_settings['individual'])) {
1053 unset($display->panel_settings['individual']);
1054 }
1055
1056 db_query("UPDATE {panels_display} SET " .
1057 "panel_settings = '%s'" .
1058 " WHERE did = %d",
1059 serialize($display->panel_settings),
1060 $display->did);
1061
1062 $sandbox['progress']++;
1063 }
1064
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'));
1068 }
1069 return $ret;
1070 }
1071
1072 /**
1073 * Establish a baseline schema version for 6.x-3.x
1074 */
1075 function panels_update_6300() {
1076 return array();
1077 }
1078
1079 function panels_update_6302() {
1080 $ret = array();
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.'));
1083 return $ret;
1084 }
1085
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.'));
1088 return $ret;
1089 }
1090
1091 if (!db_table_exists('panels_page')) {
1092 return $ret;
1093 }
1094
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;
1110 // convert access
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)) {
1117 unset($rids[$id]);
1118 }
1119 }
1120
1121 if (empty($rids)) {
1122 $page->access = array();
1123 }
1124 else {
1125 // The old access style was just a role based system, so let's convert
1126 // it to that.
1127 $page->access = array(
1128 'plugins' => array(
1129 array(
1130 'name' => 'role',
1131 'context' => 'logged-in-user',
1132 'settings' => array(
1133 'rids' => array_values($rids),
1134 )
1135 ),
1136 ),
1137 );
1138 }
1139 }
1140
1141 // Convert menu stuff.
1142 $page->menu = array(
1143 'type' => 'none',
1144 'title' => '',
1145 'weight' => 0,
1146 'name' => 'navigation',
1147 'parent' => array(
1148 'type' => 'none',
1149 'title' => '',
1150 'weight' => 0,
1151 'name' => 'navigation',
1152 ),
1153 );
1154
1155 if ($p->menu) {
1156 if ($p->menu_tab) {
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;
1162 }
1163 else {
1164 $page->menu['type'] = 'tab';
1165 }
1166 }
1167 else {
1168 $page->menu['type'] = 'normal';
1169 }
1170
1171 $page->menu['title'] = $p->menu_title;
1172 $page->menu['weight'] = $p->menu_tab_weight;
1173 }
1174
1175 $page->conf = array();
1176 $displays = unserialize($p->displays);
1177 $arguments = unserialize($p->arguments);
1178
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(),
1186 );
1187
1188 $match = FALSE;
1189 $bits = explode('/', $page->path);
1190 foreach ($bits as $pos => $bit) {
1191 if ($bit == '%') {
1192 $bits[$pos] = '%' . $argument['keyword'];
1193 $match = TRUE;
1194 $page->path = implode('/', $bits);
1195 break;
1196 }
1197 }
1198
1199 if (!$match) {
1200 if ($argument['default'] == '404') {
1201 $page->path .= '/%' . $argument['keyword'];
1202 }
1203 else {
1204 $page->path .= '/!' . $argument['keyword'];
1205 }
1206 }
1207
1208 // save this for later use.
1209 $arguments[$id]['context'] = 'argument_' . $argument['name'] . '_' . $argument['id'];
1210 }
1211
1212 // Reset the task type here if it's one of our overrides. This ensures
1213 // that we get the right names.
1214 switch ($p->path) {
1215 case 'node/%':
1216 $page->task = 'node_view';
1217 $page->subtask = '';
1218 variable_set('page_manager_node_view_disabled', FALSE);
1219 break;
1220 case 'node/add/%':
1221 // It seems nearly impossible to actually upgrade this properly.
1222 continue;
1223 case 'node/%/edit':
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);
1228 break;
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');
1235 }
1236 variable_set('page_manager_term_view_disabled', FALSE);
1237 break;
1238 case 'user/%':
1239 $page->task = 'user_view';
1240 $page->subtask = '';
1241 variable_set('page_manager_user_view_disabled', FALSE);
1242 break;
1243 // There is no default here.
1244 }
1245
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();
1251 }
1252 else {
1253 $cache->handlers = $node_edit_handlers;
1254 }
1255 _panels_update_create_handler($page, $p, NULL, array('did' => $p->did, 'title' => t('Panel')), $arguments, 0, $cache);
1256 $page->default_handlers = $cache->handlers;
1257 }
1258 else {
1259 // for each display we need to create a new handler.
1260 $weight = 0;
1261 $cache = new stdClass();
1262 if ($page->task != 'node_edit') {
1263 $cache->handlers = array();
1264 }
1265 else {
1266 $cache->handlers = $node_edit_handlers;
1267 $weight = count($cache->handlers) + 1;
1268 }
1269 foreach ($displays as $origin => $info) {
1270 if (!isset($info['argument_id'])) {
1271 $info['argument_id'] = 0;
1272 }
1273
1274 _panels_update_create_handler($page, $p, $origin, $info, $arguments, $weight++, $cache);
1275 }
1276
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;
1280 }
1281
1282 if ($page->task != 'page') {
1283 // just save the handlers.
1284 foreach ($cache->handlers as $name => $handler) {
1285 page_manager_save_task_handler($handler);
1286
1287 // Keep all node edit handlers for later use.
1288 if ($page->task == 'node_edit') {
1289 $node_edit_handlers[$name] = $handler;
1290 }
1291 }
1292 }
1293 else {
1294 page_manager_page_save($page);
1295 }
1296 }
1297
1298 $ret[] = update_sql("DROP TABLE {panels_page}");
1299
1300 // Update a couple of pane types that changed and are easily moved:
1301 switch ($GLOBALS['db_type']) {
1302 case 'mysql':
1303 case 'mysqli':
1304 $ret[] = update_sql("UPDATE {panels_pane} SET type = CONCAT(type, '_', subtype) WHERE type = 'node_form'");
1305 break;
1306
1307 case 'pgsql':
1308 $ret[] = update_sql("UPDATE {panels_pane} SET type = type || '_' || subtype WHERE type = 'node_form'");
1309 }
1310 $ret[] = update_sql("UPDATE {panels_pane} SET type = 'node_form_path' WHERE type = 'node_form_url_path'");
1311
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'));
1314 }
1315
1316 return $ret;
1317 }
1318
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);
1324
1325 $handler->weight = $weight;
1326 $handler->task = $page->task;
1327 if ($page->task == 'page') {
1328 $handler->subtask = $page->name;
1329 }
1330 $handler->export_type = EXPORT_IN_DATABASE;
1331 $handler->type = t('Normal');
1332
1333 $handler->name = page_manager_handler_get_name($task_name, $cache->handlers, $handler);
1334
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'];
1340 }
1341 else {
1342 $d = panels_load_display($p->did);
1343 if ($d) {
1344 $display_code = panels_export_display($d);
1345 eval($display_code);
1346
1347 $handler->conf['did'] = 'new';
1348 $handler->conf['display'] = $display;
1349 }
1350 }
1351 $handler->conf['title'] = !empty($info['title']) ? $info['title'] : '';
1352 $handler->conf['contexts'] = unserialize($p->contexts);
1353 $handler->conf['relationships'] = unserialize($p->relationships);
1354
1355 if ($origin && strpos($origin, '-')) {
1356 $handler->conf['access'] = array(
1357 'logic' => 'and',
1358 'plugins' => array(),
1359 );
1360
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),
1372 ),
1373 );
1374 }
1375 else {
1376 $handler->conf['access']['plugins'][] = array(
1377 'name' => 'node_type',
1378 'context' => $arguments[$info['argument_id']]['context'],
1379 'settings' => array(
1380 'type' => array($key),
1381 ),
1382 );
1383 }
1384 }
1385 else {
1386 // make sure defaults float to the bottom:
1387 $handler->weight += 100;
1388 }
1389 }
1390 $cache->handlers[$handler->name] = $handler;
1391
1392 return $handler;
1393 }
1394
1395 /**
1396 * Ensure the panels_simple_cache module does not exist.
1397 */
1398 function panels_update_6303() {
1399 $ret = array();
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'");
1403 }
1404
1405 return $ret;
1406 }
1407
1408 /**
1409 * Ensure that users are informed about the page manager module.
1410 */
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.'));
1414 }
1415
1416 return array();
1417 }
1418
1419 /**
1420 * Add the title_pane field.
1421 */
1422 function panels_update_6305() {
1423 $ret = array();
1424
1425 // Fetch schema version 2.
1426 $schema = panels_schema_2();
1427
1428 // Add new field
1429 db_add_field($ret, 'panels_display', 'title_pane', $schema['panels_display']['fields']['title_pane']);
1430
1431 return $ret;
1432 }
1433
1434 /**
1435 * Drop a table that should have been gone long ago.
1436 */
1437 function panels_update_6306() {
1438 $ret = array();
1439
1440 if (db_table_exists('panels_page_router_store')) {
1441 db_drop_table($ret, 'panels_page_router_store');
1442 }
1443
1444 return $ret;
1445 }
1446
1447 /**
1448 * This update function does nothing, it was committed in error and is
1449 * left in to prevent update problems.
1450 */
1451 function panels_update_6307() {
1452 return array();
1453 }
1454
1455 /**
1456 * Add the panels_layout table
1457 */
1458 function panels_update_6308() {
1459 $ret = array();
1460
1461 // Schema 3 is locked and should not be changed.
1462 $schema = panels_schema_3();
1463
1464 db_create_table($ret, 'panels_layout', $schema['panels_layout']);
1465 return $ret;
1466 }
1467
1468 /**
1469 * Add the panels_renderer_pipeline table
1470 */
1471 function panels_update_6309() {
1472 $ret = array();
1473
1474 // Schema 3 is locked and should not be changed.
1475 $schema = panels_schema_3();
1476
1477 db_create_table($ret, 'panels_renderer_pipeline', $schema['panels_renderer_pipeline']);
1478 return $ret;
1479 }
1480
1481 /**
1482 * Move stylizer data from Panels to CTools.
1483 */
1484 function panels_update_6310() {
1485 $ret = array();
1486 // load the module files, if possible
1487 if (!defined('PANELS_REQUIRED_CTOOLS_API')) {
1488 include_once drupal_get_path('module', 'panels') . '/panels.module';
1489 }
1490 if (!defined('CTOOLS_API_VERSION')) {
1491 include_once drupal_get_path('module', 'ctools') . '/ctools.module';
1492 }
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.'));
1496 return $ret;
1497 }
1498
1499 // Enable the stylizer module to make everything as seamless as possible.
1500 drupal_install_modules(array('stylizer'));
1501 return $ret;
1502 }