/[drupal]/contributions/modules/faq_ask/faq_ask.install
ViewVC logotype

Contents of /contributions/modules/faq_ask/faq_ask.install

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


Revision 1.11 - (show annotations) (download) (as text)
Mon Nov 24 20:13:23 2008 UTC (12 months ago) by nancyw
Branch: MAIN
CVS Tags: HEAD
Changes since 1.10: +2 -1 lines
File MIME type: text/x-php
#338165 by NancyDru for aterz - Add feature to re-assign anonymous question to expert.
1 <?php
2 // $Id: faq_ask.install,v 1.10 2008/10/27 23:16:56 nancyw Exp $
3
4 /**
5 * @file
6 * This module is an add-on to the FAQ module that allows users with the 'ask question'
7 * permission to create a question which will be queued for an 'expert' to answer.
8 */
9
10 /**
11 * Implementation of hook_schema().
12 */
13 function faq_ask_schema() {
14 $schema['faq_expert'] = array(
15 'description' => t('FAQ expert to term mapping.'),
16 'fields' => array(
17 'uid' => array(
18 'description' => t('User identifier for the expert.'),
19 'type' => 'int',
20 'unsigned' => TRUE,
21 'not null' => TRUE,
22 ),
23 'tid' => array(
24 'description' => t('Taxonomy identifier of the terms for the expert.'),
25 'type' => 'int',
26 'unsigned' => TRUE,
27 'not null' => TRUE,
28 ),
29 ),
30 'primary key' => array('uid', 'tid'),
31 'indexes' => array(
32 'tid' => array('tid', 'uid'),
33 ),
34 );
35
36 $schema['faq_questions'] = array(
37 'fields' => array(
38 'nid' => array('type' => 'int',
39 'unsigned' => TRUE,
40 'not null' => TRUE,
41 'default' => 0,
42 'disp-width' => '10'),
43 'vid' => array(
44 'type' => 'int',
45 'unsigned' => TRUE,
46 'not null' => TRUE,
47 'default' => 0,
48 'disp-width' => '10'),
49 'question' => array(
50 'type' => 'text',
51 'not null' => TRUE),
52 ),
53 'primary key' => array('nid', 'vid'),
54 );
55 return $schema;
56 }
57
58 /**
59 * Implementation of hook_install().
60 */
61 function faq_ask_install() {
62 // Note: I did not specify defaults here because an insert should fail if a value is not supplied.
63 switch ($GLOBALS['db_type']) {
64 case 'mysql':
65 case 'mysqli':
66 $result = db_query("CREATE TABLE IF NOT EXISTS {faq_expert} (
67 uid INT(10) UNSIGNED NOT NULL,
68 tid INT(10) UNSIGNED NOT NULL,
69 PRIMARY KEY (uid, tid),
70 INDEX tid (tid, uid)
71 ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
72 break;
73
74 case 'pgsql':
75 $result = db_query("CREATE TABLE {faq_expert} (
76 uid integer NOT NULL,
77 tid integer NOT NULL,
78 PRIMARY KEY (uid, tid)
79 )");
80 db_query("CREATE INDEX {faq_expert}_tid ON {faq_expert} (tid, uid)");
81 break;
82 }
83
84 if ($result) {
85 drupal_set_message(t('faq_ask module installed.'));
86 }
87 else { drupal_set_message(t('faq_ask table creation failed. Please "uninstall" the module and retry.')); }
88 }
89
90 /**
91 * Implementation of hook_update_N().
92 */
93 function faq_ask_update_5100() {
94 $ret = array();
95
96 $ret[] = update_sql('INSERT INTO {faq_expert} (uid, tid) VALUES ('. variable_get('faq_ask_default_expert', 1) .', 0)');
97
98 return $ret;
99 }
100
101 /**
102 * Implementation of hook_uninstall().
103 */
104 function faq_ask_uninstall() {
105 db_query('DROP TABLE {faq_expert}');
106
107 variable_del('faq_expert_role');
108 variable_del('faq_ask_vocabularies');
109 variable_del('faq_ask_title_len');
110 variable_del('faq_ask_suggest');
111 variable_del('faq_ask_notify');
112 variable_del('faq_ask_default_expert');
113 variable_del('faq_unanswered_count');
114 variable_del('faq_ask_expert_advice');
115 variable_del('faq_ask_help_text');
116 variable_del('faq_ask_categorize');
117 variable_del('faq_ask_expert_own');
118
119 drupal_set_message(t('faq_ask module uninstalled.'));
120 }

  ViewVC Help
Powered by ViewVC 1.1.2