Code Duplication    Length = 18-20 lines in 2 locations

admin/fields.php 2 locations

@@ 307-326 (lines=20) @@
304
        //Departments Chosen?
305
306
        //default value in value set?
307
        if (count($values)) {
308
            if (!in_array($_POST['fld_defaultvalue'], $values, true) && !array_key_exists($_POST['fld_defaultvalue'], $values) ) {
309
                $has_errors = true;
310
                $errors['fld_defaultvalue'][] = _AM_XHELP_VALID_ERR_DEFAULTVALUE;
311
            }
312
313
            //length larger than longest value?
314
            $length = intval($_POST['fld_length']);
315
            foreach($values as $key=>$value) {
316
                if (strlen($key) > $length) {
317
                    $has_errors = true;
318
                    $errors['fld_values'][] = sprintf(_AM_XHELP_VALID_ERR_VALUE_LENGTH, htmlentities($key), $length);
319
                }
320
            }
321
322
            //Values are all of the correct datatype?
323
        } elseif ($fld_needsvalues) {
324
            $has_errors = true;
325
            $errors['fld_values'][] = _AM_XHELP_VALID_ERR_VALUE;
326
        }
327
328
        if ($has_errors) {
329
            $afield = array();
@@ 645-662 (lines=18) @@
642
        }
643
644
        //default value in value set?
645
        if (count($values)) {
646
            if (!in_array($_POST['fld_defaultvalue'], $values, true) && !array_key_exists($_POST['fld_defaultvalue'], $values) ) {
647
                $has_errors = true;
648
                $errors['fld_defaultvalue'][] = _AM_XHELP_VALID_ERR_DEFAULTVALUE;
649
            }
650
651
            //length larger than longest value?
652
            $length = intval($_POST['fld_length']);
653
            foreach($values as $key=>$value) {
654
                if (strlen($key) > $length) {
655
                    $has_errors = true;
656
                    $errors['fld_values'][] = sprintf(_AM_XHELP_VALID_ERR_VALUE_LENGTH, htmlentities($key), $length);
657
                }
658
            }
659
        } elseif ($fld_needsvalues) {
660
            $has_errors = true;
661
            $errors['fld_values'][] = _AM_XHELP_VALID_ERR_VALUE;
662
        }
663
664
        if ($has_errors) {
665
            $afield = array();