You are here

function protected_node_action_protect_all_nodes in Protected Node 6

Same name and namespace in other branches
  1. 7 protected_node.settings.inc \protected_node_action_protect_all_nodes()
  2. 1.0.x protected_node.settings.inc \protected_node_action_protect_all_nodes()

Protect all nodes.

This function adds to the protected nodes list all the existing nodes and marks ALL nodes as protected.

1 string reference to 'protected_node_action_protect_all_nodes'
protected_node_admin_settings in ./protected_node.settings.inc
Define the settings form

File

./protected_node.settings.inc, line 638
Configuration file for the protected_node module.

Code

function protected_node_action_protect_all_nodes($form, &$form_state) {

  // first protect all nodes that already are in our table
  $sql = "UPDATE {protected_nodes} SET protected_node_is_protected = 1 WHERE protected_node_is_protected = 0";
  db_query($sql);

  // then update the table with ALL the existing nodes and as we're at it
  // we mark them as protected
  $sql = "INSERT INTO {protected_nodes}" . " (nid, protected_node_show_title, protected_node_is_protected)" . " (SELECT n.nid, %d, 1" . " FROM {node} n LEFT JOIN {protected_nodes} pn ON n.nid = pn.nid" . " WHERE pn.nid IS NULL)";
  db_query($sql, $form_state['values']['protected_node_show_node_titles']);
}