Issue #2002218 by mmenavas: Entityform_permission() has two return statements.
[project/entityform.git] / entityform_notifications / entityform_notifications.module
1 <?php
2
3 /**
4 * Implements hook_form_FORM_ID_alter().
5 */
6 function entityform_notifications_form_entityform_settings_alter(&$form, &$form_state, $form_id) {
7 $entityform_type = $form['#entityform_type'];
8 _entityform_notifications_type_settings($form['entityform_type_defaults']['data']['notifications_set'], $entityform_type);
9 //$form['entityform_type_defaults']['data']['notifications_set'] = $notifications_set;
10 _entityform_remove_fieldsets_from_tree($form['entityform_type_defaults']['data'], array('entityform_type_defaults', 'data'));
11 }
12 /**
13 * Implements hook_form_FORM_ID_alter()
14 */
15 function entityform_notifications_form_variable_edit_form_alter(&$form, &$form_state) {
16 $variable_id = is_array($form_state['build_info']['args'][0]) ? $form_state['build_info']['args'][0][0] : $form_state['build_info']['args'][0];
17 if (substr($variable_id, 0, 11) == 'entityform_') {
18 $form['tokens'] = array(
19 '#markup' => theme('token_tree', array('token_types' => array('entityform'), 'global_types' => FALSE)),
20 '#weight' => 99999
21 );
22 }
23 }
24 /**
25 * Implements hook_form_FORM_ID_alter().
26 */
27 function entityform_notifications_form_entityform_type_form_alter(&$form, &$form_state, $form_id) {
28 $entityform_type = $form['#entityform_type'];
29 _entityform_notifications_type_settings($form['data']['notifications_set'], $entityform_type);
30 //$form['data'] ['notifications_set'] = $notifications_set;
31 _entityform_remove_fieldsets_from_tree($form['data'], array('data'));
32
33 }
34 function _entityform_notifications_type_settings(&$notifications_fieldset, $entityform_type) {
35 //****************NOTIFICATIONS FIELDSET SETTINGS *********************//
36 $notifications_fieldset['notification_text'] = array(
37 '#type' => 'textarea',
38 '#title' => t('Email text'),
39 '#default_value' => empty($entityform_type->data['notification_text']) ? '' : $entityform_type->data['notification_text'],
40 '#description' => t('Text for Confirmation Email to submitter. DO NOT put HTML in this field'),
41 '#weight' => 70,
42 );
43 $notifications_fieldset['notify_emails'] = array(
44 '#type' => 'textfield',
45 '#title' => t('Notification emails'),
46 '#default_value' => empty($entityform_type->data['notify_emails']) ? '' : $entityform_type->data['notify_emails'],
47 '#description' => t('Enter emails that should be notified for each form submissions.'),
48 '#element_validate' => array('_entityform_form_email_list_validate'),
49 '#weight' => 80,
50 );
51 if (!module_exists('variable_admin')) {
52 //Inform user to enable this module
53 $notifications_fieldset['notify_help'] = array(
54 '#type' => 'markup',
55 '#markup' => t('Enable the %module module to edit the full body and subject of these emails', array('%module' => 'Variable admin')),
56 '#weight' => 60,
57 );
58 }
59 else {
60 $variable_path = 'admin/config/system/variable/edit/entityform_notify_';
61 $text = t('Edit the subject and body of this email');
62 $attributes = array('query' => array('destination' => current_path()));
63 $notifications_fieldset['notification_text']['#description'] .= ' ' . l($text,$variable_path . 'submitter_[mail_part]', $attributes);
64 $notifications_fieldset['notify_emails']['#description'] .= ' ' . l($text,$variable_path . 'admin_[mail_part]', $attributes);
65 }
66 //return $notifications_set;
67 }