function oa_notifications_save_for_source in Open Atrium Notifications 7.2
Save a collection of Notifications for a particular source item.
Parameters
int $source_id: The ID of the source (typically a nid).
string $source_type: The entity type of the source (defaults to 'node').
array $notifications: A collection of Notification object for this source.
1 call to oa_notifications_save_for_source()
- oa_notifications_save_notifications in ./
oa_notifications.module - Saves notifications.
File
- ./
oa_notifications.module, line 362
Code
function oa_notifications_save_for_source($source_id, $source_type, $notifications) {
if (!empty($source_id)) {
db_delete('oa_notifications')
->condition('source_id', $source_id)
->condition('source_type', $source_type)
->execute();
foreach ($notifications as $key => $value) {
if (is_numeric($key)) {
// Support a flat list of notification records
unset($value->notification_id);
drupal_write_record('oa_notifications', $value);
}
else {
foreach ($value as $id => $n) {
// Also support list keyed by notification type.
unset($n->notification_id);
drupal_write_record('oa_notifications', $n);
}
}
}
}
}