function notifications_tags_notifications in Notifications 6.2
Same name and namespace in other branches
- 5 notifications_tags/notifications_tags.module \notifications_tags_notifications()
- 6.4 notifications_tags/notifications_tags.module \notifications_tags_notifications()
- 6 notifications_tags/notifications_tags.module \notifications_tags_notifications()
- 6.3 notifications_tags/notifications_tags.module \notifications_tags_notifications()
- 7 notifications_tags/notifications_tags.module \notifications_tags_notifications()
Implementation of hook_notifications().
File
- notifications_tags/
notifications_tags.module, line 40 - Subscriptions to taxonomy terms
Code
function notifications_tags_notifications($op, &$arg0, $arg1 = NULL, $arg2 = NULL) {
switch ($op) {
case 'names':
$subs =& $arg0;
if ($subs->event_type == 'node') {
if (!empty($subs->fields['tid'])) {
$term = taxonomy_get_term($subs->fields['tid']);
$subs->names['term'] = t('Term: %name', array(
'%name' => $term->name,
));
}
}
break;
case 'subscription types':
$types['taxonomy'] = array(
'event_type' => 'node',
'title' => t('Tags'),
'description' => t('Subscribe to content tagged with a given taxonomy term.'),
'access' => 'subscribe to taxonomy terms',
'fields' => array(
'tid',
),
'page callback' => 'notifications_tags_user_page',
'user page' => 'user/%user/notifications/taxonomy',
);
return $types;
case 'subscription fields':
// Information about available fields for subscriptions
$fields['tid'] = array(
'name' => t('Taxonomy term'),
'field' => 'tid',
'type' => 'int',
'autocomplete path' => 'notifications_tags/autocomplete/single',
'format callback' => 'notifications_tags_term_name',
'value callback' => 'notifications_tags_term_tid',
);
return $fields;
case 'query':
if ($arg0 == 'event' && $arg1 == 'node' && ($node = $arg2->node) || $arg0 == 'user' && $arg1 == 'node' && ($node = $arg2)) {
if ($tids = notifications_tags_node_get_terms($node->nid)) {
$query[]['fields']['tid'] = $tids;
return $query;
}
}
break;
case 'node options':
return _notifications_tags_node_options($arg0, $arg1);
case 'access':
$type = $arg0;
$object =& $arg2;
$access = TRUE;
if ($type == 'subscription') {
$access = TRUE;
if (!empty($object->fields['tid'])) {
$term = taxonomy_get_term($object->fields['tid']);
$allowed_vocabs = notifications_tags_vocabularies();
if (!array_key_exists($term->vid, $allowed_vocabs)) {
$access = FALSE;
}
}
}
return array(
$access,
);
break;
}
}