Révision 5a7e6170
Ajouté par Florent Torregrosa il y a environ 10 ans
drupal7/sites/all/modules/panels/panels.install | ||
---|---|---|
47 | 47 |
function panels_schema() { |
48 | 48 |
// This should always point to our 'current' schema. This makes it relatively easy |
49 | 49 |
// to keep a record of schema as we make changes to it. |
50 |
return panels_schema_4(); |
|
50 |
return panels_schema_5(); |
|
51 |
} |
|
52 |
|
|
53 |
function panels_schema_5() { |
|
54 |
$schema = panels_schema_4(); |
|
55 |
|
|
56 |
$schema['panels_display']['fields']['uuid'] = array( |
|
57 |
'type' => 'char', |
|
58 |
'length' => '36', |
|
59 |
); |
|
60 |
$schema['panels_display']['export']['key'] = 'uuid'; |
|
61 |
$schema['panels_display']['export']['key name'] = 'UUID'; |
|
62 |
|
|
63 |
$schema['panels_pane']['fields']['uuid'] = array( |
|
64 |
'type' => 'char', |
|
65 |
'length' => '36', |
|
66 |
); |
|
67 |
$schema['panels_pane']['export']['key'] = 'uuid'; |
|
68 |
$schema['panels_pane']['export']['key name'] = 'UUID'; |
|
69 |
|
|
70 |
return $schema; |
|
51 | 71 |
} |
52 | 72 |
|
53 | 73 |
function panels_schema_4() { |
... | ... | |
331 | 351 |
'primary key' => array('lid'), |
332 | 352 |
); |
333 | 353 |
|
354 |
$schema['cache_panels'] = drupal_get_schema_unprocessed('system', 'cache'); |
|
355 |
|
|
334 | 356 |
return $schema; |
335 | 357 |
} |
336 | 358 |
|
... | ... | |
375 | 397 |
|
376 | 398 |
return t('panels_pane.lock field already existed, update skipped.'); |
377 | 399 |
} |
400 |
|
|
401 |
/** |
|
402 |
* Adding universally unique identifiers to panels. |
|
403 |
*/ |
|
404 |
function panels_update_7302() { |
|
405 |
// Load the schema. |
|
406 |
$schema = panels_schema_5(); |
|
407 |
$msg = array(); |
|
408 |
|
|
409 |
// Add the uuid column to the pane table. |
|
410 |
$table = 'panels_pane'; |
|
411 |
$field = 'uuid'; |
|
412 |
// Due to a previous failure, the column may already exist: |
|
413 |
if (!db_field_exists($table, $field)) { |
|
414 |
$spec = $schema[$table]['fields'][$field]; |
|
415 |
db_add_field($table, $field, $spec); |
|
416 |
$msg[] = t('Added panels_pane.uuid column.'); |
|
417 |
} |
|
418 |
|
|
419 |
// Add the uuid column to the display table. |
|
420 |
$table = 'panels_display'; |
|
421 |
$field = 'uuid'; |
|
422 |
// Due to a previous failure, the column may already exist: |
|
423 |
if (!db_field_exists($table, $field)) { |
|
424 |
$spec = $schema[$table]['fields'][$field]; |
|
425 |
db_add_field($table, $field, $spec); |
|
426 |
$msg[] = t('Added panels_display.uuid column.'); |
|
427 |
} |
|
428 |
|
|
429 |
if (empty($msg)) { |
|
430 |
$msg[] = t('UUID column already present in the panels_display & panels_pane tables.'); |
|
431 |
} |
|
432 |
|
|
433 |
// Update all DB-based panes & displays to ensure that they all contain a UUID. |
|
434 |
$display_dids = db_select('panels_display') |
|
435 |
->fields('panels_display', array('did')) |
|
436 |
->condition(db_or() |
|
437 |
->condition('uuid', '') |
|
438 |
->isNull('uuid') |
|
439 |
) |
|
440 |
->execute() |
|
441 |
->fetchCol(); |
|
442 |
|
|
443 |
// Check the panes as well, for paranoia. |
|
444 |
$pane_dids = db_select('panels_pane') |
|
445 |
->distinct() |
|
446 |
->fields('panels_pane', array('did')) |
|
447 |
->condition(db_or() |
|
448 |
->condition('uuid', '') |
|
449 |
->isNull('uuid') |
|
450 |
) |
|
451 |
->execute() |
|
452 |
->fetchCol(); |
|
453 |
|
|
454 |
$dids = array_unique(array_merge($display_dids, $pane_dids)); |
|
455 |
|
|
456 |
if ($displays = panels_load_displays($dids)) { |
|
457 |
foreach ($displays as $display) { |
|
458 |
// A display save also triggers pane saves. |
|
459 |
panels_save_display($display); |
|
460 |
} |
|
461 |
$msg[] = t('Generated UUIDs for database-based panel displays and panes.'); |
|
462 |
} |
|
463 |
else { |
|
464 |
$msg[] = t('No database-based panel displays or panes for which to generate UUIDs.'); |
|
465 |
} |
|
466 |
|
|
467 |
return implode("\n", $msg); |
|
468 |
} |
|
469 |
|
|
470 |
/** |
|
471 |
* Add a custom cache table for Panels. |
|
472 |
*/ |
|
473 |
function panels_update_7303() { |
|
474 |
$table_name = 'cache_panels'; |
|
475 |
if (!db_table_exists($table_name)) { |
|
476 |
$schema = drupal_get_schema_unprocessed('system', 'cache'); |
|
477 |
db_create_table($table_name, $schema); |
|
478 |
} |
|
479 |
} |
Formats disponibles : Unified diff
Update :