| 1 |
<?php |
<?php |
| 2 |
// $Id: fivestar.install,v 1.1.2.5 2008/03/12 06:57:24 quicksketch Exp $ |
// $Id: fivestar.install,v 1.1.2.6 2008/06/30 03:40:18 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. |
| 85 |
} |
} |
| 86 |
} |
} |
| 87 |
return array(); |
return array(); |
| 88 |
|
} |
| 89 |
|
|
| 90 |
|
|
| 91 |
|
/** |
| 92 |
|
* Update CCK target logic to rename "target" to "php_target". |
| 93 |
|
*/ |
| 94 |
|
function fivestar_update_5703() { |
| 95 |
|
$result = db_query("SELECT field_name, global_settings FROM {node_field} WHERE type = 'fivestar'"); |
| 96 |
|
while ($field = db_fetch_object($result)) { |
| 97 |
|
$settings = unserialize($field->global_settings); |
| 98 |
|
if (!empty($settings['target'])) { |
| 99 |
|
if (is_numeric($settings['target'])) { |
| 100 |
|
// If previously a straight-integer, just add a "return" to the number. |
| 101 |
|
$settings['php_target'] = 'return '. $settings['target'] .';'; |
| 102 |
|
} |
| 103 |
|
else { |
| 104 |
|
// If already PHP code, remove the PHP brackets. |
| 105 |
|
$php = trim($settings['target']); |
| 106 |
|
$php = preg_replace('/^<\?(php)?/', '', $php); |
| 107 |
|
$php = preg_replace('/\?>$/', '', $php); |
| 108 |
|
$settings['php_target'] = $php; |
| 109 |
|
} |
| 110 |
|
} |
| 111 |
|
unset($settings['target']); |
| 112 |
|
unset($settings['php']); |
| 113 |
|
db_query("UPDATE {node_field} SET global_settings = '%s' WHERE field_name = '%s'", serialize($settings), $field->field_name); |
| 114 |
|
} |
| 115 |
|
return array(); |
| 116 |
} |
} |