You are here

function oa_notifications_get_default_notifications in Open Atrium Notifications 7.2

Gets a piece of section content's default notifications.

Parameters

int $section_id: Node ID of the content's section. Optional.

int $space_id: Node ID of the content's space. Optional.

1 call to oa_notifications_get_default_notifications()
oa_notifications_form_fields in ./oa_notifications.module
Define the fields that are used for configuring notifications.

File

./oa_notifications.module, line 878

Code

function oa_notifications_get_default_notifications($section_id = 0, $space_id = 0, $allow_override = TRUE) {
  $notifications = array();

  // Space / section default to what's in the context.
  // Don't override section if is set to FALSE (like when creating subspaces).
  $section_id = $section_id || $section_id === FALSE ? $section_id : oa_core_get_section_context();
  $space_id = $space_id ? $space_id : oa_core_get_space_context();
  if ($section_id && ($section = node_load($section_id))) {
    if ($allow_override && oa_notifications_is_overriding('node', $section_id)) {
      return oa_notifications_load_multiple($section);
    }
    else {

      // Switch to the section's space, if available.
      $space_id = empty($section->{OA_SPACE_FIELD}[LANGUAGE_NONE][0]['target_id']) ? $space_id : $section->{OA_SPACE_FIELD}[LANGUAGE_NONE][0]['target_id'];
    }
  }

  // If the section isn't overriding notifications OR section ID wasn't set AND
  // the space ID is set, use the space's notifications instead.
  if ($space_id && ($space = node_load($space_id))) {
    return oa_notifications_load_multiple($space);
  }
  return array();
}