#231335. Adding token support.
[project/link.git] / link.install
CommitLineData
f695ec1c
NH
1<?php
2// $Id$
3
4/**
5 * Implementation of hook_install().
6 */
7function link_install() {
f35cf48f
NH
8 content_notify('install', 'link');
9}
10
11/**
12* Implementation of hook_uninstall().
13*/
14function link_uninstall() {
15 content_notify('uninstall', 'link');
16}
17
18/**
19* Implementation of hook_enable().
20*/
21function link_enable() {
22 content_notify('enable', 'link');
23}
24
25/**
26* Implementation of hook_disable().
27*/
28function link_disable() {
29 content_notify('disable', 'link');
d31c2959
NH
30}
31
32/**
33 * Removed link.module created tables, move data to content.module tables
34 */
35function link_update_1() {
36 $ret = array();
f695ec1c 37
d31c2959
NH
38 include_once(drupal_get_path('module', 'content') .'/content.module');
39 include_once(drupal_get_path('module', 'content') .'/content_admin.inc');
40
41 $fields = content_fields();
42
43 foreach ($fields as $field) {
44 switch ($field['type']) {
45 case 'link':
46 $columns = array(
47 'url' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => "''"),
48 'title' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => "''"),
8509ca14 49 'attributes' => array('type' => 'mediumtext', 'not null' => FALSE),
d31c2959
NH
50 );
51 content_alter_db_field(array(), array(), $field, $columns);
52 $db_info = content_database_info($field);
53 if ($field['multiple']) {
54 $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'] ."'");
55 }
56 else {
8509ca14 57 $ret[] = update_sql('UPDATE {'. $db_info['table'] .'} c, {node_field_link_data} l SET c.'. $field['field_name'] .'_url = l.field_url, c.'. $field['field_name'] .'_title = l.field_title, c.'. $field['field_name'] ."_attributes = l.attributes WHERE l.field_name = '". $field['field_name'] ."' AND c.vid = l.vid AND c.nid = l.nid");
d31c2959
NH
58 }
59 }
f695ec1c 60 }
d31c2959
NH
61
62 $ret[] = update_sql('DROP TABLE {node_field_link_data}');
8509ca14 63
d31c2959
NH
64 db_query('DELETE FROM {cache}');
65 return $ret;
f695ec1c 66}