function _protected_node_admin_settings_validate in Protected Node 7
Same name and namespace in other branches
- 6 protected_node.settings.inc \_protected_node_admin_settings_validate()
- 1.0.x protected_node.settings.inc \_protected_node_admin_settings_validate()
Validate the submitted settings form from.
This function verifies that a global password is defined if the user defines that the global password should be used by default.
1 string reference to '_protected_node_admin_settings_validate'
- protected_node_admin_settings in ./
protected_node.settings.inc - Define the settings form.
File
- ./
protected_node.settings.inc, line 772 - Configuration file for the protected_node module.
Code
function _protected_node_admin_settings_validate($form, &$form_state) {
// Make sure that a password is included if a global password is required
// and none was ever submitted before.
switch ($form_state['values']['protected_node_use_global_password']) {
case PROTECTED_NODE_PER_NODE_AND_GLOBAL_PASSWORD:
case PROTECTED_NODE_GLOBAL_PASSWORD:
if (!$form_state['values']['protected_node_global_password_field'] && !variable_get('protected_node_global_password', '')) {
form_error($form['protected_node_security']['protected_node_global_password_field'], t('A global password is required to make use of the global password functionality.'));
}
break;
}
// Email box width.
$width = $form_state['values']['protected_node_email_box_width'];
if (!is_numeric($width)) {
form_set_error('protected_node_email_box_width', t('You must enter a number for the width of the email box.'));
}
else {
if ($width < 0) {
form_set_error('protected_node_email_box_width', t('The width of the email box must be positive.'));
}
}
// Email box height.
$height = $form_state['values']['protected_node_email_box_height'];
if (!is_numeric($height)) {
form_set_error('protected_node_email_box_height', t('You must enter a number for the height of the email box.'));
}
else {
if ($height < 0) {
form_set_error('protected_node_email_box_height', t('The height of the email box must be positive.'));
}
}
if ($form_state['values']['protected_node_email_from']) {
if (!valid_email_address($form_state['values']['protected_node_email_from'])) {
form_error($form['protected_node_auto_email']['protected_node_email_from'], t('The From email address is not valid.'));
}
}
}