You are here

public function NodeActivityActionHandler::valid in Activity 7

Determine if the current Action is valid for this object.

Parameters

$eid: The entity id for the activity.

$actor: The uid of the actor for this activity.

$timestamp: Unix timestamp when this activity occurred.

array $objects: The collection of objects for this action.

mixed $argument1: The first argument passed to the action callback.

mixed $argument2: The second argument passed to the action callback.

Return value

boolean

Overrides ActivityActionHandler::valid

File

./activity_action_handlers.inc, line 501

Class

NodeActivityActionHandler
Activity handler for node module.

Code

public function valid($eid, $actor, $timestamp, $objects, $argument1, $argument2) {
  $types = array_filter($this->options['types']);
  $type_check = TRUE;
  $view_modes_check = TRUE;
  if (!empty($types)) {
    $type_check = in_array($objects['node']->type, $types);
  }
  $view_modes = array_filter($this->options['view_modes']);
  if (!empty($view_modes)) {

    // When the trigger is fired, the build mode is passed to the actions
    // callback as $a1. activity_record() takes the two arguments and places
    // them into the context array under the 'additional_arguments' key.
    // @see activity_record
    $view_modes_check = in_array($argument1, $view_modes);
  }
  return parent::valid($eid, $actor, $timestamp, $objects, $argument1, $argument2) && $type_check && $view_modes_check;
}