Code Duplication    Length = 12-15 lines in 2 locations

src/controllers/ConstraintsController.php 2 locations

@@ 586-597 (lines=12) @@
583
584
            if ($_POST['type'] == 'primary') {
585
                // Check that they've given at least one column
586
                if (!isset($_POST['IndexColumnList']) || !is_array($_POST['IndexColumnList'])
587
                    || sizeof($_POST['IndexColumnList']) == 0) {
588
                    $this->addPrimaryOrUniqueKey($_POST['type'], true, $lang['strpkneedscols']);
589
                } else {
590
                    $status = $data->addPrimaryKey($_POST['table'], $_POST['IndexColumnList'], $_POST['name'], $_POST['tablespace']);
591
                    if ($status == 0) {
592
                        $this->doDefault($lang['strpkadded']);
593
                    } else {
594
                        $this->addPrimaryOrUniqueKey($_POST['type'], true, $lang['strpkaddedbad']);
595
                    }
596
                }
597
            } elseif ($_POST['type'] == 'unique') {
598
                // Check that they've given at least one column
599
                if (!isset($_POST['IndexColumnList']) || !is_array($_POST['IndexColumnList'])
600
                    || sizeof($_POST['IndexColumnList']) == 0) {
@@ 597-611 (lines=15) @@
594
                        $this->addPrimaryOrUniqueKey($_POST['type'], true, $lang['strpkaddedbad']);
595
                    }
596
                }
597
            } elseif ($_POST['type'] == 'unique') {
598
                // Check that they've given at least one column
599
                if (!isset($_POST['IndexColumnList']) || !is_array($_POST['IndexColumnList'])
600
                    || sizeof($_POST['IndexColumnList']) == 0) {
601
                    $this->addPrimaryOrUniqueKey($_POST['type'], true, $lang['struniqneedscols']);
602
                } else {
603
                    $status = $data->addUniqueKey($_POST['table'], $_POST['IndexColumnList'], $_POST['name'], $_POST['tablespace']);
604
                    if ($status == 0) {
605
                        $this->doDefault($lang['struniqadded']);
606
                    } else {
607
                        $this->addPrimaryOrUniqueKey($_POST['type'], true, $lang['struniqaddedbad']);
608
                    }
609
                }
610
            } else {
611
                $this->doDefault($lang['strinvalidparam']);
612
            }
613
        }
614
    }