-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathactivity.install
More file actions
284 lines (265 loc) · 8.76 KB
/
activity.install
File metadata and controls
284 lines (265 loc) · 8.76 KB
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
<?php
// $Id: activity.install,v 1.1.2.1.2.6.2.4.2.15 2010/05/16 04:03:23 scottreynolds Exp $
function activity_install() {
// Set Trigger's weight to 2 so that it will fire AFTER pathauto. This makes
// pathauto alias' work.
if (activity_bad_trigger_weight()) {
drupal_set_message(t('In order for proper Pathauto behavior with Activity module, the Trigger module\'s weight needs to be fixed up. !clickhere', array('!clickhere' => l(t('Click here to fix Trigger\'s weight'), 'admin/activity/weight', array('query' => drupal_get_destination())))), 'error');
}
}
/**
* Implementation of hook_schema().
*/
function activity_schema() {
$schema['activity'] = array(
'description' => 'Provides a place to record activity messages for display.',
'fields' => array(
'aid' => array(
'description' => 'The primary identifier for any activity',
'type' => 'serial',
'not null' => TRUE,
'unsigned' => TRUE,
),
'uid' => array(
'description' => 'The user id of whomever performed the activity being recorded.',
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
),
'type' => array(
'description' => 'The hook that created this activity.',
'type' => 'varchar',
'length' => '50',
'not null' => TRUE,
),
'nid' => array(
'description' => 'A foreign key used with node_access table. Can be NULL for all non-node, comment activities',
'type' => 'int',
'unsigned' => TRUE,
),
'eid' => array(
'description' => 'Entity ID used to maintain the relationship between activity and the entity that created the activity',
'type' => 'int',
'default value' => NULL,
'unsigned' => TRUE,
),
'created' => array(
'description' => 'When the activity was recorded',
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
),
'actions_id' => array(
'description' => 'Id of the action stored in the actions table.',
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
),
'argument1' => array(
'description' => 'Serialized value of first argument passed to the actions callback',
'type' => 'text',
'size' => 'big',
'default' => NULL,
),
'argument2' => array(
'description' => 'Serialized value of second argument passed to the actions callback',
'type' => 'text',
'size' => 'big',
'default' => NULL,
),
'status' => array(
'description' => 'Whether or not this Activity is published',
'type' => 'int',
'size' => 'tiny',
'default' => 1,
),
),
'primary key' => array('aid'),
'indexes' => array(
'nid' => array('nid'),
'eid' => array('eid'),
'created' => array('created'),
),
'foreign keys' => array(
'nid' => array('node' => 'nid'),
'actions_id' => array('actions' => 'aid'),
'uid' => array('user' => 'uid'),
),
);
$schema['activity_targets'] = array(
'fields' => array(
'aid' => array(
'description' => 'Foreign key to the activity table',
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
),
'uid' => array(
'description' => "The uid for which this message is for",
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
),
'amid' => array(
'description' => "The message id for this uid/aid combination",
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
'default' => 0,
),
'language' => array(
'description' => "The IS0-3166 name of the langauge for the associated message.",
'type' => 'varchar',
'not null' => TRUE,
'length' => '12',
),
),
'primary key' => array('aid', 'uid', 'language'),
'unique keys' => array(
'amid' => array('amid'),
),
'foreign keys' => array(
'aid' => array('activity' => 'aid'),
'uid' => array('user' => 'uid'),
'amid' => array('activity_messages' => 'amid'),
),
);
$schema['activity_messages'] = array(
'fields' => array(
'amid' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'The Unique id of the message',
),
'message' => array(
'descripiton' => 'The full plaintext message',
'type' => 'text',
'size' => 'big',
'not null' => TRUE,
),
),
'primary key' => array('amid'),
);
$schema['activity_access'] = array(
'description' => 'Provides access control on a very granular level to activity items',
'fields' => array(
'aid' => array(
'description' => 'The primary identifier for an activity',
'type' => 'int',
'not null' => TRUE,
'unsigned' => TRUE,
),
'realm' => array(
'description' => 'The module providing the access control',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'value' => array(
'description' => 'The provided value from the implementing module. E.g a uid, nid or a tid',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'unsigned' => TRUE,
),
),
// UGG!!!
'primary key' => array('aid', 'realm', 'value'),
'foreign keys' => array(
'aid' => array('activity' => 'aid'),
),
);
return $schema;
}
function activity_uninstall() {
drupal_uninstall_schema('activity');
// clean up actions and triggers
db_query("DELETE FROM {trigger_assignments} WHERE aid IN (SELECT aid FROM {actions} WHERE callback = 'activity_record')");
db_query("DELETE FROM {actions} WHERE callback = 'activity_record'");
// clean variable table
db_query("DELETE FROM {variable} WHERE name = 'activity_expire' OR name = 'activity_count_expire' OR name = 'activity_access_realms'");
}
/**
* Implementation of hook_requirements().
*/
function activity_requirements($phase) {
$requirements = array();
$t = get_t();
if (activity_bad_trigger_weight()) {
$requirements['activity_trigger_weight'] = array(
'title' => $t('Activity Trigger Weight'),
'description' => $t('Activity2 requires Trigger\'s weight be greater then Pathauto\'s in order to produce proper aliased paths. !clickhere to fix that', array('!clickhere' => l(t('Click here'), 'admin/activity/weight', array('query' => drupal_get_destination())))),
'severity' => REQUIREMENT_WARNING,
);
}
return $requirements;
}
/**
* Sets Trigger modules weight to be higher then pathauto.
*/
function activity_fix_trigger_weight() {
db_query("UPDATE {system} SET weight = 2 WHERE name = 'trigger'");
drupal_goto();
}
/**
* Check to see if we need to fix the Trigger weight.
*/
function activity_bad_trigger_weight() {
// Verify Triggers weight.
$pathauto_weight = db_query("SELECT weight FROM {system} WHERE name = 'pathauto'")->fetchField();
if ($pathauto_weight !== FALSE) {
$trigger_weight = db_query("SELECT weight FROM {system} WHERE name = 'trigger'")->fetchField();
return $trigger_weight <= $pathauto_weight;
}
return FALSE;
}
/**
* Update the Activity Messages.amid field to be not null.
* @see: http://drupal.org/node/778662
*/
function activity_update_6201() {
$ret = array();
db_change_field($ret, 'activity_messages', 'amid', 'amid', array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE));
return $ret;
}
/**
* Update {activity} table to have a status field
* @see: http://drupal.org/node/582230
*/
function activity_update_6203() {
$ret = array();
db_add_field ($ret, 'activity', 'status', array(
'description' => 'Whether or not this Activity is published',
'type' => 'int',
'size' => 'tiny',
'default' => 1,
)
);
return $ret;
}
/**
* Upgrade from Drupal 6 to Drupal 7
*/
function activity_update_7300() {
db_query("UPDATE {activity} SET type = CONCAT(type, '_', op)");
drupal_set_message(t('Updated the {activity}.type field by combining it with the op field. In the event that this doesn\'t map properly for some activities, the op field remains for historical purposes only'), 'warning');
$new_fields = array(
'argument1' => array(
'description' => 'Serialized value of first argument passed to the actions callback',
'type' => 'text',
'size' => 'big',
'default' => NULL,
),
'argument2' => array(
'description' => 'Serialized value of second argument passed to the actions callback',
'type' => 'text',
'size' => 'big',
'default' => NULL,
),
);
foreach ($new_fields as $field_name => $field_def) {
db_add_field('activity', $field_name, $field_def);
}
}