Code Duplication    Length = 40-40 lines in 2 locations

src/projects/fcreate.php 2 locations

@@ 243-282 (lines=40) @@
240
241
    // 2nd step of new field (string) has been submitted
242
243
    elseif (try_request('submitted') == 'stringform')
244
    {
245
        debug_write_log(DEBUG_NOTICE, 'Data for step #2 (string) are submitted.');
246
247
        $field_name     = ustrcut($_REQUEST['field_name'], MAX_FIELD_NAME);
248
        $field_type     = FIELD_TYPE_STRING;
249
        $max_length     = ustrcut($_REQUEST['max_length'], ustrlen(MAX_FIELD_STRING));
250
        $is_required    = isset($_REQUEST['is_required']);
251
        $guest_access   = isset($_REQUEST['guest_access']);
252
        $add_separator  = isset($_REQUEST['add_separator']);
253
        $show_in_emails = isset($_REQUEST['show_in_emails']);
254
        $description    = ustrcut($_REQUEST['description'],   MAX_FIELD_DESCRIPTION);
255
        $regex_check    = ustrcut($_REQUEST['regex_check'],   MAX_FIELD_REGEX);
256
        $regex_search   = ustrcut($_REQUEST['regex_search'],  MAX_FIELD_REGEX);
257
        $regex_replace  = ustrcut($_REQUEST['regex_replace'], MAX_FIELD_REGEX);
258
259
        $error = field_validate_string($field_name, $max_length);
260
261
        if ($error == NO_ERROR)
262
        {
263
            $def_value = ustrcut($_REQUEST['def_value'], $max_length);
264
            $value_id  = (ustrlen($def_value) == 0 ? NULL : value_find_string($def_value));
265
266
            $error = field_create($state['template_id'],
267
                                  $id,
268
                                  $field_name,
269
                                  $field_type,
270
                                  $is_required,
271
                                  $add_separator,
272
                                  $guest_access,
273
                                  $show_in_emails,
274
                                  $description,
275
                                  $regex_check,
276
                                  $regex_search,
277
                                  $regex_replace,
278
                                  $max_length,
279
                                  NULL,
280
                                  $value_id);
281
        }
282
    }
283
284
    // 2nd step of new field (multilined) has been submitted
285
@@ 286-325 (lines=40) @@
283
284
    // 2nd step of new field (multilined) has been submitted
285
286
    elseif (try_request('submitted') == 'multilinedform')
287
    {
288
        debug_write_log(DEBUG_NOTICE, 'Data for step #2 (multilined text) are submitted.');
289
290
        $field_name     = ustrcut($_REQUEST['field_name'], MAX_FIELD_NAME);
291
        $field_type     = FIELD_TYPE_MULTILINED;
292
        $max_length     = ustrcut($_REQUEST['max_length'], ustrlen(MAX_FIELD_MULTILINED));
293
        $is_required    = isset($_REQUEST['is_required']);
294
        $guest_access   = isset($_REQUEST['guest_access']);
295
        $add_separator  = isset($_REQUEST['add_separator']);
296
        $show_in_emails = isset($_REQUEST['show_in_emails']);
297
        $description    = ustrcut($_REQUEST['description'],   MAX_FIELD_DESCRIPTION);
298
        $regex_check    = ustrcut($_REQUEST['regex_check'],   MAX_FIELD_REGEX);
299
        $regex_search   = ustrcut($_REQUEST['regex_search'],  MAX_FIELD_REGEX);
300
        $regex_replace  = ustrcut($_REQUEST['regex_replace'], MAX_FIELD_REGEX);
301
302
        $error = field_validate_multilined($field_name, $max_length);
303
304
        if ($error == NO_ERROR)
305
        {
306
            $def_value = ustrcut($_REQUEST['def_value'], $max_length);
307
            $value_id  = (ustrlen($def_value) == 0 ? NULL : value_find_multilined($def_value));
308
309
            $error = field_create($state['template_id'],
310
                                  $id,
311
                                  $field_name,
312
                                  $field_type,
313
                                  $is_required,
314
                                  $add_separator,
315
                                  $guest_access,
316
                                  $show_in_emails,
317
                                  $description,
318
                                  $regex_check,
319
                                  $regex_search,
320
                                  $regex_replace,
321
                                  $max_length,
322
                                  NULL,
323
                                  $value_id);
324
        }
325
    }
326
327
    // 2nd step of new field (checkbox) has been submitted
328