| 1 |
<?php |
<?php |
| 2 |
// $Id: fivestar.install,v 1.5.2.5 2008/04/19 05:59:17 quicksketch Exp $ |
// $Id: fivestar.install,v 1.5.2.6 2008/06/30 03:40:15 quicksketch Exp $ |
| 3 |
|
|
| 4 |
// Get the current schema so that updates that have already run for 5 don't get |
// Get the current schema so that updates that have already run for 5 don't get |
| 5 |
// run a second time when upgrading to 6. |
// run a second time when upgrading to 6. |
| 139 |
} |
} |
| 140 |
} |
} |
| 141 |
return array(); |
return array(); |
| 142 |
|
} |
| 143 |
|
|
| 144 |
|
/** |
| 145 |
|
* Update CCK target logic to rename "target" to "php_target". |
| 146 |
|
*/ |
| 147 |
|
function fivestar_update_6104() { |
| 148 |
|
// Previously ran as fivestar_update_5703 on Drupal 5. |
| 149 |
|
if (FIVESTAR_VERSION >= 6100) { |
| 150 |
|
$result = db_query("SELECT field_name, global_settings FROM {content_node_field} WHERE type = 'fivestar'"); |
| 151 |
|
while ($field = db_fetch_object($result)) { |
| 152 |
|
$settings = unserialize($field->global_settings); |
| 153 |
|
if (!empty($settings['target'])) { |
| 154 |
|
if (is_numeric($settings['target'])) { |
| 155 |
|
// If previously a straight integer, just add a "return" to the number. |
| 156 |
|
$settings['php_target'] = 'return '. $settings['target']; |
| 157 |
|
} |
| 158 |
|
else { |
| 159 |
|
// If already PHP code, remove the PHP brackets. |
| 160 |
|
$php = trim($settings['target']); |
| 161 |
|
$php = preg_replace('/^<\?(php)?/', '', $php); |
| 162 |
|
$php = preg_replace('/\?>$/', '', $php); |
| 163 |
|
$settings['php_target'] = $php; |
| 164 |
|
} |
| 165 |
|
} |
| 166 |
|
unset($settings['target']); |
| 167 |
|
unset($settings['php']); |
| 168 |
|
db_query("UPDATE {content_node_field} SET global_settings = '%s' WHERE field_name = '%s'", serialize($settings), $field->field_name); |
| 169 |
|
} |
| 170 |
|
} |
| 171 |
|
return array(); |
| 172 |
} |
} |