You are here

function custom_pub_rules_action_set_publish_type in Custom Publishing Options 7

Toggles the "on" or "off" state of a Custom Publishing option for a node.

Parameters

object $node The node to update.:

string $type The machine name of the custom publishing option.:

integer $toggled "1" for "On" and "0" for "Off".:

File

./custom_pub.rules.inc, line 93
Rules integration for Custom Publishing Options module.

Code

function custom_pub_rules_action_set_publish_type($node, $type, $toggled) {
  $types = variable_get('custom_pub_types', array());

  // Check if the publishing option is applicable for this node.
  if (!empty($type) && in_array($node->type, array_keys($types[$type]['node_types']))) {
    $node->{$type} = (bool) $toggled;
    watchdog('action', 'Toggled @type %title custom publishing option: @label to @action', array(
      '@action' => $toggled ? 'on' : 'off',
      '@type' => node_type_get_types('name', $node),
      '%title' => $node->title,
      '@label' => $types[$type]['name'],
    ));
  }
}