function _protected_node_node_type_validate in Protected Node 7
Same name and namespace in other branches
- 6 protected_node.settings.inc \_protected_node_node_type_validate()
- 1.0.x protected_node.settings.inc \_protected_node_node_type_validate()
Implements the validation of the protected node node type form.
This function ensures that the password is encrypted.
1 string reference to '_protected_node_node_type_validate'
File
- ./
protected_node.settings.inc, line 1033 - Configuration file for the protected_node module.
Code
function _protected_node_node_type_validate($form, &$form_state) {
if (!empty($form_state['values']['protected_node_node_type_password_field'])) {
$form_state['values']['protected_node_node_type_password'] = hash('sha256', $form_state['values']['protected_node_node_type_password_field']);
}
else {
$node_type = trim($form_state['values']['type']);
$old_node_type = isset($form_state['values']['old_type']) ? $form_state['values']['old_type'] : '';
if ($node_type != $old_node_type) {
$passwd = variable_get('protected_node_node_type_password_' . $old_node_type, '');
if ($passwd) {
// Save only if available, we don't need an empty password.
$form_state['values']['protected_node_node_type_password'] = $passwd;
}
variable_del('protected_node_node_type_password_' . $old_node_type);
}
}
unset($form_state['values']['protected_node_node_type_password_field']);
}