| 1 |
<?php |
<?php |
| 2 |
|
|
| 3 |
// $Id$ |
// $Id: voting_actions.install,v 1.5.2.1 2007/04/17 21:59:36 eaton Exp $ |
| 4 |
|
|
| 5 |
function voting_actions_install() { |
function voting_actions_install() { |
| 6 |
switch ($GLOBALS['db_type']) { |
switch ($GLOBALS['db_type']) { |
| 92 |
return $ret; |
return $ret; |
| 93 |
} |
} |
| 94 |
|
|
| 95 |
|
// Major schema update. Converts old 4.7 era tables to the new 5.0v2 schema. |
| 96 |
|
function voting_actions_update_5200() { |
| 97 |
|
// First trigger the install function to build a clean set of tables. |
| 98 |
|
voting_actions_install(); |
| 99 |
|
|
| 100 |
|
$sets = array(); |
| 101 |
|
$action_sets = db_query("SELECT * FROM {voting_actions}"); |
| 102 |
|
while ($old_set = db_fetch_array($action_sets)) { |
| 103 |
|
$new_set = array(); |
| 104 |
|
$new_set = _voting_actions_populate_set_defaults(); |
| 105 |
|
$new_set['name'] = strtolower(form_clean_id($old_set['name'])); |
| 106 |
|
|
| 107 |
|
$criteria_set = db_query("SELECT * FROM {voting_actions_conditions} WHERE vasid = %d", $old_set['vasid']); |
| 108 |
|
while ($old_crit = db_fetch_array($criteria_set)) { |
| 109 |
|
$new_criteria = array(); |
| 110 |
|
|
| 111 |
|
$new_criteria['name'] = 'vote_result'; |
| 112 |
|
$new_criteria['data']['value_type'] = $old_crit['value_type']; |
| 113 |
|
$new_criteria['data']['tag'] = $old_crit['tag']; |
| 114 |
|
$new_criteria['data']['function'] = $old_crit['function']; |
| 115 |
|
$new_criteria['data']['operation'] = $old_crit['comparison']; |
| 116 |
|
$new_criteria['data']['value'] = $old_crit['value']; |
| 117 |
|
|
| 118 |
|
$new_set['criteria'][] = $new_criteria; |
| 119 |
|
} |
| 120 |
|
|
| 121 |
|
$actions = db_query("SELECT * FROM {voting_actions_actions} WHERE vasid = %d", $old_set['vasid']); |
| 122 |
|
while ($old_action = db_fetch_array($actions)) { |
| 123 |
|
$new_set['actions'][] = $old_action['aid']; |
| 124 |
|
} |
| 125 |
|
$sets[] = $new_set; |
| 126 |
|
} |
| 127 |
|
|
| 128 |
|
foreach($sets as $set_to_save) { |
| 129 |
|
_voting_actions_insert_set($set_to_save); |
| 130 |
|
} |
| 131 |
|
|
| 132 |
|
// Now drop the old tables. |
| 133 |
|
db_query("DROP TABLE {voting_actions_sets}"); |
| 134 |
|
db_query("DROP TABLE {voting_actions_conditions}"); |
| 135 |
|
db_query("DROP TABLE {voting_actions_actions}"); |
| 136 |
|
} |
| 137 |
|
|
| 138 |
|
|
| 139 |
function voting_actions_uninstall() { |
function voting_actions_uninstall() { |
| 140 |
db_query("DROP TABLE {voting_actions_set}"); |
db_query("DROP TABLE {voting_actions_set}"); |
| 141 |
db_query("DROP TABLE {voting_actions_condition}"); |
db_query("DROP TABLE {voting_actions_condition}"); |
| 142 |
db_query("DROP TABLE {voting_actions_action}"); |
db_query("DROP TABLE {voting_actions_action}"); |
|
} |
|
|
|
|
|
/** |
|
|
*This space reserved for the migration from voting_actions 1 to voting_actions 2. |
|
|
function voting_actions_update_5200() { |
|
|
// Stuff! Stuff should happen here! |
|
|
} |
|
|
*/ |
|
| 143 |
|
} |