View source
<?php
define('HEARTBEAT_OG_PUBLIC', 10);
function og_activity_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'og_create_admin_confirm') {
$form['#submit'][] = 'og_activity_create_admin_confirm';
}
if (in_array($form_id, array(
'heartbeat_messages_edit',
'heartbeat_messages_add',
))) {
$form['perms']['#options'] += array(
HEARTBEAT_OG_PUBLIC => t('Everyone if group is set to public'),
);
}
}
function og_activity_heartbeat_message_info() {
$info = array(
'og_activity_0' => array(
'message' => '!user is now a coadministrator of !group.',
'message_concat' => '%user% is now a coadministrator of !group.',
'message_id' => 'og_become_co_admin',
'concat_args' => array(
'type' => 'summary',
'group_by' => 'node',
'group_target' => 'user',
'group_by_target' => '',
'group_num_max' => '2',
'merge_separator' => ', ',
'merge_end_separator' => ' and ',
'roles' => array(
0 => '0',
1 => '0',
2 => '0',
3 => '0',
4 => '0',
),
),
'description' => 'Become a coadministrator of a group',
'perms' => '1',
'custom' => '1',
'variables' => array(),
),
);
return $info;
}
function og_activity_heartbeat_register_access_types() {
return array(
0 => array(
'name' => 'Organic group activity',
'class' => 'OgHeartbeat',
'path' => 'ogheartbeat.inc',
'module' => 'og_activity',
),
1 => array(
'name' => 'Organic groups activity',
'class' => 'GroupsActivity',
'path' => 'groupsactivity.inc',
'module' => 'og_activity',
),
2 => array(
'name' => 'Organic group member activity',
'class' => 'MembersActivity',
'path' => 'membersactivity.inc',
'module' => 'og_activity',
),
);
}
function og_activity_token_list($type = 'all') {
if ($type == 'node' || $type == 'all') {
$tokens['node']['ogname-title-link'] = t('title of top group with a link to it.');
return $tokens;
}
}
function og_activity_token_values($type, $object = NULL, $options = array()) {
switch ($type) {
case 'node':
if (!empty($object->og_groups) && is_array($object->og_groups)) {
$gids = array_keys(array_filter($object->og_groups));
$title = db_result(db_query("SELECT title FROM {node} WHERE nid = %d", $gids[0]));
$values['ogname-title-link'] = l(check_plain($title), 'node/' . $gids[0], array(
'html' => TRUE,
));
return $values;
}
break;
}
}
function og_activity_heartbeat_activity_log($heartbeatactivity, $args) {
$in_group = (int) db_result(db_query_range("SELECT 1 FROM {og_ancestry} WHERE (nid = %d OR group_nid = %d OR group_nid = %d)", $heartbeatactivity->nid, $heartbeatactivity->nid, $heartbeatactivity->nid_target, 0, 1));
if ($in_group) {
db_query("UPDATE {heartbeat_activity} SET in_group = 1 WHERE nid = %d AND nid_target = %d ", $heartbeatactivity->nid, $heartbeatactivity->nid_target);
}
}
function og_activity_create_admin_confirm($form, $form_state) {
rules_invoke_event('og_become_co_admin', $form_state['values']['node'], $form_state['values']['account']);
}