You are here

function _og_notification_check_message in Organic groups 5.3

Same name and namespace in other branches
  1. 6.2 modules/og_notifications/og_notifications.module \_og_notification_check_message()
  2. 6 modules/og_notifications/og_notifications.module \_og_notification_check_message()

Helper function for og_notifications_message_alter. This function checks to see if the message object being passed is an OG notification.

Parameters

Object $message: The message object.

Return value

Integer The subscription ID if this is an OG notification message. 0, otherwise ...

1 call to _og_notification_check_message()
og_notifications_message_alter in og_notifications/og_notifications.module
A workaround to ensure that OG can provide custom message templates for notifications.

File

og_notifications/og_notifications.module, line 773
Provide notifications and messaging support for organic groups.

Code

function _og_notification_check_message($message) {
  $sid = 0;
  if (isset($message->notifications) && isset($message->notifications['subscriptions'])) {
    $params = current($message->notifications['subscriptions']);
    if (count($params) > 1) {

      // Check if "group" is one of the fields. This is a general presumption
      // that any subscription with at least two fields, one of them being a
      // group, is an OG subscription.
      $sid = db_result(db_query("SELECT sid FROM {notifications_fields} WHERE field = 'group' AND sid IN (" . db_placeholders($params) . ")", $params));
    }
  }
  return $sid > 0 ? $sid : 0;
}