Projet

Général

Profil

Paste
Télécharger (2,73 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / user_stats / user_stats.install @ 87dbc3bf

1
<?php
2

    
3
/**
4
 * @file
5
 * Install and update hooks for the User Stats module.
6
 */
7

    
8
/**
9
 * Implements hook_schema().
10
 */
11
function user_stats_schema() {
12
  $schema['user_stats_values'] = array(
13
    'description' => 'User Stats data.',
14
    'fields' => array(
15
      'name' => array(
16
        'type' => 'varchar',
17
        'length' => 128,
18
        'not null' => TRUE,
19
        'default' => '',
20
        'description' => 'The name of the statistic.',
21
      ),
22
      'uid' => array(
23
        'type' => 'int',
24
        'unsigned' => TRUE,
25
        'not null' => TRUE,
26
        'default' => 0,
27
        'description' => 'The {users}.uid of the statistic user.',
28
      ),
29
      'value' => array(
30
        'type' => 'int',
31
        'not null' => TRUE,
32
        'default' => 0,
33
        'description' => 'The value of the statistic.',
34
      ),
35
    ),
36
    'primary key' => array('name', 'uid'),
37
  );
38
  $schema['user_stats_ips'] = array(
39
    'description' => 'IP address storage, links timestamps and uids to IP',
40
    'fields' => array(
41
      'iid' => array(
42
        'type' => 'serial',
43
        'not null' => TRUE,
44
        'description' => 'Primary key: IP address unique ID.',
45
      ),
46
      'uid' => array(
47
        'type' => 'int',
48
        'unsigned' => TRUE,
49
        'not null' => TRUE,
50
        'default' => 0,
51
        'description' => 'The {users}.uid of the user.',
52
      ),
53
      'ip_address' => array(
54
        'type' => 'varchar',
55
        'length' => 40,
56
        'not null' => TRUE,
57
        'default' => '',
58
        'description' => "The user's IP address.",
59
      ),
60
      'first_seen_timestamp' => array(
61
        'description' => 'The Unix timestamp when the IP address was first used by this user.',
62
        'type' => 'int',
63
        'not null' => TRUE,
64
        'default' => 0,
65
      ),
66
    ),
67
    'primary key' => array('iid'),
68
    'indexes' => array(
69
      'uid' => array('uid'),
70
      'first_seen_timestamp' => array('first_seen_timestamp'),
71
    ),
72
  );
73

    
74
  return $schema;
75
}
76

    
77
/**
78
 * Implements hook_uninstall().
79
 */
80
function user_stats_uninstall() {
81
  variable_del('user_stats_rebuild_stats');
82
  variable_del('user_stats_last_cron_check');
83
  variable_del('user_stats_included_content_types');
84
  variable_del('user_stats_reset_login_count');
85
  variable_del('user_stats_reset_post_count');
86
  variable_del('user_stats_user_per_cron');
87
  variable_del('user_stats_count_posts');
88
  variable_del('user_stats_count_comments');
89
  variable_del('user_stats_count_logins');
90
}
91

    
92
/**
93
 * Expands the width of the field table to 40.
94
 */
95
function user_stats_update_7102(&$sandbox) {
96
  $ip_address = array(
97
    'type' => 'varchar',
98
    'length' => 40,
99
    'not null' => TRUE,
100
    'default' => '',
101
    'description' => "The user's IP address.",
102
  );
103
  db_change_field('user_stats_ips', 'ip_address', 'ip_address', $ip_address);
104
}