$name) { $style = variable_get('fivestar_style_'. $key, 'default'); $enabled = variable_get('fivestar_'. $key, FALSE); // Split the display style into two variables for stars and text. if ($enabled) { switch ($style) { case 'default': variable_set('fivestar_style_'. $key, 'user'); variable_set('fivestar_text_'. $key, 'average'); break; case 'compact': variable_set('fivestar_style_'. $key, 'user'); variable_set('fivestar_text_'. $key, 'none'); break; case 'dual': variable_set('fivestar_text_'. $key, 'none'); break; } } // We no longer save any settings if Fivestar is disabled. else { variable_del('fivestar_unvote_'. $key); variable_del('fivestar_style_'. $key); variable_del('fivestar_position_'. $key); variable_del('fivestar_position_teaser_'. $key); } } return array(); } /** * Upgrade to Drupal 6 and VotingAPI 2. * * Remove anonymous vote interval from Fivestar, now handled by VotingAPI. */ function fivestar_update_6100() { // If using CCK, make sure it has updated first. if (function_exists('content_check_update') && ($abort = content_check_update('fivestar'))) { return $abort; } $ret = array(); variable_del('fivestar_anonymous_vote_interval'); $ret[] = array('success' => TRUE, 'query' => "variable_del('fivestar_anonymous_vote_interval')"); return $ret; } /** * Add vote_id column to the fivestar_comment table. */ function fivestar_update_6101() { // Moved to fivestar_commment_update_6100(). return array(); } /** * Set Fivestar weight to -1 so that it can load before content.module. */ function fivestar_update_6102() { $ret = array(); // This update will already be run as fivestar_update_5701 on Drupal 5. if (fivestar_update_version() >= 6100) { $ret[] = update_sql("UPDATE {system} SET weight = -1 WHERE type = 'module' AND name = 'fivestar'"); } return $ret; } /** * Move comment support to a separate module. */ function fivestar_update_6103() { // Comment support was added in schema version 1. if (fivestar_update_version() >= 6100) { // Enable the module, but don't run the install hook (tables already exist). if (module_exists('comment')) { module_rebuild_cache(); module_enable(array('fivestar_comment')); $version = array_pop(drupal_get_schema_versions('fivestar_comment')); drupal_set_installed_schema_version('fivestar_comment', $version); module_rebuild_cache(); } // If the comment table needs an update, run fivestar_comment_update_5100(). if (fivestar_update_version() < 6101) { module_load_install('fivestar_comment'); fivestar_comment_update_6100(); } } return array(); } /** * Update CCK target logic to rename "target" to "php_target". */ function fivestar_update_6104() { // Previously ran as fivestar_update_5703 on Drupal 5. // Also, don't run this update if CCK is not enabled. if (fivestar_update_version() >= 6100 && module_exists('content')) { $result = db_query("SELECT field_name, global_settings FROM {content_node_field} WHERE type = 'fivestar'"); while ($field = db_fetch_object($result)) { $settings = unserialize($field->global_settings); if (!empty($settings['target'])) { if (is_numeric($settings['target'])) { // If previously a straight integer, just add a "return" to the number. $settings['php_target'] = 'return '. $settings['target']; } else { // If already PHP code, remove the PHP brackets. $php = trim($settings['target']); $php = preg_replace('/^<\?(php)?/', '', $php); $php = preg_replace('/\?>$/', '', $php); $settings['php_target'] = $php; } } unset($settings['target']); unset($settings['php']); db_query("UPDATE {content_node_field} SET global_settings = '%s' WHERE field_name = '%s'", serialize($settings), $field->field_name); } } return array(); } /** * Belated update for Drupal 6: Re-enable Fivestar CCK fields. */ function fivestar_update_6105() { $ret = array(); if (!module_exists('content')) { $ret[] = array('success' => TRUE, 'query' => t('CCK is not installed. No update ran.')); return $ret; } if ($abort = content_check_update('fivestar')) { return $abort; } // All CCK fields are disabled by Content module during the D6 upgrade. // Re-enable the Fivestar fields. module_load_include('inc', 'fivestar', 'fivestar_field'); content_associate_fields('fivestar'); $ret[] = array('success' => TRUE, 'query' => t('Re-enabled Fivestar CCK fields.')); return $ret; }