function contact_attach_admin_settings_validate in Contact Attach 7
Form validation handler for contact_attach_admin_settings().
1 string reference to 'contact_attach_admin_settings_validate'
- contact_attach_admin_settings in ./
contact_attach.admin.inc - Form constructor for the settings form.
File
- ./
contact_attach.admin.inc, line 117 - Module settings UI for the Contact Attach module.
Code
function contact_attach_admin_settings_validate($form, &$form_state) {
$exceed_max_msg = t('Your PHP settings limit the maximum file size per upload to %size.', array(
'%size' => format_size(file_upload_max_size()),
)) . '<br/>';
$more_info = t("Depending on your server environment, these settings may be changed in the system-wide php.ini file, a php.ini file in your Drupal root directory, in your Drupal site's settings.php file, or in the .htaccess file in your Drupal root directory.");
foreach ($form_state['values']['contact_attach_contact_forms'] as $contact_form_short) {
foreach ($form_state['values']['contact_attach_roles_' . $contact_form_short] as $role => $rid) {
$uploadsize = $form_state['values']['contact_attach_uploadsize_' . $contact_form_short][$rid];
if (!ctype_digit($form_state['values']['contact_attach_number_' . $contact_form_short][$rid])) {
form_set_error('contact_attach_number_' . $contact_form_short . '][' . $rid, t('The number of file attachments for the %role role must be a positive integer.', array(
'%role' => $role,
)));
}
elseif ($form_state['values']['contact_attach_number_' . $contact_form_short][$rid] === '0') {
form_set_error('contact_attach_number_' . $contact_form_short . '][' . $rid, t('The number of file attachments for the %role role cannot be 0. If you want to disable the ability of attaching files on contact forms for a role, revoke its permission on the <a href="@permissions">permissions</a> page.', array(
'%role' => $role,
'@permissions' => url('admin/people/permissions'),
)));
}
if (!is_numeric($uploadsize) || $uploadsize <= 0) {
form_set_error('contact_attach_uploadsize_' . $contact_form_short . '][' . $rid, t('The %role role file size limit must be a number and greater than zero.', array(
'%role' => $role,
)));
}
if ($uploadsize * 1024 * 1024 > file_upload_max_size()) {
form_set_error('contact_attach_uploadsize_' . $contact_form_short . '][' . $rid, $exceed_max_msg . $more_info);
$more_info = '';
}
}
// Unset messenger value for roles, so that it is not saved as a variable.
unset($form_state['values']['contact_attach_roles_' . $contact_form_short]);
}
// Unset contact form messenger value, so that it is not saved as a variable.
unset($form_state['values']['contact_attach_contact_forms']);
}