| 1 |
<?php |
<?php |
| 2 |
|
// $Id$ |
| 3 |
/** |
/** |
| 4 |
* Install/update component for the Zeitgeist module for Drupal 5.x |
* @file |
| 5 |
|
* Install/update component for the Zeitgeist module for Drupal 6.x |
| 6 |
* |
* |
| 7 |
* @copyright (c) 2006-2007 FG Marand. |
* @copyright (c) 2006-2006 FG Marand. |
| 8 |
* @license Licensed under the CeCILL 2.0 license. |
* @license Licensed under the CeCILL 2.0 license and GPL version 2 and later. |
| 9 |
* @since Drupal 4.7 |
* @since Drupal 4.7 |
| 10 |
*/ |
*/ |
| 11 |
|
|
|
// $Id: zeitgeist.install,v 1.1.6.3 2007/10/14 16:52:53 fgm Exp $ |
|
|
|
|
| 12 |
/** |
/** |
| 13 |
* Define the structure of the non-core tables used by Zeitgeist. |
* Define the structure of the non-core tables used by Zeitgeist. |
| 14 |
* This used to live in zeitgeist.schema until some point in the D6 beta process |
* This used to live in zeitgeist.schema until some point in the D6 beta process |
| 16 |
* |
* |
| 17 |
* @return array |
* @return array |
| 18 |
*/ |
*/ |
| 19 |
function zeitgeist_schema() |
function zeitgeist_schema() { |
| 20 |
{ |
$t = get_t(); |
| 21 |
$schema['zeitgeist'] = array |
$schema['zeitgeist'] = array( |
| 22 |
( |
'fields' => array( |
| 23 |
'fields' => array |
'search' => array( |
|
( |
|
|
'search' => array |
|
|
( |
|
| 24 |
'type' => 'varchar', |
'type' => 'varchar', |
| 25 |
'length' => 80, |
'length' => 80, |
| 26 |
'not null' => true, |
'not null' => TRUE, |
| 27 |
'default' => '', |
'default' => '', |
| 28 |
'description' => t('The query string. Will statistically often be empty is ZG is allowed to log empty searches.'), |
'description' => $t('The query string. Will statistically often be empty is ZG is allowed to log empty searches.'), |
| 29 |
), |
), |
| 30 |
'category' => array |
'category' => array( |
|
( |
|
| 31 |
'type' => 'varchar', |
'type' => 'varchar', |
| 32 |
'length' => 64, |
'length' => 64, |
| 33 |
'not null' => true, |
'not null' => TRUE, |
| 34 |
'default' => 'node', |
'default' => 'node', |
| 35 |
'description' => t('The search category. Core categories are "node" and "user".'), |
'description' => $t('The search category. Core categories are "node" and "user".'), |
| 36 |
), |
), |
| 37 |
'ts' => array |
'ts' => array( |
|
( |
|
| 38 |
'type' => 'int', |
'type' => 'int', |
| 39 |
'unsigned' => true, |
'unsigned' => TRUE, |
| 40 |
'not null' => true, |
'not null' => TRUE, |
| 41 |
'default' => 0, |
'default' => 0, |
| 42 |
'description' => t('The timestamp of search submission. Duplicates <em>do</em> happen due to timer granularity.'), |
'description' => $t('The timestamp of search submission. Duplicates <em>do</em> happen due to timer granularity.'), |
|
), |
|
| 43 |
), |
), |
| 44 |
|
), |
| 45 |
|
|
| 46 |
/* |
/* |
| 47 |
* ZG does not use a PK, because the timer granularity can actually cause duplicates, |
* ZG does not use a PK, because the timer granularity can actually cause duplicates, |
| 48 |
* and there is no actual need to differentiate them. The alternatives would be heavier: |
* and there is no actual need to differentiate them. The alternatives would be heavier: |
| 54 |
// 'primary key' => array(), |
// 'primary key' => array(), |
| 55 |
'unique keys' => array(), |
'unique keys' => array(), |
| 56 |
'indexes' => array('search' => array('search')), |
'indexes' => array('search' => array('search')), |
| 57 |
'description' => t('The search logging table for the Zeitgeist module.'), |
'description' => $t('The search logging table for the Zeitgeist module.'), |
| 58 |
); |
); |
| 59 |
|
|
| 60 |
return $schema; |
return $schema; |
| 61 |
} |
} |
| 62 |
|
|
| 63 |
/** |
/** |
| 64 |
* Extend category width to 64 to match table "blocks". Was varchar(5) in 1.1, |
* Extend category width to 64 to match table "blocks". |
| 65 |
* then 64 ever since. |
* |
| 66 |
|
* Was varchar(5) in 1.1, then varchar(64) ever since. |
| 67 |
* |
* |
| 68 |
* @return array |
* @return array |
| 69 |
*/ |
*/ |
| 70 |
function zeitgeist_update_1() |
function zeitgeist_update_1() { |
|
{ |
|
| 71 |
$ret = array(); |
$ret = array(); |
| 72 |
db_change_column($ret, 'zeitgeist', 'category', 'category', array |
db_change_column($ret, 'zeitgeist', 'category', 'category', array( |
|
( |
|
| 73 |
'type' => 'varchar', |
'type' => 'varchar', |
| 74 |
'length' => 64, |
'length' => 64, |
| 75 |
'default' => 'node', |
'default' => 'node', |
| 76 |
'not null' => true) |
'not null' => TRUE) |
| 77 |
); |
); |
| 78 |
return $ret; |
return $ret; |
| 79 |
} |
} |
| 80 |
|
|
| 81 |
/** |
/** |
| 82 |
* Switch to the new schema numbering scheme. No actual change from 1 |
* Switch to the new schema numbering scheme. No actual change from 1 |
| 83 |
* |
* |
| 84 |
* @return array |
* @return array |
| 85 |
*/ |
*/ |
| 86 |
function zeitgeist_update_6000() |
function zeitgeist_update_6000() { |
|
{ |
|
| 87 |
$ret = array(); |
$ret = array(); |
| 88 |
return $ret; |
return $ret; |
| 89 |
} |
} |
| 90 |
|
|
| 91 |
/** |
/** |
| 92 |
* implementation of hook_install from #72166 and #72662 combined |
* Implementation of hook_install from #72166 and #72662 combined. |
| 93 |
* |
* |
| 94 |
* @return void |
* @return void |
| 95 |
*/ |
*/ |
| 96 |
function zeitgeist_install() |
function zeitgeist_install() { |
| 97 |
{ |
$t = get_t(); |
| 98 |
drupal_install_schema('zeitgeist'); |
drupal_install_schema('zeitgeist'); |
| 99 |
drupal_set_message(t('Installed Zeitgeist schema'), 'status'); |
drupal_set_message($t('Installed Zeitgeist schema'), 'status'); |
| 100 |
} |
} |
| 101 |
|
|
| 102 |
/** |
/** |
| 103 |
* Implement hook_uninstall |
* Implement hook_uninstall |
| 104 |
* @return void |
* @return void |
| 105 |
*/ |
*/ |
| 106 |
function zeitgeist_uninstall() |
function zeitgeist_uninstall() { |
| 107 |
{ |
$t = get_t(); |
| 108 |
// Remove tables. |
// Remove tables. |
| 109 |
drupal_uninstall_schema('zeitgeist'); |
drupal_uninstall_schema('zeitgeist'); |
| 110 |
drupal_set_message(t('Uninstalled Zeitgeist schema'), 'status'); |
drupal_set_message($t('Uninstalled Zeitgeist schema'), 'status'); |
| 111 |
|
|
| 112 |
$constants = get_defined_constants(); |
$constants = get_defined_constants(); |
| 113 |
foreach ($constants as $constant) |
foreach ($constants as $constant) { |
| 114 |
{ |
if (strpos($constant, 'zeitgeist_' === 0)) { |
|
if (strpos($constant, 'zeitgeist_' === 0)) |
|
|
{ |
|
| 115 |
variable_del($constant); |
variable_del($constant); |
|
} |
|
| 116 |
} |
} |
| 117 |
drupal_set_message(t('Zeitgeist settings have been removed.')); |
} |
| 118 |
|
drupal_set_message($t('Zeitgeist settings have been removed.')); |
| 119 |
|
|
| 120 |
db_query("DELETE FROM {blocks} WHERE module = 'zeitgeist'"); |
db_query("DELETE FROM {blocks} WHERE module = 'zeitgeist'"); |
| 121 |
drupal_set_message(t('Zeitgeist blocks have been removed.')); |
drupal_set_message($t('Zeitgeist blocks have been removed.')); |
| 122 |
} |
} |