At the moment we can not select for which node types (content types) we want to offer node protection.

There are guys they are realizing that by a cck filed. For that see: http://drupal.org/project/password and this feature request: http://drupal.org/node/126129

I've solved this problem by adding a settings page where you can select the node types. And then I changed the hook_form_alter:


// check if this node type should be protected
$types_to_protect = variable_get('protected_node_nodetypes');

if (!in_array($form['type']['#value'], $types_to_protect)) {
  return;
}

and

hook_nodeapi

$types_to_protect = variable_get('protected_node_nodetypes');
	
if (!in_array($node->type, $types_to_protect)) {
  return;
}

I hope that's all. :)

Comments

osopolar’s picture

I was reviewing it and saw that it was not working for anonymos. The reason was the missing 2nd parameter in variable_get

variable_get('protected_node_nodetypes');

should be 0 or an empty array

variable_get('protected_node_nodetypes',array());

I hope it's ok now.

mtolmacs’s picture

I think it's ready for HEAD, so I merged it. Please report any problems you find.

mtolmacs’s picture

Assigned: Unassigned » mtolmacs
mtolmacs’s picture

Status: Needs review » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.