3 function activity_install() {
4 drupal_install_schema('activity');
5 // Set Trigger's weight to 2 so that it will fire AFTER pathauto. This makes
6 // pathauto alias' work.
7 if (activity_bad_trigger_weight()) {
8 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');
12 function activity_schema() {
13 $schema['activity'] = array(
14 'description' => 'Provides a place to record activity messages for display.',
17 'description' => 'The primary identifier for any activity',
23 'description' => 'The user id of whomever performed the activity being recorded.',
29 'description' => 'The operation being performed (update, insert, etc.)',
35 'description' => 'The type of object being acted upon (node, user, etc.)',
41 'description' => 'A foreign key used with node_access table. Can be NULL for all non-node, comment activities',
46 'description' => 'Entity ID used to maintain the relationship between activity and the entity that created the activity',
48 'default value' => NULL
,
52 'description' => 'When the activity was recorded',
57 'actions_id' => array(
58 'description' => 'Foreign key to the actions table.',
65 'description' => 'Whether or not this Activity is published',
71 'primary key' => array('aid'),
73 'nid' => array('nid'),
74 'eid' => array('eid'),
75 'created' => array('created'), // Probably not at all useful.
76 'actions_id' => array('actions_id'),
80 $schema['activity_targets'] = array(
83 'description' => 'Foreign key to the activity table',
89 'description' => "The uid for which this message is for",
96 'description' => "The message id for this uid/aid combination",
103 'description' => "The IS0-3166 name of the langauge for the associated message.",
109 'primary key' => array('aid', 'uid', 'language'),
110 'unique keys' => array(
111 'amid' => array('amid'),
115 $schema['activity_messages'] = array(
121 'description' => 'The Unique id of the message',
124 'descripiton' => 'The full plaintext message',
130 'primary key' => array('amid'),
133 $schema['activity_access'] = array(
134 'description' => 'Provides access control on a very granular level to activity items',
137 'description' => 'The primary identifier for an activity',
143 'description' => 'The module providing the access control',
149 'description' => 'The provided value from the implementing module. E.g a uid, nid or a tid',
157 'primary key' => array('aid', 'realm', 'value'),
162 function activity_uninstall() {
163 drupal_uninstall_schema('activity');
165 // clean up actions and triggers
166 db_query("DELETE FROM {trigger_assignments} WHERE aid IN (SELECT aid FROM {actions} WHERE callback = 'activity_record')");
167 db_query("DELETE FROM {actions} WHERE callback = 'activity_record'");
169 // clean variable table
170 db_query("DELETE FROM {variable} WHERE name = 'activity_expire' OR name = 'activity_count_expire' OR name = 'activity_access_realms'");
174 * Implementation of hook_requirements().
176 function activity_requirements($phase) {
177 $requirements = array();
179 $views_schema_version = db_result(db_query("SELECT schema_version FROM {system} WHERE name = 'views'"));
180 if (intval($views_schema_version) < 6006) {
181 $requirements['activity_views'] = array(
182 'title' => $t('Activity Views'),
183 'description' => $t('Activity2 requires Views >= 6.2. It can be downloaded !release. The change that is required by Activity2 is !issue', array('!release' => l('here', 'http://drupal.org/node/488082'), '!issue' => l('#419270', 'http://drupal.org/node/419270'))),
184 // set the severity to warning on install because we don't want to stop the install...
185 'severity' => ($phase == 'install') ? REQUIREMENT_WARNING
: REQUIREMENT_ERROR
,
189 if (activity_bad_trigger_weight()) {
190 $requirements['activity_trigger_weight'] = array(
191 'title' => $t('Activity Trigger Weight'),
192 '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())))),
193 'severity' => REQUIREMENT_WARNING
,
196 return $requirements;
200 * Sets Trigger modules weight to be higher then pathauto.
202 function activity_fix_trigger_weight() {
203 db_query("UPDATE {system} SET weight = 2 WHERE name = 'trigger'");
208 * Check to see if we need to fix the Trigger weight.
210 function activity_bad_trigger_weight() {
211 // Verify Triggers weight.
212 $pathauto_weight = db_result(db_query("SELECT weight FROM {system} WHERE name = 'pathauto'"));
213 if ($pathauto_weight !== FALSE
) {
214 $trigger_weight = db_result(db_query("SELECT weight FROM {system} WHERE name = 'trigger'"));
215 return $trigger_weight <= $pathauto_weight;
221 * Update the Activity Messages.amid field to be not null.
222 * @see: http://drupal.org/node/778662
224 function activity_update_6201() {
226 db_change_field($ret, 'activity_messages', 'amid', 'amid', array('type' => 'serial', 'unsigned' => TRUE
, 'not null' => TRUE
));
231 * Update {activity} table to have the actions_id field.
232 * @see: http://drupal.org/node/463854
234 function activity_update_6202() {
237 db_add_field($ret, 'activity', 'actions_id', array(
238 'description' => 'Foreign key to the actions table.',
244 array('indexes' => array('actions_id' => array('actions_id'))));
250 * Update {activity} table to have a status field
251 * @see: http://drupal.org/node/582230
253 function activity_update_6203() {
256 db_add_field ($ret, 'activity', 'status', array(
257 'description' => 'Whether or not this Activity is published',