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