Control panel will hide applications if the setting is disabled

This commit is contained in:
Pinga 2023-12-29 21:49:28 +02:00
parent 22337dc0ba
commit 4cf0d8c5dd
3 changed files with 26 additions and 8 deletions

View file

@ -11,7 +11,14 @@ class ApplicationsController extends Controller
public function listApplications(Request $request, Response $response) public function listApplications(Request $request, Response $response)
{ {
return view($response,'admin/domains/listApplications.twig'); $db = $this->container->get('db');
$launch_phases = $db->selectValue("SELECT value FROM settings WHERE name = 'launch_phases'");
if ($launch_phases == 'on') {
return view($response,'admin/domains/listApplications.twig');
} else {
$this->container->get('flash')->addMessage('info', 'Applications are disabled.');
return $response->withHeader('Location', '/domains')->withStatus(302);
}
} }
public function createApplication(Request $request, Response $response) public function createApplication(Request $request, Response $response)
@ -606,10 +613,16 @@ class ApplicationsController extends Controller
} }
// Default view for GET requests or if POST data is not set // Default view for GET requests or if POST data is not set
return view($response,'admin/domains/createApplication.twig', [ $launch_phases = $db->selectValue("SELECT value FROM settings WHERE name = 'launch_phases'");
'registrars' => $registrars, if ($launch_phases == 'on') {
'registrar' => $registrar, return view($response,'admin/domains/createApplication.twig', [
]); 'registrars' => $registrars,
'registrar' => $registrar,
]);
} else {
$this->container->get('flash')->addMessage('info', 'Applications are disabled.');
return $response->withHeader('Location', '/domains')->withStatus(302);
}
} }
public function viewApplication(Request $request, Response $response, $args) public function viewApplication(Request $request, Response $response, $args)

View file

@ -105,7 +105,7 @@ class DomainsController extends Controller
$contactTech = $data['contactTech'] ?? null; $contactTech = $data['contactTech'] ?? null;
$contactBilling = $data['contactBilling'] ?? null; $contactBilling = $data['contactBilling'] ?? null;
$phaseType = $data['phaseType'] ?? null; $phaseType = $data['phaseType'] ?? 'NONE';
$smd = $data['smd'] ?? null; $smd = $data['smd'] ?? null;
$nameservers = !empty($data['nameserver']) ? $data['nameserver'] : null; $nameservers = !empty($data['nameserver']) ? $data['nameserver'] : null;
@ -187,7 +187,7 @@ class DomainsController extends Controller
); );
if ($phase_details !== 'First-Come-First-Serve') { if ($phase_details !== 'First-Come-First-Serve') {
if ($phaseType !== null && $phaseType !== '') { if ($phaseType == null && $phaseType == '') {
return view($response, 'admin/domains/createDomain.twig', [ return view($response, 'admin/domains/createDomain.twig', [
'domainName' => $domainName, 'domainName' => $domainName,
'error' => 'The launch phase ' . $phaseType . ' is improperly configured. Please check the settings or contact support.', 'error' => 'The launch phase ' . $phaseType . ' is improperly configured. Please check the settings or contact support.',
@ -195,7 +195,7 @@ class DomainsController extends Controller
'registrar' => $registrar, 'registrar' => $registrar,
]); ]);
} }
} else if ($phaseType !== null && $phaseType !== '') { } else if ($phaseType == null && $phaseType == '') {
return view($response, 'admin/domains/createDomain.twig', [ return view($response, 'admin/domains/createDomain.twig', [
'domainName' => $domainName, 'domainName' => $domainName,
'error' => 'The launch phase ' . $phaseType . ' is improperly configured. Please check the settings or contact support.', 'error' => 'The launch phase ' . $phaseType . ' is improperly configured. Please check the settings or contact support.',
@ -907,12 +907,15 @@ class DomainsController extends Controller
// Determine currency position (before or after) // Determine currency position (before or after)
$position = (strpos($pattern, '¤') < strpos($pattern, '#')) ? 'before' : 'after'; $position = (strpos($pattern, '¤') < strpos($pattern, '#')) ? 'before' : 'after';
$launch_phases = $db->selectValue("SELECT value FROM settings WHERE name = 'launch_phases'");
// Default view for GET requests or if POST data is not set // Default view for GET requests or if POST data is not set
return view($response,'admin/domains/createDomain.twig', [ return view($response,'admin/domains/createDomain.twig', [
'registrars' => $registrars, 'registrars' => $registrars,
'currencySymbol' => $symbol, 'currencySymbol' => $symbol,
'currencyPosition' => $position, 'currencyPosition' => $position,
'registrar' => $registrar, 'registrar' => $registrar,
'launch_phases' => $launch_phases
]); ]);
} }

View file

@ -219,6 +219,7 @@
</div> </div>
{% endif %} {% endif %}
{% if launch_phases == 'on' %}
<div class="mb-3"> <div class="mb-3">
<label for="phaseType" class="form-label">Phase Type</label> <label for="phaseType" class="form-label">Phase Type</label>
<select class="form-select" id="phaseType" name="phaseType"> <select class="form-select" id="phaseType" name="phaseType">
@ -235,6 +236,7 @@
<label class="form-label">Signed Mark Information</label> <label class="form-label">Signed Mark Information</label>
<textarea class="form-control" data-bs-toggle="autosize" name="smd" placeholder="Paste SMD contents…"></textarea> <textarea class="form-control" data-bs-toggle="autosize" name="smd" placeholder="Paste SMD contents…"></textarea>
</div> </div>
{% endif %}
</div> </div>
<div class="card-footer"> <div class="card-footer">