You are here

function notifications_notifications in Notifications 6.3

Same name and namespace in other branches
  1. 5 notifications.module \notifications_notifications()
  2. 6.4 notifications.module \notifications_notifications()
  3. 6 notifications.module \notifications_notifications()
  4. 6.2 notifications.module \notifications_notifications()
  5. 7 notifications.module \notifications_notifications()

Implementation of notifications_hook()

Check access permissions to subscriptions

File

./notifications.module, line 1420
Notifications module

Code

function notifications_notifications($op, &$arg0, $arg1 = NULL, $arg2 = NULL) {
  switch ($op) {
    case 'access':
      if ($arg0 == 'subscription') {
        $account = $arg1;
        $subscription = $arg2;

        // First we check valid subscription type
        $access = FALSE;
        if ($subscription->type && ($info = notifications_subscription_types($subscription->type))) {

          // To allow mixed subscription types to work we dont have a fixed field list
          // Then check specific access to this type. Each type must have a permission
          if (!empty($info['access callback'])) {
            $access = call_user_func($info['access callback'], $account, $subscription);
          }
          elseif (!empty($info['access']) && user_access($info['access'], $account) || user_access('administer notifications', $account)) {

            // Check matching fields
            if (!array_diff($info['fields'], array_keys($subscription->fields))) {
              $access = TRUE;
            }
          }
        }
        return array(
          $access,
        );
      }
      break;
    case 'build methods':

      // Return array of building engines
      $info['simple'] = array(
        'type' => 'simple',
        'name' => t('Simple'),
        'description' => t('Produces one message per event, without digesting.'),
        'build callback' => 'notifications_process_build_simple',
        'digest' => FALSE,
      );
      return $info;
  }
}