.pot, tag DRUPAL-6--2-6
[project/link.git] / link.install
1 <?php
2 // $Id$
3
4 /**
5 * Implementation of hook_install().
6 */
7 function link_install() {
8 content_notify('install', 'link');
9 }
10
11 /**
12 * Implementation of hook_uninstall().
13 */
14 function link_uninstall() {
15 content_notify('uninstall', 'link');
16 }
17
18 /**
19 * Implementation of hook_enable().
20 */
21 function link_enable() {
22 content_notify('enable', 'link');
23 }
24
25 /**
26 * Implementation of hook_disable().
27 */
28 function link_disable() {
29 content_notify('disable', 'link');
30 }
31
32 /**
33 * Removed link.module created tables, move data to content.module tables
34 */
35 function link_update_1() {
36 $ret = array();
37
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' => "''"),
49 'attributes' => array('type' => 'mediumtext', 'not null' => FALSE),
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 {
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");
58 }
59 }
60 }
61
62 $ret[] = update_sql('DROP TABLE {node_field_link_data}');
63
64 db_query('DELETE FROM {cache}');
65 return $ret;
66 }