You are here

function _node_noindex_node_set_noindex in Node Noindex 7

Same name and namespace in other branches
  1. 6 node_noindex.module \_node_noindex_node_set_noindex()

Sets or deletes the noindex option on the node.

Parameters

object $node:

2 calls to _node_noindex_node_set_noindex()
node_noindex_node_insert in ./node_noindex.module
Implements hook_node_insert().
node_noindex_node_update in ./node_noindex.module
Implements hook_node_update().

File

./node_noindex.module, line 215

Code

function _node_noindex_node_set_noindex($node) {

  // If the noindex checkbox is present...
  if (isset($node->node_noindex['noindex'])) {

    // If the noindex checkbox is checked...
    if ($node->node_noindex['noindex']) {

      // Insert/update the noindex value to 1.
      db_merge('node_noindex')
        ->key(array(
        'nid' => $node->nid,
      ))
        ->fields(array(
        'noindex' => 1,
      ))
        ->execute();
    }
    elseif (!$node->is_new) {

      // Delete the noindex value.
      _node_noindex_node_delete_noindex($node);
    }
  }
}