You are here

function protected_node_unset_protected in Protected Node 7

Same name and namespace in other branches
  1. 5 protected_node.module \protected_node_unset_protected()
  2. 6 protected_node.module \protected_node_unset_protected()
  3. 1.0.x protected_node.module \protected_node_unset_protected()

This method marks the specified node as unprotected.

This function ensures that the specified node is not protected anymore. It does not delete the row from the database which means calling the protected_node_set_protected() function with the same $nid parameter will restore the previous state (assuming the node was protected before.)

When the node was previously protected and this call succeeds, the method returns TRUE.

If an invalid $nid is passed FALSE is returned.

@param[in] int $nid The node identifier.

Return value

bool TRUE if the node was protected before the call, FALSE otherwise.

File

./protected_node.module, line 1304
Protected Node module.

Code

function protected_node_unset_protected($nid) {
  $result = db_select('protected_nodes')
    ->fields('protected_nodes', array(
    'protected_node_is_protected',
  ))
    ->condition('nid', $nid)
    ->execute()
    ->fetchField() == 1;
  db_update('protected_nodes')
    ->fields(array(
    'protected_node_is_protected' => 0,
  ))
    ->condition('nid', $nid)
    ->execute();
  return $result;
}