aboutsummaryrefslogtreecommitdiff
path: root/reminder.install
blob: 38de02f362a7bc20f1c549cbc408d8a23e372db4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<?php

/**
 * @file
 *
 * Reminder installation callbacks.
 */

/**
 * Implements hook_schema()
 */
function reminder_schema() {
  $schema['reminder'] = array(
    'description' => 'The main informations of the reminders.',
    'fields' => array(
      'nid' => array(
        'description' => 'The contact with the base node.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE
      ),
      'uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0
      ),
      'anonym_name' => array(
        'type' => 'varchar',
        'length' => 100,
        'default' => ''
      ),
      'anonym_email' => array(
        'type' => 'varchar',
        'length' => 100,
        'default' => ''
      ),
      'until' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '0'
      ),
      'interval' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '0'
      ),
      'url' => array(
        'type' => 'varchar',
        'length' => 10,
        'not null' => TRUE,
        'default' => ''
      ),
      'admin_url' => array(
        'type' => 'varchar',
        'length' => 25,
        'not null' => TRUE,
        'default' => ''
      ),
      'secure' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => '0'
      ),
    ),
    'primary key' => array('nid'),
  );

  $schema['reminder_subscriptions'] = array(
    'description' => 'The table of subscribed users.',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE
      ),
      'email' => array(
        'type' => 'varchar',
        'length' => 100,
        'default' => ''
      ),
      'reminder_id' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0
      ),
      'unsubscribe_url' => array(
        'type' => 'varchar',
        'length' => 25,
        'not null' => TRUE,
        'default' => ''
      ),
    ),

    'primary key' => array('id'),
  );

  $schema['reminder_logs'] = array(
    'description' => 'Log table.',
    'fields' => array(
      'log_id' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE
      ),
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0
      ),
      'username' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => ''
      ),
      'dt' => array(
        'type' => 'int',
        'not null' => TRUE,
      ),
    ),

    'primary key' => array('log_id'),
  );

  $schema['reminder_notifications'] = array(
    'description' => 'The table of sent notifications.',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE
      ),
      'reminder_id' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
        'default' => 0
      ),
      'last' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '0'
      ),
    ),

    'primary key' => array('id'),
  );

  return $schema;
}

/**
 * Adds notification table.
 */
function reminder_update_7000(&$sandbox) {
  // Make sure to not run this update twice.
  if (db_table_exists('reminder_notifications')) {
    return;
  }

  $schema = reminder_schema();
  db_create_table('reminder_notifications', $schema['reminder_notifications']);
}