| 1 |
<?php
|
| 2 |
// $Id: nodefamily.install,v 1.8 2007/02/28 16:38:45 fago Exp $
|
| 3 |
|
| 4 |
function nodefamily_install() {
|
| 5 |
switch ($GLOBALS['db_type']) {
|
| 6 |
case 'mysqli':
|
| 7 |
case 'mysql':
|
| 8 |
db_query("CREATE TABLE if not exists {nodefamily} (
|
| 9 |
parent_nid int(10) unsigned NOT NULL,
|
| 10 |
child_nid int(10) unsigned NOT NULL,
|
| 11 |
PRIMARY KEY(parent_nid,child_nid)
|
| 12 |
) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
|
| 13 |
break;
|
| 14 |
case 'pgsql':
|
| 15 |
db_query("CREATE TABLE {nodefamily} (
|
| 16 |
parent_nid integer NOT NULL,
|
| 17 |
child_nid integer NOT NULL,
|
| 18 |
PRIMARY KEY(parent_nid,child_nid)
|
| 19 |
)");
|
| 20 |
default:
|
| 21 |
break;
|
| 22 |
}
|
| 23 |
// Set the module weight to -2, so that the hook_form_alter() implementation
|
| 24 |
// get's called before nodeprofile's implementation
|
| 25 |
db_query("UPDATE {system} SET weight = -2 WHERE name = 'nodefamily'");
|
| 26 |
}
|
| 27 |
|
| 28 |
function nodefamily_uninstall() {
|
| 29 |
include_once('nodefamily.module');
|
| 30 |
|
| 31 |
// relations
|
| 32 |
variable_del('nodefamily_relations');
|
| 33 |
db_query("DROP TABLE {nodefamily}");
|
| 34 |
|
| 35 |
// maximum population
|
| 36 |
foreach (node_get_types('names') as $typename => $visiblename) {
|
| 37 |
_nodefamily_content_type_del_max($typename);
|
| 38 |
}
|
| 39 |
}
|
| 40 |
|
| 41 |
|
| 42 |
/**
|
| 43 |
* Rename variables: nodefamily_typename_max -> nodefamily_max_typename.
|
| 44 |
*/
|
| 45 |
function nodefamily_update_1() {
|
| 46 |
foreach (node_get_types('names') as $typename => $visiblename) {
|
| 47 |
$type_max_population = variable_get('nodefamily_'. $typename .'_max', -1);
|
| 48 |
if ($type_max_population != -1) {
|
| 49 |
variable_del('nodefamily_'. $typename .'_max');
|
| 50 |
variable_set('nodefamily_max_'. $typename, $type_max_population);
|
| 51 |
}
|
| 52 |
}
|
| 53 |
|
| 54 |
return array(
|
| 55 |
array(
|
| 56 |
'success' => TRUE,
|
| 57 |
'query' => 'Renamed variables: nodefamily_typename_max -> nodefamily_max_typename.',
|
| 58 |
),
|
| 59 |
);
|
| 60 |
}
|
| 61 |
|
| 62 |
|
| 63 |
/*
|
| 64 |
* Update existing views fusion to use the new table name
|
| 65 |
*/
|
| 66 |
function nodefamily_update_2() {
|
| 67 |
$ret = array();
|
| 68 |
if (module_exists('views_fusion')) {
|
| 69 |
$ret[] = update_sql("UPDATE {views_fusion} SET uses = 'nodefamily_parent' WHERE uses = 'nodefamily'");
|
| 70 |
}
|
| 71 |
return $ret;
|
| 72 |
}
|
| 73 |
|
| 74 |
/*
|
| 75 |
* Call update 1 again, so that people upgrading from 4.7.x get it too
|
| 76 |
*/
|
| 77 |
function nodefamily_update_3() {
|
| 78 |
return nodefamily_update_1();
|
| 79 |
}
|
| 80 |
|
| 81 |
/**
|
| 82 |
* Set module weight to -2, as explained in nodefamily_install().
|
| 83 |
*/
|
| 84 |
function nodefamily_update_4() {
|
| 85 |
$ret = array();
|
| 86 |
$ret[] = update_sql("UPDATE {system} SET weight = -2 WHERE name = 'nodefamily'");
|
| 87 |
return $ret;
|
| 88 |
}
|