You are here

function activity_record_check in Activity 6.2

determines if the current trigger should be ignored

@see: activity_get_module_info()

Parameters

stdClass $object: the object passed in by trigger.module

array $context: the context array passed in by trigger.module

array $token_objects: The types that a prepared for the token replace. Generally, the represent $info->objects

stdClass $activity_object: The activity object from the activity_info() hook

Return value

boolean whether or not to record this trigger

1 call to activity_record_check()
activity_record in ./activity.module
Implementation of a configurable Drupal action. Tokenize and record an activity message.

File

./activity.module, line 540
Primarily Drupal hooks and global API functions to manipulate activity.

Code

function activity_record_check($object, $context, $token_objects, $activity_object) {
  $account = user_load($context['actor']);

  // First check to see if the user opts out.
  $aid = db_result(db_query("SELECT aid FROM {trigger_assignments} WHERE hook = '%s' AND op = '%s'", $context['hook'], $context['op']));
  if (isset($account->activity_ignore[$aid]) && $account->activity_ignore[$aid] == 0) {

    // user has opted out of this particular action
    return FALSE;
  }

  // Node View is 'special'. Handle it here.
  // argument1 is $teaser and argument2 is $view. The only time node view should
  // be recorded is when $teaser is FALSE and $view is TRUE.
  if ($context['hook'] == 'nodeapi' && $context['op'] == 'view' && ($context['argument1'] || !$context['argument2'])) {
    return FALSE;
  }

  // Checkboxes says 'story' => 0 when story wasn't checked so array_filter().
  $types = array();
  if (isset($context['activity_types'])) {
    $types = array_filter($context['activity_types']);
  }
  if (!empty($types)) {
    return module_invoke(activity_module_name($context['hook']), 'activity_type_check', $token_objects, $types);
  }
  return TRUE;
}