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

Diff of /contributions/modules/coppa/coppa.install

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

revision 1.1, Tue Jul 22 22:47:21 2008 UTC revision 1.2, Mon Feb 9 19:12:26 2009 UTC
# Line 2  Line 2 
2    
3  // $Id  // $Id
4    
5    /**
6     * Implementation of hook_install().
7     */
8  function coppa_install() {  function coppa_install() {
9    // key is a db reserved word for some db's so we use code instead    drupal_install_schema('coppa');
   switch ($GLOBALS['db_type']) {  
     case 'mysql':  
     case 'mysqli':  
       db_query("CREATE TABLE {coppa} (  
         pid INT NOT NULL DEFAULT 0,  
         cid INT NOT NULL DEFAULT 0,  
         status INT(10) NOT NULL DEFAULT 0,  
         PRIMARY KEY coppa_pkey (`pid`, `cid`),  
         INDEX `pid` (`pid`),  
         INDEX `cid` (`cid`)  
       )  
       /*!40100 DEFAULT CHARACTER SET utf8 */ COMMENT = 'track P/G relationship to children and COPPA compliance status (0=>not compliant child < 13, 1=>coppa not necessary child > 13, datestamp=>date P/G signed coppa'");  
       break;  
   }  
   
   // add profile dob if not present  
   // no API for this :-(  
   $result = db_query("SELECT fid FROM {profile_fields} WHERE title = 'Date of Birth'");  
   $r = db_fetch_array($result);  
   if (!$r) {  
     db_query("INSERT INTO {profile_fields} (title, name, explanation, category, type, weight, required, register, visibility, autocomplete, options, page)  
               VALUES ('%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, %d, '%s', '%s')",  
               'Date of Birth', 'profile_dob', 'Users\' date of birth', 'coppa', 'date', 0, 0, 0, PROFILE_PUBLIC, 0, '', '');  
     watchdog('profile', t('Profile field Date of Birth added under category coppa.'));  
     cache_clear_all();  
   }  
   
10  }  }
11    
12    /**
13     * Implementation of hook_uninstall().
14     */
15  function coppa_uninstall() {  function coppa_uninstall() {
16    switch ($GLOBALS['db_type']) {    drupal_uninstall_schema('coppa');
17      case 'mysql':  }
18      case 'mysqli':  
19        db_query("DROP TABLE {coppa}");  /**
20        break;   * Implementation of hook_schema().
21    }   */
22    function coppa_schema() {
23      $schema['coppa'] = array(
24        'description' => 'Track parent/guardian relationship to children and COPPA compliance status.',
25        'fields' => array(
26          'pid' => array(
27            'description' => 'Parent ID referencing {users}.uid.',
28            'type' => 'int',
29            'unsigned' => TRUE,
30            'not null' => TRUE,
31          ),
32          'cid' => array(
33            'description' => 'Child ID referencing {users}.uid.',
34            'type' => 'int',
35            'unsigned' => TRUE,
36            'not null' => TRUE,
37          ),
38          'status' => array(
39            'description' => 'COPPA compliance status.',
40            'type' => 'int',
41            'unsigned' => TRUE,
42            'default' => 0,
43            'not null' => TRUE,
44          ),
45        ),
46        'primary key' => array('pid', 'cid'),
47        'indexes' => array(
48          'pid' => array('pid'),
49          'cid' => array('cid'),
50        ),
51      );
52    
53      return $schema;
54  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.2