View source
<?php
function entityform_notifications_form_entityform_settings_alter(&$form, &$form_state, $form_id) {
$entityform_type = $form['#entityform_type'];
_entityform_notifications_type_settings($form['entityform_type_defaults']['data']['notifications_set'], $entityform_type);
_entityform_remove_fieldsets_from_tree($form['entityform_type_defaults']['data'], array(
'entityform_type_defaults',
'data',
));
}
function entityform_notifications_form_variable_edit_form_alter(&$form, &$form_state) {
$variable_id = is_array($form_state['build_info']['args'][0]) ? $form_state['build_info']['args'][0][0] : $form_state['build_info']['args'][0];
if (substr($variable_id, 0, 11) == 'entityform_') {
$form['tokens'] = array(
'#markup' => theme('token_tree', array(
'token_types' => array(
'entityform',
),
'global_types' => FALSE,
)),
'#weight' => 99999,
);
}
}
function entityform_notifications_form_entityform_type_form_alter(&$form, &$form_state, $form_id) {
$entityform_type = $form['#entityform_type'];
_entityform_notifications_type_settings($form['data']['notifications_set'], $entityform_type);
_entityform_remove_fieldsets_from_tree($form['data'], array(
'data',
));
}
function _entityform_notifications_type_settings(&$notifications_fieldset, $entityform_type) {
$notifications_fieldset['notification_text'] = array(
'#type' => 'textarea',
'#title' => t('Email text'),
'#default_value' => empty($entityform_type->data['notification_text']) ? '' : $entityform_type->data['notification_text'],
'#description' => t('Text for Confirmation Email to submitter. DO NOT put HTML in this field'),
'#weight' => 70,
);
$notifications_fieldset['notify_emails'] = array(
'#type' => 'textfield',
'#title' => t('Notification emails'),
'#default_value' => empty($entityform_type->data['notify_emails']) ? '' : $entityform_type->data['notify_emails'],
'#description' => t('Enter emails that should be notified for each form submissions.'),
'#element_validate' => array(
'_entityform_form_email_list_validate',
),
'#weight' => 80,
);
if (!module_exists('variable_admin')) {
$notifications_fieldset['notify_help'] = array(
'#type' => 'markup',
'#markup' => t('Enable the %module module to edit the full body and subject of these emails', array(
'%module' => 'Variable admin',
)),
'#weight' => 60,
);
}
else {
$variable_path = 'admin/config/system/variable/edit/entityform_notify_';
$text = t('Edit the subject and body of this email');
$attributes = array(
'query' => array(
'destination' => current_path(),
),
);
$notifications_fieldset['notification_text']['#description'] .= ' ' . l($text, $variable_path . 'submitter_[mail_part]', $attributes);
$notifications_fieldset['notify_emails']['#description'] .= ' ' . l($text, $variable_path . 'admin_[mail_part]', $attributes);
}
}