diff --git a/cp/app/Controllers/SystemController.php b/cp/app/Controllers/SystemController.php index f7f4800..0025797 100644 --- a/cp/app/Controllers/SystemController.php +++ b/cp/app/Controllers/SystemController.php @@ -1497,7 +1497,13 @@ class SystemController extends Controller OR (start_date >= ? AND (end_date IS NULL OR end_date <= ?)) ) AND (end_date IS NULL OR end_date >= NOW()) -- Ensures ongoing phases count - ) AS dateOverlapExists"; + ) AS dateOverlapExists, + + (SELECT COUNT(*) + FROM launch_phases + WHERE tld_id = ? + AND phase_name = ? + ) AS duplicatePhaseNameExists"; $result = $db->selectRow( $query, @@ -1505,7 +1511,8 @@ class SystemController extends Controller $sData['tldid'], $sData['phaseType'], $sData['phaseName'], $sData['tldid'], $sData['phaseEnd'], $sData['phaseStart'], $sData['phaseStart'], $sData['phaseEnd'], - $sData['phaseStart'], $sData['phaseEnd'] + $sData['phaseStart'], $sData['phaseEnd'], + $sData['tldid'], $sData['phaseName'] ] ); @@ -1516,6 +1523,12 @@ class SystemController extends Controller return $response->withHeader('Location', '/registry/tld/'.$sData['extension'])->withStatus(302); } + if ($result['duplicatePhaseNameExists'] > 0) { + $db->rollBack(); + $this->container->get('flash')->addMessage('error', 'A phase with this name already exists for this TLD.'); + return $response->withHeader('Location', '/registry/tld/'.$sData['extension'])->withStatus(302); + } + if ($result['dateOverlapExists'] > 0) { // Date range overlaps with an existing entry $db->rollBack();