function oa_messages_determine_user_notifiers in Open Atrium Core 7.2
Determine's a users's notifiers based on message type and message content.
1 call to oa_messages_determine_user_notifiers()
- oa_messages_build_subscribe_options in modules/
oa_messages/ oa_messages.module - Builds the subscribe options for a message.
File
- modules/
oa_messages/ oa_messages.module, line 189
Code
function oa_messages_determine_user_notifiers($user, $entity, $message, $notifiers = array()) {
if (empty($notifiers)) {
$notifiers = oa_message_notifiers();
}
$allowed_notifiers = array();
$settings = !empty($user->data['oa_messages']['message_notifications']) ? $user->data['oa_messages']['message_notifications'] : array();
if (!empty($entity->{OA_SPACE_FIELD}[LANGUAGE_NONE][0]['target_id'])) {
$space_id = $entity->{OA_SPACE_FIELD}[LANGUAGE_NONE][0]['target_id'];
}
else {
$space_id = oa_core_get_group_from_node($entity);
}
if (isset($space_id)) {
// If no settings have been saved, set defaults.
if (empty($settings[$space_id])) {
foreach ($notifiers as $notifier) {
if (!empty($notifier['default'])) {
$allowed_notifiers[] = $notifier['id'];
}
}
}
elseif (!empty($settings[$space_id]['messages'][$message->type])) {
if (!empty($settings[$space_id]['methods'])) {
foreach ($settings[$space_id]['methods'] as $method) {
$allowed_notifiers[] = $method;
}
}
}
}
return $allowed_notifiers;
}