mirror of
https://github.com/getnamingo/registry.git
synced 2025-07-23 11:05:57 +02:00
Notification system improvement
Also only registry can now approve and reject applications
This commit is contained in:
parent
edc2bdab04
commit
f942607363
5 changed files with 105 additions and 19 deletions
|
@ -467,8 +467,8 @@ class ApplicationsController extends Controller
|
|||
'error_log',
|
||||
[
|
||||
'channel' => 'control_panel',
|
||||
'level' => 3,
|
||||
'level_name' => 'warning',
|
||||
'level' => 300,
|
||||
'level_name' => 'WARNING',
|
||||
'message' => "Application: $domainName; hostName: $nameserver - is duplicated",
|
||||
'context' => json_encode([
|
||||
'registrar_id' => $clid,
|
||||
|
@ -588,7 +588,26 @@ class ApplicationsController extends Controller
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$db->insert('error_log', [
|
||||
'channel' => 'applications',
|
||||
'level' => 250,
|
||||
'level_name' => 'NOTICE',
|
||||
'message' => "User {$_SESSION['auth_user_id']} from registrar {$clid} created a domain application: {$domainName}",
|
||||
'context' => json_encode([
|
||||
'domain_name' => $domainName,
|
||||
'user_id' => $_SESSION['auth_user_id'],
|
||||
'registrar' => $clid,
|
||||
'status' => 'pending'
|
||||
]),
|
||||
'extra' => json_encode([
|
||||
'received_on' => date('Y-m-d H:i:s'),
|
||||
'read_on' => null,
|
||||
'is_read' => false,
|
||||
'message_type' => 'application_creation'
|
||||
])
|
||||
]);
|
||||
|
||||
$db->commit();
|
||||
} catch (Exception $e) {
|
||||
$db->rollBack();
|
||||
|
@ -1034,9 +1053,14 @@ class ApplicationsController extends Controller
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function approveApplication(Request $request, Response $response, $args)
|
||||
{
|
||||
if ($_SESSION["auth_roles"] != 0) {
|
||||
$this->container->get('flash')->addMessage('error', 'Only registry administrators can perform this action.');
|
||||
return $response->withHeader('Location', '/applications')->withStatus(302);
|
||||
}
|
||||
|
||||
// if ($request->getMethod() === 'POST') {
|
||||
$db = $this->container->get('db');
|
||||
// Get the current URI
|
||||
|
@ -1248,7 +1272,26 @@ class ApplicationsController extends Controller
|
|||
"SELECT crdate FROM domain WHERE id = ? LIMIT 1",
|
||||
[$domain_id]
|
||||
);
|
||||
|
||||
|
||||
$db->insert('error_log', [
|
||||
'channel' => 'applications',
|
||||
'level' => 250,
|
||||
'level_name' => 'NOTICE',
|
||||
'message' => "User {$_SESSION['auth_user_id']} from registrar {$clid} approved the domain application: {$domainName}",
|
||||
'context' => json_encode([
|
||||
'domain_name' => $domainName,
|
||||
'user_id' => $_SESSION['auth_user_id'],
|
||||
'registrar' => $clid,
|
||||
'status' => 'approved'
|
||||
]),
|
||||
'extra' => json_encode([
|
||||
'received_on' => date('Y-m-d H:i:s'),
|
||||
'read_on' => null,
|
||||
'is_read' => false,
|
||||
'message_type' => 'application_approval'
|
||||
])
|
||||
]);
|
||||
|
||||
$this->container->get('flash')->addMessage('success', 'Domain ' . $domainName . ' has been created successfully on ' . $crdate);
|
||||
return $response->withHeader('Location', '/domains')->withStatus(302);
|
||||
} catch (Exception $e) {
|
||||
|
@ -1271,6 +1314,11 @@ class ApplicationsController extends Controller
|
|||
|
||||
public function rejectApplication(Request $request, Response $response, $args)
|
||||
{
|
||||
if ($_SESSION["auth_roles"] != 0) {
|
||||
$this->container->get('flash')->addMessage('error', 'Only registry administrators can perform this action.');
|
||||
return $response->withHeader('Location', '/applications')->withStatus(302);
|
||||
}
|
||||
|
||||
// if ($request->getMethod() === 'POST') {
|
||||
$db = $this->container->get('db');
|
||||
// Get the current URI
|
||||
|
@ -1322,7 +1370,26 @@ class ApplicationsController extends Controller
|
|||
'domain_id' => $domain_id
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
$db->insert('error_log', [
|
||||
'channel' => 'applications',
|
||||
'level' => 250,
|
||||
'level_name' => 'NOTICE',
|
||||
'message' => "User {$_SESSION['auth_user_id']} from registrar {$clid} rejected the domain application: {$domainName}",
|
||||
'context' => json_encode([
|
||||
'domain_name' => $domainName,
|
||||
'user_id' => $_SESSION['auth_user_id'],
|
||||
'registrar' => $clid,
|
||||
'status' => 'rejected'
|
||||
]),
|
||||
'extra' => json_encode([
|
||||
'received_on' => date('Y-m-d H:i:s'),
|
||||
'read_on' => null,
|
||||
'is_read' => false,
|
||||
'message_type' => 'application_rejection'
|
||||
])
|
||||
]);
|
||||
|
||||
$db->commit();
|
||||
} catch (Exception $e) {
|
||||
$db->rollBack();
|
||||
|
@ -1417,7 +1484,26 @@ class ApplicationsController extends Controller
|
|||
'id' => $domain_id
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
$db->insert('error_log', [
|
||||
'channel' => 'applications',
|
||||
'level' => 250, // NOTICE level
|
||||
'level_name' => 'NOTICE',
|
||||
'message' => "User {$_SESSION['auth_user_id']} from registrar {$clid} deleted the domain application: {$domainName}",
|
||||
'context' => json_encode([
|
||||
'domain_name' => $domainName,
|
||||
'user_id' => $_SESSION['auth_user_id'],
|
||||
'registrar' => $clid,
|
||||
'status' => 'deleted'
|
||||
]),
|
||||
'extra' => json_encode([
|
||||
'received_on' => date('Y-m-d H:i:s'),
|
||||
'read_on' => null,
|
||||
'is_read' => false,
|
||||
'message_type' => 'application_deletion'
|
||||
])
|
||||
]);
|
||||
|
||||
$db->commit();
|
||||
} catch (Exception $e) {
|
||||
$db->rollBack();
|
||||
|
|
|
@ -749,8 +749,8 @@ class DomainsController extends Controller
|
|||
'error_log',
|
||||
[
|
||||
'channel' => 'control_panel',
|
||||
'level' => 3,
|
||||
'level_name' => 'warning',
|
||||
'level' => 300,
|
||||
'level_name' => 'WARNING',
|
||||
'message' => "Domain: $domainName; hostName: $nameserver - is duplicated",
|
||||
'context' => json_encode([
|
||||
'registrar_id' => $clid,
|
||||
|
@ -3129,7 +3129,7 @@ class DomainsController extends Controller
|
|||
$db->exec(
|
||||
'INSERT INTO error_log (channel, level, level_name, message, context, extra) VALUES (?, ?, ?, ?, ?, ?)',
|
||||
[
|
||||
'manual_transfer_reject',
|
||||
'manual_transfer',
|
||||
250, // NOTICE level
|
||||
'NOTICE',
|
||||
"Manual domain transfer rejected: $domainName (Losing Registrar: $clid)",
|
||||
|
@ -3239,7 +3239,7 @@ class DomainsController extends Controller
|
|||
$db->exec(
|
||||
'INSERT INTO error_log (channel, level, level_name, message, context, extra) VALUES (?, ?, ?, ?, ?, ?)',
|
||||
[
|
||||
'manual_transfer_cancel',
|
||||
'manual_transfer',
|
||||
250, // NOTICE level
|
||||
'NOTICE',
|
||||
"Manual domain transfer canceled: $domainName (Applicant: $clid)",
|
||||
|
|
|
@ -1367,7 +1367,7 @@ function processDomainCreate($conn, $db, $xml, $clid, $database_type, $trans, $m
|
|||
} else {
|
||||
$errorLogStmt = $db->prepare("INSERT INTO error_log
|
||||
(channel, level, level_name, message, context, extra, created_at)
|
||||
VALUES ('epp', 3, 'warning', :log, :context, '{}', CURRENT_TIMESTAMP)");
|
||||
VALUES ('epp', 300, 'WARNING', :log, :context, '{}', CURRENT_TIMESTAMP)");
|
||||
$errorLogStmt->execute([
|
||||
':log' => "Domain: $domainName; hostObj: $hostObj - is duplicated",
|
||||
':context' => json_encode(['registrar_id' => $clid, 'domain' => $domainName, 'host' => $hostObj])
|
||||
|
@ -1437,7 +1437,7 @@ function processDomainCreate($conn, $db, $xml, $clid, $database_type, $trans, $m
|
|||
// Log duplicate mapping error
|
||||
$stmt = $db->prepare("INSERT INTO error_log
|
||||
(channel, level, level_name, message, context, extra, created_at)
|
||||
VALUES ('epp', 3, 'warning', ?, ?, '{}', CURRENT_TIMESTAMP)");
|
||||
VALUES ('epp', 300, 'WARNING', ?, ?, '{}', CURRENT_TIMESTAMP)");
|
||||
$stmt->execute([
|
||||
"Domain: $domainName; hostName: $hostName - duplicate mapping",
|
||||
json_encode(['registrar_id' => $clid, 'domain' => $domainName, 'host' => $hostName])
|
||||
|
@ -1736,7 +1736,7 @@ function processDomainCreate($conn, $db, $xml, $clid, $database_type, $trans, $m
|
|||
} else {
|
||||
$errorLogStmt = $db->prepare("INSERT INTO error_log
|
||||
(channel, level, level_name, message, context, extra, created_at)
|
||||
VALUES ('epp', 3, 'warning', :log, :context, '{}', CURRENT_TIMESTAMP)");
|
||||
VALUES ('epp', 300, 'WARNING', :log, :context, '{}', CURRENT_TIMESTAMP)");
|
||||
$errorLogStmt->execute([
|
||||
':log' => "Domain: $domainName; hostObj: $hostObj - is duplicated",
|
||||
':context' => json_encode(['registrar_id' => $clid, 'domain' => $domainName, 'host' => $hostObj])
|
||||
|
@ -1806,7 +1806,7 @@ function processDomainCreate($conn, $db, $xml, $clid, $database_type, $trans, $m
|
|||
// Log duplicate mapping error
|
||||
$stmt = $db->prepare("INSERT INTO error_log
|
||||
(channel, level, level_name, message, context, extra, created_at)
|
||||
VALUES ('epp', 3, 'warning', ?, ?, '{}', CURRENT_TIMESTAMP)");
|
||||
VALUES ('epp', 300, 'WARNING', ?, ?, '{}', CURRENT_TIMESTAMP)");
|
||||
$stmt->execute([
|
||||
"Domain: $domainName; hostName: $hostName - duplicate mapping",
|
||||
json_encode(['registrar_id' => $clid, 'domain' => $domainName, 'host' => $hostName])
|
||||
|
|
|
@ -578,7 +578,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
|
|||
|
||||
$stmt_log = $db->prepare("INSERT INTO error_log (channel, level, level_name, message, context, extra) VALUES (?, ?, ?, ?, ?, ?)");
|
||||
$stmt_log->execute([
|
||||
'domain_transfer',
|
||||
'manual_transfer',
|
||||
250,
|
||||
'NOTICE',
|
||||
"Domain transfer manually approved: $domainName (New registrant: $newRegistrantId, Registrar: $reid)",
|
||||
|
@ -730,7 +730,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
|
|||
|
||||
$stmt_log = $db->prepare("INSERT INTO error_log (channel, level, level_name, message, context, extra) VALUES (?, ?, ?, ?, ?, ?)");
|
||||
$stmt_log->execute([
|
||||
'domain_transfer',
|
||||
'manual_transfer',
|
||||
250,
|
||||
'NOTICE',
|
||||
"Domain transfer manually canceled: $domainName (Registrar: $reid)",
|
||||
|
@ -879,7 +879,7 @@ function processDomainTransfer($conn, $db, $xml, $clid, $database_type, $trans)
|
|||
|
||||
$stmt_log = $db->prepare("INSERT INTO error_log (channel, level, level_name, message, context, extra) VALUES (?, ?, ?, ?, ?, ?)");
|
||||
$stmt_log->execute([
|
||||
'domain_transfer',
|
||||
'manual_transfer',
|
||||
250,
|
||||
'NOTICE',
|
||||
"Domain transfer manually rejected: $domainName (Registrar: $reid)",
|
||||
|
|
|
@ -1537,7 +1537,7 @@ function processDomainUpdate($conn, $db, $xml, $clid, $database_type, $trans) {
|
|||
]);
|
||||
$stmt = $db->prepare("INSERT INTO error_log
|
||||
(channel, level, level_name, message, context, extra, created_at)
|
||||
VALUES ('epp', 3, 'warning', ?, ?, '{}', CURRENT_TIMESTAMP)");
|
||||
VALUES ('epp', 300, 'WARNING', ?, ?, '{}', CURRENT_TIMESTAMP)");
|
||||
$stmt->execute([$logMessage, $contextData]);
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue