| 1 |
<?php |
<?php |
| 2 |
// $Id$ |
// $Id: custom_links.install,v 1.1.4.1 2007/02/28 08:32:54 eaton Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* Implementation of hook_install(). |
* Implementation of hook_install(). |
| 6 |
*/ |
*/ |
| 7 |
function custom_links_install() { |
function custom_links_install() { |
| 8 |
|
drupal_install_schema('custom_links'); |
| 9 |
|
} |
| 10 |
|
|
| 11 |
|
function custom_links_schema() { |
| 12 |
|
$schema['custom_link'] = array( |
| 13 |
|
'description' => t('Stores custom links to be added to nodes.'), |
| 14 |
|
'fields' => array( |
| 15 |
|
'lid' => array( |
| 16 |
|
'type' => 'serial', |
| 17 |
|
'unsigned' => TRUE, |
| 18 |
|
'not null' => TRUE, |
| 19 |
|
'description' => t('Unique identifier for the {custom_link}.'), |
| 20 |
|
), |
| 21 |
|
'link_key' => array( |
| 22 |
|
'type' => 'varchar', |
| 23 |
|
'length' => 64, |
| 24 |
|
'not null' => TRUE, |
| 25 |
|
'default' => '', |
| 26 |
|
'description' => t("A unique CSS class for the link.") |
| 27 |
|
), |
| 28 |
|
'node_type' => array( |
| 29 |
|
'type' => 'varchar', |
| 30 |
|
'length' => 64, |
| 31 |
|
'not null' => TRUE, |
| 32 |
|
'default' => '', |
| 33 |
|
'description' => t("The node type the {custom_link} should be associated with.") |
| 34 |
|
), |
| 35 |
|
'title' => array( |
| 36 |
|
'type' => 'varchar', |
| 37 |
|
'length' => 255, |
| 38 |
|
'not null' => TRUE, |
| 39 |
|
'default' => '', |
| 40 |
|
'description' => t("The visible title of the {custom_link}.") |
| 41 |
|
), |
| 42 |
|
'path' => array( |
| 43 |
|
'type' => 'varchar', |
| 44 |
|
'length' => 255, |
| 45 |
|
'not null' => FALSE, |
| 46 |
|
'description' => t("The URL path of the {custom_link}."), |
| 47 |
|
), |
| 48 |
|
'viewer_perm' => array( |
| 49 |
|
'type' => 'varchar', |
| 50 |
|
'length' => 64, |
| 51 |
|
'not null' => FALSE, |
| 52 |
|
'default' => '', |
| 53 |
|
'description' => t("A role that the viewer must have for the link to be displayed.") |
| 54 |
|
), |
| 55 |
|
'author_perm' => array( |
| 56 |
|
'type' => 'varchar', |
| 57 |
|
'length' => 64, |
| 58 |
|
'not null' => FALSE, |
| 59 |
|
'default' => '', |
| 60 |
|
'description' => t("A role that the author must have for the link to be displayed.") |
| 61 |
|
), |
| 62 |
|
'check_html' => array( |
| 63 |
|
'type' => 'int', |
| 64 |
|
'not null' => TRUE, |
| 65 |
|
'size' => 'small', |
| 66 |
|
'default' => 1, |
| 67 |
|
'description' => t('A boolean flag indicating whether the title field contains raw HTML.'), |
| 68 |
|
), |
| 69 |
|
'display' => array( |
| 70 |
|
'type' => 'int', |
| 71 |
|
'not null' => TRUE, |
| 72 |
|
'size' => 'small', |
| 73 |
|
'default' => 2, |
| 74 |
|
'description' => t('An integer indicating what contexts the link should display in.'), |
| 75 |
|
), |
| 76 |
|
'query' => array( |
| 77 |
|
'type' => 'varchar', |
| 78 |
|
'length' => 255, |
| 79 |
|
'not null' => FALSE, |
| 80 |
|
'default' => 'AND', |
| 81 |
|
'description' => t("An optional querystring to be appended to the URL path."), |
| 82 |
|
), |
| 83 |
|
'fragment' => array( |
| 84 |
|
'type' => 'varchar', |
| 85 |
|
'length' => 255, |
| 86 |
|
'not null' => FALSE, |
| 87 |
|
'default' => 'AND', |
| 88 |
|
'description' => t("An optional anchor fragment to be appended to the URL path."), |
| 89 |
|
), |
| 90 |
|
), |
| 91 |
|
'primary key' => array('lid'), |
| 92 |
|
); |
| 93 |
|
return $schema; |
| 94 |
|
} |
| 95 |
|
|
| 96 |
|
function custom_links_update_1() { |
| 97 |
|
$ret = array(); |
| 98 |
switch ($GLOBALS['db_type']) { |
switch ($GLOBALS['db_type']) { |
| 99 |
case 'mysql': |
case 'mysql': |
| 100 |
case 'mysqli': |
case 'mysqli': |
| 101 |
db_query("CREATE TABLE {custom_link} ( |
$ret[] = update_sql("ALTER TABLE {custom_link} ADD fragment varchar(255)"); |
| 102 |
lid int unsigned NOT NULL auto_increment, |
$ret[] = update_sql("ALTER TABLE {custom_link} ADD query varchar(255)"); |
|
link_key varchar(64) NOT NULL default '', |
|
|
title varchar(255) NOT NULL default '', |
|
|
path varchar(255) NOT NULL default '', |
|
|
node_type varchar(64) default '', |
|
|
author_perm varchar(64) default '', |
|
|
viewer_perm varchar(64) default '', |
|
|
check_html tinyint NOT NULL default 1, |
|
|
display tinyint NOT NULL default 2, |
|
|
PRIMARY KEY (lid) |
|
|
) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); |
|
| 103 |
break; |
break; |
| 104 |
case 'pgsql': |
case 'pgsql': |
| 105 |
db_query("CREATE TABLE {custom_link} ( |
db_add_column($ret, 'custom_link', 'fragment', 'varchar', array('default' => '')); |
| 106 |
lid serial CHECK (nid >= 0), |
db_add_column($ret, 'custom_link', 'query', 'varchar', array('default' => '')); |
|
link_key varchar(64) NOT NULL default '', |
|
|
title varchar(255) NOT NULL default '', |
|
|
path varchar(255) NOT NULL default '', |
|
|
node_type varchar(64) default '', |
|
|
author_perm varchar(64) default '', |
|
|
viewer_perm varchar(64) default '', |
|
|
check_html smallint NOT NULL default 1, |
|
|
display smallint NOT NULL default 2 |
|
|
)"); |
|
|
db_query("CREATE INDEX {custom_link}_lid_idx ON {custom_link} (lid)"); |
|
| 107 |
break; |
break; |
| 108 |
} |
} |
| 109 |
|
return $ret; |
| 110 |
} |
} |
| 111 |
|
|
| 112 |
function custom_links_uninstall() { |
function custom_links_uninstall() { |
| 113 |
db_query('DROP TABLE {custom_link}'); |
drupal_uninstall_schema('custom_links'); |
| 114 |
} |
} |