function commons_notifications_group_access in Drupal Commons 6.2
Access callback to determine whether a user can subcribe for notifications for a given group
Parameters
$group: The group object being subscribed to
$user: Optionally supply the user, otherwise use current
Return value
TRUE if the user can subscribe to the group, otherwise FALSE
1 call to commons_notifications_group_access()
- commons_notifications_og_links_alter in modules/
features/ commons_notifications/ commons_notifications.module - Implementation of hook_og_links_alter()
1 string reference to 'commons_notifications_group_access'
- commons_notifications_menu in modules/
features/ commons_notifications/ commons_notifications.module - Implementation of hook_menu()
File
- modules/
features/ commons_notifications/ commons_notifications.module, line 156
Code
function commons_notifications_group_access($group, $user = NULL) {
// If user not provided, load the current
if (!$user) {
global $user;
}
// Make sure the group is a group
if (og_is_group_type($group->type)) {
// Make sure the user is a member of the group
if (og_is_group_member($group->nid, TRUE, $user->uid)) {
// Check notification permissions
if (user_access('maintain own subscriptions', $user)) {
// Check og_notifications permissions
if (user_access('subscribe to content in groups', $user)) {
return TRUE;
}
}
}
}
return FALSE;
}