You are here

function custom_pub_on_action in Custom Publishing Options 7

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

Implements a configurable action.

Toggles a custom publishing option on as an action.

Parameters

$node: The node object of the current node.

$context: The available context of the current action.

File

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

Code

function custom_pub_on_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 (!empty($type) && in_array($node->type, array_keys($types[$type]['node_types']))) {
      $node->{$type} = 1;
      node_save($node);
      watchdog('action', 'Toggled @type %title custom publishing option: @label to on.', array(
        '@type' => node_type_get_types('name', $node),
        '%title' => $node->title,
        '@label' => $types[$type]['name'],
      ));
    }
  }
}