You are here

function notifications_user_notifications_object_user in Notifications 7

Implementation of hook_notifications_object_user()

File

notifications_user/notifications_user.module, line 110
Notifications module - User subscriptions tabs

Code

function notifications_user_notifications_object_user($op, $user, $account = NULL) {
  switch ($op) {
    case 'conditions':

      // Condition fields for subscriptions to this object type (user)
      return array(
        'uid' => $user->uid,
        'author' => $user->uid,
      );
    case 'subscriptions':

      // Option subscriptions to user account. Checking permissions here will save some processing.
      $options = array();

      // All posts by author
      if (!$account || user_access('subscribe to author', $account)) {
        $options[] = notifications_subscription('content_author')
          ->add_field('node:uid', $user->uid)
          ->set_name(t('All posts by @name', array(
          '@name' => $user->name,
        )));
      }

      // Content types with author subscriptions
      if (!$account || user_access('subscribe to content type', $account) && user_access('subscribe to author', $account)) {
        foreach (notifications_content_types('content_type_author') as $type => $type_name) {
          $options[] = notifications_subscription('content_type_author')
            ->add_field('node:uid', $user->uid)
            ->add_field('node:type', $type)
            ->set_name(t('@type posts by @name', array(
            '@name' => $user->name,
            '@type' => node_type_get_name($type),
          )));
        }
      }
      return $options;
  }
}