Issue #1426576 by ay13, ezra-g: Fixed Activity log resizes images regardless of Image...
[project/activity_log.git] / activity_log.install
1 <?php
2
3 /**
4 * @file
5 * (Un)installs the Rules Activity Logging module.
6 */
7
8 /**
9 * Implementation of hook_schema().
10 */
11 function activity_log_schema() {
12 $schema = array();
13 $schema['activity_log_templates'] = array(
14 'description' => 'Stores log templates.',
15 'fields' => array(
16 'tid' => array(
17 'type' => 'serial',
18 'not null' => TRUE,
19 'unsigned' => TRUE,
20 'description' => 'The template ID.',
21 ),
22 'rule' => array(
23 'type' => 'varchar',
24 'length' => '255',
25 'not null' => TRUE,
26 'default' => '',
27 'description' => 'The rule with which this template is associated.',
28 ),
29 'action_label' => array(
30 'type' => 'varchar',
31 'length' => '255',
32 'not null' => TRUE,
33 'default' => '',
34 'description' => 'The label of the action with which this template is associated.',
35 ),
36 'template' => array(
37 'type' => 'text',
38 'not null' => TRUE,
39 'description' => 'The template.',
40 ),
41 'group_template' => array(
42 'type' => 'text',
43 'not null' => TRUE,
44 'description' => 'The grouped message template.',
45 ),
46 'group_summary' => array(
47 'type' => 'text',
48 'not null' => TRUE,
49 'description' => 'The short template summary for grouped messages.',
50 ),
51 'collapse_method' => array(
52 'type' => 'varchar',
53 'length' => '255',
54 'not null' => TRUE,
55 'default' => '',
56 'description' => 'The method used to combine action summaries if applicable.',
57 ),
58 'pid' => array(
59 'type' => 'int',
60 'not null' => TRUE,
61 'unsigned' => TRUE,
62 'default' => 0,
63 'description' => 'The public name ID.',
64 ),
65 'eval_input' => array(
66 'type' => 'text',
67 'not null' => TRUE,
68 'description' => 'An array of the input evaluators to run over the template.',
69 ),
70 'resources' => array(
71 'type' => 'text',
72 'not null' => TRUE,
73 'description' => 'The CSS and JS resources required by this template.',
74 ),
75 'cacheable' => array(
76 'type' => 'int',
77 'size' => 'tiny',
78 'not null' => TRUE,
79 'unsigned' => TRUE,
80 'default' => 0,
81 'description' => 'Whether messages saved with this template should be cached.',
82 ),
83 'display_type' => array(
84 'type' => 'varchar',
85 'length' => '255',
86 'not null' => TRUE,
87 'default' => 'web',
88 'description' => 'Where messages generated using this template should be displayed. Typical values are "web," "email," and "alert." There may also be a use for "mobile," "print," etc. but there is not a default implementation for these.',
89 ),
90 ),
91 'indexes' => array(
92 'pid' => array('pid'),
93 ),
94 'primary key' => array('tid'),
95 );
96 $schema['activity_log_events'] = array(
97 'description' => 'Stores activity records.',
98 'fields' => array(
99 'aid' => array(
100 'type' => 'serial',
101 'not null' => TRUE,
102 'unsigned' => TRUE,
103 'description' => 'The activity ID.',
104 ),
105 'tid' => array(
106 'type' => 'int',
107 'not null' => TRUE,
108 'unsigned' => TRUE,
109 'default' => 0,
110 'description' => 'The template ID.',
111 ),
112 'created' => array(
113 'type' => 'int',
114 'not null' => TRUE,
115 'unsigned' => TRUE,
116 'default' => 0,
117 'description' => 'The time the activity occurred.',
118 ),
119 'acting_uid' => array(
120 'type' => 'int',
121 'not null' => TRUE,
122 'unsigned' => TRUE,
123 'default' => 0,
124 'description' => 'The ID of the user who took the action.',
125 ),
126 'target_id' => array(
127 'type' => 'int',
128 'unsigned' => TRUE,
129 'not null' => TRUE,
130 'default' => 0,
131 'description' => 'The ID of the entity this action is about.',
132 ),
133 'target_type' => array(
134 'type' => 'varchar',
135 'length' => 255,
136 'not null' => TRUE,
137 'default' => '',
138 'description' => 'The type of the entity this action is about.',
139 ),
140 'target_class' => array(
141 'type' => 'varchar',
142 'length' => 255,
143 'not null' => TRUE,
144 'default' => '',
145 'description' => 'The Rules data type class of the entity this action is about.',
146 ),
147 'id_map' => array(
148 'type' => 'text',
149 'not null' => TRUE,
150 'description' => 'Data used to generate tokens to interpret the message.',
151 ),
152 ),
153 'indexes' => array(
154 'tid' => array('tid'),
155 'created' => array('created'),
156 'acting_uid' => array('acting_uid'),
157 'target_id' => array('target_id'),
158 ),
159 'primary key' => array('aid'),
160 );
161 $schema['activity_log_messages'] = array(
162 'description' => 'Stores the information used to build the actual streams, including grouped events.',
163 'fields' => array(
164 'mid' => array(
165 'type' => 'serial',
166 'not null' => TRUE,
167 'unsigned' => TRUE,
168 'description' => 'The message ID.',
169 ),
170 'tid' => array(
171 'type' => 'int',
172 'not null' => TRUE,
173 'unsigned' => TRUE,
174 'default' => 0,
175 'description' => 'The template ID.',
176 ),
177 'aids' => array(
178 'type' => 'text',
179 'not null' => TRUE,
180 'description' => 'A comma-separated list of activity record IDs (foreign keys to the events table).',
181 ),
182 'created' => array(
183 'type' => 'int',
184 'not null' => TRUE,
185 'unsigned' => TRUE,
186 'default' => 0,
187 'description' => 'The time the first event in the group occurred.',
188 ),
189 'last_updated' => array(
190 'type' => 'int',
191 'not null' => TRUE,
192 'unsigned' => TRUE,
193 'default' => 0,
194 'description' => 'The time the most recent event was added to this group.',
195 ),
196 'stream_owner_id' => array(
197 'type' => 'int',
198 'unsigned' => TRUE,
199 'not null' => TRUE,
200 'default' => 0,
201 'description' => 'The ID of the entity in whose stream this record should appear.',
202 ),
203 'stream_owner_type' => array(
204 'type' => 'varchar',
205 'length' => 255,
206 'not null' => TRUE,
207 'default' => '',
208 'description' => 'The entity type of the stream owner.',
209 ),
210 'viewer_id' => array(
211 'type' => 'int',
212 'unsigned' => FALSE, // Negative numbers are flags. Range -/+ 2,147,483,647
213 'not null' => TRUE,
214 'default' => 0,
215 'description' => 'The ID of the user to whom this message will appear.',
216 ),
217 'target_id' => array(
218 'type' => 'int',
219 'unsigned' => TRUE,
220 'not null' => TRUE,
221 'default' => 0,
222 'description' => 'The ID of the entity this action is about.',
223 ),
224 'target_type' => array(
225 'type' => 'varchar',
226 'length' => 255,
227 'not null' => TRUE,
228 'default' => '',
229 'description' => 'The type of the entity this action is about.',
230 ),
231 'acting_uid' => array(
232 'type' => 'int',
233 'not null' => TRUE,
234 'unsigned' => TRUE,
235 'default' => 0,
236 'description' => 'The ID of the user who took the action.',
237 ),
238 'cached' => array(
239 'type' => 'text',
240 'not null' => TRUE,
241 'description' => 'The cached message HTML, fully evaluated.',
242 ),
243 ),
244 'indexes' => array(
245 'tid' => array('tid'),
246 'last_updated' => array('last_updated'),
247 'stream_owner_id' => array('stream_owner_id'),
248 'viewer_id' => array('viewer_id'),
249 'target_id' => array('target_id'),
250 'acting_uid' => array('acting_uid'),
251 ),
252 'primary key' => array('mid'),
253 );
254 $schema['activity_log_disabled_types'] = array(
255 'description' => 'Stores log templates.',
256 'fields' => array(
257 'uid' => array(
258 'type' => 'int',
259 'unsigned' => TRUE,
260 'not null' => TRUE,
261 'default' => 0,
262 'description' => 'The ID of the user who disabled this type.',
263 ),
264 'pid' => array(
265 'type' => 'int',
266 'unsigned' => TRUE,
267 'not null' => TRUE,
268 'default' => 0,
269 'description' => 'The activity type the user does not want included in their stream.',
270 ),
271 ),
272 'indexes' => array(
273 'uid' => array('uid'),
274 ),
275 );
276 $schema['activity_log_action_names'] = array(
277 'description' => 'Stores activity records.',
278 'fields' => array(
279 'pid' => array(
280 'type' => 'serial',
281 'not null' => TRUE,
282 'unsigned' => TRUE,
283 'description' => 'The name ID.',
284 ),
285 'public_name' => array(
286 'type' => 'varchar',
287 'length' => '255',
288 'not null' => TRUE,
289 'default' => '',
290 'description' => 'The title of the activity type that is shown to users who have the option to enable/disable activity types.',
291 ),
292 ),
293 'unique keys' => array(
294 'public_name' => array('public_name'),
295 ),
296 'primary key' => array('pid'),
297 );
298 return $schema;
299 }
300
301 /**
302 * Implementation of hook_install().
303 */
304 function activity_log_install() {
305 drupal_install_schema('activity_log');
306
307 module_load_include('module', 'activity_log');
308 if (function_exists('_activity_log_rebuild_templates')) {
309 $default_rule_count = _activity_log_rebuild_templates();
310 if ($default_rule_count) {
311 drupal_set_message(st('Finished building !count default Activity Log templates.', array('!count' => $default_rule_count)));
312 }
313 }
314
315 variable_set('facebook_status_user_other_view', 'activity_log_stream');
316
317 drupal_set_message(st('The Activity Log module has finished installing.') .' '.
318 empty($default_rule_count) ?
319 st('To begin recording activity messages, <a href="!rules">create a Rule</a> that executes the "Log Activity" action.',
320 array('!rules' => url('admin/rules/trigger'))
321 ) .' '. st('Once you have your Rules configured, you can use the <a href="!activities">Activities view</a> to see activity on your site.',
322 array('!activities' => url('activities'))
323 ) : st('Default activity message templates have already been installed.') .' '.
324 st('Activity Log uses Rules to define its templates, so you can change which ones to use by <a href="!rules">configuring Rules</a>.',
325 array('!rules' => url('admin/rules/trigger'))
326 )
327 );
328 }
329
330 /**
331 * Implementation of hook_uninstall().
332 */
333 function activity_log_uninstall() {
334 drupal_uninstall_schema('activity_log');
335 variable_del('activity_log_max_age');
336 variable_del('activity_log_comments_bump');
337 if (db_table_exists('radioactivity')) {
338 db_query("DELETE FROM {radioactivity} WHERE class='act_log'");
339 }
340 if (!module_exists('facebook_status')) {
341 variable_del('facebook_status_user_other_view');
342 }
343 }