function og_notifications_notifications in Organic groups 5.7
Same name and namespace in other branches
- 5.8 og_notifications/og_notifications.module \og_notifications_notifications()
- 5 og_notifications/og_notifications.module \og_notifications_notifications()
- 5.3 og_notifications/og_notifications.module \og_notifications_notifications()
- 6.2 modules/og_notifications/og_notifications.module \og_notifications_notifications()
- 6 modules/og_notifications/og_notifications.module \og_notifications_notifications()
Implementation of hook_notifications().
File
- og_notifications/
og_notifications.module, line 146 - Subscriptions to content in groups.
Code
function og_notifications_notifications($op, &$arg0, $arg1 = NULL, $arg2 = NULL) {
switch ($op) {
case 'names':
$subs =& $arg0;
if ($subs->event_type == 'node') {
if (!empty($subs->fields['group']) && ($group = node_load($subs->fields['group']))) {
$subs->names['group'] = t('Group: %name', array(
'%name' => $group->title,
));
}
}
break;
case 'subscription types':
$types['group'] = array(
'event_type' => 'node',
'title' => t('Groups'),
'access' => 'subscribe to content in groups',
'page' => 'og_notifications_user_page',
'fields' => array(
'group',
),
);
$types['grouptype'] = array(
'event_type' => 'node',
'title' => t('Content type in group'),
'access' => 'subscribe to content in groups',
'fields' => array(
'group',
'type',
),
);
return $types;
case 'query':
// $arg0 = 'event' and $arg1 = 'node' and $event = $arg2
// $arg0 = 'user' and $arg1 = 'noe' and $node = $arg2
if ($arg0 == 'event' && $arg1 == 'node' && ($node = $arg2->node) || $arg0 == 'user' && $arg1 == 'node' && ($node = $arg2)) {
$query = array();
if ($node->og_groups) {
$query[] = array(
'join' => "LEFT JOIN {og_ancestry} og ON f.field = 'group' AND f.value = CAST(og.group_nid AS CHAR(255))",
'where' => 'og.nid = %d',
'args' => array(
$node->nid,
),
);
}
if ($arg0 == 'user' && og_is_group_type($node->type)) {
$query[]['fields']['group'] = $node->nid;
}
return $query;
}
break;
case 'node options':
return _og_notifications_node_options($arg0, $arg1);
case 'event load':
// $arg0 is event
// Nothing to load here, the user may be subscribed through one of many parent groups
break;
case 'event types':
// Event types for this are defined in notifications_content module
break;
case 'access':
$type = $arg0;
$account =& $arg1;
$object =& $arg2;
if ($type == 'subscription' && !empty($object->fields['group'])) {
if (($group = node_load($object->fields['group'])) && og_is_group_type($group->type) && notifications_content_node_allow($account, $group)) {
return array(
TRUE,
);
}
else {
return array(
FALSE,
);
}
}
break;
}
}