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

Diff of /contributions/modules/timemap/timemap.install

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

revision 1.1, Mon Jun 2 03:43:49 2008 UTC revision 1.2, Tue Jul 7 03:27:15 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id$  // $Id: timemap.install,v 1.1 2008/06/02 03:43:49 sethfreach Exp $
3    
4    
5    /**
6     * Implementation of hook_schema().
7     */
8    function timemap_schema() {
9      $schema['timemap_doings'] = array(
10        'description' => t('table that stores the entries'),
11        'fields' => array(
12          'did' => array(
13            'description' => t('doing ID'),
14            'type' => 'serial',
15            'unsigned' => TRUE,
16            'not null' => TRUE,
17          ),
18          'uid' => array(
19            'description' => t('user uid'),
20            'type' => 'int',
21            'unsigned' => TRUE,
22            'not null' => TRUE,
23            'default' => 0,
24          ),
25          'cid' => array(
26            'description' => t('category cid'),
27            'type' => 'int',
28            'not null' => TRUE,
29            'default' => 0,
30          ),
31          'task' => array(
32            'description' => t('actual text entered'),
33            'type' => 'varchar',
34            'length' => 255,
35            'not null' => TRUE,
36            'default' => '',
37          ),
38          'time' => array(
39            'description' => t('timestamp start'),
40            'type' => 'int',
41            'unsigned' => TRUE,
42            'not null' => TRUE,
43            'default' => 0,
44          ),
45          'stop' => array(
46            'description' => t('timestamp stop'),
47            'type' => 'int',
48            'unsigned' => TRUE,
49            'not null' => TRUE,
50            'default' => 0,
51          ),
52        ),
53        'indexes' => array(
54          'uid' => array('uid'),
55        ),
56        'primary key' => array('did'),
57      );
58    
59      $schema['timemap_categories'] = array(
60        'description' => t('Categories that tasks can fall into'),
61        'fields' => array(
62          'cid' => array(
63            'description' => t('category ID'),
64            'type' => 'serial',
65            'unsigned' => TRUE,
66            'not null' => TRUE,
67          ),
68          'uid' => array(
69            'description' => t('user uid'),
70            'type' => 'int',
71            'unsigned' => TRUE,
72            'not null' => TRUE,
73            'default' => 0,
74          ),
75          'category' => array(
76            'description' => t('text name of the category'),
77            'type' => 'varchar',
78            'length' => 255,
79            'not null' => TRUE,
80            'default' => '',
81          ),
82          'active' => array(
83            'description' => t('off / on switch'),
84            'type' => 'int',
85            'size' => 'tiny',
86            'unsigned' => TRUE,
87            'not null' => TRUE,
88            'default' => 1,
89          ),
90        ),
91        'indexes' => array(
92          'uid' => array('uid'),
93          'active' => array('active'),
94        ),
95        'primary key' => array('cid'),
96      );
97    
98      $schema['timemap_catcolor'] = array(
99        'description' => t('colors to assign categories'),
100        'fields' => array(
101          'ccid' => array(
102            'description' => t('category color ID'),
103            'type' => 'serial',
104            'unsigned' => TRUE,
105            'not null' => TRUE,
106          ),
107          'cid' => array(
108            'description' => t('category ID'),
109            'type' => 'int',
110            'unsigned' => TRUE,
111            'not null' => TRUE,
112            'default' => 0,
113          ),
114          'uid' => array(
115            'description' => t('user UID'),
116            'type' => 'int',
117            'unsigned' => TRUE,
118            'not null' => TRUE,
119            'default' => 0,
120          ),
121          'hex' => array(
122            'description' => t('hex value of color'),
123            'type' => 'char',
124            'not null' => TRUE,
125            'default' => ffffff,
126          ),
127        ),
128        'indexes' => array(
129          'uid' => array('uid'),
130        ),
131        'primary key' => array('ccid'),
132      );
133    
134      return $schema;
135    }
136    
137  function timemap_install() {  function timemap_install() {
138    switch ($GLOBALS['db_type']) {    // Create tables.
139      case 'mysqli':    drupal_install_schema('timemap');
     case 'mysql':  
       $query1 = db_query(  
 <<<QUERY  
 CREATE TABLE {timemap_doings} (  
   did int(10) unsigned NOT NULL AUTO_INCREMENT,  
   uid int(10) unsigned NOT NULL default '0',  
   cid int(10) NOT NULL default '0',  
   task varchar(255) NOT NULL default '',  
   time int(10) unsigned NOT NULL default '0',  
   stop int(10) unsigned NOT NULL default '0',  
   PRIMARY KEY  (did),  
   KEY uid (uid)  
 ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;  
 QUERY  
       );  
         $query2 = db_query(  
 <<<QUERY  
 CREATE TABLE {timemap_categories} (  
   cid int(10) unsigned NOT NULL AUTO_INCREMENT,  
   uid int(10) unsigned NOT NULL default '0',  
   category varchar(255) NOT NULL default '',  
   active tinyint(1) unsigned NOT NULL default '1',  
   PRIMARY KEY cid (cid),  
   KEY uid (uid),  
   KEY active (active)  
 ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;  
 QUERY  
       );  
         $query3 = db_query(  
 <<<QUERY  
 CREATE TABLE {timemap_catcolor} (  
   ccid int(10) unsigned NOT NULL AUTO_INCREMENT,  
   cid int(10) unsigned NOT NULL default '0',  
   uid int(10) unsigned NOT NULL default '0',  
   hex char(7) NOT NULL default 'ffffff',  
   PRIMARY KEY ccid (ccid),  
   KEY uid (uid)  
 ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;  
 QUERY  
       );  
   
   
       if ($query1 && $query2 && $query3) {  
         drupal_set_message(t('The timemap module has successfully added tables to the MySQL database.'));  
       }  
       else {  
         drupal_set_message(t('Drupal was unable to install the database tables for the timemap module.'), 'error');  
       }  
       break;  
   
     case 'pgsql':  
         drupal_set_message(t('Drupal was unable to install the database tables for the timemap module.'));  
       break;  
   }  
140  }  }
141    
142  /**  /**
143   * Implementation of hook_uninstall().   * Implementation of hook_uninstall().
144   */   */
145  function timemap_uninstall() {  function timemap_uninstall() {
146    db_query('DROP TABLE {timemap_doings}');    // Remove tables.
147    db_query('DROP TABLE {timemap_categories}');    drupal_uninstall_schema('timemap');
148    db_query('DROP TABLE {timemap_catcolor}');  
149  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.2