| 1 |
<?php |
<?php |
| 2 |
// $Id: taxonomy_dss.install,v 1.7 2007/04/05 21:57:46 moonray Exp $ |
// $Id: taxonomy_dss.install,v 1.8 2007/06/21 20:41:44 moonray Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file taxonomy_dss.install |
* @file taxonomy_dss.install |
| 15 |
case 'mysql': |
case 'mysql': |
| 16 |
case 'mysqli': |
case 'mysqli': |
| 17 |
db_query("CREATE TABLE {taxonomy_dss_term} ( |
db_query("CREATE TABLE {taxonomy_dss_term} ( |
| 18 |
tid VARCHAR(32) NOT NULL DEFAULT '', |
tids VARCHAR(32) NOT NULL DEFAULT '', |
| 19 |
nid INT(10) UNSIGNED NOT NULL DEFAULT 0, |
nid INT(10) UNSIGNED NOT NULL DEFAULT 0, |
| 20 |
|
vid INT(10) UNSIGNED NOT NULL DEFAULT 0, |
| 21 |
hidden TINYINT UNSIGNED NOT NULL DEFAULT 0, |
hidden TINYINT UNSIGNED NOT NULL DEFAULT 0, |
| 22 |
toc_hidden TINYINT UNSIGNED NOT NULL DEFAULT 0, |
toc_hidden TINYINT UNSIGNED NOT NULL DEFAULT 0, |
| 23 |
toc_depth TINYINT NOT NULL DEFAULT -1, |
toc_depth TINYINT NOT NULL DEFAULT -1, |
| 51 |
'type' => 'term', |
'type' => 'term', |
| 52 |
'name' => t('Term'), |
'name' => t('Term'), |
| 53 |
'module' => 'node', |
'module' => 'node', |
| 54 |
'description' => t('Special pages for taxonomy terms. Used by Taxonomy Groups module.'), |
'description' => t('Special pages for taxonomy terms. Used by Taxonomy DSS module.'), |
| 55 |
'has_title' => FALSE, |
'has_title' => FALSE, |
| 56 |
'custom' => FALSE, |
'custom' => FALSE, |
| 57 |
'modified' => TRUE, |
'modified' => TRUE, |
| 89 |
'type' => 'term', |
'type' => 'term', |
| 90 |
'name' => t('Term'), |
'name' => t('Term'), |
| 91 |
'module' => 'node', |
'module' => 'node', |
| 92 |
'description' => t('Special pages for taxonomy terms. Used by Taxonomy Groups module.'), |
'description' => t('Special pages for taxonomy terms. Used by Taxonomy DSS module.'), |
| 93 |
'custom' => TRUE, |
'custom' => TRUE, |
| 94 |
'has_title' => FALSE, |
'has_title' => FALSE, |
| 95 |
'modified' => TRUE, |
'modified' => TRUE, |
| 163 |
|
|
| 164 |
return $ret; |
return $ret; |
| 165 |
} |
} |
| 166 |
|
|
| 167 |
|
function taxonomy_dss_update_8() { |
| 168 |
|
$ret = array(); |
| 169 |
|
|
| 170 |
|
// Update termset type |
| 171 |
|
$type = array( |
| 172 |
|
'old_type' => 'term', |
| 173 |
|
'type' => 'termset', |
| 174 |
|
'name' => t('Termset'), |
| 175 |
|
'module' => 'taxonomy_dss', |
| 176 |
|
'description' => t('Special pages for taxonomy terms. Used by Taxonomy DSS module.'), |
| 177 |
|
'custom' => FALSE, |
| 178 |
|
'has_title' => FALSE, |
| 179 |
|
'modified' => FALSE, |
| 180 |
|
'locked' => TRUE, |
| 181 |
|
'existing_type' => 'termset', |
| 182 |
|
); |
| 183 |
|
|
| 184 |
|
$type = (object) _node_type_set_defaults($type); |
| 185 |
|
$ret[] = node_type_save($type); |
| 186 |
|
|
| 187 |
|
// Update termset type in nodes |
| 188 |
|
$ret[] = update_sql("UPDATE {node} SET type = 'termset' WHERE type = 'term'"); |
| 189 |
|
|
| 190 |
|
// Update tid field to tids |
| 191 |
|
$ret[] = update_sql("ALTER TABLE {taxonomy_dss_term} CHANGE tid tids VARCHAR(32) NOT NULL DEFAULT ''"); |
| 192 |
|
|
| 193 |
|
// Add vid field |
| 194 |
|
$ret[] = update_sql("ALTER TABLE {taxonomy_dss_term} ADD COLUMN vid INT(10) UNSIGNED NOT NULL DEFAULT 0 AFTER nid;"); |
| 195 |
|
|
| 196 |
|
// Update termset data to include vid |
| 197 |
|
$ret[] = update_sql("UPDATE {taxonomy_dss_term} SET vid = (SELECT vid FROM {node} WHERE {node}.nid = {taxonomy_dss_term}.nid)"); |
| 198 |
|
|
| 199 |
|
// Update primary key |
| 200 |
|
$ret[] = update_sql("ALTER TABLE {taxonomy_dss_term} DROP PRIMARY KEY, ADD PRIMARY KEY (vid)"); |
| 201 |
|
|
| 202 |
|
// Need to add path aliasing to all termset nodes |
| 203 |
|
$result = db_query("SELECT tids, nid FROM {taxonomy_dss_term}"); |
| 204 |
|
while ($row = db_fetch_array($result)) { |
| 205 |
|
path_set_alias('node/'. $row['nid'], 'taxonomy/term/'. $row['tids']); |
| 206 |
|
} |
| 207 |
|
|
| 208 |
|
return $ret; |
| 209 |
|
} |