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

Diff of /contributions/modules/planet/planet.install

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

revision 1.3 by daryl, Wed May 30 03:22:01 2007 UTC revision 1.4 by swe3tdave, Wed Mar 11 23:15:34 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: planet.install,v 1.2 2007/05/10 20:27:41 daryl Exp $  // $Id: planet.install Exp $
3    
4    /**
5     * Implementation of hook_schema().
6     */
7    
8    function planet_schema() {
9      $schema['planet_feeds'] = array(
10        'description' => t('The base table for planet.'),
11        'fields' => array(
12          'fid' => array(
13            'description' => t('The primary identifier for a planet_feeds table.'),
14            'type' => 'serial',
15            'unsigned' => TRUE,
16            'not null' => TRUE,
17          ),
18          'uid' => array(
19            'type' => 'int',
20            'unsigned' => 1,
21            'not null' => FALSE,
22          ),
23          'title' => array(
24            'type' => 'varchar',
25            'length' => 50,
26            'not null' => TRUE,
27          ),
28          'link' => array(
29            'type' => 'varchar',
30            'length' => 80,
31            'not null' => TRUE,
32          ),
33          'image' => array(
34            'type' => 'varchar',
35            'length' => 120,
36            'not null' => FALSE,
37          ),
38          'checked' => array(
39            'type' => 'int',
40            'not null' => FALSE,
41          ),
42          'frozen' => array(
43            'type' => 'int',
44            'not null' => TRUE,
45            'default' => 0,
46          ),
47        ),
48        'primary key' => array('fid'),
49      );
50    
51      $schema['planet_items'] = array(
52        'description' => t('contain feed id and its corresponding nid'),
53        'fields' => array(
54          'id' => array(
55            'description' => t('The primary identifier for a planet_items table'),
56            'type' => 'serial',
57            'unsigned' => 1,
58            'not null' => TRUE,
59          ),
60          'fid' => array(
61            'type' => 'int',
62            'unsigned' => 1,
63            'not null' => FALSE,
64          ),
65          'nid' => array(
66            'type' => 'int',
67            'unsigned' => 1,
68            'not null' => FALSE,
69          ),
70          'guid' => array(
71            'type' => 'varchar',
72            'length' => 120,
73            'not null' => FALSE,
74          ),
75          'link' => array(
76            'type' => 'varchar',
77            'length' => 180,
78            'not null' => FALSE,
79          ),
80          'created' => array(
81            'type' => 'int',
82            'not null' => FALSE,
83          ),
84        ),
85        'primary key' => array('id'),
86      );
87    
88      return $schema;
89    }
90    
91  /**  /**
92   * Implementation of hook_install()   * Implementation of hook_install()
# Line 8  Line 95 
95   *   *
96   * If you are using another database, you will have to install the tables by hand, using the queries below as a reference.   * If you are using another database, you will have to install the tables by hand, using the queries below as a reference.
97   *   *
98   * Note that the curly braces around table names are a drupal-specific feature to allow for automatic database table prefixing,   *
  * and will need to be removed.  
99   */   */
100    
101  function planet_install() {  function planet_install() {
102          switch ($GLOBALS['db_type']) {    // Create tables.
103                  case 'mysql':    drupal_install_schema('planet');
                 case 'mysqli':  
                         db_query("CREATE TABLE {planet_feeds}(  
                         fid int(10) unsigned zerofill not null primary key auto_increment,  
                         uid int(10) unsigned zerofill,  
                         title varchar(50),  
                         link varchar(80),  
                         image varchar(120),  
                         checked int(11),  
                         frozen tinyint default 0  
                         ) /*!40100 DEFAULT CHARACTER SET utf8 */;");  
   
                         db_query("CREATE TABLE {planet_items}(  
                                 id int(10) unsigned zerofill not null primary key auto_increment,  
                                 fid int(10) unsigned zerofill,  
                                 nid int(10) unsigned zerofill,  
                                 guid varchar(120),  
                                 link varchar(180),  
                                 created int(11)  
                                 ) /*!40100 DEFAULT CHARACTER SET utf8 */;");  
   
                         break;  
         }  
104  }  }
105    
106  ?>  /**
107     * Implementation of hook_uninstall()
108     *
109     * This will automatically uninstall the database tables for the planet module for MySQL.
110     *
111     *
112     */
113    
114    function planet_uninstall() {
115      variable_del('planet_redirect_page');
116      variable_del('planet_filter_formats');
117      variable_del('planet_author_roles');
118      cache_clear_all('planet:', 'cache', true);
119      drupal_uninstall_schema('planet');
120      db_query("DELETE FROM {node} WHERE type = '%s'", planet);
121    
122    }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.3