function spamicide_admin_form_validate in Spamicide 7
Same name and namespace in other branches
- 5 spamicide.module \spamicide_admin_form_validate()
- 6 spamicide.module \spamicide_admin_form_validate()
Implements hook_form_validate(). Enter description here ...
_state
Parameters
unknown_type $form:
File
- ./
spamicide.module, line 202 - This module provides yet another tool to eliminate spam.
Code
function spamicide_admin_form_validate($form, &$form_state) {
foreach ($form_state['values']['spamicide_form'] as $spamicide_form_id => $data) {
if (!$data['form_field']) {
form_set_error('spamicide_form][' . $spamicide_form_id . '][form_field', t("%field field name cannot be empty", array(
'%field' => $spamicide_form_id,
)));
}
if (preg_match_all('[\\W]', $data['form_field'], $str)) {
form_set_error('spamicide_form][' . $spamicide_form_id . '][form_field', t("Only AlphaNumeric characters or the underscore please"));
}
}
if (!$form_state['values']['spamicide_dir']) {
form_set_error('spamicide_dir', t("Spamicide directory name cannot be empty"));
}
if (preg_match_all('[\\W]', $form_state['values']['spamicide_dir'], $str)) {
form_set_error('spamicide_dir', t("Only AlphaNumeric characters or the underscore please"));
}
elseif ($form_state['values']['spamicide_dir'] != variable_get('spamicide_dir')) {
$path = 'public://' . $form_state['values']['spamicide_dir'];
if (is_dir($path)) {
form_set_error('spamicide_dir', t("Unable to create new directory, it already exists, please choose another name"));
}
elseif (!file_prepare_directory($path, FILE_CREATE_DIRECTORY)) {
form_set_error('spamicide_dir', t("Unable to create new directory, please double check file system permissions and try again"));
}
}
if (!$form_state['values']['spamicide_description']) {
form_set_error('spamicide_description', t("The description should not be emtpy for accessibility purposes"));
}
}