source: sipes/modules_contrib/link/link.install @ c43ea01

stableversion-3.0
Last change on this file since c43ea01 was cd414e9, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se actualizo el modulo

  • Propiedad mode establecida a 100755
File size: 3.9 KB
Línea 
1<?php
2
3/**
4 * @file
5 * Install file for the link module.
6 */
7
8/**
9 * Implementation of hook_install().
10 */
11function link_install() {
12  drupal_load('module', 'content');
13  content_notify('install', 'link');
14}
15
16/**
17* Implementation of hook_uninstall().
18*/
19function link_uninstall() {
20  drupal_load('module', 'content');
21  content_notify('uninstall', 'link');
22}
23
24/**
25* Implementation of hook_enable().
26*/
27function link_enable() {
28  drupal_load('module', 'content');
29  content_notify('enable', 'link');
30}
31
32/**
33* Implementation of hook_disable().
34*/
35function link_disable() {
36  drupal_load('module', 'content');
37  content_notify('disable', 'link');
38}
39
40/**
41 * Removed link.module created tables, move data to content.module tables
42 *
43 * Even though most everyone will not be using this particular update, several
44 * folks have complained that their upgrades of link.module do not work because
45 * of this function being missing when schema expects it. - JCF
46 * And on further review, I'm removing the body, since some of those calls
47 * no longer exist in Drupal 6.  Remember to upgrade from 4.7 to 5 first, and
48 * *then* from 5 to 6.  kthx! -JCF
49 */
50function link_update_1() {
51  $ret = array();
52  // GNDN
53  return $ret;
54}
55
56
57/**
58 * Ensure that content.module is updated before link module.
59 */
60function link_update_6000() {
61  if ($abort = content_check_update('link')) {
62    return $abort;
63  }
64  return array();
65}
66
67/**
68 * Change the database schema to allow NULL values.
69 */
70function link_update_6001() {
71  $ret = array();
72 
73  // Build a list of fields that need updating.
74  $update_fields = array();
75  foreach (content_types_install() as $type_name => $fields) {
76    foreach ($fields as $field) {
77      if ($field['type'] == 'link') {
78        // We only process a given field once.
79        $update_fields[$field['field_name']] = $field;
80      }
81    }
82  }
83 
84  // Update each field's storage to match the current definition.
85  foreach ($update_fields as $field) {
86    $db_info = content_database_info($field);
87    foreach ($db_info['columns'] as $column) {
88      db_change_field($ret, $db_info['table'], $column['column'], $column['column'], $column);
89      $ret[] = update_sql("UPDATE {". $db_info['table'] ."} SET ". $column['column'] ." = NULL WHERE ". $column['column'] ." = '' OR ". $column['column'] ." = 'N;'");
90    }
91  }
92 
93  // Let CCK re-associate link fields with Link module and activate the fields.
94  content_associate_fields('link');
95 
96  return $ret;
97}
98
99/**
100 * 6.x-2.7 had code that mistakenly wrote 'a:3:{s:6:"target";s:7:"default";s:5:"class";s:0:"";s:3:"rel";s:0:"";}'
101 * to the attributes field, when it should have written NULL.
102 *
103 * This fixes that.  Ticket #626932.
104 */
105function link_update_6002() {
106  $ret = array();
107 
108  // Build a list of fields that need updating.
109  $update_fields = array();
110  foreach (content_types_install() as $type_name => $fields) {
111    foreach ($fields as $field) {
112      if ($field['type'] == 'link') {
113        // We only process a given field once.
114        $update_fields[$field['field_name']] = $field;
115      }
116    }
117  }
118 
119  // Update each field's storage to match the current definition.
120  foreach ($update_fields as $field) {
121    $db_info = content_database_info($field);
122    foreach ($db_info['columns'] as $column) {
123      //db_change_field($ret, $db_info['table'], $column['column'], $column['column'], $column);
124      if (preg_match('/_attributes$/', $column['column'])) {
125        //we can't use update_sql, because it doesn't handle serialized data.
126        $sql = "UPDATE {". $db_info['table'] ."} SET ". $column['column'] ." = NULL WHERE ". $column['column'] ." = '%s'";
127        $result = db_query($sql, 'a:3:{s:6:"target";s:7:"default";s:5:"class";s:0:"";s:3:"rel";s:0:"";}');
128        $ret[] = array('success' => $result !== FALSE, 'query' => check_plain($sql));
129      }
130    }
131  }
132 
133  // Let CCK re-associate link fields with Link module and activate the fields.
134  content_associate_fields('link');
135 
136  return $ret;
137}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.