Révision a45e4bc1
Ajouté par Assos Assos il y a environ 9 ans
drupal7/sites/all/modules/webform/includes/webform.admin.inc | ||
---|---|---|
11 | 11 |
function webform_admin_settings() { |
12 | 12 |
module_load_include('inc', 'webform', 'includes/webform.export'); |
13 | 13 |
|
14 |
$node_types = node_type_get_names(); |
|
15 |
$form['node_types'] = array( |
|
16 |
'#type' => 'checkboxes', |
|
17 |
'#title' => t('Webform-enabled content types'), |
|
18 |
'#description' => t('Webform allows you to enable the webform components for any content type. Choose the types on which you would like to associate webform components.'), |
|
19 |
'#options' => $node_types, |
|
20 |
'#default_value' => webform_variable_get('webform_node_types'), |
|
21 |
); |
|
22 |
|
|
23 | 14 |
$form['components'] = array( |
24 | 15 |
'#type' => 'fieldset', |
25 | 16 |
'#title' => t('Available components'), |
... | ... | |
51 | 42 |
$form['email']['webform_default_from_address'] = array( |
52 | 43 |
'#type' => 'textfield', |
53 | 44 |
'#title' => t('From address'), |
54 |
'#default_value' => variable_get('webform_default_from_address', variable_get('site_mail', ini_get('sendmail_from'))),
|
|
45 |
'#default_value' => webform_variable_get('webform_default_from_address'),
|
|
55 | 46 |
'#description' => t('The default sender address for emailed webform results; often the e-mail address of the maintainer of your forms.'), |
56 | 47 |
); |
57 | 48 |
|
58 | 49 |
$form['email']['webform_default_from_name'] = array( |
59 | 50 |
'#type' => 'textfield', |
60 | 51 |
'#title' => t('From name'), |
61 |
'#default_value' => variable_get('webform_default_from_name', variable_get('site_name', '')),
|
|
52 |
'#default_value' => webform_variable_get('webform_default_from_name'),
|
|
62 | 53 |
'#description' => t('The default sender name which is used along with the default from address.'), |
63 | 54 |
); |
64 | 55 |
|
65 | 56 |
$form['email']['webform_default_subject'] = array( |
66 | 57 |
'#type' => 'textfield', |
67 | 58 |
'#title' => t('Default subject'), |
68 |
'#default_value' => variable_get('webform_default_subject', t('Form submission from: %title')),
|
|
59 |
'#default_value' => webform_variable_get('webform_default_subject'),
|
|
69 | 60 |
'#description' => t('The default subject line of any e-mailed results.'), |
70 | 61 |
); |
71 | 62 |
|
63 |
$form['email']['webform_email_replyto'] = array( |
|
64 |
'#type' => 'checkbox', |
|
65 |
'#title' => t('Use Reply-To header'), |
|
66 |
'#default_value' => webform_variable_get('webform_email_replyto'), |
|
67 |
'#description' => t('Sends all e-mail from the domain of the default address above and sets the "Reply-To" header to the actual sender. Helps prevent e-mail from being flagged as spam.'), |
|
68 |
); |
|
69 |
|
|
70 |
$form['email']['webform_email_html_capable'] = array( |
|
71 |
'#type' => 'checkbox', |
|
72 |
'#title' => t('HTML mail system'), |
|
73 |
'#default_value' => webform_variable_get('webform_email_html_capable'), |
|
74 |
'#description' => t('Whether the mail system configured for webform is capable of sending mail in HTML format.'), |
|
75 |
); |
|
76 |
|
|
72 | 77 |
$form['email']['webform_default_format'] = array( |
73 | 78 |
'#type' => 'radios', |
74 | 79 |
'#title' => t('Format'), |
... | ... | |
76 | 81 |
0 => t('Plain text'), |
77 | 82 |
1 => t('HTML'), |
78 | 83 |
), |
79 |
'#default_value' => variable_get('webform_default_format', 0),
|
|
84 |
'#default_value' => webform_variable_get('webform_default_format'),
|
|
80 | 85 |
'#description' => t('The default format for new e-mail settings. Webform e-mail options take precedence over the settings for system-wide e-mails configured in MIME mail.'), |
81 |
'#access' => webform_email_html_capable(), |
|
86 |
'#states' => array( |
|
87 |
'visible' => array( |
|
88 |
':input[name="webform_email_html_capable"]' => array('checked' => TRUE), |
|
89 |
), |
|
90 |
), |
|
82 | 91 |
); |
83 | 92 |
|
84 | 93 |
$form['email']['webform_format_override'] = array( |
... | ... | |
88 | 97 |
0 => t('Per-webform configuration of e-mail format'), |
89 | 98 |
1 => t('Send all e-mails in the default format'), |
90 | 99 |
), |
91 |
'#default_value' => variable_get('webform_format_override', 0),
|
|
100 |
'#default_value' => webform_variable_get('webform_format_override'),
|
|
92 | 101 |
'#description' => t('Force all webform e-mails to be sent in the default format.'), |
93 |
'#access' => webform_email_html_capable(), |
|
102 |
'#states' => array( |
|
103 |
'visible' => array( |
|
104 |
':input[name="webform_email_html_capable"]' => array('checked' => TRUE), |
|
105 |
), |
|
106 |
), |
|
94 | 107 |
); |
95 | 108 |
|
96 |
$form['advanced'] = array(
|
|
109 |
$form['progressbar'] = array(
|
|
97 | 110 |
'#type' => 'fieldset', |
98 |
'#title' => t('Advanced options'),
|
|
111 |
'#title' => t('Progress bar'),
|
|
99 | 112 |
'#collapsible' => TRUE, |
100 | 113 |
'#collapsed' => TRUE, |
101 | 114 |
); |
115 |
$form['progressbar']['webform_progressbar_style'] = array( |
|
116 |
'#type' => 'checkboxes', |
|
117 |
'#title' => t('Progress bar style'), |
|
118 |
'#options' => array( |
|
119 |
'progressbar_bar' => t('Show progress bar'), |
|
120 |
'progressbar_page_number' => t('Show page number as number of completed (i.e. Page 1 of 10)'), |
|
121 |
'progressbar_percent' => t('Show percentage completed (i.e. 10%)'), |
|
122 |
'progressbar_pagebreak_labels' => t('Show page labels from page break components'), |
|
123 |
'progressbar_include_confirmation' => t('Include confirmation page in progress bar'), |
|
124 |
), |
|
125 |
'#default_value' => webform_variable_get('webform_progressbar_style'), |
|
126 |
'#description' => t('Choose how the progress bar should be displayed for multi-page forms.'), |
|
127 |
); |
|
128 |
$form['progressbar']['webform_progressbar_label_first'] = array( |
|
129 |
'#type' => 'textfield', |
|
130 |
'#title' => t('First page label'), |
|
131 |
'#default_value' => webform_variable_get('webform_progressbar_label_first'), |
|
132 |
'#maxlength' => 255, |
|
133 |
); |
|
134 |
$form['progressbar']['webform_progressbar_label_confirmation'] = array( |
|
135 |
'#type' => 'textfield', |
|
136 |
'#title' => t('Confirmation page label'), |
|
137 |
'#default_value' => webform_variable_get('webform_progressbar_label_confirmation'), |
|
138 |
'#maxlength' => 255, |
|
139 |
); |
|
102 | 140 |
|
103 |
$form['advanced']['webform_use_cookies'] = array(
|
|
104 |
'#type' => 'checkbox',
|
|
105 |
'#checked_value' => 1,
|
|
106 |
'#title' => t('Allow cookies for tracking submissions'),
|
|
107 |
'#default_value' => variable_get('webform_use_cookies', 0),
|
|
108 |
'#description' => t('<a href="http://www.wikipedia.org/wiki/HTTP_cookie">Cookies</a> can be used to help prevent the same user from repeatedly submitting a webform. This feature is not needed for limiting submissions per user, though it can increase accuracy in some situations. Besides cookies, Webform also uses IP addresses and site usernames to prevent repeated submissions.'),
|
|
141 |
$form['advanced'] = array( |
|
142 |
'#type' => 'fieldset',
|
|
143 |
'#title' => t('Advanced options'),
|
|
144 |
'#collapsible' => TRUE,
|
|
145 |
'#collapsed' => TRUE,
|
|
146 |
'#weight' => 20,
|
|
109 | 147 |
); |
110 | 148 |
|
111 |
$form['advanced']['webform_search_index'] = array( |
|
112 |
'#type' => 'checkbox', |
|
113 |
'#checked_value' => 1, |
|
114 |
'#title' => t('Include webform forms in search index'), |
|
115 |
'#default_value' => variable_get('webform_search_index', 1), |
|
116 |
'#description' => t('When selected, all Webform nodes will have their form components indexed by the search engine.'), |
|
117 |
'#access' => module_exists('search'), |
|
149 |
$form['advanced']['webform_tracking_mode'] = array( |
|
150 |
'#type' => 'radios', |
|
151 |
'#title' => t('Track anonymous users by:'), |
|
152 |
'#options' => array( |
|
153 |
'cookie' => t('Cookie only (least strict)'), |
|
154 |
'ip_address' => t('IP address only'), |
|
155 |
'strict' => t('Both cookie and IP address (most strict)'), |
|
156 |
), |
|
157 |
'#default_value' => webform_variable_get('webform_tracking_mode'), |
|
158 |
'#description' => t('<a href="http://www.wikipedia.org/wiki/HTTP_cookie">Cookies</a> can be used to help prevent the same user from repeatedly submitting a webform. Limiting by IP address is more effective against repeated submissions, but may result in unintentional blocking of users sharing the same address. Confidential submissions are tracked by cookie only. Logged-in users are always tracked by their user ID and are not affected by this option.'), |
|
118 | 159 |
); |
119 | 160 |
|
120 | 161 |
$form['advanced']['webform_email_address_format'] = array( |
... | ... | |
124 | 165 |
'long' => t('Long format: "Example Name" <name@example.com>'), |
125 | 166 |
'short' => t('Short format: name@example.com'), |
126 | 167 |
), |
127 |
'#default_value' => variable_get('webform_email_address_format', 'long'),
|
|
168 |
'#default_value' => webform_variable_get('webform_email_address_format'),
|
|
128 | 169 |
'#description' => t('Most servers support the "long" format which will allow for more friendly From addresses in e-mails sent. However many Windows-based servers are unable to send in the long format. Change this option if experiencing problems sending e-mails with Webform.'), |
129 | 170 |
); |
130 | 171 |
|
172 |
$form['advanced']['webform_email_address_individual'] = array( |
|
173 |
'#type' => 'radios', |
|
174 |
'#title' => t('E-mailing multiple recipients'), |
|
175 |
'#options' => array( |
|
176 |
'0' => t('Send a single e-mail to all recipients'), |
|
177 |
'1' => t('Send individual e-mails to each recipient'), |
|
178 |
), |
|
179 |
'#default_value' => webform_variable_get('webform_email_address_individual'), |
|
180 |
'#description' => t('Individual e-mails increases privacy by not revealing the addresses of other recipients. A single e-mail to all recipients lets them use "Reply All" to communicate.'), |
|
181 |
); |
|
182 |
|
|
183 |
$date_format_options = array(); |
|
184 |
foreach (system_get_date_types() as $type => $type_info) { |
|
185 |
$date_format_options[$type] = t('@title — @sample', array('@title' => $type_info['title'], '@sample' => format_date(REQUEST_TIME, 'custom', webform_date_format($type)))); |
|
186 |
} |
|
187 |
$form['advanced']['webform_date_type'] = array( |
|
188 |
'#type' => 'select', |
|
189 |
'#title' => t('Date format'), |
|
190 |
'#options' => $date_format_options, |
|
191 |
'#default_value' => webform_variable_get('webform_date_type'), |
|
192 |
'#description' => t('Choose the format for the display of date components. Only the date portion of the format is used. Reporting and export use the short format.'), |
|
193 |
); |
|
194 |
|
|
131 | 195 |
$form['advanced']['webform_export_format'] = array( |
132 | 196 |
'#type' => 'radios', |
133 | 197 |
'#title' => t('Default export format'), |
134 | 198 |
'#options' => webform_export_list(), |
135 |
'#default_value' => variable_get('webform_export_format', 'delimited'),
|
|
199 |
'#default_value' => webform_variable_get('webform_export_format'),
|
|
136 | 200 |
); |
137 | 201 |
|
138 | 202 |
$form['advanced']['webform_csv_delimiter'] = array( |
139 | 203 |
'#type' => 'select', |
140 | 204 |
'#title' => t('Default export delimiter'), |
141 | 205 |
'#description' => t('This is the delimiter used in the CSV/TSV file when downloading Webform results. Using tabs in the export is the most reliable method for preserving non-latin characters. You may want to change this to another character depending on the program with which you anticipate importing results.'), |
142 |
'#default_value' => variable_get('webform_csv_delimiter', '\t'),
|
|
206 |
'#default_value' => webform_variable_get('webform_csv_delimiter'),
|
|
143 | 207 |
'#options' => array( |
144 | 208 |
',' => t('Comma (,)'), |
145 | 209 |
'\t' => t('Tab (\t)'), |
... | ... | |
151 | 215 |
), |
152 | 216 |
); |
153 | 217 |
|
218 |
$form['advanced']['webform_export_wordwrap'] = array( |
|
219 |
'#type' => 'radios', |
|
220 |
'#title' => t('Export word-wrap'), |
|
221 |
'#options' => array( |
|
222 |
'0' => t('Only text containing return characters'), |
|
223 |
'1' => t('All text'), |
|
224 |
), |
|
225 |
'#default_value' => webform_variable_get('webform_export_wordwrap'), |
|
226 |
'#description' => t('Some export formats, such as Microsoft Excel, support word-wrapped text cells.'), |
|
227 |
); |
|
228 |
|
|
154 | 229 |
$form['advanced']['webform_submission_access_control'] = array( |
155 | 230 |
'#type' => 'radios', |
156 | 231 |
'#title' => t('Submission access control'), |
... | ... | |
158 | 233 |
'1' => t('Select the user roles that may submit each individual webform'), |
159 | 234 |
'0' => t('Disable Webform submission access control'), |
160 | 235 |
), |
161 |
'#default_value' => variable_get('webform_submission_access_control', 1),
|
|
236 |
'#default_value' => webform_variable_get('webform_submission_access_control'),
|
|
162 | 237 |
'#description' => t('By default, the configuration form for each webform allows the administrator to choose which roles may submit the form. You may want to allow users to always submit the form if you are using a separate node access module to control access to webform nodes themselves.'), |
163 | 238 |
); |
164 | 239 |
|
240 |
$form['advanced']['webform_email_select_max'] = array( |
|
241 |
'#type' => 'textfield', |
|
242 |
'#title' => t("Select email mapping limit"), |
|
243 |
'#default_value' => webform_variable_get('webform_email_select_max'), |
|
244 |
'#description' => t('When mapping emails addresses to a select component, limit the choice to components with less than the amount of options indicated. This is to avoid flooding the email settings form.'), |
|
245 |
); |
|
246 |
|
|
165 | 247 |
$form = system_settings_form($form); |
166 | 248 |
$form['#theme'] = 'webform_admin_settings'; |
167 | 249 |
array_unshift($form['#submit'], 'webform_admin_settings_submit'); |
... | ... | |
183 | 265 |
$form_state['values']['webform_disabled_components'] = $disabled_components; |
184 | 266 |
unset($form_state['values']['components']); |
185 | 267 |
|
186 |
// Change the name of the node type variable and clean it up. |
|
187 |
$form_state['values']['webform_node_types'] = array_keys(array_filter($form_state['values']['node_types'])); |
|
188 |
unset($form_state['values']['node_types']); |
|
268 |
// Trim out empty options in the progress bar options. |
|
269 |
$form_state['values']['webform_progressbar_style'] = array_keys(array_filter($form_state['values']['webform_progressbar_style'])); |
|
189 | 270 |
} |
190 | 271 |
|
191 | 272 |
/** |
... | ... | |
220 | 301 |
* Menu callback for admin/content/webform. Displays all webforms on the site. |
221 | 302 |
*/ |
222 | 303 |
function webform_admin_content() { |
304 |
// Determine whether views or hard-coded tables should be used for the webforms table. |
|
305 |
if (!webform_variable_get('webform_table')) { |
|
306 |
$view = views_get_view('webform_webforms'); |
|
307 |
return $view->preview('default'); |
|
308 |
} |
|
309 |
|
|
223 | 310 |
$query = db_select('webform', 'w'); |
224 | 311 |
$query->join('node', 'n', 'w.nid = n.nid'); |
225 | 312 |
$query->fields('n'); |
... | ... | |
231 | 318 |
* Create a comma-separate list of content types that are webform enabled. |
232 | 319 |
*/ |
233 | 320 |
function webform_admin_type_list() { |
234 |
$webform_types = webform_variable_get('webform_node_types');
|
|
321 |
$webform_types = webform_node_types();
|
|
235 | 322 |
$webform_type_list = ''; |
236 | 323 |
$webform_type_count = count($webform_types); |
237 | 324 |
foreach ($webform_types as $n => $type) { |
238 |
$webform_type_list .= l(node_type_get_name($type), 'node/add/' . $type);
|
|
325 |
$webform_type_list .= l(node_type_get_name($type), 'node/add/' . str_replace('_', '-', $type));
|
|
239 | 326 |
if ($n + 1 < $webform_type_count) { |
240 | 327 |
$webform_type_list .= $webform_type_count == 2 ? ' ' : ', '; |
241 | 328 |
} |
... | ... | |
273 | 360 |
} |
274 | 361 |
|
275 | 362 |
if (empty($rows)) { |
276 |
$webform_types = webform_variable_get('webform_node_types');
|
|
363 |
$webform_types = webform_node_types();
|
|
277 | 364 |
if (empty($webform_types)) { |
278 | 365 |
$message = t('Webform is currently not enabled on any content types.') . ' ' . t('Visit the <a href="!url">Webform settings</a> page and enable Webform on at least one content type.', array('!url' => url('admin/config/content/webform'))); |
279 | 366 |
} |
Formats disponibles : Unified diff
Update webform to 4.10