function contact_attach_form_alter in Contact Attach 5
Same name and namespace in other branches
- 6 contact_attach.module \contact_attach_form_alter()
- 7 contact_attach.module \contact_attach_form_alter()
Implementation of hook_form_alter().
File
- ./
contact_attach.module, line 89 - This is the main code file for the Contact attach module. This module gives users the ability of attaching one or more files to e-mails sent using the site-wide contact form.
Code
function contact_attach_form_alter($form_id, &$form) {
if ($form_id == 'contact_mail_user' && user_access('send attachments with user contact form') || $form_id == 'contact_mail_page' && user_access('send attachments with site-wide contact form') || $form_id == 'og_contact_mail_page' && user_access('send attachments with og contact form')) {
for ($i = 1; $i <= variable_get('contact_attach_number', '3'); $i++) {
$form['contact_attach_' . $i] = array(
'#type' => 'file',
'#title' => t('Attachment #!number', array(
'!number' => $i,
)),
'#weight' => $i,
);
}
// We do not allow anonymous users to send themselves a copy because it
// can be abused to spam people.
global $user;
if ($user->uid) {
$form['copy'] = array(
'#type' => 'checkbox',
'#title' => t('Send yourself a copy.'),
'#weight' => $i,
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Send e-mail'),
'#weight' => $i + 1,
);
$form['#attributes']['enctype'] = 'multipart/form-data';
switch ($form_id) {
case 'contact_mail_user':
$form['#validate'] = array(
'contact_attach_contact_mail_user_validate' => array(),
);
$form['#submit'] = array(
'contact_attach_contact_mail_user_submit' => array(),
);
break;
case 'contact_mail_page':
$form['#validate'] = array(
'contact_attach_contact_mail_page_validate' => array(),
);
$form['#submit'] = array(
'contact_attach_contact_mail_page_submit' => array(),
);
break;
case 'og_contact_mail_page':
$form['#validate'] = array(
'contact_attach_og_contact_mail_page_validate' => array(),
);
$form['#submit'] = array(
'contact_attach_og_contact_mail_page_submit' => array(),
);
break;
}
}
}