You are here

function og_notifications_notifications in Organic groups 5.3

Same name and namespace in other branches
  1. 5.8 og_notifications/og_notifications.module \og_notifications_notifications()
  2. 5 og_notifications/og_notifications.module \og_notifications_notifications()
  3. 5.7 og_notifications/og_notifications.module \og_notifications_notifications()
  4. 6.2 modules/og_notifications/og_notifications.module \og_notifications_notifications()
  5. 6 modules/og_notifications/og_notifications.module \og_notifications_notifications()

Implementation of hook_notifications().

File

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

Code

function og_notifications_notifications($op, &$arg0, $arg1 = NULL, $arg2 = NULL) {
  switch ($op) {
    case 'names':
      $subs =& $arg0;
      if ($subs->event_type == 'node') {
        if (!empty($subs->fields['group']) && ($group = node_load($subs->fields['group']))) {
          $subs->names['group'] = t('Group: %name', array(
            '%name' => $group->title,
          ));
        }
      }
      break;
    case 'subscription types':
      $types['group'] = array(
        'event_type' => 'node',
        'title' => t('Groups'),
        'access' => 'subscribe to content in groups',
        'page' => 'og_notifications_user_page',
        'fields' => array(
          'group',
        ),
      );
      $types['grouptype'] = array(
        'event_type' => 'node',
        'title' => t('Content type in group'),
        'access' => 'subscribe to content in groups',
        'page' => 'og_notifications_user_page',
        'fields' => array(
          'group',
          'type',
        ),
      );
      return $types;
    case 'subscription fields':

      // Information about available fields for subscriptions
      $fields['group'] = array(
        'name' => t('Group'),
        'field' => 'group',
        'type' => 'int',
      );
      return $fields;
    case 'query':
      if ($arg0 == 'event' && $arg1 == 'node' && ($node = $arg2->node) || $arg0 == 'user' && $arg1 == 'node' && ($node = $arg2)) {
        $query = array();
        if ($node->og_groups) {
          $query[]['fields']['group'] = $node->og_groups;
        }
        if ($arg0 == 'user' && og_is_group_type($node->type)) {
          $query[]['fields']['group'] = $node->nid;
        }
        return $query;
      }
      break;
    case 'node options':
      return _og_notifications_node_options($arg0, $arg1);
    case 'event load':

      // Piggy-backing on notifications_content.
      break;
    case 'event types':

      // Piggy-backing on notifications_content.
      break;
    case 'access':
      $type = $arg0;
      $account = $arg1;
      $object = $arg2;
      if ($type == 'subscription' && !empty($object->fields['group'])) {
        if (($group = node_load($object->fields['group'])) && og_is_group_type($group->type) && notifications_content_node_allow($account, $group)) {
          return array(
            TRUE,
          );
        }
        else {
          return array(
            FALSE,
          );
        }
      }
      break;
  }
}