You are here

function custom_pub_off_action in Custom Publishing Options 7

Same name and namespace in other branches
  1. 6 custom_pub.module \custom_pub_off_action()

Implements a configurable action.

Toggles a custom publishing option off as an action.

Parameters

$node: The node object of the current node.

$context: The available context of the current action.

Return value

array

File

./custom_pub.module, line 319
Adds the ability to add Custom publishing options to the node Add/Edit forms.

Code

function custom_pub_off_action(&$node, &$context) {

  //This is mainly for the Rules Module. I couldn't get a node to save unless I set this manually
  $context['auto_save'] = TRUE;
  $types = variable_get('custom_pub_types', array());
  foreach ($context['types'] as $type) {
    if (in_array($node->type, array_keys($types[$type]['node_types']))) {
      $node->{$type} = 0;
      node_save($node);
      watchdog('action', 'Toggled @type %title custom publishing option: @label to off.', array(
        '@type' => node_type_get_types('name', $node),
        '%title' => $node->title,
        '@label' => $types[$type]['name'],
      ));
    }
  }
  return array(
    'node' => $node,
  );
}