/[drupal]/contributions/modules/netforum_nodes/netforum_node.install
ViewVC logotype

Contents of /contributions/modules/netforum_nodes/netforum_node.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.11 - (show annotations) (download) (as text)
Thu Nov 29 03:28:51 2007 UTC (2 years ago) by jamesmichaelhill
Branch: MAIN
CVS Tags: DRUPAL-5--0-8-5, DRUPAL-5--0-8-7, DRUPAL-5--0-8-6, HEAD
Branch point for: DRUPAL-5
Changes since 1.10: +5 -2 lines
File MIME type: text/x-php
Expanded template code options for creating and linking to nodes
1 <?php
2 // $Id: netforum_node.install,v 1.10 2007/11/18 19:39:32 jamesmichaelhill Exp $
3
4 function netforum_node_update_1() {
5 switch ($GLOBALS['db_type']) {
6 case 'pgsql':
7 return array();
8 break;
9
10 case 'mysql':
11 case 'mysqli':
12 $ret[] = update_sql("ALTER TABLE {netforum_node_types} ADD (nftid int(10) unsigned not null, code varchar(60) not null, is_default int(1) default 0, taxonomy text, format int(11) not null )");
13 $ret[] = update_sql("UPDATE {netforum_node_types} set code=substring(nft_obj_key, 1, 8)");
14 $res = db_query("SELECT nft_obj_key FROM {netforum_node_types}");
15 while($row = db_fetch_array($res)) {
16 $ret[] = update_sql("UPDATE {netforum_node_types} SET nftid = ". db_next_id("{netforum_node_types}_nftid") ." WHERE nft_obj_key = '". $row['nft_obj_key'] ."' " );
17 }
18 $ret[] = update_sql("ALTER TABLE {netforum_node_types} drop primary key");
19 $ret[] = update_sql("ALTER TABLE {netforum_node_types} ADD PRIMARY KEY(nftid)");
20 $ret[] = update_sql("ALTER TABLE {netforum_node_types} ADD key(nft_obj_key)");
21 $ret[] = update_sql("ALTER TABLE {netforum_node_types} ADD key(code) ");
22
23 $ret[] = update_sql("ALTER TABLE {netforum_node} ADD (template_code varchar(60))");
24 break;
25 }
26
27 cache_clear_all('*', 'cache_menu', TRUE);
28
29 return $ret;
30
31 }
32
33 /**
34 * Implementation of hook_install
35 * Adding table netforum_request_cache
36 */
37 function netforum_node_install() {
38 switch ($GLOBALS['db_type']) {
39 case 'pgsql':
40 $success = FALSE;
41 break;
42
43 case 'mysql':
44 case 'mysqli':
45
46 db_query("CREATE TABLE {netforum_node_types} (
47 nftid int(10) unsigned not null,
48 nft_obj_key varchar(36) NOT NULL,
49 code varchar(60) NOT NULL,
50 is_default int(1) default 0,
51 default_title varchar(128),
52 default_body longtext,
53 taxonomy text,
54 format int(11) not null,
55 PRIMARY KEY (nftid),
56 KEY (nft_obj_key),
57 KEY (code)
58 ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
59
60 db_query("CREATE TABLE {netforum_node} (
61 nid int(10) unsigned not null,
62 vid int(10) unsigned not null,
63 nfn_obj_key varchar(36),
64 nfn_key varchar(36),
65 template_code varchar(60),
66 unparsed_title varchar(128),
67 unparsed_body longtext,
68 PRIMARY KEY (vid, nid),
69 KEY (nfn_obj_key),
70 KEY (nfn_key)
71 ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
72
73 db_query("CREATE TABLE {netforum_node_special_fields} (
74 field_code varchar(100) not null,
75 field_description varchar(255),
76 field_value text,
77 PRIMARY KEY (field_code)
78 ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
79
80 $default_special_fields = array(
81 'Defaultatckey' => array('field_value' => '', 'field_description' => t('Default business unit key')),
82 'Businessunitdefaultkey' => array('field_value' => '', 'field_description' => t('Default business unit key')),
83 'Currentdate' => array('field_value' => '<?php print strftime("%Y-%m-%d"); ?>', 'field_description' => t('Current date in mm/dd/yyyy format')),
84 'Currentdatetime' => array('field_value' => '<?php print strftime("%Y-%m-%d %I:%M %p"); ?>', 'field_description' => t('Current date and time in mm/dd/yyyy HH:MM am/pm format')),
85 'Httpserverpath' => array('field_value' => '<?php print base_path(); ?>', 'field_description' => t('Base server path')),
86 'Httpservername' => array('field_value' => '<?php print $_SERVER["HTTP_HOST"]; ?>', 'field_description' => t('Server name')),
87 'Applicationpath' => array('field_value' => '<?php print $_GET["q"]; ?>', 'field_description' => t('Application path')),
88 'Apptitle' => array('field_value' => '<?php print variable_get("site_name", ""); ?>', 'field_description' => t('Site title')),
89 'Currentusergroups' => array('field_value' => '<?php global $user; print implode(", ", $user->roles); ?>', 'field_description' => t('Current roles on the Drupal site')),
90 'Sessionid' => array('field_value' => '<?php print session_id(); ?>', 'field_description' => t('PHP Session ID')),
91 'Currentuserkey' => array('field_value' => '<?php global $user; print $user->cst_key; ?>', 'field_description' => t('Current user key')),
92 'Customerkey' => array('field_value' => '<?php global $user; print $user->cst_key; ?>', 'field_description' => t('Current customer key')),
93 'Currentusername' => array('field_value' => '<?php global $user; print $user->cst_name_cp; ?>', 'field_description' => t('Current user name')),
94 'Currentuserlogin' => array('field_value' => '<?php global $user; print $user->name; ?>', 'field_description' => t('Current user login')),
95 'Customertype' => array('field_value' => '<?php global $user; print $user->cst_type; ?>', 'field_description' => t('Current user customer type (Individual or Organization)')),
96 'BasePath' => array('field_value' => '<?php print base_path(); ?>', 'field_description' => t('The base path of the Drupal installation')),
97 );
98 foreach ($default_special_fields as $field_code => $data) {
99 db_query("INSERT INTO {netforum_node_special_fields} (field_code, field_value, field_description) VALUES('%s', '%s', '%s') ", $field_code, $data['field_value'], $data['field_description']);
100 }
101
102 $success = TRUE;
103 break;
104 } // End case
105
106 // Notify of changes
107 if ($success) {
108 drupal_set_message(t('netFORUM Dynamic Facade Nodes module installed tables successfully.'));
109 }
110 else {
111 drupal_set_message(t('The installation of netFORUM Dynamic Facade Nodes module was unsuccessful.'), 'error');
112 }
113 }
114
115 function netforum_node_uninstall() {
116 db_query('DROP TABLE {netforum_node_types}');
117 db_query('DROP TABLE {netforum_node}');
118 db_query('DROP TABLE {netforum_node_special_fields}');
119 drupal_set_message(t('netFORUM Dynamic Facade Nodes module has been successfully uninstalled.'));
120 }

  ViewVC Help
Powered by ViewVC 1.1.2