1
|
<?php
|
2
|
/**
|
3
|
* @file
|
4
|
* Contains configuration form for Recovery Password.
|
5
|
*/
|
6
|
|
7
|
/**
|
8
|
* Callback to admin/config/people/recovery-pass.
|
9
|
*/
|
10
|
function recovery_pass_config_form($form, &$form_state) {
|
11
|
$form = array();
|
12
|
$form['recovery_pass_help_text'] = array(
|
13
|
'#type' => 'item',
|
14
|
'#markup' => t('Edit the e-mail messages sent to users who request a new password. The list of available tokens that can be used in e-mails is provided below. For displaying new password please use <strong>[user_new_password]</strong> placeholder.'),
|
15
|
);
|
16
|
|
17
|
$form['recovery_pass_email_subject'] = array(
|
18
|
'#type' => 'textfield',
|
19
|
'#title' => t('Subject'),
|
20
|
'#required' => TRUE,
|
21
|
'#default_value' => _recovery_pass_mail_text('email_subject'),
|
22
|
);
|
23
|
|
24
|
$form['recovery_pass_email_text'] = array(
|
25
|
'#type' => 'textarea',
|
26
|
'#title' => t('Email Body'),
|
27
|
'#required' => TRUE,
|
28
|
'#default_value' => _recovery_pass_mail_text('email_text'),
|
29
|
);
|
30
|
|
31
|
if (module_exists("htmlmail")) {
|
32
|
// Adding description incase HTMLMAIL module exists.
|
33
|
$form['recovery_pass_email_text']['#description'] = t('Supports HTML Mail provided HTMLMAIL module is enabled.');
|
34
|
}
|
35
|
|
36
|
if (module_exists("token")) {
|
37
|
$form['token_help'] = array(
|
38
|
'#type' => 'markup',
|
39
|
'#token_types' => array('user'),
|
40
|
'#theme' => 'token_tree_link',
|
41
|
);
|
42
|
}
|
43
|
$form['recovery_pass_old_pass_show'] = array(
|
44
|
'#type' => 'checkbox',
|
45
|
'#title' => t('Show Warning message to users for trying old password at login form.'),
|
46
|
'#default_value' => variable_get('recovery_pass_old_pass_show', 1),
|
47
|
);
|
48
|
|
49
|
$form['recovery_pass_old_pass_warning'] = array(
|
50
|
'#type' => 'textarea',
|
51
|
'#rows' => 2,
|
52
|
'#title' => t('Old Password Warning Message'),
|
53
|
'#description' => t('Warning message to be shown, if user after resetting the password uses the old password again.'),
|
54
|
'#default_value' => _recovery_pass_mail_text('old_pass_warning'),
|
55
|
);
|
56
|
|
57
|
$form['recovery_pass_fpass_redirect'] = array(
|
58
|
'#type' => 'textfield',
|
59
|
'#title' => t('Redirect Path after Forgot Password Page'),
|
60
|
'#maxlength' => 255,
|
61
|
'#default_value' => variable_get('recovery_pass_fpass_redirect', 'user'),
|
62
|
'#description' => t('The path to redirect user, after forgot password form. This can be an internal Drupal path such as %add-node or an external URL such as %drupal. Enter %front to link to the front page.',
|
63
|
array(
|
64
|
'%front' => '<front>',
|
65
|
'%add-node' => 'node/add',
|
66
|
'%drupal' => 'http://drupal.org',
|
67
|
)
|
68
|
),
|
69
|
'#required' => TRUE,
|
70
|
'#element_validate' => array('_recovery_pass_validate_path'),
|
71
|
);
|
72
|
|
73
|
$form['recovery_pass_expiry_period'] = array(
|
74
|
'#type' => 'textfield',
|
75
|
'#title' => t('Expiry Period'),
|
76
|
'#description' => t('Please enter expiry period in weeks. After these many weeks the record for old password warning to be shown to that particular user would be deleted.'),
|
77
|
'#default_value' => variable_get('recovery_pass_expiry_period', '1'),
|
78
|
'#element_validate' => array('element_validate_integer_positive'),
|
79
|
);
|
80
|
|
81
|
return system_settings_form($form);
|
82
|
}
|
83
|
|
84
|
/**
|
85
|
* Validates path entered by user.
|
86
|
*/
|
87
|
function _recovery_pass_validate_path($element, &$form_state, $form) {
|
88
|
if (!empty($element['#value'])) {
|
89
|
$path = $element['#value'];
|
90
|
if (!drupal_valid_path($path) && !drupal_lookup_path('source', $path) && !url_is_external($path)) {
|
91
|
form_error($element, t('Please provide valid redirect path.'));
|
92
|
}
|
93
|
}
|
94
|
}
|