| 1 |
<?php // $Id$ |
<?php |
| 2 |
|
// $Id: bio.install,v 1.1.2.6 2008/03/25 16:09:44 dww Exp $ |
| 3 |
|
|
| 4 |
|
/** |
| 5 |
|
* @file |
| 6 |
|
* Installation file for Bio module. |
| 7 |
|
*/ |
| 8 |
|
|
| 9 |
|
/** |
| 10 |
|
* Implementation of hook_install(). |
| 11 |
|
*/ |
| 12 |
|
function bio_install() { |
| 13 |
|
switch ($GLOBALS['db_type']) { |
| 14 |
|
case 'mysql': |
| 15 |
|
case 'mysqli': |
| 16 |
|
db_query("CREATE TABLE {bio} ( |
| 17 |
|
nid int unsigned NOT NULL default '0', |
| 18 |
|
uid int unsigned NOT NULL default '0', |
| 19 |
|
PRIMARY KEY (nid, uid) |
| 20 |
|
) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); |
| 21 |
|
break; |
| 22 |
|
case 'pgsql': |
| 23 |
|
db_query("CREATE TABLE {bio} ( |
| 24 |
|
nid int_unsigned NOT NULL default '0', |
| 25 |
|
uid int_unsigned NOT NULL default '0', |
| 26 |
|
PRIMARY KEY (nid, uid) |
| 27 |
|
)"); |
| 28 |
|
break; |
| 29 |
|
} |
| 30 |
|
drupal_set_message(t('You can configure the bio module on the <a href="@url">bio settings page</a>.', array('@url' => url('admin/user/bio')))); |
| 31 |
|
} |
| 32 |
|
|
| 33 |
|
/** |
| 34 |
|
* @defgroup bio-updates-legacy Bio updates for versions prior to 5.x-1.x |
| 35 |
|
* @{ |
| 36 |
|
*/ |
| 37 |
|
|
| 38 |
|
/** |
| 39 |
|
* 4.7.x -> 5.x upgrade. |
| 40 |
|
*/ |
| 41 |
function bio_update_1() { |
function bio_update_1() { |
| 42 |
|
$ret = array(); |
| 43 |
|
|
| 44 |
// copy per-nodetype link settings into different format |
// Copy per-node type link settings into different format. |
| 45 |
$bio_link = array(); |
$bio_link = array(); |
| 46 |
foreach(node_get_types() as $key => $type) { |
foreach (node_get_types() as $key => $type) { |
| 47 |
$bio_link[$key] = variable_get('bio_'.$key, 0) ? $key : 0; |
$bio_link[$key] = variable_get('bio_'. $key, 0) ? $key : 0; |
| 48 |
} |
} |
| 49 |
variable_set('bio_link', $bio_link); |
variable_set('bio_link', $bio_link); |
| 50 |
|
|
| 51 |
return array( |
// Keep permissions while using a node type handled by the node module. |
| 52 |
// Keep permissions while using a node type handled by the node module. |
$ret[] = update_sql("DELETE FROM {variable} WHERE name LIKE 'bio%%'"); |
| 53 |
update_query("DELETE FROM {variable} WHERE name LIKE 'bio%%'"), |
|
| 54 |
|
// Purge old settings. |
| 55 |
// purge old settings |
$ret[] = update_sql("UPDATE {permission} SET perm = REPLACE(perm, 'create biography', 'add bio, edit own bio')"); |
| 56 |
update_query("UPDATE {permission} SET perm = REPLACE(perm, 'create biography', 'add bio, edit own bio')"), |
|
| 57 |
); |
return $ret; |
| 58 |
|
} |
| 59 |
|
|
| 60 |
|
/** |
| 61 |
|
* @} End of "defgroup bio-updates-legacy" |
| 62 |
|
*/ |
| 63 |
|
|
| 64 |
|
/** |
| 65 |
|
* @defgroup bio-updates-5.x-1.x Bio updates for 5.x-1.x |
| 66 |
|
* @{ |
| 67 |
|
*/ |
| 68 |
|
|
| 69 |
|
/** |
| 70 |
|
* Creates and populates a table to hold uid/nid combination. |
| 71 |
|
* |
| 72 |
|
* Workaround for node_user's annoying behaviour of anonymizing bio nodes |
| 73 |
|
* which prevents us from deleting them. |
| 74 |
|
*/ |
| 75 |
|
function bio_update_5100() { |
| 76 |
|
$ret = array(); |
| 77 |
|
|
| 78 |
|
// Create bio table. |
| 79 |
|
switch ($GLOBALS['db_type']) { |
| 80 |
|
case 'mysql': |
| 81 |
|
case 'mysqli': |
| 82 |
|
$ret[] = update_sql("CREATE TABLE {bio} ( |
| 83 |
|
nid int unsigned NOT NULL default '0', |
| 84 |
|
uid int unsigned NOT NULL default '0', |
| 85 |
|
PRIMARY KEY (nid, uid) |
| 86 |
|
) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); |
| 87 |
|
break; |
| 88 |
|
case 'pgsql': |
| 89 |
|
$ret[] = update_sql("CREATE TABLE {bio} ( |
| 90 |
|
nid int_unsigned NOT NULL default '0', |
| 91 |
|
uid int_unsigned NOT NULL default '0', |
| 92 |
|
PRIMARY KEY (nid, uid) |
| 93 |
|
)"); |
| 94 |
|
break; |
| 95 |
|
} |
| 96 |
|
|
| 97 |
|
// Populate table. |
| 98 |
|
$type = db_escape_string(variable_get('bio_nodetype', 'bio')); |
| 99 |
|
$ret[] = update_sql("INSERT INTO {bio} SELECT nid, uid FROM {node} WHERE type = '$type' AND uid != 0"); |
| 100 |
|
|
| 101 |
|
return $ret; |
| 102 |
|
} |
| 103 |
|
|
| 104 |
|
/** |
| 105 |
|
* @} End of "defgroup bio-updates-5.x-1.x" |
| 106 |
|
*/ |
| 107 |
|
|
| 108 |
|
/** |
| 109 |
|
* Implementation of hook_uninstall(). |
| 110 |
|
*/ |
| 111 |
|
function bio_uninstall() { |
| 112 |
|
db_query('DROP TABLE {bio}'); |
| 113 |
|
variable_del('bio_nodetype'); |
| 114 |
|
variable_del('bio_link'); |
| 115 |
|
variable_del('bio_profile'); |
| 116 |
|
variable_del('bio_profile_takeover'); |
| 117 |
|
variable_del('bio_regstration_form'); |
| 118 |
|
variable_del('bio_regstration_form_fields'); |
| 119 |
} |
} |