Added minimum data set support for panel

This commit is contained in:
Pinga 2024-07-24 14:06:07 +03:00
parent d91307da55
commit 15673ff56f
12 changed files with 74 additions and 42 deletions

View file

@ -17,11 +17,19 @@ class ContactsController extends Controller
{
public function listContacts(Request $request, Response $response)
{
if (envi('MINIMUM_DATA') === 'true') {
return $response->withHeader('Location', '/dashboard')->withStatus(302);
}
return view($response,'admin/contacts/listContacts.twig');
}
public function createContact(Request $request, Response $response)
{
if (envi('MINIMUM_DATA') === 'true') {
return $response->withHeader('Location', '/dashboard')->withStatus(302);
}
if ($request->getMethod() === 'POST') {
// Retrieve POST data
$data = $request->getParsedBody();
@ -385,6 +393,10 @@ class ContactsController extends Controller
public function viewContact(Request $request, Response $response, $args)
{
if (envi('MINIMUM_DATA') === 'true') {
return $response->withHeader('Location', '/dashboard')->withStatus(302);
}
$db = $this->container->get('db');
// Get the current URI
$uri = $request->getUri()->getPath();
@ -464,6 +476,10 @@ class ContactsController extends Controller
public function updateContact(Request $request, Response $response, $args)
{
if (envi('MINIMUM_DATA') === 'true') {
return $response->withHeader('Location', '/dashboard')->withStatus(302);
}
$db = $this->container->get('db');
// Get the current URI
$uri = $request->getUri()->getPath();
@ -542,6 +558,10 @@ class ContactsController extends Controller
public function validateContact(Request $request, Response $response, $args)
{
if (envi('MINIMUM_DATA') === 'true') {
return $response->withHeader('Location', '/dashboard')->withStatus(302);
}
$db = $this->container->get('db');
$verifyPhone = $db->selectValue("SELECT value FROM settings WHERE name = 'verifyPhone'");
$verifyEmail = $db->selectValue("SELECT value FROM settings WHERE name = 'verifyEmail'");
@ -664,6 +684,10 @@ class ContactsController extends Controller
public function approveContact(Request $request, Response $response)
{
if (envi('MINIMUM_DATA') === 'true') {
return $response->withHeader('Location', '/dashboard')->withStatus(302);
}
if ($request->getMethod() === 'POST') {
$db = $this->container->get('db');
$verifyPhone = $db->selectValue("SELECT value FROM settings WHERE name = 'verifyPhone'");
@ -745,6 +769,10 @@ class ContactsController extends Controller
public function updateContactProcess(Request $request, Response $response)
{
if (envi('MINIMUM_DATA') === 'true') {
return $response->withHeader('Location', '/dashboard')->withStatus(302);
}
if ($request->getMethod() === 'POST') {
// Retrieve POST data
$data = $request->getParsedBody();
@ -1101,6 +1129,10 @@ class ContactsController extends Controller
public function deleteContact(Request $request, Response $response, $args)
{
if (envi('MINIMUM_DATA') === 'true') {
return $response->withHeader('Location', '/dashboard')->withStatus(302);
}
// if ($request->getMethod() === 'POST') {
$db = $this->container->get('db');
// Get the current URI

View file

@ -1183,8 +1183,10 @@ class DomainsController extends Controller
return $response->withHeader('Location', '/domain/update/'.$domainName)->withStatus(302);
}
} else {
$this->container->get('flash')->addMessage('error', 'Please provide registrant identifier');
return $response->withHeader('Location', '/domain/update/'.$domainName)->withStatus(302);
if (envi('MINIMUM_DATA') === 'false') {
$this->container->get('flash')->addMessage('error', 'Please provide registrant identifier');
return $response->withHeader('Location', '/domain/update/'.$domainName)->withStatus(302);
}
}
if ($contactAdmin) {
@ -1201,8 +1203,10 @@ class DomainsController extends Controller
return $response->withHeader('Location', '/domain/update/'.$domainName)->withStatus(302);
}
} else {
$this->container->get('flash')->addMessage('error', 'Please provide admin contact identifier');
return $response->withHeader('Location', '/domain/update/'.$domainName)->withStatus(302);
if (envi('MINIMUM_DATA') === 'false') {
$this->container->get('flash')->addMessage('error', 'Please provide admin contact identifier');
return $response->withHeader('Location', '/domain/update/'.$domainName)->withStatus(302);
}
}
if ($contactTech) {
@ -1219,8 +1223,10 @@ class DomainsController extends Controller
return $response->withHeader('Location', '/domain/update/'.$domainName)->withStatus(302);
}
} else {
$this->container->get('flash')->addMessage('error', 'Please provide tech contact identifier');
return $response->withHeader('Location', '/domain/update/'.$domainName)->withStatus(302);
if (envi('MINIMUM_DATA') === 'false') {
$this->container->get('flash')->addMessage('error', 'Please provide tech contact identifier');
return $response->withHeader('Location', '/domain/update/'.$domainName)->withStatus(302);
}
}
if ($contactBilling) {
@ -1236,9 +1242,6 @@ class DomainsController extends Controller
$this->container->get('flash')->addMessage('error', 'The contact requested in the command does NOT belong to the current registrar');
return $response->withHeader('Location', '/domain/update/'.$domainName)->withStatus(302);
}
} else {
$this->container->get('flash')->addMessage('error', 'Please provide billing contact identifier');
return $response->withHeader('Location', '/domain/update/'.$domainName)->withStatus(302);
}
if (!$authInfo) {

View file

@ -126,6 +126,11 @@ $container->set('view', function ($container) {
} else {
$view->getEnvironment()->addGlobal('screen_mode', 'light');
}
if (envi('MINIMUM_DATA') === 'true') {
$view->getEnvironment()->addGlobal('minimum_data', 'true');
} else {
$view->getEnvironment()->addGlobal('minimum_data', 'false');
}
if (isset($_SESSION['auth_roles'])) {
$view->getEnvironment()->addGlobal('roles', $_SESSION['auth_roles']);
}

View file

@ -14,6 +14,7 @@ return [
'url' => $_ENV['APP_URL'] ?? 'http://localhost',
'domain' => $_ENV['APP_DOMAIN'] ?? 'example.com',
'root' => $_ENV['APP_ROOT'] ?? '/var/www/cp',
'minimum_data' => $_ENV['MINIMUM_DATA'] ?? false,
'timezone' => $_ENV['TIME_ZONE'] ?? 'UTC',
'default' => $_ENV['DB_DRIVER'] ?? 'mysql',
'connections' => [
@ -47,16 +48,6 @@ return [
'schema' => 'public',
'sslmode' => 'prefer',
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => $_ENV['DB_HOST'] ?? 'localhost',
'port' => $_ENV['DB_PORT'] ?? '1433',
'database' => $_ENV['DB_DATABASE'] ?? 'db_username',
'username' => $_ENV['DB_USERNAME'] ?? 'db_password',
'password' => $_ENV['DB_PASSWORD'] ?? '',
'charset' => 'utf8',
'prefix' => '',
],
],
'mail' => [
'driver' => $_ENV['MAIL_DRIVER'] ?? 'smtp',

View file

@ -3,6 +3,7 @@ APP_ENV=public
APP_URL=https://cp.example.com
APP_DOMAIN=example.com
APP_ROOT=/var/www/cp
MINIMUM_DATA=false
DB_DRIVER=mysql
DB_HOST=localhost

View file

@ -45,7 +45,7 @@
<div class="col-12">
<div class="row row-cards">
{% if registrars %}
<div class="col-sm-6 col-lg-3">
<div class="{% if minimum_data == 'false' %}col-sm-6 col-lg-3{% else %}col-sm-4 col-lg-4{% endif %}">
<a class="card card-link" href="{{route('listDomains')}}">
<div class="card-body">
<div class="row align-items-center">
@ -61,7 +61,7 @@
</div>
</div>
</a>
</div>
</div>{% if minimum_data == 'false' %}
<div class="col-sm-6 col-lg-3">
<a class="card card-link" href="{{route('listContacts')}}">
<div class="card-body">
@ -78,8 +78,8 @@
</div>
</div>
</a>
</div>
<div class="col-sm-6 col-lg-3">
</div>{% endif %}
<div class="{% if minimum_data == 'false' %}col-sm-6 col-lg-3{% else %}col-sm-4 col-lg-4{% endif %}">
<a class="card card-link" href="{{route('listHosts')}}">
<div class="card-body">
<div class="row align-items-center">
@ -96,7 +96,7 @@
</div>
</a>
</div>
<div class="col-sm-6 col-lg-3">
<div class="{% if minimum_data == 'false' %}col-sm-6 col-lg-3{% else %}col-sm-4 col-lg-4{% endif %}">
<a class="card card-link" href="{{route('registrars')}}">
<div class="card-body">
<div class="row align-items-center">
@ -138,7 +138,7 @@
</div>
</div>
{% else %}
<div class="col-sm-4 col-lg-4">
<div class="{% if minimum_data == 'false' %}col-sm-4 col-lg-4{% else %}col-sm-6 col-lg-6{% endif %}">
<a class="card card-link" href="{{route('listDomains')}}">
<div class="card-body">
<div class="row align-items-center">
@ -154,7 +154,7 @@
</div>
</div>
</a>
</div>
</div>{% if minimum_data == 'false' %}
<div class="col-sm-4 col-lg-4">
<a class="card card-link" href="{{route('listContacts')}}">
<div class="card-body">
@ -171,8 +171,8 @@
</div>
</div>
</a>
</div>
<div class="col-sm-4 col-lg-4">
</div>{% endif %}
<div class="{% if minimum_data == 'false' %}col-sm-4 col-lg-4{% else %}col-sm-6 col-lg-6{% endif %}">
<a class="card card-link" href="{{route('listHosts')}}">
<div class="card-body">
<div class="row align-items-center">

View file

@ -62,14 +62,14 @@
</div>
{% endif %}
<!-- Fields for 4 contacts with roles -->
{% if minimum_data == 'false' %}<!-- Fields for 4 contacts with roles -->
<div class="mb-3">
<label for="contactRegistrant" class="form-label required">{{ __('Contacts') }}</label>
<input type="text" class="form-control mb-2" placeholder="{{ __('Registrant Contact') }}" name="contactRegistrant" id="contactRegistrant" required="required">
<input type="text" class="form-control mb-2" placeholder="{{ __('Admin Contact') }}" name="contactAdmin">
<input type="text" class="form-control mb-2" placeholder="{{ __('Tech Contact') }}" name="contactTech">
<input type="text" class="form-control mb-2" placeholder="{{ __('Billing Contact') }}" name="contactBilling">
</div>
</div>{% endif %}
<!-- Fields for nameservers -->
<div id="nameserverFields">

View file

@ -57,14 +57,14 @@
<strong>{{ __('Estimated Price') }}: </strong><span id="domainPrice">{{ currency }} 0.00</span>
</div>
<!-- Fields for 4 contacts with roles -->
{% if minimum_data == 'false' %}<!-- Fields for 4 contacts with roles -->
<div class="mb-3">
<label for="contactRegistrant" class="form-label required">{{ __('Contacts') }}</label>
<input type="text" class="form-control mb-2" placeholder="{{ __('Registrant Contact') }}" name="contactRegistrant" id="contactRegistrant" required="required">
<input type="text" class="form-control mb-2" placeholder="{{ __('Admin Contact') }}" name="contactAdmin">
<input type="text" class="form-control mb-2" placeholder="{{ __('Tech Contact') }}" name="contactTech">
<input type="text" class="form-control mb-2" placeholder="{{ __('Billing Contact') }}" name="contactBilling">
</div>
</div>{% endif %}
<!-- Fields for nameservers -->
<div id="nameserverFields">

View file

@ -77,7 +77,7 @@
<div class="row">
<!-- Fields for 4 contacts with roles -->
<div class="col-md-6">
<div class="mb-3">
{% if minimum_data == 'false' %}<div class="mb-3">
<label for="contactRegistrant" class="form-label required">{{ __('Registrant Contact') }}</label>
<input type="text" class="form-control mb-2" placeholder="{{ __('Registrant Contact') }}" name="contactRegistrant" id="contactRegistrant" value="{{ domainRegistrant.identifier }}" required>
@ -99,9 +99,9 @@
<input type="text" class="form-control mb-2" placeholder="{{ __('Admin Contact') }}" name="contactAdmin" id="contactAdmin" value="{{ contactAdmin }}" required>
<label for="contactTech" class="form-label required">{{ __('Tech Contact') }}</label>
<input type="text" class="form-control mb-2" placeholder="{{ __('Tech Contact') }}" name="contactTech" id="contactTech" value="{{ contactTech }}" required>
<label for="contactBilling" class="form-label required">{{ __('Billing Contact') }}</label>
<input type="text" class="form-control mb-2" placeholder="{{ __('Billing Contact') }}" name="contactBilling" id="contactBilling" value="{{ contactBilling }}" required>
</div>
<label for="contactBilling" class="form-label">{{ __('Billing Contact') }}</label>
<input type="text" class="form-control mb-2" placeholder="{{ __('Billing Contact') }}" name="contactBilling" id="contactBilling" value="{{ contactBilling }}">
</div>{% endif %}
<div class="hr-text">
<span>{{ __('Domain Security') }}</span>

View file

@ -64,7 +64,7 @@
<div class="datagrid-item">
<div class="datagrid-title">{{ __('Registrar') }}</div>
<div class="datagrid-content">{{ registrars.name }}</div>
</div>
</div>{% if minimum_data == 'false' %}
<div class="datagrid-item">
<div class="datagrid-title">{{ __('Registrant') }}</div>
<div class="datagrid-content">{{ domainRegistrant.identifier }}</div>
@ -74,7 +74,7 @@
<div class="datagrid-title">{{ contact.type }} {{ __('contact') }}</div>
<div class="datagrid-content">{{ contact.identifier }}</div>
</div>
{% endfor %}
{% endfor %}{% endif %}
<div class="datagrid-item">
<div class="datagrid-title">{{ __('Auth Type') }}</div>
<div class="datagrid-content">

View file

@ -63,7 +63,7 @@
<div class="datagrid-item">
<div class="datagrid-title">{{ __('Registrar') }}</div>
<div class="datagrid-content">{{ registrars.name }}</div>
</div>
</div>{% if minimum_data == 'false' %}
<div class="datagrid-item">
<div class="datagrid-title">{{ __('Registrant') }}</div>
<div class="datagrid-content">{{ domainRegistrant.identifier }}</div>
@ -73,7 +73,7 @@
<div class="datagrid-title">{{ contact.type }} {{ __('contact') }}</div>
<div class="datagrid-content">{{ contact.identifier }}</div>
</div>
{% endfor %}
{% endfor %}{% endif %}
<div class="datagrid-item">
<div class="datagrid-title">{{ __('Auth Type') }}</div>
<div class="datagrid-content">

View file

@ -114,7 +114,7 @@
{{ __('Request Transfer') }}
</a>
</div>
</li>
</li>{% if minimum_data == 'false' %}
<li {{ is_current_url('listContacts') or is_current_url('createContact') or 'contact' in currentUri ? 'class="nav-item dropdown active"' : 'class="nav-item dropdown"' }}>
<a class="nav-link dropdown-toggle" href="#" data-bs-toggle="dropdown" data-bs-auto-close="outside" role="button" aria-expanded="false">
<span class="nav-link-icon d-md-none d-lg-inline-block"><svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M20 6v12a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2z"></path><path d="M10 16h6"></path><path d="M13 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"></path><path d="M4 8h3"></path><path d="M4 12h3"></path><path d="M4 16h3"></path></svg>
@ -131,7 +131,7 @@
{{ __('Create Contact') }}
</a>
</div>
</li>
</li>{% endif %}
<li {{ is_current_url('listHosts') or is_current_url('createHost') or 'host' in currentUri ? 'class="nav-item dropdown active"' : 'class="nav-item dropdown"' }}>
<a class="nav-link dropdown-toggle" href="#" data-bs-toggle="dropdown" data-bs-auto-close="outside" role="button" aria-expanded="false">
<span class="nav-link-icon d-md-none d-lg-inline-block"><svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M12 9m-6 0a6 6 0 1 0 12 0a6 6 0 1 0 -12 0"></path><path d="M12 3c1.333 .333 2 2.333 2 6s-.667 5.667 -2 6"></path><path d="M12 3c-1.333 .333 -2 2.333 -2 6s.667 5.667 2 6"></path><path d="M6 9h12"></path><path d="M3 19h7"></path><path d="M14 19h7"></path><path d="M12 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"></path><path d="M12 15v2"></path></svg>