function notifications_notifications in Notifications 6
Same name and namespace in other branches
- 5 notifications.module \notifications_notifications()
- 6.4 notifications.module \notifications_notifications()
- 6.2 notifications.module \notifications_notifications()
- 6.3 notifications.module \notifications_notifications()
- 7 notifications.module \notifications_notifications()
Implementation of notifications_hook()
Check access permissions to subscriptions
File
- ./
notifications.module, line 1326 - Notifications module
Code
function notifications_notifications($op, &$arg0, $arg1 = NULL, $arg2 = NULL) {
switch ($op) {
case 'access':
if ($arg0 == 'subscription') {
$account = $arg1;
$subscription = $arg2;
// First we check valid subscription type
$access = FALSE;
if ($subscription->type && ($info = notifications_subscription_types($subscription->type))) {
// To allow mixed subscription types to work we dont have a fixed field list
// Then check specific access to this type. Each type must have a permission
if (!empty($info['access callback'])) {
$access = call_user_func($info['access callback'], $account, $subscription);
}
elseif (!empty($info['access']) && user_access($info['access'], $account) || user_access('administer notifications', $account)) {
// Check matching fields
if (!array_diff($info['fields'], array_keys($subscription->fields))) {
$access = TRUE;
}
}
}
return array(
$access,
);
}
break;
case 'digest methods':
// Return array of digesting engines
$info['short'] = array(
'type' => 'short',
'name' => t('Short'),
'description' => t('Produces one line per event, grouped by object'),
'digest callback' => 'notifications_process_digest_short',
);
$info['long'] = array(
'type' => 'long',
'name' => t('Long'),
'description' => t('Adds full information for each event'),
'digest callback' => 'notifications_process_digest_long',
);
return $info;
}
}