| 1 |
<?php |
<?php |
| 2 |
// $Id: category.install,v 1.20 2009/03/05 22:23:54 jaza Exp $ |
// $Id: category.install,v 1.21 2009/05/31 10:21:06 jaza Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 97 |
*/ |
*/ |
| 98 |
function category_schema() { |
function category_schema() { |
| 99 |
$schema['category'] = array( |
$schema['category'] = array( |
| 100 |
'description' => t('Stores category information.'), |
'description' => 'Stores category information.', |
| 101 |
'fields' => array( |
'fields' => array( |
| 102 |
'cid' => array( |
'cid' => array( |
| 103 |
'type' => 'int', |
'type' => 'int', |
| 104 |
'unsigned' => TRUE, |
'unsigned' => TRUE, |
| 105 |
'not null' => TRUE, |
'not null' => TRUE, |
| 106 |
'default' => 0, |
'default' => 0, |
| 107 |
'description' => t("Primary key: The category's {node}.nid."), |
'description' => "Primary key: The category's {node}.nid.", |
| 108 |
), |
), |
| 109 |
'cnid' => array( |
'cnid' => array( |
| 110 |
'type' => 'int', |
'type' => 'int', |
| 111 |
'unsigned' => TRUE, |
'unsigned' => TRUE, |
| 112 |
'not null' => TRUE, |
'not null' => TRUE, |
| 113 |
'default' => 0, |
'default' => 0, |
| 114 |
'description' => t('The {category_cont}.cid of the container to which the category is assigned. (0 = category is a container)'), |
'description' => 'The {category_cont}.cid of the container to which the category is assigned. (0 = category is a container)', |
| 115 |
), |
), |
| 116 |
'weight' => array( |
'weight' => array( |
| 117 |
'type' => 'int', |
'type' => 'int', |
| 118 |
'not null' => TRUE, |
'not null' => TRUE, |
| 119 |
'default' => 0, |
'default' => 0, |
| 120 |
'size' => 'tiny', |
'size' => 'tiny', |
| 121 |
'description' => t('The weight of this category in relation to other categories.'), |
'description' => 'The weight of this category in relation to other categories.', |
| 122 |
), |
), |
| 123 |
'depth' => array( |
'depth' => array( |
| 124 |
'type' => 'int', |
'type' => 'int', |
| 125 |
'not null' => TRUE, |
'not null' => TRUE, |
| 126 |
'default' => 0, |
'default' => 0, |
| 127 |
'size' => 'tiny', |
'size' => 'tiny', |
| 128 |
'description' => t('The depth of child categories that are reflected in node listings for this category.'), |
'description' => 'The depth of child categories that are reflected in node listings for this category.', |
| 129 |
), |
), |
| 130 |
), |
), |
| 131 |
'primary key' => array('cid'), |
'primary key' => array('cid'), |
| 136 |
); |
); |
| 137 |
|
|
| 138 |
$schema['category_hierarchy'] = array( |
$schema['category_hierarchy'] = array( |
| 139 |
'description' => t('Stores the hierarchical relationship between categories.'), |
'description' => 'Stores the hierarchical relationship between categories.', |
| 140 |
'fields' => array( |
'fields' => array( |
| 141 |
'cid' => array( |
'cid' => array( |
| 142 |
'type' => 'int', |
'type' => 'int', |
| 143 |
'unsigned' => TRUE, |
'unsigned' => TRUE, |
| 144 |
'not null' => TRUE, |
'not null' => TRUE, |
| 145 |
'default' => 0, |
'default' => 0, |
| 146 |
'description' => t('Primary Key: The {category}.cid of the category.'), |
'description' => 'Primary Key: The {category}.cid of the category.', |
| 147 |
), |
), |
| 148 |
'parent' => array( |
'parent' => array( |
| 149 |
'type' => 'int', |
'type' => 'int', |
| 150 |
'unsigned' => TRUE, |
'unsigned' => TRUE, |
| 151 |
'not null' => TRUE, |
'not null' => TRUE, |
| 152 |
'default' => 0, |
'default' => 0, |
| 153 |
'description' => t("Primary Key: The {category}.cid of the category's parent. 0 indicates no parent."), |
'description' => "Primary Key: The {category}.cid of the category's parent. 0 indicates no parent.", |
| 154 |
), |
), |
| 155 |
), |
), |
| 156 |
'primary key' => array('cid', 'parent'), |
'primary key' => array('cid', 'parent'), |
| 160 |
); |
); |
| 161 |
|
|
| 162 |
$schema['category_node'] = array( |
$schema['category_node'] = array( |
| 163 |
'description' => t('Stores the relationship of categories to nodes.'), |
'description' => 'Stores the relationship of categories to nodes.', |
| 164 |
'fields' => array( |
'fields' => array( |
| 165 |
'nid' => array( |
'nid' => array( |
| 166 |
'type' => 'int', |
'type' => 'int', |
| 167 |
'unsigned' => TRUE, |
'unsigned' => TRUE, |
| 168 |
'not null' => TRUE, |
'not null' => TRUE, |
| 169 |
'default' => 0, |
'default' => 0, |
| 170 |
'description' => t('Primary Key: The {node}.nid of the node.'), |
'description' => 'The {node}.nid of the node.', |
| 171 |
), |
), |
| 172 |
'vid' => array( |
'vid' => array( |
| 173 |
'type' => 'int', |
'type' => 'int', |
| 174 |
'unsigned' => TRUE, |
'unsigned' => TRUE, |
| 175 |
'not null' => TRUE, |
'not null' => TRUE, |
| 176 |
'default' => 0, |
'default' => 0, |
| 177 |
'description' => t('Primary Key: The {node}.vid of the node.'), |
'description' => 'Primary Key: The {node}.vid of the node.', |
| 178 |
), |
), |
| 179 |
'cid' => array( |
'cid' => array( |
| 180 |
'type' => 'int', |
'type' => 'int', |
| 181 |
'unsigned' => TRUE, |
'unsigned' => TRUE, |
| 182 |
'not null' => TRUE, |
'not null' => TRUE, |
| 183 |
'default' => 0, |
'default' => 0, |
| 184 |
'description' => t('Primary Key: The {category}.cid of a category assigned to the node.'), |
'description' => 'Primary Key: The {category}.cid of a category assigned to the node.', |
| 185 |
), |
), |
| 186 |
), |
), |
| 187 |
'primary key' => array('cid', 'vid'), |
'primary key' => array('cid', 'vid'), |
| 192 |
); |
); |
| 193 |
|
|
| 194 |
$schema['category_relation'] = array( |
$schema['category_relation'] = array( |
| 195 |
'description' => t('Stores non-hierarchical relationships between categories.'), |
'description' => 'Stores non-hierarchical relationships between categories.', |
| 196 |
'fields' => array( |
'fields' => array( |
| 197 |
'crid' => array( |
'crid' => array( |
| 198 |
'type' => 'serial', |
'type' => 'serial', |
| 199 |
'not null' => TRUE, |
'not null' => TRUE, |
| 200 |
'description' => t('Primary Key: Unique category relation ID.'), |
'description' => 'Primary Key: Unique category relation ID.', |
| 201 |
), |
), |
| 202 |
'cid1' => array( |
'cid1' => array( |
| 203 |
'type' => 'int', |
'type' => 'int', |
| 204 |
'unsigned' => TRUE, |
'unsigned' => TRUE, |
| 205 |
'not null' => TRUE, |
'not null' => TRUE, |
| 206 |
'default' => 0, |
'default' => 0, |
| 207 |
'description' => t('The {category}.cid of the first category in a relationship.'), |
'description' => 'The {category}.cid of the first category in a relationship.', |
| 208 |
), |
), |
| 209 |
'cid2' => array( |
'cid2' => array( |
| 210 |
'type' => 'int', |
'type' => 'int', |
| 211 |
'unsigned' => TRUE, |
'unsigned' => TRUE, |
| 212 |
'not null' => TRUE, |
'not null' => TRUE, |
| 213 |
'default' => 0, |
'default' => 0, |
| 214 |
'description' => t('The {category}.cid of the second category in a relationship.'), |
'description' => 'The {category}.cid of the second category in a relationship.', |
| 215 |
), |
), |
| 216 |
), |
), |
| 217 |
'primary key' => array('crid'), |
'primary key' => array('crid'), |
| 224 |
); |
); |
| 225 |
|
|
| 226 |
$schema['category_synonym'] = array( |
$schema['category_synonym'] = array( |
| 227 |
'description' => t('Stores category synonyms.'), |
'description' => 'Stores category synonyms.', |
| 228 |
'fields' => array( |
'fields' => array( |
| 229 |
'csid' => array( |
'csid' => array( |
| 230 |
'type' => 'serial', |
'type' => 'serial', |
| 231 |
'not null' => TRUE, |
'not null' => TRUE, |
| 232 |
'description' => t('Primary Key: Unique category synonym ID.'), |
'description' => 'Primary Key: Unique category synonym ID.', |
| 233 |
), |
), |
| 234 |
'cid' => array( |
'cid' => array( |
| 235 |
'type' => 'int', |
'type' => 'int', |
| 236 |
'unsigned' => TRUE, |
'unsigned' => TRUE, |
| 237 |
'not null' => TRUE, |
'not null' => TRUE, |
| 238 |
'default' => 0, |
'default' => 0, |
| 239 |
'description' => t('The {category}.cid of the category.'), |
'description' => 'The {category}.cid of the category.', |
| 240 |
), |
), |
| 241 |
'name' => array( |
'name' => array( |
| 242 |
'type' => 'varchar', |
'type' => 'varchar', |
| 243 |
'length' => 255, |
'length' => 255, |
| 244 |
'not null' => TRUE, |
'not null' => TRUE, |
| 245 |
'default' => '', |
'default' => '', |
| 246 |
'description' => t('The name of the synonym.'), |
'description' => 'The name of the synonym.', |
| 247 |
), |
), |
| 248 |
), |
), |
| 249 |
'primary key' => array('csid'), |
'primary key' => array('csid'), |
| 254 |
); |
); |
| 255 |
|
|
| 256 |
$schema['category_cont'] = array( |
$schema['category_cont'] = array( |
| 257 |
'description' => t('Stores container information.'), |
'description' => 'Stores container information.', |
| 258 |
'fields' => array( |
'fields' => array( |
| 259 |
'cid' => array( |
'cid' => array( |
| 260 |
'type' => 'int', |
'type' => 'int', |
| 261 |
'unsigned' => TRUE, |
'unsigned' => TRUE, |
| 262 |
'not null' => TRUE, |
'not null' => TRUE, |
| 263 |
'default' => 0, |
'default' => 0, |
| 264 |
'description' => t('Primary Key: The {category}.cid of the container.'), |
'description' => 'Primary Key: The {category}.cid of the container.', |
| 265 |
), |
), |
| 266 |
'admin_title' => array( |
'admin_title' => array( |
| 267 |
'type' => 'varchar', |
'type' => 'varchar', |
| 268 |
'length' => 255, |
'length' => 255, |
| 269 |
'not null' => TRUE, |
'not null' => TRUE, |
| 270 |
'default' => '', |
'default' => '', |
| 271 |
'description' => t('Title of the container for administrative purposes.'), |
'description' => 'Title of the container for administrative purposes.', |
| 272 |
), |
), |
| 273 |
'help' => array( |
'help' => array( |
| 274 |
'type' => 'varchar', |
'type' => 'varchar', |
| 275 |
'length' => 255, |
'length' => 255, |
| 276 |
'not null' => TRUE, |
'not null' => TRUE, |
| 277 |
'default' => '', |
'default' => '', |
| 278 |
'description' => t('Help text to display for the container.'), |
'description' => 'Help text to display for the container.', |
| 279 |
), |
), |
| 280 |
'module' => array( |
'module' => array( |
| 281 |
'type' => 'varchar', |
'type' => 'varchar', |
| 282 |
'length' => 255, |
'length' => 255, |
| 283 |
'not null' => TRUE, |
'not null' => TRUE, |
| 284 |
'default' => '', |
'default' => '', |
| 285 |
'description' => t('The module which created the container.'), |
'description' => 'The module which created the container.', |
| 286 |
), |
), |
| 287 |
'relations' => array( |
'relations' => array( |
| 288 |
'type' => 'int', |
'type' => 'int', |
| 290 |
'not null' => TRUE, |
'not null' => TRUE, |
| 291 |
'default' => 0, |
'default' => 0, |
| 292 |
'size' => 'tiny', |
'size' => 'tiny', |
| 293 |
'description' => t('Whether or not related categories are enabled within the container. (0 = disabled, 1 = enabled)'), |
'description' => 'Whether or not related categories are enabled within the container. (0 = disabled, 1 = enabled)', |
| 294 |
), |
), |
| 295 |
'synonyms' => array( |
'synonyms' => array( |
| 296 |
'type' => 'int', |
'type' => 'int', |
| 298 |
'not null' => TRUE, |
'not null' => TRUE, |
| 299 |
'default' => 0, |
'default' => 0, |
| 300 |
'size' => 'tiny', |
'size' => 'tiny', |
| 301 |
'description' => t('Whether or not synonyms for categories are enabled within the container. (0 = disabled, 1 = enabled)'), |
'description' => 'Whether or not synonyms for categories are enabled within the container. (0 = disabled, 1 = enabled)', |
| 302 |
), |
), |
| 303 |
'hierarchy' => array( |
'hierarchy' => array( |
| 304 |
'type' => 'int', |
'type' => 'int', |
| 306 |
'not null' => TRUE, |
'not null' => TRUE, |
| 307 |
'default' => 0, |
'default' => 0, |
| 308 |
'size' => 'tiny', |
'size' => 'tiny', |
| 309 |
'description' => t('The type of hierarchy allowed within the container. (0 = disabled, 1 = single, 2 = multiple)'), |
'description' => 'The type of hierarchy allowed within the container. (0 = disabled, 1 = single, 2 = multiple)', |
| 310 |
), |
), |
| 311 |
'multiple' => array( |
'multiple' => array( |
| 312 |
'type' => 'int', |
'type' => 'int', |
| 314 |
'not null' => TRUE, |
'not null' => TRUE, |
| 315 |
'default' => 0, |
'default' => 0, |
| 316 |
'size' => 'tiny', |
'size' => 'tiny', |
| 317 |
'description' => t('Whether or not multiple categories from this container may be assigned to a node. (0 = disabled, 1 = enabled)'), |
'description' => 'Whether or not multiple categories from this container may be assigned to a node. (0 = disabled, 1 = enabled)', |
| 318 |
), |
), |
| 319 |
'required' => array( |
'required' => array( |
| 320 |
'type' => 'int', |
'type' => 'int', |
| 322 |
'not null' => TRUE, |
'not null' => TRUE, |
| 323 |
'default' => 0, |
'default' => 0, |
| 324 |
'size' => 'tiny', |
'size' => 'tiny', |
| 325 |
'description' => t('Whether or not categories are required for nodes using this container. (0 = disabled, 1 = enabled)'), |
'description' => 'Whether or not categories are required for nodes using this container. (0 = disabled, 1 = enabled)', |
| 326 |
), |
), |
| 327 |
'tags' => array( |
'tags' => array( |
| 328 |
'type' => 'int', |
'type' => 'int', |
| 330 |
'not null' => TRUE, |
'not null' => TRUE, |
| 331 |
'default' => 0, |
'default' => 0, |
| 332 |
'size' => 'tiny', |
'size' => 'tiny', |
| 333 |
'description' => t('Whether or not free tagging is enabled for the container. (0 = disabled, 1 = enabled)'), |
'description' => 'Whether or not free tagging is enabled for the container. (0 = disabled, 1 = enabled)', |
| 334 |
), |
), |
| 335 |
'hidden_cont' => array( |
'hidden_cont' => array( |
| 336 |
'type' => 'int', |
'type' => 'int', |
| 338 |
'not null' => TRUE, |
'not null' => TRUE, |
| 339 |
'default' => 0, |
'default' => 0, |
| 340 |
'size' => 'tiny', |
'size' => 'tiny', |
| 341 |
'description' => t('Whether or not this container is hidden from your category hierarchy for end-users. (0 = disabled, 1 = enabled)'), |
'description' => 'Whether or not this container is hidden from your category hierarchy for end-users. (0 = disabled, 1 = enabled)', |
| 342 |
), |
), |
| 343 |
'allowed_parent' => array( |
'allowed_parent' => array( |
| 344 |
'type' => 'int', |
'type' => 'int', |
| 345 |
'unsigned' => TRUE, |
'unsigned' => TRUE, |
| 346 |
'not null' => TRUE, |
'not null' => TRUE, |
| 347 |
'default' => 0, |
'default' => 0, |
| 348 |
'description' => t("The {category}.cid of a container whose categories the categories in this container may have as parents. (0 = this container or a category within it is an allowed parent)"), |
'description' => "The {category}.cid of a container whose categories the categories in this container may have as parents. (0 = this container or a category within it is an allowed parent)", |
| 349 |
), |
), |
| 350 |
), |
), |
| 351 |
'primary key' => array('cid'), |
'primary key' => array('cid'), |
| 356 |
); |
); |
| 357 |
|
|
| 358 |
$schema['category_cont_node_types'] = array( |
$schema['category_cont_node_types'] = array( |
| 359 |
'description' => t("Stores which node types containers may be used with. (I.e. categories in container 'cid' may be used to tag content of type 'type'.)"), |
'description' => "Stores which node types containers may be used with. (I.e. categories in container 'cid' may be used to tag content of type 'type'.)", |
| 360 |
'fields' => array( |
'fields' => array( |
| 361 |
'cid' => array( |
'cid' => array( |
| 362 |
'type' => 'int', |
'type' => 'int', |
| 363 |
'unsigned' => TRUE, |
'unsigned' => TRUE, |
| 364 |
'not null' => TRUE, |
'not null' => TRUE, |
| 365 |
'default' => 0, |
'default' => 0, |
| 366 |
'description' => t('Primary Key: the {category}.cid of the container.'), |
'description' => 'Primary Key: the {category}.cid of the container.', |
| 367 |
), |
), |
| 368 |
'type' => array( |
'type' => array( |
| 369 |
'type' => 'varchar', |
'type' => 'varchar', |
| 370 |
'length' => 32, |
'length' => 32, |
| 371 |
'not null' => TRUE, |
'not null' => TRUE, |
| 372 |
'default' => '', |
'default' => '', |
| 373 |
'description' => t('The {node_type}.type of the node type for which the container may be used.'), |
'description' => 'The {node_type}.type of the node type for which the container may be used.', |
| 374 |
), |
), |
| 375 |
), |
), |
| 376 |
'primary key' => array('cid', 'type'), |
'primary key' => array('cid', 'type'), |
| 379 |
), |
), |
| 380 |
); |
); |
| 381 |
|
|
| 382 |
|
$schema['cache_category'] = drupal_get_schema_unprocessed('system', 'cache'); |
| 383 |
|
$schema['cache_category']['description'] = 'Cache table for category module, to store various preprocessed data, both per-node and global.'; |
| 384 |
|
|
| 385 |
return $schema; |
return $schema; |
| 386 |
} |
} |
| 387 |
|
|
| 481 |
} |
} |
| 482 |
return $ret; |
return $ret; |
| 483 |
} |
} |
| 484 |
|
|
| 485 |
|
/** |
| 486 |
|
* Uninstall and remove Menu wrapper module, if present. The wrapper only existed in |
| 487 |
|
* 6.x releases 6.x-2.0-beta3 and below. |
| 488 |
|
*/ |
| 489 |
|
function category_update_6002() { |
| 490 |
|
$ret = array(); |
| 491 |
|
|
| 492 |
|
$wrapper_path = drupal_get_path('module', 'category') .'/wrappers/menu'; |
| 493 |
|
if (is_dir($wrapper_path)) { |
| 494 |
|
$success = TRUE; |
| 495 |
|
$files = array('menu.admin.inc', 'menu.info', 'menu.info.php', 'menu.install', 'menu.install.php', 'menu.module', 'menu.module.php'); |
| 496 |
|
foreach ($files as $file) { |
| 497 |
|
$filepath = $wrapper_path .'/'. $file; |
| 498 |
|
if (is_file($filepath) && !@unlink($filepath)) { |
| 499 |
|
$success = FALSE; |
| 500 |
|
} |
| 501 |
|
} |
| 502 |
|
if (!@rmdir($wrapper_path)) { |
| 503 |
|
$success = FALSE; |
| 504 |
|
} |
| 505 |
|
|
| 506 |
|
drupal_flush_all_caches(); |
| 507 |
|
module_rebuild_cache(); |
| 508 |
|
|
| 509 |
|
if (!$success) { |
| 510 |
|
drupal_set_message("The attempt to remove <em>$wrapper_path</em> directory and all it's contents failed. Please ensure that the webserver have write permissions to the <em>wrappers</em> directory and below, and re-run the Category module's update 6002. If that's not possible, you might need to remove the files manually.", 'error'); |
| 511 |
|
} |
| 512 |
|
$ret[] = array('success' => $success, 'query' => "Uninstall Menu wrapper, and remove $wrapper_path directory."); |
| 513 |
|
} |
| 514 |
|
|
| 515 |
|
return $ret; |
| 516 |
|
} |
| 517 |
|
|
| 518 |
|
/** |
| 519 |
|
* Add cache table. |
| 520 |
|
*/ |
| 521 |
|
function category_update_6003() { |
| 522 |
|
$ret = array(); |
| 523 |
|
|
| 524 |
|
// This is verbatim from system module (minus descriptions), to avoid call to |
| 525 |
|
// drupal_get_schema_unprocessed() which may change in future, per schema/updates |
| 526 |
|
// guidelines. |
| 527 |
|
$schema = array( |
| 528 |
|
'fields' => array( |
| 529 |
|
'cid' => array( |
| 530 |
|
'type' => 'varchar', |
| 531 |
|
'length' => 255, |
| 532 |
|
'not null' => TRUE, |
| 533 |
|
'default' => ''), |
| 534 |
|
'data' => array( |
| 535 |
|
'type' => 'blob', |
| 536 |
|
'not null' => FALSE, |
| 537 |
|
'size' => 'big'), |
| 538 |
|
'expire' => array( |
| 539 |
|
'type' => 'int', |
| 540 |
|
'not null' => TRUE, |
| 541 |
|
'default' => 0), |
| 542 |
|
'created' => array( |
| 543 |
|
'type' => 'int', |
| 544 |
|
'not null' => TRUE, |
| 545 |
|
'default' => 0), |
| 546 |
|
'headers' => array( |
| 547 |
|
'type' => 'text', |
| 548 |
|
'not null' => FALSE), |
| 549 |
|
'serialized' => array( |
| 550 |
|
'type' => 'int', |
| 551 |
|
'size' => 'small', |
| 552 |
|
'not null' => TRUE, |
| 553 |
|
'default' => 0) |
| 554 |
|
), |
| 555 |
|
'indexes' => array('expire' => array('expire')), |
| 556 |
|
'primary key' => array('cid'), |
| 557 |
|
); |
| 558 |
|
|
| 559 |
|
db_create_table($ret, 'cache_category', $schema); |
| 560 |
|
return $ret; |
| 561 |
|
} |