You are here

function casetracker_notifications_notifications_object_node in Case Tracker 6

Same name and namespace in other branches
  1. 7 casetracker_notifications/casetracker_notifications.module \casetracker_notifications_notifications_object_node()

Implementation of hook_notifications_object_node()

File

casetracker_notifications/casetracker_notifications.module, line 73

Code

function casetracker_notifications_notifications_object_node($op, $node, $account = NULL) {
  switch ($op) {
    case 'conditions':
      if (casetracker_is_case($node) && user_access('subscribe to cases')) {
        $conditions = array();

        // The assignee can be no user or anonymous so we just make sure we return an integer
        // @todo Other values may be possible, check with casetracker maintainers
        if (isset($node->casetracker->assign_to)) {
          $conditions['casetracker_assign'] = (int) $node->casetracker->assign_to;
        }
        if (!empty($node->casetracker->pid)) {
          $conditions['casetracker_project'] = $node->casetracker->pid;
        }
        return $conditions;
      }
      break;
    case 'subscriptions':

      // Return available subscription options for this project and this user account
      if (casetracker_is_project($node) && user_access('subscribe to cases')) {
        $options[] = array(
          'name' => t('Cases for this project'),
          'type' => 'casetracker_project',
          'fields' => array(
            'casetracker_project' => $node->nid,
          ),
        );
      }
      if (casetracker_is_case($node) && user_access('subscribe to cases')) {
        $options[] = array(
          'name' => t('Cases assigned to me'),
          'type' => 'casetracker_assigned',
          'fields' => array(
            'casetracker_assign' => $GLOBALS['user']->uid,
          ),
        );
        return $options;
      }
  }
}