Mercurial > hg > isophonics-drupal-site
comparison core/modules/tracker/tracker.install @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 /** | |
4 * @file | |
5 * Install, update, and uninstall functions for tracker.module. | |
6 */ | |
7 | |
8 /** | |
9 * Implements hook_uninstall(). | |
10 */ | |
11 function tracker_uninstall() { | |
12 \Drupal::state()->delete('tracker.index_nid'); | |
13 } | |
14 | |
15 /** | |
16 * Implements hook_install(). | |
17 */ | |
18 function tracker_install() { | |
19 $max_nid = db_query('SELECT MAX(nid) FROM {node}')->fetchField(); | |
20 if ($max_nid != 0) { | |
21 \Drupal::state()->set('tracker.index_nid', $max_nid); | |
22 // To avoid timing out while attempting to do a complete indexing, we | |
23 // simply call our cron job to remove stale records and begin the process. | |
24 tracker_cron(); | |
25 } | |
26 } | |
27 | |
28 /** | |
29 * Implements hook_schema(). | |
30 */ | |
31 function tracker_schema() { | |
32 $schema['tracker_node'] = [ | |
33 'description' => 'Tracks when nodes were last changed or commented on.', | |
34 'fields' => [ | |
35 'nid' => [ | |
36 'description' => 'The {node}.nid this record tracks.', | |
37 'type' => 'int', | |
38 'unsigned' => TRUE, | |
39 'not null' => TRUE, | |
40 'default' => 0, | |
41 ], | |
42 'published' => [ | |
43 'description' => 'Boolean indicating whether the node is published.', | |
44 'type' => 'int', | |
45 'not null' => FALSE, | |
46 'default' => 0, | |
47 'size' => 'tiny', | |
48 ], | |
49 'changed' => [ | |
50 'description' => 'The Unix timestamp when the node was most recently saved or commented on.', | |
51 'type' => 'int', | |
52 'unsigned' => TRUE, | |
53 'not null' => TRUE, | |
54 'default' => 0, | |
55 ], | |
56 ], | |
57 'indexes' => [ | |
58 'tracker' => ['published', 'changed'], | |
59 ], | |
60 'primary key' => ['nid'], | |
61 'foreign keys' => [ | |
62 'tracked_node' => [ | |
63 'table' => 'node', | |
64 'columns' => ['nid' => 'nid'], | |
65 ], | |
66 ], | |
67 ]; | |
68 | |
69 $schema['tracker_user'] = [ | |
70 'description' => 'Tracks when nodes were last changed or commented on, for each user that authored the node or one of its comments.', | |
71 'fields' => [ | |
72 'nid' => [ | |
73 'description' => 'The {node}.nid this record tracks.', | |
74 'type' => 'int', | |
75 'unsigned' => TRUE, | |
76 'not null' => TRUE, | |
77 'default' => 0, | |
78 ], | |
79 'uid' => [ | |
80 'description' => 'The {users}.uid of the node author or commenter.', | |
81 'type' => 'int', | |
82 'unsigned' => TRUE, | |
83 'not null' => TRUE, | |
84 'default' => 0, | |
85 ], | |
86 'published' => [ | |
87 'description' => 'Boolean indicating whether the node is published.', | |
88 'type' => 'int', | |
89 'not null' => FALSE, | |
90 'default' => 0, | |
91 'size' => 'tiny', | |
92 ], | |
93 'changed' => [ | |
94 'description' => 'The Unix timestamp when the node was most recently saved or commented on.', | |
95 'type' => 'int', | |
96 'unsigned' => TRUE, | |
97 'not null' => TRUE, | |
98 'default' => 0, | |
99 ], | |
100 ], | |
101 'indexes' => [ | |
102 'tracker' => ['uid', 'published', 'changed'], | |
103 ], | |
104 'primary key' => ['nid', 'uid'], | |
105 'foreign keys' => [ | |
106 'tracked_node' => [ | |
107 'table' => 'node', | |
108 'columns' => ['nid' => 'nid'], | |
109 ], | |
110 'tracked_user' => [ | |
111 'table' => 'users', | |
112 'columns' => ['uid' => 'uid'], | |
113 ], | |
114 ], | |
115 ]; | |
116 | |
117 return $schema; | |
118 } |