link.install 1.75 KB
Newer Older
Nathan Haug's avatar
Nathan Haug committed
1
2
3
4
5
6
7
<?php
// $Id$

/**
 * Implementation of hook_install().
 */
function link_install() {
8
9
10
11
12
13
14
15
  return;
}

/**
 * Removed link.module created tables, move data to content.module tables
 */
function link_update_1() {
  $ret = array();
Nathan Haug's avatar
Nathan Haug committed
16

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  include_once(drupal_get_path('module', 'content') .'/content.module');
  include_once(drupal_get_path('module', 'content') .'/content_admin.inc');

  $fields = content_fields();

  foreach ($fields as $field) {
    switch ($field['type']) {
      case 'link':
        $columns = array(
          'url' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => "''"),
          'title' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => "''"),
          'attributes' => array('type' => 'mediumtext', 'not null' => TRUE, 'default' => "''"),
        );
        content_alter_db_field(array(), array(), $field, $columns);
        $db_info = content_database_info($field);
        if ($field['multiple']) {
          $ret[] = update_sql('INSERT INTO {'. $db_info['table'] .'} (vid, delta, nid, '. $field['field_name'] .'_url, '. $field['field_name'] .'_title, '. $field['field_name'] ."_attributes) SELECT vid, delta, nid, field_url, field_title, attributes FROM {node_field_link_data} WHERE field_name = '". $field['field_name'] ."'");
        }
        else {
          $ret[] = update_sql('INSERT INTO {'. $db_info['table'] .'} (vid, nid, '. $field['field_name'] .'_url, '. $field['field_name'] .'_title, '. $field['field_name'] ."_attributes) SELECT vid, nid, field_url, field_title, attributes FROM {node_field_link_data} WHERE field_name = '". $field['field_name'] ."'");
        }
    }
Nathan Haug's avatar
Nathan Haug committed
39
  }
40
41
42
43
44

  $ret[] = update_sql('DROP TABLE {node_field_link_data}');
  
  db_query('DELETE FROM {cache}');
  return $ret;
Nathan Haug's avatar
Nathan Haug committed
45
}