5 * Hook documentation for the Activity Log module.
9 * Implementation of hook_activity_log_collapse_methods().
11 * Specifies available options for combining an array of strings into a single
12 * string. These options are exposed on the "Log activity" Rules action form
13 * and are used to collapse an array of evaluated items into the [collection]
14 * token in the group template.
17 * An associative array of options where the key is the name of the
18 * function for collapsing an array and the value is the human-friendly name
19 * of the option. The available functions should take a $collection array and
20 * an integral $count of the number of items in that collection as parameters
21 * and return a string summarizing the items in the $collection. The
22 * $collection will always have at least 2 items.
24 function hook_activity_log_collapse_methods() {
26 'activity_log_collapse_inline' => t('Inline (A, B, and 3 others)'),
27 'activity_log_collapse_list_horizontal' => t('Horizontal list (A B C D)'),
28 'activity_log_collapse_list_vertical' => t('Vertical list (each item on its own line)'),
33 * Implementation of hook_activity_log_event().
35 * Invoked when an activity is logged; allows taking action when this happens.
38 * The activity event object (properties correspond with the columns in the
39 * {activity_log_events} table).
41 * The activity message object (properties correspond with the columns in the
42 * {activity_log_messages} table).
44 * An array containing the evaluated settings for the executed Activity Log
47 function hook_activity_log_event($event, $group, $settings) {
48 if (module_exists('radioactivity')) {
49 module_load_include('inc', 'radioactivity');
50 $aids = explode(',', $group->aids
);
51 if (count($aids) > 1) {
52 radioactivity_add_energy($group->mid
, 'act_log', 'group:'.
$event->tid
);
55 radioactivity_add_energy($group->mid
, 'act_log', 'event:'.
$event->tid
);
61 * Implementation of hook_activity_log_entity_groups().
63 * Defines groups of potential stream owners and message viewers for an action.
65 * @param $stream_owner
66 * If TRUE, the groups returned are valid for stream owners -- that is, all
67 * entity types, but "everyone" is not valid. If FALSE, the groups returned
68 * are only for users, and so are valid for message viewers.
70 * An associative array of group definitions keyed by the machine name.
71 * Values are also associative arrays that can have the following elements:
72 * - items callback: A function that returns an associative array where the
73 * keys are valid stream owner types (node, user, taxonomy_term) and the
74 * values are arrays of stream owner IDs of that type.
75 * - title: A translated, human-friendly name of the group.
76 * - weight: (Optional) The group's weight in an ordering of all groups.
77 * Lighter weights float to the top. Defaults to 0.
78 * - expose fields: (Optional) An array of which additional fields should be
79 * exposed if this group is selected. Valid values for this array are "id,"
80 * "type," and (if you know what you're doing) "acting_uid." Defaults to
82 * - additional arguments: (Optional) Extra arguments to pass to the items
84 * - data types: (Optional) An array containing names of Rules data types for
85 * which this group is valid. If not specified, this group is assumed to be
86 * valid for all Rules data types. Valid data types that can be specified
87 * here include anything returned by
88 * activity_log_get_rules_data_types(array('stream owner types' => 'all)).
89 * - file: (Optional) The file where the items callback exists.
91 function hook_activity_log_entity_groups($stream_owner = TRUE
) {
92 module_load_include('inc', 'activity_log', 'activity_log.entity_groups');
93 return activity_log_entity_groups($stream_owner);
97 * Implementation of hook_activity_log_regenerate_info().
99 * Returns an associative array describing Rules events for which we support
100 * regenerating activity messages. The keys are the Rules event machine name
101 * (valid values can be found using array_keys(rules_get_events())) and the
102 * values are associative arrays with the following elements:
104 * - callback: A function that triggers the relevant event once for each
106 * - arguments: An array of additional arguments to pass to the count and
107 * generate callbacks. Useful for events with conditional names.
108 * - file: (Optional) A file to include before the callbacks are executed.
109 * - target_type: (Optional) The Rules data type of the entity for which your
110 * event regenerates activity messages. Existing activity messages that use
111 * this data type will be deleted before activity is regenerated to avoid
114 * The callback's parameters include:
116 * - $age: Content created after this timestamp should have activity messages
118 * - $context: The return value of the previous time that callback was invoked.
119 * The first time the callback is invoked, the value of this argument is
120 * FALSE. You can use the last return value to keep track of an "offset,"
121 * e.g. so you can only process a limited number of entities in one batch
122 * request and you know where to pick up on the next request.
123 * - Any arguments passed via the "arguments" key.
125 * The callback will be invoked repeatedly until it returns something that
126 * evaluates to FALSE.
128 function hook_activity_log_regenerate_info() {
129 $path = drupal_get_path('module', 'activity_log') .
'/activity_log.generate.inc';
131 'comment_insert' => array(
132 'callback' => 'activity_log_regenerate_comments',
134 'target_type' => 'comment',
136 'node_insert' => array(
137 'callback' => 'activity_log_regenerate_nodes',
139 'target_type' => 'node',
141 'taxonomy_term_insert' => array(
142 'callback' => 'activity_log_regenerate_taxonomy_terms',
144 'target_type' => 'taxonomy_term',
146 'user_insert' => array(
147 'callback' => 'activity_log_regenerate_users',
149 'target_type' => 'user',
156 * Implementation of hook_activity_log_token_resources().
158 * Maps tokens to CSS and JS resources they require. The specified resources
159 * will be loaded for cached messages that use the relevant tokens.
161 function hook_activity_log_token_resources() {
163 '[:global:token]' => array(
165 drupal_get_path('module', 'hook') .
'/hook.css',
168 drupal_get_path('module', 'hook') .
'/hook.js',
175 * Implementation of hook_activity_log_uncacheable_tokens().
177 * Returns an array of tokens that cannot be cached. Messages generated from
178 * templates that use these tokens will never be cached.
180 function hook_activity_log_uncacheable_tokens() {
183 '[:global:user-mail]',
184 '[:global:user-name]',
190 * Implementation of hook_activity_log_display_types().
192 * Returns an associative array of locations where activity messages can be
193 * displayed. The keys are the machine names and the values are the translated
194 * human-friendly names of the destinations.
196 function hook_activity_log_display_types() {
198 'web' => t('Web stream'),