#920266 by dereine: Typo in cache.inc caused wsods in rare circumstances.
[project/panels.git] / panels.install
CommitLineData
9f3609c9
EM
1<?php
2// $Id$
3
4/**
26e7b0ef
SB
5 * Test requirements for installation and running.
6 */
7function panels_requirements($phase) {
946024d2
SB
8 $function = "panels_requirements_$phase";
9 return function_exists($function) ? $function() : array();
10}
11
12/**
13 * Check install-time requirements.
14 */
15function panels_requirements_install() {
26e7b0ef
SB
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.
946024d2 20 if (!(defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'install')) {
26e7b0ef
SB
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/**
946024d2
SB
46 * Check runtime requirements (status report).
47 */
48function 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
2f354acb 72 $list[] = array('data' => $values['explanation'] ."\n" . theme('item_list', array('items' => $modules)));
946024d2
SB
73 }
74
2f354acb 75 $description .= theme('item_list', array('items' => $list));
946024d2
SB
76
77 $requirements['panels_legacy'] = array(
78 'title' => $t('Panels operating in Legacy mode'),
79 'severity' => REQUIREMENT_WARNING,
80 'description' => $description,
81 );
82 }
83 return $requirements;
84}
85
86/**
f2e5a0c5 87 * Implementation of hook_schema().
9f3609c9 88 */
f2e5a0c5
EM
89function panels_schema() {
90 // This should always point to our 'current' schema. This makes it relatively easy
91 // to keep a record of schema as we make changes to it.
946024d2
SB
92 return panels_schema_3();
93}
94
95/**
96 * Schema that adds the panels_layout table.
97 */
98function panels_schema_3() {
99 // Schema 3 is now locked. If you need to make changes, please create
100 // schema 4 and add them.
101 $schema = panels_schema_2();
102
103 $schema['panels_renderer_pipeline'] = array(
104 'description' => 'Contains renderer pipelines for Panels. Each pipeline contains one or more renderers and access rules to select which renderer gets used.',
105 'export' => array(
106 'identifier' => 'pipeline',
107 'bulk export' => TRUE,
108 'primary key' => 'rpid',
109 'api' => array(
110 'owner' => 'panels',
111 'api' => 'pipelines',
112 'minimum_version' => 1,
113 'current_version' => 1,
114 ),
115 ),
116 'fields' => array(
117 'rpid' => array(
118 'type' => 'serial',
119 'description' => 'A database primary key to ensure uniqueness.',
120 'not null' => TRUE,
121 'no export' => TRUE,
122 ),
123 'name' => array(
124 'type' => 'varchar',
125 'length' => '255',
126 'description' => 'Unique ID for this content. Used to identify it programmatically.',
127 ),
128 'admin_title' => array(
129 'type' => 'varchar',
130 'length' => '255',
131 'description' => 'Administrative title for this pipeline.',
132 ),
133 'admin_description' => array(
134 'type' => 'text',
135 'size' => 'big',
136 'description' => 'Administrative description for this pipeline.',
137 'object default' => '',
138 ),
139 'weight' => array(
140 'type' => 'int',
141 'size' => 'small',
142 'default' => 0,
143 ),
144 'settings' => array(
145 'type' => 'text',
146 'size' => 'big',
147 'description' => 'Serialized settings for the actual pipeline. The contents of this field are up to the plugin that uses it.',
148 'serialize' => TRUE,
149 'object default' => array(),
150 ),
151 ),
152 'primary key' => array('rpid'),
153 );
154
155 $schema['panels_layout'] = array(
156 'description' => 'Contains exportable customized layouts for this site.',
157 'export' => array(
158 'identifier' => 'layout',
159 'bulk export' => TRUE,
160 'primary key' => 'lid',
161 'api' => array(
162 'owner' => 'panels',
163 'api' => 'layouts',
164 'minimum_version' => 1,
165 'current_version' => 1,
166 ),
167 ),
168 'fields' => array(
169 'lid' => array(
170 'type' => 'serial',
171 'description' => 'A database primary key to ensure uniqueness.',
172 'not null' => TRUE,
173 'no export' => TRUE,
174 ),
175 'name' => array(
176 'type' => 'varchar',
177 'length' => '255',
178 'description' => 'Unique ID for this content. Used to identify it programmatically.',
179 ),
180 'admin_title' => array(
181 'type' => 'varchar',
182 'length' => '255',
183 'description' => 'Administrative title for this layout.',
184 ),
185 'admin_description' => array(
186 'type' => 'text',
187 'size' => 'big',
188 'description' => 'Administrative description for this layout.',
189 'object default' => '',
190 ),
191 'category' => array(
192 'type' => 'varchar',
193 'length' => '255',
194 'description' => 'Administrative category for this layout.',
195 ),
196 'plugin' => array(
197 'type' => 'varchar',
198 'length' => '255',
199 'description' => 'The layout plugin that owns this layout.',
200 ),
201 'settings' => array(
202 'type' => 'text',
203 'size' => 'big',
204 'description' => 'Serialized settings for the actual layout. The contents of this field are up to the plugin that uses it.',
205 'serialize' => TRUE,
206 'object default' => array(),
207 ),
208 ),
209 'primary key' => array('lid'),
210 );
211
212 return $schema;
26e7b0ef
SB
213}
214
215/**
216 * Schema that adds the title_pane field.
217 */
218function panels_schema_2() {
219 $schema = panels_schema_1();
220
221 $schema['panels_display']['fields']['title_pane'] = array(
222 'type' => 'int',
223 'default' => 0,
224 'no export' => TRUE,
225 );
226
227 return $schema;
f2e5a0c5
EM
228}
229
230/**
231 * Schema version 1 for Panels in D6.
26e7b0ef
SB
232 *
233 * Schema v1 is now LOCKED; any changes should be done via panels_schema_2.
f2e5a0c5
EM
234 */
235function panels_schema_1() {
236 $schema = array();
237
238 $schema['panels_display'] = array(
26e7b0ef
SB
239 'export' => array(
240 'object' => 'panels_display',
241 'bulk export' => FALSE,
242 'export callback' => 'panels_export_display',
243 'can disable' => FALSE,
244 'identifier' => 'display',
245 ),
f2e5a0c5
EM
246 'fields' => array(
247 'did' => array(
248 'type' => 'serial',
249 'not null' => TRUE,
26e7b0ef 250 'no export' => TRUE,
f2e5a0c5
EM
251 ),
252 'layout' => array(
253 'type' => 'varchar',
254 'length' => '32',
26e7b0ef 255 'default' => '',
f2e5a0c5
EM
256 ),
257 'layout_settings' => array(
258 'type' => 'text',
259 'size' => 'big',
26e7b0ef
SB
260 'serialize' => TRUE,
261 'object default' => array(),
262 'initial ' => array(),
f2e5a0c5
EM
263 ),
264 'panel_settings' => array(
265 'type' => 'text',
266 'size' => 'big',
26e7b0ef
SB
267 'serialize' => TRUE,
268 'object default' => array(),
269 'initial ' => array(),
f2e5a0c5
EM
270 ),
271 'cache' => array(
272 'type' => 'text',
26e7b0ef
SB
273 'serialize' => TRUE,
274 'object default' => array(),
275 'initial ' => array(),
f2e5a0c5
EM
276 ),
277 'title' => array(
278 'type' => 'varchar',
279 'length' => '255',
26e7b0ef 280 'default' => '',
f2e5a0c5
EM
281 ),
282 'hide_title' => array(
283 'type' => 'int',
284 'size' => 'tiny',
26e7b0ef
SB
285 'default' => 0,
286 'no export' => TRUE,
f2e5a0c5
EM
287 ),
288 ),
289 'primary key' => array('did'),
290 );
291
292 $schema['panels_pane'] = array(
26e7b0ef
SB
293 'export' => array(
294 'can disable' => FALSE,
295 'identifier' => 'pane',
296 'bulk export' => FALSE,
297 ),
f2e5a0c5
EM
298 'fields' => array(
299 'pid' => array(
300 'type' => 'serial',
301 'not null' => TRUE,
302 ),
303 'did' => array(
304 'type' => 'int',
305 'not null' => TRUE,
306 'default' => 0,
26e7b0ef 307 'no export' => TRUE,
f2e5a0c5
EM
308 ),
309 'panel' => array(
310 'type' => 'varchar',
311 'length' => '32',
26e7b0ef 312 'default' => '',
f2e5a0c5
EM
313 ),
314 'type' => array(
315 'type' => 'varchar',
316 'length' => '32',
26e7b0ef 317 'default' => '',
f2e5a0c5
EM
318 ),
319 'subtype' => array(
320 'type' => 'varchar',
321 'length' => '64',
26e7b0ef 322 'default' => '',
f2e5a0c5
EM
323 ),
324 'shown' => array(
325 'type' => 'int',
326 'size' => 'tiny',
327 'default' => 1,
328 ),
329 'access' => array(
f2e5a0c5
EM
330 'type' => 'text',
331 'size' => 'big',
26e7b0ef
SB
332 'serialize' => TRUE,
333 'object default' => array(),
334 'initial ' => array(),
f2e5a0c5
EM
335 ),
336 'configuration' => array(
337 'type' => 'text',
338 'size' => 'big',
26e7b0ef
SB
339 'serialize' => TRUE,
340 'object default' => array(),
341 'initial ' => array(),
f2e5a0c5
EM
342 ),
343 'cache' => array(
344 'type' => 'text',
345 'size' => 'big',
26e7b0ef
SB
346 'serialize' => TRUE,
347 'object default' => array(),
348 'initial ' => array(),
f2e5a0c5 349 ),
26e7b0ef
SB
350 'style' => array(
351 'type' => 'text',
352 'size' => 'big',
353 'serialize' => TRUE,
354 'object default' => array(),
355 'initial ' => array(),
f2e5a0c5 356 ),
26e7b0ef
SB
357 'css' => array(
358 'type' => 'text',
359 'size' => 'big',
360 'serialize' => TRUE,
361 'object default' => array(),
362 'initial ' => array(),
f2e5a0c5 363 ),
26e7b0ef 364 'extras' => array(
f2e5a0c5
EM
365 'type' => 'text',
366 'size' => 'big',
26e7b0ef
SB
367 'serialize' => TRUE,
368 'object default' => array(),
369 'initial ' => array(),
f2e5a0c5 370 ),
26e7b0ef 371 'position' => array(
f2e5a0c5 372 'type' => 'int',
26e7b0ef
SB
373 'size' => 'small',
374 'default' => 0,
f2e5a0c5
EM
375 ),
376 ),
26e7b0ef 377 'primary key' => array('pid'),
f2e5a0c5 378 'indexes' => array(
26e7b0ef 379 'did_idx' => array('did')
f2e5a0c5 380 ),
9f3609c9 381 );
26e7b0ef 382
f2e5a0c5
EM
383 return $schema;
384}
9f3609c9 385
26e7b0ef
SB
386function panels_update_1000() {
387 // Panels D6 2 had *no* update functions in it, so the schema version is
388 // completely wrong. If we run this update with no schema version, we
389 // were actually that version and we must therefore skip to the proper
390 // update.
391 if (db_table_exists('panels_pane')) {
392 $GLOBALS['SKIP_PANELS_UPDATES'] = TRUE;
393 return array();
394 }
395 $ret = array();
396
397 $ret[] = update_sql("ALTER TABLE {panels_info} RENAME {panels_page}");
398 $ret[] = update_sql("ALTER TABLE {panels_page} CHANGE COLUMN did pid int(10) NOT NULL DEFAULT 0;");
399 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN did int(10) NOT NULL DEFAULT 0 AFTER pid");
400 $ret[] = update_sql("UPDATE {panels_page} SET did = pid");
401
402 $max_pid = db_result(db_query("SELECT MAX(pid) FROM {panels_page}"));
403 if ($max_pid) {
404 $ret[] = update_sql("INSERT INTO {sequences} (name, id) VALUES ('{panels_page}_pid', $max_pid)");
405 }
406
407 $ret[] = update_sql("ALTER TABLE {panels_area} RENAME {panels_pane}");
408 $ret[] = update_sql("ALTER TABLE {panels_pane} ADD COLUMN pid int(10) NOT NULL DEFAULT 0 FIRST");
409 $ret[] = update_sql("ALTER TABLE {panels_pane} CHANGE area panel varchar(32)");
410 $result = db_query("SELECT * FROM {panels_pane}");
411 while ($pane = db_fetch_object($result)) {
412 $count++;
413 $ret[] = update_sql("UPDATE {panels_pane} SET pid = $count WHERE did = $pane->did AND panel = '$pane->panel' AND position = $pane->position");
414 }
415 if ($count) {
416 $ret[] = update_sql("INSERT INTO {sequences} (name, id) VALUES ('{panels_pane}_pid', $count)");
417 }
418
419 $ret[] = update_sql(<<<EOT
420 CREATE TABLE {panels_display} (
421 did INT(10) NOT NULL DEFAULT 0 PRIMARY KEY,
422 layout VARCHAR(32)
423 ) /*!40100 DEFAULT CHARACTER SET utf8 */
424EOT
425 );
426 $result = db_query("SELECT did, layout FROM {panels_page}");
427 $max_did = 0;
428 while ($display = db_fetch_object($result)) {
429 $ret[] = update_sql("INSERT INTO {panels_display} VALUES ($display->did, '$display->layout')");
430 if ($display->did > $max_did) {
431 $max_did = $display->did;
432 }
433 }
434 $ret[] = update_sql("ALTER TABLE {panels_page} DROP COLUMN layout");
435 if ($max_did) {
436 $ret[] = update_sql("INSERT INTO {sequences} (name, id) VALUES ('{panels_display}_did', $max_did)");
437 }
438 return $ret;
439}
440
441function panels_update_1001() {
442 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
443 return array();
444 }
445 $ret = array();
446 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN no_blocks int(1)");
447 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu int(1) DEFAULT 0");
448 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu_tab int(1)");
449 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu_tab_weight int(4)");
450 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu_title varchar(255)");
451 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu_tab_default int(1)");
452 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu_tab_default_parent_type varchar(10)");
453 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu_parent_title varchar(255)");
454 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu_parent_tab_weight int(4)");
455 return $ret;
456}
457
458// Create a field for the layout settings
459function panels_update_1002() {
460 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
461 return array();
462 }
463 $ret = array();
464 $ret[] = update_sql("ALTER TABLE {panels_display} ADD COLUMN layout_settings longtext");
465 $ret[] = update_sql("ALTER TABLE {panels_pane} ADD COLUMN access varchar(128) AFTER type");
466 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN css longtext AFTER css_id");
467 return $ret;
468}
469
470// Create a field for the panel settings.
471function panels_update_1003() {
472 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
473 return array();
474 }
475 $ret = array();
476 $ret[] = update_sql("ALTER TABLE {panels_display} ADD COLUMN panel_settings longtext");
477 return $ret;
478}
479
480// Kept up updates from older versions of Panels 2 for D5 to smooth updates.
481// Create a field for the panel settings.
482// Renumbering to proper numbering scheme.
483function panels_update_5204() {
484 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
485 return array();
486 }
487 $ret = array();
488 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN name varchar(255) UNIQUE");
489 $ret[] = update_sql("ALTER TABLE {panels_display} ADD COLUMN name varchar(255) UNIQUE");
490 // Give all our panels a name.
491 $ret[] = update_sql("UPDATE {panels_page} SET name = CONCAT('panel_page_', pid)");
492 $ret[] = update_sql("UPDATE {panels_display} SET name = CONCAT('display_', did)");
493 return $ret;
494}
495
496// Add the arguments field
497function panels_update_5205() {
498 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
499 return array();
500 }
501 $ret = array();
502 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN arguments longtext");
503 return $ret;
504}
505
506// Add a field so that panes can remember their subtype so we can retrieve
507// context information about it.
508function panels_update_5206() {
509 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
510 return array();
511 }
512 $ret = array();
513 $ret[] = update_sql("ALTER TABLE {panels_pane} ADD COLUMN subtype varchar(64)");
514 return $ret;
515}
516
517// Add fields for displays and extra contexts
518function panels_update_5207() {
519 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
520 return array();
521 }
522 $ret = array();
523 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN displays longtext");
524 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN contexts longtext");
525 return $ret;
526}
527
528// Correct the mistaken {panels_display}_id when it should be {panels_display}_did
529function panels_update_5208() {
530 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
531 return array();
532 }
533 $ret = array();
534 $count = db_result(db_query("SELECT MAX(did) FROM {panels_display}"));
535 $ret[] = update_sql("DELETE FROM {sequences} WHERE name = '{panels_display}_did'");
536 $ret[] = update_sql("DELETE FROM {sequences} WHERE name = '{panels_display}_id'");
537 if ($count) {
538 $ret[] = update_sql("INSERT INTO {sequences} (name, id) VALUES ('{panels_display}_did',
539 $count)");
540 }
541
542 return $ret;
543}
544
545// Update argument, relationship and context code to be more correct.
546function panels_update_5209() {
547 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
548 return array();
549 }
550 $ret = array();
551 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN relationships longtext");
552 $result = db_query("SELECT * FROM {panels_page}");
553
554 // This code removed due to call to panels_get_argument(). People with
555 // older versions will just have to suffer.
556 return $ret;
946024d2 557 ctools_include('plugins', 'panels');
26e7b0ef
SB
558
559 while ($page = db_fetch_object($result)) {
560 $args = unserialize($page->arguments);
561 $arguments = $ids = $keywords = array();
562 if (!empty($args)) {
563 // Update each argument
564 foreach ($args as $id => $argument) {
565 $name = $argument['name'];
566 $info = panels_get_argument($name);
567 if (!$info) {
568 continue;
569 }
570 // Make sure the id is valid
571 if (empty($argument['id'])) {
572 if (empty($ids[$name])) {
573 $ids[$name] = 1;
574 }
575 else {
576 $ids[$name]++;
577 }
578
579 $argument['id'] = $ids[$name];
580 }
581
582 // Give it an identifier if it doesn't already have one
583 if (empty($argument['identifier'])) {
584 $argument['identifier'] = $info['title'] . ($id > 1 ? ' ' . $id : '');
26e7b0ef
SB
585 }
586
587 // Give it a unique keyword if it doesn't already have one
588 if (empty($argument['keyword'])) {
589 $keyword = $base = $info['keyword'];
590 $count = 0;
591 while (!empty($keywords[$keyword])) {
592 $keyword = $base . '_' . ++$count;
593 }
594 $keywords[$keyword] = TRUE;
595 $argument['keyword'] = $keyword;
26e7b0ef
SB
596 }
597 $arguments[$id] = $argument;
598 }
599 }
600 // Move old relationships (stored as contexts) to relationships, where
601 // the belong
602 $rels = unserialize($page->contexts);
603 // Not resetting $keywords!
604 $relationships = $ids = array();
605 if (!empty($rels)) {
606 foreach ($rels as $id => $relationship) {
607 $name = $relationship['name'];
608 $info = panels_get_relationship($name);
609 if (!$info) {
610 continue;
611 }
612 // Make sure the id is valid
613 if (empty($relationship['id'])) {
614 if (empty($ids[$name])) {
615 $ids[$name] = 1;
616 }
617 else {
618 $ids[$name]++;
619 }
620
621 $relationship['id'] = $ids[$name];
622 }
623
624 // Give it an identifier if it doesn't already have one
625 if (empty($relationship['identifier'])) {
626 $relationship['identifier'] = $info['title'] . ($id > 1 ? ' ' . $id : '');
627 }
628
629 // Give it a unique keyword if it doesn't already have one
630 if (empty($relationship['keyword'])) {
631 $keyword = $base = $info['keyword'];
632 $count = 0;
633 while (!empty($keywords[$keyword])) {
634 $keyword = $base . '_' . ++$count;
635 }
636 $keywords[$keyword] = TRUE;
637 $relationship['keyword'] = $keyword;
638 }
639 $relationships[$id] = $relationship;
640 }
641 }
642 db_query("UPDATE {panels_page} " .
643 "SET arguments = '%s', " .
644 "relationships = '%s', " .
645 "contexts = '%s' " .
646 "WHERE pid = $page->pid", serialize($arguments), serialize($relationships), serialize(array()), $page->pid
647 );
648 }
649 return $ret;
650}
651
652function panels_update_5210() {
653 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
654 return array();
655 }
656 $ret = array();
657 $ret[] = update_sql("UPDATE {system} SET weight = 10 WHERE name = 'panels'");
658 return $ret;
659}
660
661/**
662 * Force a menu update
663 */
664function panels_update_5211() {
665// menu_rebuild();
666 return array();
667}
668
669/**
670 * Add a field to store pane caching information.
671 */
672function panels_update_5213() {
673 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
674 return array();
675 }
676 $ret = array();
677 switch ($GLOBALS['db_type']) {
678 case 'mysql':
679 case 'mysqli':
680 $ret[] = update_sql("ALTER TABLE {panels_pane} ADD COLUMN cache longtext AFTER configuration");
681 $ret[] = update_sql("ALTER TABLE {panels_display} ADD COLUMN cache longtext AFTER panel_settings");
682 break;
683
684 case 'pgsql':
685 db_add_column($ret, 'panels_pane', 'cache', 'text');
686 db_add_column($ret, 'panels_display', 'cache', 'text');
687 }
688 return $ret;
689}
690
691/**
692 * Create a new table for object caching. This isn't part of the cache
693 * system.
694 */
695function panels_update_5214() {
696 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
697 return array();
698 }
699 $ret = array();
700 return $ret;
701 switch ($GLOBALS['db_type']) {
702 case 'mysql':
703 case 'mysqli':
704 $ret[] = update_sql(<<<EOT
705 CREATE TABLE {panels_object_cache} (
706 sid varchar(64),
707 did integer,
708 obj varchar(255),
709 timestamp integer,
710 data text,
711 KEY (sid, obj, did),
712 KEY (timestamp)
713 ) /*!40100 DEFAULT CHARACTER SET utf8 */
714EOT
715 );
716 case 'pgsql':
717 }
718 return !empty($ret) ? $ret : $ret;
719}
720
721/**
722 * Increase the size of the data column in the {panels_object_cache} table
723 * on MySQL.
724 *
725 * Also gets rid of some duplicate indexes resulting the CREATE TABLE queries
726 * in the install() of schema 5214
727 */
728function panels_update_5215() {
729 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
730 return array();
731 }
732 $ret = array();
733 switch ($GLOBALS['db_type']) {
734 case 'mysql':
735 case 'mysqli':
736 $ret[] = update_sql("ALTER TABLE {panels_pane} ADD PRIMARY KEY (pid)");
737 break;
738
739 case 'pgsql':
740 $ret[] = update_sql("ALTER TABLE {panels_pane} ADD PRIMARY KEY (pid)");
741 }
742 return $ret;
743}
744
745/**
746 * Adds the 'shown' field to the panels_pane table in order to accomodate
747 * the new show/hide panes feature.
748 */
749function panels_update_5216() {
750 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
751 return array();
752 }
753 $ret = array();
754 switch ($GLOBALS['db_type']) {
755 case 'mysql':
756 case 'mysqli':
757 $ret[] = update_sql("ALTER TABLE {panels_pane} ADD COLUMN shown int(1) DEFAULT 1 AFTER subtype");
758 $ret[] = update_sql("ALTER TABLE {panels_display} ADD COLUMN title varchar(128) AFTER cache");
759 $ret[] = update_sql("ALTER TABLE {panels_display} ADD COLUMN hide_title int(1) AFTER title");
760 $ret[] = update_sql("ALTER TABLE {panels_display} DROP COLUMN name");
761 $ret[] = update_sql("ALTER TABLE {panels_pane} ADD COLUMN visibility text AFTER access");
762 break;
763
764 case 'pgsql':
765 db_add_column($ret, 'panels_pane', 'shown', 'tinyint', array('default' => 1));
766 db_add_column($ret, 'panels_display', 'title', 'varchar(128)');
767 db_add_column($ret, 'panels_display', 'hide_title', 'tinyint', array('default' => 0));
768 $ret = update_sql("ALTER TABLE {panels_display} DROP name");
769 db_add_column($ret, 'panels_pane', 'visibility', 'text');
770 }
771 return $ret;
772}
773
774/**
775 * Add the switcher fields to the database
776 */
777function panels_update_5217() {
778 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
779 return array();
780 }
781 $ret = array();
782 switch ($GLOBALS['db_type']) {
783 case 'mysql':
784 case 'mysqli':
785 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN switcher_type varchar(128) AFTER no_blocks");
786 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN switcher_name varchar(128) AFTER no_blocks");
787 $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN switcher_options longtext AFTER switcher_type");
788 break;
789
790 case 'pgsql':
791 db_add_column($ret, 'panels_page', 'switcher_type', 'varchar(128)');
792 db_add_column($ret, 'panels_page', 'switcher_name', 'varchar(128)');
793 db_add_column($ret, 'panels_page', 'switcher_options', 'text');
794 }
795 return $ret;
796}
797
798
799/**
800 * Oversight in 5216: 'tinyint' is not a field type in pgsql; the type we wanted
801 * was 'smallint.'
802 */
803function panels_update_5218() {
804 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
805 return array();
806 }
807 $ret = array();
808 switch ($GLOBALS['db_type']) {
809 case 'mysql':
810 case 'mysqli':
811 $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.'));
812 break;
813
814 case 'pgsql':
815 db_add_column($ret, 'panels_pane', 'shown', 'smallint', array('default' => 1));
816 db_add_column($ret, 'panels_display', 'hide_title', 'smallint', array('default' => 0));
817 $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.'));
818 }
819 return $ret;
820}
821
822/**
823 * Update from 5.x v2
824 */
825function panels_update_5299() {
826 if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
827 return array();
828 }
829 $ret = array();
830 // Fetch schema version 1.
831 $schema = panels_schema_1();
832
833 // Certain really old versions of Panels had errors that would cause invalid
834 // panes to be written. This wipes them so that the conversion won't fail:
835 $ret[] = update_sql("DELETE FROM {panels_pane} WHERE pid = 0");
836
837 // update pid and did to be serial
838 db_drop_primary_key($ret, 'panels_pane');
839 db_change_field($ret, 'panels_pane', 'pid', 'pid', $schema['panels_pane']['fields']['pid'], array('primary key' => array('pid')));
840 db_drop_primary_key($ret, 'panels_display');
841 db_change_field($ret, 'panels_display', 'did', 'did', $schema['panels_display']['fields']['did'], array('primary key' => array('did')));
842
843 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.'));
844
845 return $ret;
846}
847
848/**
849 * Update from 6.x v2.
850 */
851function panels_update_6290() {
852 $ret = array();
853 if (!module_exists('panels')) {
854 $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.'));
855 return $ret;
856 }
857
858 // Fetch schema version 1.
859 $schema = panels_schema_1();
860
861 // Update size of pane 'access' field.
862 db_change_field($ret, 'panels_pane', 'access', 'access', $schema['panels_pane']['fields']['access']);
863
864 // Remove the no longer used visibility field
865 if (db_column_exists('panels_pane', 'visibility')) {
866 db_drop_field($ret, 'panels_pane', 'visibility');
867 }
868
869 // Remove panels_object_cache table
870 if (db_table_exists('panels_object_cache')) {
871 db_drop_table($ret, 'panels_object_cache');
872 }
873
874 // Doublecheck that ctools is enabled. If not, automatically disable the module.
875 if (!module_exists('ctools')) {
876 // Try to enable it:
877 drupal_install_modules(array('ctools'));
878
879 // If that fails, shut off all Panels.
880 if (!module_exists('ctools')) {
881 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.'));
882 module_disable(array('panels', 'panels_mini', 'panels_export', 'panels_node', 'panels_simple_cache'));
883 }
884 }
885
886 if (!module_exists('page_manager') && db_table_exists('panels_page')) {
887 drupal_set_message('Page manager module has been automatically enabled to replace the Panels pages module.');
888 drupal_install_modules(array('page_manager'));
889 }
890
891 $ret[] = update_sql("DELETE FROM {system} WHERE name IN ('panels_page', 'panels_views')");
892
893 return $ret;
894}
895
896/**
897 * Special update function for the alpha2 to alpha3 transition after
898 * I messed it up.
899 */
900function panels_update_6291() {
901 $ret = array();
902 if (!module_exists('panels')) {
903 $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.'));
904 return $ret;
905 }
906
907 // Fetch schema version 1.
908 $schema = panels_schema_1();
909
910
911 // Add some new fields
912 db_add_field($ret, 'panels_pane', 'style', $schema['panels_pane']['fields']['style']);
913 db_add_field($ret, 'panels_pane', 'css', $schema['panels_pane']['fields']['css']);
914 db_add_field($ret, 'panels_pane', 'extras', $schema['panels_pane']['fields']['extras']);
915
916 return $ret;
917}
918
919/**
920 * Update panels pane fields using batch API.
921 */
922function panels_update_6292(&$sandbox) {
923 $ret = array();
924 if (!module_exists('panels')) {
925 $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.'));
926 return $ret;
927 }
928
929 if (!isset($sandbox['progress'])) {
930 $sandbox['progress'] = 0;
931 // We'll -1 to disregard the uid 0...
932 $sandbox['max'] = db_result(db_query('SELECT COUNT(*) FROM {panels_pane}'));
933 }
934
935 // configuration
936 $result = db_query_range("SELECT pid, access, configuration FROM {panels_pane} ORDER BY pid ASC", $sandbox['progress'], 20);
937 while ($pane = db_fetch_object($result)) {
938 // access
939 if (!empty($pane->access)) {
940 $rids = explode(', ', $pane->access);
941 // For safety, eliminate any non-numeric rids, as we occasionally had
942 // problems with nulls and such getting in here:
943 foreach ($rids as $id => $rid) {
944 if (!is_numeric($rid)) {
945 unset($rids[$id]);
946 }
947 }
948
949 if (empty($rids)) {
950 $pane->access = array();
951 }
952 else {
953 // The old access style was just a role based system, so let's convert
954 // it to that.
955 $pane->access = array(
956 'plugins' => array(
957 array(
958 'name' => 'role',
959 'context' => 'logged-in-user',
960 'settings' => array(
961 'rids' => array_values($rids),
962 )
963 ),
964 ),
965 );
966 }
967 }
968 else {
969 $pane->access = array();
970 }
971
972 // Move style from configuration.
973 $pane->configuration = unserialize($pane->configuration);
974 $pane->style = array();
975 if (!empty($pane->configuration['style'])) {
976 $pane->style['style'] = $pane->configuration['style'];
977 unset($pane->configuration['style']);
978 }
979
980 $pane->css = array();
981 // Move css configuration from configuration
982 if (isset($pane->configuration['css_id'])) {
983 $pane->css['css_id'] = $pane->configuration['css_id'];
984 unset($pane->configuration['css_id']);
985 }
986
987 if (isset($pane->configuration['css_class'])) {
988 $pane->css['css_class'] = $pane->configuration['css_class'];
989 unset($pane->configuration['css_class']);
990 }
991
992 // Make sure extras is an array. This isn't used by anything in Panels
993 // yet, so an empty array is just fine.
994 $pane->extras = array();
995 db_query("UPDATE {panels_pane} SET " .
996 "access = '%s', css = '%s', style = '%s', configuration = '%s', extras = '%s'" .
997 " WHERE pid = %d",
998 serialize($pane->access),
999 serialize($pane->css),
1000 serialize($pane->style),
1001 serialize($pane->configuration),
1002 serialize($pane->extras),
1003 $pane->pid);
1004
1005 $sandbox['progress']++;
1006 }
1007
1008 $ret['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']);
1009 if ($ret['#finished'] === 1) {
1010 $ret[] = array('success' => TRUE, 'query' => t('Panel panes were updated'));
1011 }
1012 return $ret;
1013}
1014
1015/**
1016 * Update panels display fields using batch API.
1017 */
1018function panels_update_6293(&$sandbox) {
1019 $ret = array();
1020 if (!module_exists('panels')) {
1021 $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.'));
1022 return $ret;
1023 }
1024
1025 if (!isset($sandbox['progress'])) {
1026 $sandbox['progress'] = 0;
1027 // We'll -1 to disregard the uid 0...
1028 $sandbox['max'] = db_result(db_query('SELECT COUNT(*) FROM {panels_display}'));
1029 }
1030
1031 // configuration
1032 $result = db_query_range("SELECT did, panel_settings FROM {panels_display} ORDER BY did ASC", $sandbox['progress'], 20);
1033 while ($display = db_fetch_object($result)) {
1034 if (empty($display->panel_settings)) {
1035 $display->panel_settings = array();
1036 }
1037 else {
1038 $display->panel_settings = unserialize($display->panel_settings);
1039 if (!is_array($display->panel_settings)) {
1040 $display->panel_settings = array();
1041 }
1042 }
1043
1044 if (isset($display->panel_settings['panel'])) {
1045 foreach ($display->panel_settings['panel'] as $key => $settings) {
1046 $display->panel_settings[$key] = $settings;
1047 }
1048 unset($display->panel_settings['panel']);
1049 }
1050
1051 if (isset($display->panel_settings['individual'])) {
1052 unset($display->panel_settings['individual']);
1053 }
1054
1055 db_query("UPDATE {panels_display} SET " .
1056 "panel_settings = '%s'" .
1057 " WHERE did = %d",
1058 serialize($display->panel_settings),
1059 $display->did);
1060
1061 $sandbox['progress']++;
1062 }
1063
1064 $ret['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']);
1065 if ($ret['#finished'] === 1) {
1066 $ret[] = array('success' => TRUE, 'query' => t('Panel displays were updated'));
1067 }
1068 return $ret;
1069}
1070
1071/**
1072 * Establish a baseline schema version for 6.x-3.x
1073 */
1074function panels_update_6300() {
1075 return array();
1076}
1077
1078function panels_update_6302() {
1079 $ret = array();
1080 if (!module_exists('panels')) {
1081 $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.'));
1082 return $ret;
1083 }
1084
1085 if (!module_exists('page_manager') && db_table_exists('panels_page')) {
1086 $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.'));
1087 return $ret;
1088 }
1089
1090 if (!db_table_exists('panels_page')) {
1091 return $ret;
1092 }
1093
1094 // Store the node edit handlers because we merged the edit/add path and we
1095 // need to be able to keep these together to make sure the names work ok.
1096 $node_edit_handlers = array();
1097 page_manager_get_task('page');
1098 $result = db_query("SELECT * FROM {panels_page}");
1099 while ($p = db_fetch_object($result)) {
1100 $page = page_manager_page_new();
1101 $page->default_handlers = array();
1102 // Should we check for uniqueness here? It doesn't seem really
1103 // plausible that there could be page manager pages already.
1104 $page->name = $p->name;
1105 $page->task = 'page'; // could become custom later.
1106 $page->subtask = $p->name;
1107 $page->admin_title = $p->name;
1108 $page->path = $p->path;
1109 // convert access
1110 if (!empty($p->access)) {
1111 $rids = explode(', ', $p->access);
1112 // For safety, eliminate any non-numeric rids, as we occasionally had
1113 // problems with nulls and such getting in here:
1114 foreach ($rids as $id => $rid) {
1115 if (!is_numeric($rid)) {
1116 unset($rids[$id]);
1117 }
1118 }
1119
1120 if (empty($rids)) {
1121 $page->access = array();
1122 }
1123 else {
1124 // The old access style was just a role based system, so let's convert
1125 // it to that.
1126 $page->access = array(
1127 'plugins' => array(
1128 array(
1129 'name' => 'role',
1130 'context' => 'logged-in-user',
1131 'settings' => array(
1132 'rids' => array_values($rids),
1133 )
1134 ),
1135 ),
1136 );
1137 }
1138 }
1139
1140 // Convert menu stuff.
1141 $page->menu = array(
1142 'type' => 'none',
1143 'title' => '',
1144 'weight' => 0,
1145 'name' => 'navigation',
1146 'parent' => array(
1147 'type' => 'none',
1148 'title' => '',
1149 'weight' => 0,
1150 'name' => 'navigation',
1151 ),
1152 );
1153
1154 if ($p->menu) {
1155 if ($p->menu_tab) {
1156 if ($p->menu_tab_default) {
1157 $page->menu['type'] = 'default tab';
1158 $page->menu['parent']['type'] = $p->menu_tab_default_parent_type;
1159 $page->menu['parent']['title'] = $p->menu_parent_title;
1160 $page->menu['parent']['weight'] = $p->menu_parent_tab_weight;
1161 }
1162 else {
1163 $page->menu['type'] = 'tab';
1164 }
1165 }
1166 else {
1167 $page->menu['type'] = 'normal';
1168 }
1169
1170 $page->menu['title'] = $p->menu_title;
1171 $page->menu['weight'] = $p->menu_tab_weight;
1172 }
1173
1174 $page->conf = array();
1175 $displays = unserialize($p->displays);
1176 $arguments = unserialize($p->arguments);
1177
1178 foreach ($arguments as $id => $argument) {
1179 $page->arguments[$argument['keyword']] = array(
1180 'name' => $argument['name'],
1181 'identifier' => $argument['identifier'],
1182 'title' => $argument['title'],
1183 'id' => $argument['id'],
1184 'settings' => isset($argument['argument_settings']) ? $argument['argument_settings'] : array(),
1185 );
1186
1187 $match = FALSE;
1188 $bits = explode('/', $page->path);
1189 foreach ($bits as $pos => $bit) {
1190 if ($bit == '%') {
1191 $bits[$pos] = '%' . $argument['keyword'];
1192 $match = TRUE;
1193 $page->path = implode('/', $bits);
1194 break;
1195 }
1196 }
1197
1198 if (!$match) {
1199 if ($argument['default'] == '404') {
1200 $page->path .= '/%' . $argument['keyword'];
1201 }
1202 else {
1203 $page->path .= '/!' . $argument['keyword'];
1204 }
1205 }
1206
1207 // save this for later use.
1208 $arguments[$id]['context'] = 'argument_' . $argument['name'] . '_' . $argument['id'];
1209 }
1210
1211 // Reset the task type here if it's one of our overrides. This ensures
1212 // that we get the right names.
1213 switch ($p->path) {
1214 case 'node/%':
1215 $page->task = 'node_view';
1216 $page->subtask = '';
1217 variable_set('page_manager_node_view_disabled', FALSE);
1218 break;
1219 case 'node/add/%':
1220 // It seems nearly impossible to actually upgrade this properly.
1221 continue;
1222 case 'node/%/edit':
1223 // Could we get conflicts here if they had both?
1224 $page->task = 'node_edit';
1225 $page->subtask = '';
1226 variable_set('page_manager_node_edit_disabled', FALSE);
1227 break;
1228 case 'taxonomy/term':
1229 case 'taxonomy/term/%':
1230 $page->task = 'term_view';
1231 $page->subtask = '';
1232 if ($arguments[0]['name'] == 'term') {
1233 variable_set('page_manager_term_view_type', 'single');
1234 }
1235 variable_set('page_manager_term_view_disabled', FALSE);
1236 break;
1237 case 'user/%':
1238 $page->task = 'user_view';
1239 $page->subtask = '';
1240 variable_set('page_manager_user_view_disabled', FALSE);
1241 break;
1242 // There is no default here.
1243 }
1244
1245 if (empty($displays)) {
1246 // only one display on this panel, mak
1247 $cache = new stdClass();
1248 if ($page->task != 'node_edit') {
1249 $cache->handlers = array();
1250 }
1251 else {
1252 $cache->handlers = $node_edit_handlers;
1253 }
1254 _panels_update_create_handler($page, $p, NULL, array('did' => $p->did, 'title' => t('Panel')), $arguments, 0, $cache);
1255 $page->default_handlers = $cache->handlers;
1256 }
1257 else {
1258 // for each display we need to create a new handler.
1259 $weight = 0;
1260 $cache = new stdClass();
1261 if ($page->task != 'node_edit') {
1262 $cache->handlers = array();
1263 }
1264 else {
1265 $cache->handlers = $node_edit_handlers;
1266 $weight = count($cache->handlers) + 1;
1267 }
1268 foreach ($displays as $origin => $info) {
1269 if (!isset($info['argument_id'])) {
1270 $info['argument_id'] = 0;
1271 }
1272
1273 _panels_update_create_handler($page, $p, $origin, $info, $arguments, $weight++, $cache);
1274 }
1275
1276 // Also add the primary display as a default with no selector.
1277// _panels_update_create_handler($page, $p, NULL, array('did' => $p->did, 'title' => t('Default')), $arguments, $weight++, $cache);
1278 $page->default_handlers = $cache->handlers;
1279 }
1280
1281 if ($page->task != 'page') {
1282 // just save the handlers.
1283 foreach ($cache->handlers as $name => $handler) {
1284 page_manager_save_task_handler($handler);
1285
1286 // Keep all node edit handlers for later use.
1287 if ($page->task == 'node_edit') {
1288 $node_edit_handlers[$name] = $handler;
1289 }
1290 }
1291 }
1292 else {
1293 page_manager_page_save($page);
1294 }
1295 }
1296
1297 $ret[] = update_sql("DROP TABLE {panels_page}");
1298
1299 // Update a couple of pane types that changed and are easily moved:
1300 switch ($GLOBALS['db_type']) {
1301 case 'mysql':
1302 case 'mysqli':
1303 $ret[] = update_sql("UPDATE {panels_pane} SET type = CONCAT(type, '_', subtype) WHERE type = 'node_form'");
1304 break;
1305
1306 case 'pgsql':
1307 $ret[] = update_sql("UPDATE {panels_pane} SET type = type || '_' || subtype WHERE type = 'node_form'");
1308 }
1309 $ret[] = update_sql("UPDATE {panels_pane} SET type = 'node_form_path' WHERE type = 'node_form_url_path'");
1310
1311 if (module_exists('ctools') && !module_exists('views_content') && db_result(db_query("SELECT pid FROM {panels_pane} WHERE type = 'views'"))) {
1312 drupal_install_modules(array('views_content'));
1313 }
1314
1315 return $ret;
1316}
1317
1318function _panels_update_create_handler($page, $p, $origin, $info, $arguments, $weight, &$cache) {
1319 $task = page_manager_get_task($page->task);
1320 $task_name = 'page-' . $page->name;
1321 $plugin = page_manager_get_task_handler('panel_context');
1322 $handler = page_manager_new_task_handler($plugin);
1323
1324 $handler->weight = $weight;
1325 $handler->task = $page->task;
1326 if ($page->task == 'page') {
1327 $handler->subtask = $page->name;
1328 }
1329 $handler->export_type = EXPORT_IN_DATABASE;
1330 $handler->type = t('Normal');
1331
1332 $handler->name = page_manager_handler_get_name($task_name, $cache->handlers, $handler);
1333
1334 $handler->conf['css'] = $p->css;
1335 $handler->conf['css_id'] = $p->css_id;
1336 $handler->conf['no_blocks'] = $p->no_blocks;
1337 if (!empty($info['did']) && is_numeric($info['did'])) {
1338 $handler->conf['did'] = $info['did'];
1339 }
1340 else {
1341 $d = panels_load_display($p->did);
1342 if ($d) {
1343 $display_code = panels_export_display($d);
1344 eval($display_code);
1345
1346 $handler->conf['did'] = 'new';
1347 $handler->conf['display'] = $display;
1348 }
1349 }
1350 $handler->conf['title'] = !empty($info['title']) ? $info['title'] : '';
1351 $handler->conf['contexts'] = unserialize($p->contexts);
1352 $handler->conf['relationships'] = unserialize($p->relationships);
1353
1354 if ($origin && strpos($origin, '-')) {
1355 $handler->conf['access'] = array(
1356 'logic' => 'and',
1357 'plugins' => array(),
1358 );
1359
1360 // Only 4 types of arguments supported having their own displays:
1361 // nid, node_add_form, node_edit_form and term. 3 of those simply used
1362 // node type and the last simply used vocabulary.
1363 list($junk, $key) = explode('-', $origin);
1364 if ($key && $key != 'default') {
1365 if ($arguments[$info['argument_id']]['name'] == 'term') {
1366 $handler->conf['access']['plugins'][] = array(
1367 'name' => 'term_vocabulary',
1368 'context' => $arguments[$info['argument_id']]['context'],
1369 'settings' => array(
1370 'vids' => array($key),
1371 ),
1372 );
1373 }
1374 else {
1375 $handler->conf['access']['plugins'][] = array(
1376 'name' => 'node_type',
1377 'context' => $arguments[$info['argument_id']]['context'],
1378 'settings' => array(
1379 'type' => array($key),
1380 ),
1381 );
1382 }
1383 }
1384 else {
1385 // make sure defaults float to the bottom:
1386 $handler->weight += 100;
1387 }
1388 }
1389 $cache->handlers[$handler->name] = $handler;
1390
1391 return $handler;
1392}
1393
1394/**
1395 * Ensure the panels_simple_cache module does not exist.
1396 */
1397function panels_update_6303() {
1398 $ret = array();
1399 if (module_exists('panels_simple_cache')) {
1400 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.'));
1401 $ret[] = update_sql("DELETE FROM {system} WHERE name = 'panels_simple_cache'");
1402 }
1403
1404 return $ret;
1405}
1406
1407/**
1408 * Ensure that users are informed about the page manager module.
1409 */
1410function panels_update_6304() {
1411 if (!module_exists('page_manager')) {
1412 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.'));
1413 }
1414
1415 return array();
1416}
1417
1418/**
1419 * Add the title_pane field.
1420 */
1421function panels_update_6305() {
1422 $ret = array();
1423
1424 // Fetch schema version 2.
1425 $schema = panels_schema_2();
1426
1427 // Add new field
1428 db_add_field($ret, 'panels_display', 'title_pane', $schema['panels_display']['fields']['title_pane']);
1429
1430 return $ret;
1431}
1432
1433/**
1434 * Drop a table that should have been gone long ago.
1435 */
1436function panels_update_6306() {
1437 $ret = array();
1438
1439 if (db_table_exists('panels_page_router_store')) {
1440 db_drop_table($ret, 'panels_page_router_store');
1441 }
1442
1443 return $ret;
1444}
946024d2
SB
1445
1446/**
1447 * This update function does nothing, it was committed in error and is
1448 * left in to prevent update problems.
1449 */
1450function panels_update_6307() {
1451 return array();
1452}
1453
1454/**
1455 * Add the panels_layout table
1456 */
1457function panels_update_6308() {
1458 $ret = array();
1459
1460 // Schema 3 is locked and should not be changed.
1461 $schema = panels_schema_3();
1462
1463 db_create_table($ret, 'panels_layout', $schema['panels_layout']);
1464 return $ret;
1465}
1466
1467/**
1468 * Add the panels_renderer_pipeline table
1469 */
1470function panels_update_6309() {
1471 $ret = array();
1472
1473 // Schema 3 is locked and should not be changed.
1474 $schema = panels_schema_3();
1475
1476 db_create_table($ret, 'panels_renderer_pipeline', $schema['panels_renderer_pipeline']);
1477 return $ret;
1478}
1479
1480/**
1481 * Move stylizer data from Panels to CTools.
1482 */
1483function panels_update_6310() {
1484 $ret = array();
1485 // Safety: go away if CTools is not at an appropriate version.
1486 if (!module_invoke('ctools', 'api_version', PANELS_REQUIRED_CTOOLS_API)) {
1487 $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.'));
1488 return $ret;
1489 }
1490
1491 // Enable the stylizer module to make everything as seamless as possible.
1492 drupal_install_modules(array('stylizer'));
1493 return $ret;
1494}