function oa_notifications_load_multiple in Open Atrium Notifications 7.2
Return all notifications for given source. Optionally filtered by type.
Parameters
object $source_entity: The loaded source entity.
string $source_type: The entity type of the source (defaults to 'node').
string $target_type: An optional parameter that allows to filter the notification based on target type (group, team, user).
Return value
array Returns an associative array of notifications first keyed by target type, then beneath that keyed by the target_id.
5 calls to oa_notifications_load_multiple()
- oa_notifications_form_fields in ./
oa_notifications.module - Define the fields that are used for configuring notifications.
- oa_notifications_get_default_notifications in ./
oa_notifications.module - Gets a piece of section content's default notifications.
- oa_notifications_get_notifications in ./
oa_notifications.module - Return the resolved list of all users to be notified on a piece of content.
- oa_notifications_render_view in ./
oa_notifications.module - Render the read only version of the notifications listing.
- oa_notifications_save_notifications in ./
oa_notifications.module - Saves notifications.
File
- ./
oa_notifications.module, line 221
Code
function oa_notifications_load_multiple($source_entity, $source_type = 'node', $target_type = NULL) {
if (is_numeric($source_entity)) {
$source_entity = entity_load($source_type, array(
$source_entity,
));
$source_entity = current($source_entity);
}
$source_id = current(entity_extract_ids($source_type, $source_entity));
$query = db_select('oa_notifications', 'n')
->fields('n')
->condition('n.source_id', $source_id)
->condition('n.source_type', $source_type);
if (isset($target_type)) {
$query
->condition('n.target_type', $target_type);
}
$notifications = array();
$results = $query
->execute()
->fetchAllAssoc('notification_id');
foreach ($results as $row) {
$notifications[$row->target_type][$row->target_id] = $row;
}
drupal_alter('oa_notifications_load', $notifications, $source_entity, $source_type, $target_type);
return $notifications;
}