summaryrefslogtreecommitdiffstats
path: root/link.install
blob: 178b9959fca7203b84f7b010feeaf392ac3f1f63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php

/**
 * @file
 * Install file for the link module.
 */

/**
 * Implementation of hook_install().
 */
function link_install() {
  drupal_load('module', 'content');
  content_notify('install', 'link');
}

/**
* Implementation of hook_uninstall().
*/
function link_uninstall() {
  drupal_load('module', 'content');
  content_notify('uninstall', 'link');
}

/**
* Implementation of hook_enable().
*/
function link_enable() {
  drupal_load('module', 'content');
  content_notify('enable', 'link');
}

/**
* Implementation of hook_disable().
*/
function link_disable() {
  drupal_load('module', 'content');
  content_notify('disable', 'link');
}

/**
 * Removed link.module created tables, move data to content.module tables
 *
 * Even though most everyone will not be using this particular update, several
 * folks have complained that their upgrades of link.module do not work because
 * of this function being missing when schema expects it. - JCF
 * And on further review, I'm removing the body, since some of those calls
 * no longer exist in Drupal 6.  Remember to upgrade from 4.7 to 5 first, and
 * *then* from 5 to 6.  kthx! -JCF
 */
function link_update_1() {
  $ret = array();
  // GNDN
  return $ret;
}


/**
 * Ensure that content.module is updated before link module.
 */
function link_update_6000() {
  if ($abort = content_check_update('link')) {
    return $abort;
  }
  return array();
}

/**
 * Change the database schema to allow NULL values.
 */
function link_update_6001() {
  $ret = array();
  
  // Build a list of fields that need updating.
  $update_fields = array();
  foreach (content_types_install() as $type_name => $fields) {
    foreach ($fields as $field) {
      if ($field['type'] == 'link') {
        // We only process a given field once.
        $update_fields[$field['field_name']] = $field;
      }
    }
  }
  
  // Update each field's storage to match the current definition.
  foreach ($update_fields as $field) {
    $db_info = content_database_info($field);
    foreach ($db_info['columns'] as $column) {
      db_change_field($ret, $db_info['table'], $column['column'], $column['column'], $column);
      $ret[] = update_sql("UPDATE {". $db_info['table'] ."} SET ". $column['column'] ." = NULL WHERE ". $column['column'] ." = '' OR ". $column['column'] ." = 'N;'");
    }
  }
  
  // Let CCK re-associate link fields with Link module and activate the fields.
  content_associate_fields('link');
  
  return $ret;
}