| 1 |
<?php |
<?php |
| 2 |
// $Id: comment_revisions.install,v 1.1.1.1 2007/12/09 01:51:56 Raiden-San Exp $ |
// $Id: comment_revisions.install,v 1.2.2.10 2008/06/29 14:47:58 Raiden Exp $ |
| 3 |
|
|
| 4 |
/* |
/* |
| 5 |
* Creates Database sheme for |
* Creates Database sheme for |
| 6 |
* GB Comment Revisions |
* GB Comment Revisions |
| 7 |
*/ |
*/ |
| 8 |
|
function comment_revisions_schema() { |
| 9 |
|
$schema['comment_revisions'] = array( |
| 10 |
|
'fields' => array( |
| 11 |
|
'vid' => array( |
| 12 |
|
'type' => 'serial', |
| 13 |
|
'unsinged' => TRUE, |
| 14 |
|
'not null' => TRUE |
| 15 |
|
), |
| 16 |
|
'cid' => array( |
| 17 |
|
'type' => 'int', |
| 18 |
|
'unsinged' => TRUE, |
| 19 |
|
'not null' => TRUE |
| 20 |
|
), |
| 21 |
|
'comment' => array( |
| 22 |
|
'type' => 'text', |
| 23 |
|
'size' => 'big', |
| 24 |
|
'not null' => TRUE |
| 25 |
|
), |
| 26 |
|
'subject' => array( |
| 27 |
|
'type' => 'varchar', |
| 28 |
|
'length' => 64, |
| 29 |
|
'not null' => TRUE, |
| 30 |
|
'default' => '', |
| 31 |
|
'description' => t('The comment title') |
| 32 |
|
), |
| 33 |
|
'logmessage' => array( |
| 34 |
|
'type' => 'varchar', |
| 35 |
|
'length' => 256, |
| 36 |
|
'default' => NULL |
| 37 |
|
), |
| 38 |
|
'createdon' => array( |
| 39 |
|
'type' => 'int', |
| 40 |
|
'unsigned' => TRUE, |
| 41 |
|
'not null' => TRUE |
| 42 |
|
), |
| 43 |
|
'createdby' => array( |
| 44 |
|
'type' => 'varchar', |
| 45 |
|
'length' => 60, |
| 46 |
|
'not null' => TRUE |
| 47 |
|
), |
| 48 |
|
'isusrrev' => array( |
| 49 |
|
'type' => 'int', |
| 50 |
|
'size' => 'tiny', |
| 51 |
|
'not null' => TRUE, |
| 52 |
|
'default' => 0 |
| 53 |
|
) |
| 54 |
|
), 'primary key' => array('vid'), 'unique key' => array( 'rid' => array('vid')) |
| 55 |
|
); |
| 56 |
|
|
| 57 |
|
$schema['comment_revisions_actual'] = array( |
| 58 |
|
'fields' => array( |
| 59 |
|
'cid' => array( |
| 60 |
|
'type' => 'int', |
| 61 |
|
'unsigned' => TRUE, |
| 62 |
|
'not null' => TRUE |
| 63 |
|
), |
| 64 |
|
'vid' => array( |
| 65 |
|
'type' => 'int', |
| 66 |
|
'unsigned' => TRUE, |
| 67 |
|
'not null' => TRUE |
| 68 |
|
) |
| 69 |
|
), 'primary key' => array('vid'), 'unique keys' => array('cid' => array('cid', 'vid')) |
| 70 |
|
); |
| 71 |
|
|
| 72 |
|
return $schema; |
| 73 |
|
} |
| 74 |
|
|
| 75 |
function comment_revisions_install() { |
function comment_revisions_install() { |
| 76 |
|
|
|
/* |
|
|
* Installing the tables. |
|
|
* |
|
|
* Table: comment_revisions |
|
|
* Fields: |
|
|
* rid INT |
|
|
* cid INT |
|
|
* comment LONGTEXT |
|
|
* subject VARCHAR(64) |
|
|
* createdOn DATE |
|
|
* createdBy VARCHAR(60) |
|
|
* isUsrRev BOOL |
|
|
* |
|
|
* Table: comment_revisions_actual |
|
|
* Fields: |
|
|
* cid INT |
|
|
* rid INT |
|
|
*/ |
|
| 77 |
drupal_set_message('Installing GB Comment Revisions'); |
drupal_set_message('Installing GB Comment Revisions'); |
|
switch ($GLOBALS['db_type']) { |
|
|
case 'mysql': |
|
|
case 'mysqli': |
|
|
|
|
|
db_query("CREATE TABLE IF NOT EXISTS {comment_revisions} ( |
|
|
`vid` int(10) unsigned NOT NULL, |
|
|
`cid` int(10) unsigned NOT NULL, |
|
|
`comment` longtext NOT NULL, |
|
|
`subject` varchar(64) NOT NULL, |
|
|
`logMessage` varchar(260) default NULL, |
|
|
`createdOn` int(10) unsigned NOT NULL, |
|
|
`createdBy` varchar(60) NOT NULL, |
|
|
`isUsrRev` enum('1','0') NOT NULL default '0', |
|
|
PRIMARY KEY (`vid`), |
|
|
UNIQUE KEY `rid` (`vid`) |
|
|
)/*!40100 DEFAULT CHARACTER SET utf8 */"); |
|
|
|
|
|
db_query("CREATE TABLE IF NOT EXISTS {comment_revisions_actual} ( |
|
|
`cid` int(10) unsigned NOT NULL, |
|
|
`vid` int(10) unsigned NOT NULL, |
|
|
PRIMARY KEY (`vid`), |
|
|
UNIQUE KEY `cid` (`cid`,`vid`) |
|
|
)/*!40100 DEFAULT CHARACTER SET utf8 */"); |
|
| 78 |
|
|
| 79 |
$success = TRUE; |
$result = drupal_install_schema('comment_revisions'); |
| 80 |
break; |
if($result[0]['success'] != 1) { |
| 81 |
|
drupal_set_message(t('Creation of comment_revisions failed')); |
| 82 |
} |
} |
| 83 |
if ($success) { |
if($result[1]['success'] != 1) { |
| 84 |
drupal_set_message(t('GB Comment Revisions database tables successfully installed. Settings available under !link', |
drupal_set_message(t('Creation of comment_revisions_actual failed')); |
|
array('!link' => l('Administer -> Site Configuration -> GB Comment Revisions', 'admin/settings/commentrevisions')) |
|
|
)); |
|
| 85 |
} |
} |
| 86 |
|
drupal_set_message(t('GB Comment Revisions installed.')); |
| 87 |
} |
} |
| 88 |
|
|
| 89 |
function comment_revisions_uninstall() { |
function comment_revisions_uninstall() { |
| 90 |
db_query("DROP TABLE {comment_revisions}"); |
drupal_uninstall_schema('comment_revisions'); |
| 91 |
db_query("DROP TABLE {comment_revisions_actual}"); |
drupal_uninstall_schema('comment_revisions_actual'); |
| 92 |
variable_del('comment_revisions_enable_usr_rev'); |
variable_del('comment_revisions_enable_usr_rev'); |
| 93 |
variable_del('comment_revisions_max_usr_revisions'); |
variable_del('comment_revisions_max_usr_revisions'); |
| 94 |
variable_del('comment_revisions_max_admin'); |
variable_del('comment_revisions_max_admin'); |
| 95 |
|
drupal_set_message(t('GB Comment Revisions uninstalled.')); |
| 96 |
} |
} |