| 1 |
<?php |
<?php |
| 2 |
// $Id: authorship.install,v 1.4 2007/02/06 23:22:13 karpuz Exp $ |
// $Id: authorship.install,v 1.6 2007/04/11 01:10:29 lafo Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 18 |
case 'mysqli': |
case 'mysqli': |
| 19 |
$query1 = db_query("CREATE TABLE IF NOT EXISTS {node_authorship} (". |
$query1 = db_query("CREATE TABLE IF NOT EXISTS {node_authorship} (". |
| 20 |
"nid INT(10) NOT NULL DEFAULT 0,". |
"nid INT(10) NOT NULL DEFAULT 0,". |
| 21 |
|
"cid INT(10) NOT NULL DEFAULT 0,". |
| 22 |
"authorship VARCHAR(255) NOT NULL DEFAULT '',". |
"authorship VARCHAR(255) NOT NULL DEFAULT '',". |
| 23 |
"profile_real_name INT(2) DEFAULT 0, ". |
"profile_real_name INT(2) DEFAULT 0, ". |
| 24 |
"PRIMARY KEY (nid),". |
"PRIMARY KEY (nid, cid),". |
| 25 |
"INDEX(authorship(8))". |
"INDEX(authorship(8))". |
| 26 |
") /*!40100 DEFAULT CHARACTER SET utf8 */"); |
") /*!40100 DEFAULT CHARACTER SET utf8 */"); |
| 27 |
if($query1) { |
if($query1) { |
| 32 |
case 'pgsql': |
case 'pgsql': |
| 33 |
$query1 = db_query("CREATE TABLE {node_authorship} (". |
$query1 = db_query("CREATE TABLE {node_authorship} (". |
| 34 |
"nid INT NOT NULL DEFAULT 0,". |
"nid INT NOT NULL DEFAULT 0,". |
| 35 |
|
"cid INT NOT NULL DEFAULT 0,". |
| 36 |
"authorship VARCHAR(255) NOT NULL DEFAULT '',". |
"authorship VARCHAR(255) NOT NULL DEFAULT '',". |
| 37 |
"profile_real_name SMALLINT DEFAULT 0, ". |
"profile_real_name SMALLINT DEFAULT 0, ". |
| 38 |
"PRIMARY KEY (nid)"); |
"PRIMARY KEY (nid, cid)"); |
| 39 |
$query2 = db_query("CREATE INDEX node_authorship_idx ON {node_authorship} (authorship);"); |
$query2 = db_query("CREATE INDEX node_authorship_idx ON {node_authorship} (authorship);"); |
| 40 |
if($query1 && $query2) { |
if($query1 && $query2) { |
| 41 |
$created = TRUE; |
$created = TRUE; |
| 71 |
return $items; |
return $items; |
| 72 |
} |
} |
| 73 |
|
|
| 74 |
|
function authorship_update_2() { |
| 75 |
|
$items = array(); |
| 76 |
|
$items[] = update_sql("ALTER TABLE {node_authorship} ADD cid INT(10) NOT NULL DEFAULT 0 AFTER nid"); |
| 77 |
|
$items[] = update_sql("ALTER TABLE {node_authorship} DROP PRIMARY KEY"); |
| 78 |
|
$items[] = update_sql("ALTER TABLE {node_authorship} ADD PRIMARY KEY (nid, cid)"); |
| 79 |
|
return $items; |
| 80 |
|
} |
| 81 |
|
|
| 82 |
|
/** |
| 83 |
|
* Implementation of hook_uninstall(). |
| 84 |
|
*/ |
| 85 |
|
function authorship_uninstall() { |
| 86 |
|
if(db_table_exists('{node_authorship}')) { |
| 87 |
|
db_query('DROP TABLE {node_authorship}'); |
| 88 |
|
} |
| 89 |
|
// delete variables |
| 90 |
|
$node_types = node_get_types('names'); |
| 91 |
|
$node_types = array_keys($node_types); |
| 92 |
|
$node_types[] = 'comment'; |
| 93 |
|
foreach($node_types as $node_type) { |
| 94 |
|
variable_del('authorship_real_name_' . $node_type); |
| 95 |
|
variable_del('authorship_' . $node_type); |
| 96 |
|
} |
| 97 |
|
} |