diff --git a/cp/app/Controllers/ContactsController.php b/cp/app/Controllers/ContactsController.php index 6ab40e0..32eb6b5 100644 --- a/cp/app/Controllers/ContactsController.php +++ b/cp/app/Controllers/ContactsController.php @@ -521,4 +521,61 @@ class ContactsController extends Controller 'registrar' => $registrar, ]); } + + public function viewContact(Request $request, Response $response, $args) + { + $db = $this->container->get('db'); + // Get the current URI + $uri = $request->getUri()->getPath(); + + if ($args) { + $contact = $db->selectRow('SELECT id, identifier, voice, fax, email, nin, nin_type, crdate, clid, disclose_voice, disclose_fax, disclose_email FROM contact WHERE identifier = ?', + [ $args ]); + + if ($contact) { + $registrars = $db->selectRow('SELECT id, clid, name FROM registrar WHERE id = ?', [$contact['clid']]); + + // Check if the user is not an admin (assuming role 0 is admin) + if ($_SESSION["auth_roles"] != 0) { + $userRegistrars = $db->select('SELECT registrar_id FROM registrar_users WHERE user_id = ?', [$_SESSION['auth_user_id']]); + + // Assuming $userRegistrars returns an array of arrays, each containing 'registrar_id' + $userRegistrarIds = array_column($userRegistrars, 'registrar_id'); + + // Check if the registrar's ID is in the user's list of registrar IDs + if (!in_array($registrars['id'], $userRegistrarIds)) { + // Redirect to the contacts view if the user is not authorized for this contact + return $response->withHeader('Location', '/contacts')->withStatus(302); + } + } + + $contactStatus = $db->selectRow('SELECT status FROM contact_status WHERE contact_id = ?', + [ $contact['id'] ]); + $contactAuth = $db->selectRow('SELECT authinfo FROM contact_authInfo WHERE contact_id = ?', + [ $contact['id'] ]); + $contactLinked = $db->selectRow('SELECT domain_id, type FROM domain_contact_map WHERE contact_id = ?', + [ $contact['id'] ]); + $contactPostal = $db->select('SELECT * FROM contact_postalInfo WHERE contact_id = ?', + [ $contact['id'] ]); + + return view($response,'admin/contacts/viewContact.twig', [ + 'contact' => $contact, + 'contactStatus' => $contactStatus, + 'contactLinked' => $contactLinked, + 'contactAuth' => $contactAuth, + 'contactPostal' => $contactPostal, + 'registrars' => $registrars, + 'currentUri' => $uri + ]); + } else { + // Contact does not exist, redirect to the contacts view + return $response->withHeader('Location', '/contacts')->withStatus(302); + } + + } else { + // Redirect to the contacts view + return $response->withHeader('Location', '/contacts')->withStatus(302); + } + + } } \ No newline at end of file diff --git a/cp/resources/views/admin/contacts/viewContact.twig b/cp/resources/views/admin/contacts/viewContact.twig new file mode 100644 index 0000000..84beeec --- /dev/null +++ b/cp/resources/views/admin/contacts/viewContact.twig @@ -0,0 +1,246 @@ +{% extends "layouts/app.twig" %} + +{% block title %}{{ __('Contact Details') }}{% endblock %} + +{% block content %} +
+ + + +
+
+
+
+
+

Contact {{ contact.identifier }} {{ contactStatus.status }}{% if contactLinked is not null %} linked{% endif %}

+
+
+
+
+
Email
+
{{ contact.email }} {% if contact.disclose_email == '1' %}Visible in Public{% else %}Hidden from Public{% endif %}
+
+
+
Phone
+
{{ contact.voice }} {% if contact.disclose_voice == '1' %}Visible in Public{% else %}Hidden from Public{% endif %}
+
+
+
Creation Date
+
{{ contact.crdate }}
+
+
+
Registrar
+
{{ registrars.name }}
+
+
+
+
+
+
+ +
+
+
+ {% if contactPostal is not empty %} + {% set intExists = false %} + {% set locExists = false %} + {% for postal in contactPostal %} + {% if postal.type == 'int' %} + {% set intExists = true %} +
+

International Contact Details

+
+
+
Name
+
{{ postal.name }} {% if postal.disclose_name_int == '1' %} + Visible in Public + {% else %} + Hidden from Public + {% endif %}
+
+
+
Organization
+
{{ postal.org }} {% if postal.disclose_org_int == '1' %} + Visible in Public + {% else %} + Hidden from Public + {% endif %}
+
+
+
Street 1
+
{{ postal.street1 }} {% if postal.disclose_addr_int == '1' %} + Visible in Public + {% else %} + Hidden from Public + {% endif %}
+
+
+
Street 2
+
{{ postal.street1 }} {% if postal.disclose_addr_int == '1' %} + Visible in Public + {% else %} + Hidden from Public + {% endif %}
+
+
+
City
+
{{ postal.city }} {% if postal.disclose_addr_int == '1' %} + Visible in Public + {% else %} + Hidden from Public + {% endif %}
+
+
+
State/Province
+
{{ postal.sp }} {% if postal.disclose_addr_int == '1' %} + Visible in Public + {% else %} + Hidden from Public + {% endif %}
+
+
+
Postal Code
+
{{ postal.pc }} {% if postal.disclose_addr_int == '1' %} + Visible in Public + {% else %} + Hidden from Public + {% endif %}
+
+
+
Country
+
{{ postal.cc }} {% if postal.disclose_addr_int == '1' %} + Visible in Public + {% else %} + Hidden from Public + {% endif %}
+
+
+
+ {% elseif postal.type == 'loc' %} + {% set locExists = true %} + {% endif %} + {% endfor %} + + {% if locExists %} + {% for postal in contactPostal %} + {% if postal.type == 'loc' %} +
+

Localized Contact Details

+
+
+
Name
+
{{ postal.name }} {% if postal.disclose_name_loc == '1' %} + Visible in Public + {% else %} + Hidden from Public + {% endif %}
+
+
+
Organization
+
{{ postal.org }} {% if postal.disclose_org_loc == '1' %} + Visible in Public + {% else %} + Hidden from Public + {% endif %}
+
+
+
Street 1
+
{{ postal.street1 }} {% if postal.disclose_addr_loc == '1' %} + Visible in Public + {% else %} + Hidden from Public + {% endif %}
+
+
+
Street 2
+
{{ postal.street1 }} {% if postal.disclose_addr_loc == '1' %} + Visible in Public + {% else %} + Hidden from Public + {% endif %}
+
+
+
City
+
{{ postal.city }} {% if postal.disclose_addr_loc == '1' %} + Visible in Public + {% else %} + Hidden from Public + {% endif %}
+
+
+
State/Province
+
{{ postal.sp }} {% if postal.disclose_addr_loc == '1' %} + Visible in Public + {% else %} + Hidden from Public + {% endif %}
+
+
+
Postal Code
+
{{ postal.pc }} {% if postal.disclose_addr_loc == '1' %} + Visible in Public + {% else %} + Hidden from Public + {% endif %}
+
+
+
Country
+
{{ postal.cc }} {% if postal.disclose_addr_loc == '1' %} + Visible in Public + {% else %} + Hidden from Public + {% endif %}
+
+
+
+ {% endif %} + {% endfor %} + {% else %} +
+

Localized Contact Details

+
No Localized Contact Information Available
+
+ {% endif %} + {% endif %} +
+
+
+
+
+
+
+ + +{% endblock %} \ No newline at end of file diff --git a/cp/resources/views/layouts/app.twig b/cp/resources/views/layouts/app.twig index 3d75500..25fe7fe 100644 --- a/cp/resources/views/layouts/app.twig +++ b/cp/resources/views/layouts/app.twig @@ -114,7 +114,7 @@ -
  • +