mirror of https://github.com/itflow-org/itflow
Added Bulk Archive, unarchive support to domains
This commit is contained in:
parent
64c5cbda52
commit
fb16ecd0c6
|
|
@ -21,7 +21,7 @@ $sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS domains.*,
|
|||
LEFT JOIN vendors AS mailhost ON domains.domain_mailhost = mailhost.vendor_id
|
||||
LEFT JOIN vendors AS webhost ON domains.domain_webhost = webhost.vendor_id
|
||||
WHERE domain_client_id = $client_id
|
||||
AND domain_archived_at IS NULL
|
||||
AND domain_$archive_query
|
||||
AND (domains.domain_name LIKE '%$q%' OR domains.domain_description LIKE '%$q%' OR registrar.vendor_name LIKE '%$q%' OR dnshost.vendor_name LIKE '%$q%' OR mailhost.vendor_name LIKE '%$q%' OR webhost.vendor_name LIKE '%$q%')
|
||||
ORDER BY $sort $order LIMIT $record_from, $record_to");
|
||||
|
||||
|
|
@ -60,15 +60,31 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
|
||||
<div class="col-md-8">
|
||||
<div class="btn-group float-right">
|
||||
<a href="?client_id=<?php echo $client_id; ?>&archived=<?php if($archived == 1){ echo 0; } else { echo 1; } ?>"
|
||||
class="btn btn-<?php if($archived == 1){ echo "primary"; } else { echo "default"; } ?>">
|
||||
<i class="fa fa-fw fa-archive mr-2"></i>Archived
|
||||
</a>
|
||||
<div class="dropdown ml-2" id="bulkActionButton" hidden>
|
||||
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">
|
||||
<i class="fas fa-fw fa-layer-group mr-2"></i>Bulk Action (<span id="selectedCount">0</span>)
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
<?php if ($archived) { ?>
|
||||
<button class="dropdown-item text-info"
|
||||
type="submit" form="bulkActions" name="bulk_unarchive_domains">
|
||||
<i class="fas fa-fw fa-redo mr-2"></i>Unarchive
|
||||
</button>
|
||||
<div class="dropdown-divider"></div>
|
||||
<button class="dropdown-item text-danger text-bold"
|
||||
type="submit" form="bulkActions" name="bulk_delete_domains">
|
||||
type="submit" form="bulkActions" name="bulk_delete_domains">
|
||||
<i class="fas fa-fw fa-trash mr-2"></i>Delete
|
||||
</button>
|
||||
<?php } else { ?>
|
||||
<button class="dropdown-item text-danger confirm-link"
|
||||
type="submit" form="bulkActions" name="bulk_archive_domains">
|
||||
<i class="fas fa-fw fa-archive mr-2"></i>Archive
|
||||
</button>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -118,6 +134,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
$domain_dnshost_name = nullable_htmlentities($row['dnshost_name']);
|
||||
$domain_mailhost_name = nullable_htmlentities($row['mailhost_name']);
|
||||
$domain_created_at = nullable_htmlentities($row['domain_created_at']);
|
||||
$domain_archived_at = nullable_htmlentities($row['domain_archived_at']);
|
||||
// Add - if empty on the table
|
||||
$domain_registrar_name_display = $domain_registrar_name ? $domain_registrar_name : "-";
|
||||
$domain_webhost_name_display = $domain_webhost_name ? $domain_webhost_name : "-";
|
||||
|
|
@ -156,17 +173,24 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
<a class="dropdown-item" href="#" data-toggle="modal" onclick="populateDomainEditModal(<?php echo $client_id, ",", $domain_id ?>)" data-target="#editDomainModal">
|
||||
<i class="fas fa-fw fa-edit mr-2"></i>Edit
|
||||
</a>
|
||||
<?php if ($session_user_role > 1) { ?>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_domain=<?php echo $domain_id; ?>">
|
||||
<i class="fas fa-fw fa-archive mr-2"></i>Archive
|
||||
</a>
|
||||
<?php } ?>
|
||||
<?php if ($session_user_role == 3) { ?>
|
||||
<?php if ($domain_archived_at) { ?>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item text-info confirm-link" href="post.php?unarchive_domain=<?php echo $domain_id; ?>">
|
||||
<i class="fas fa-fw fa-redo mr-2"></i>Unarchive
|
||||
</a>
|
||||
<?php if ($config_destructive_deletes_enable) { ?>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item text-danger text-bold confirm-link" href="post.php?delete_domain=<?php echo $domain_id; ?>">
|
||||
<i class="fas fa-fw fa-trash mr-2"></i>Delete
|
||||
</a>
|
||||
<?php } ?>
|
||||
<?php } else { ?>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_domain=<?php echo $domain_id; ?>">
|
||||
<i class="fas fa-fw fa-archive mr-2"></i>Archive
|
||||
</a>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
119
post/domain.php
119
post/domain.php
|
|
@ -119,6 +119,46 @@ if (isset($_POST['edit_domain'])) {
|
|||
|
||||
}
|
||||
|
||||
if (isset($_GET['archive_domain'])) {
|
||||
$domain_id = intval($_GET['archive_domain']);
|
||||
|
||||
//Get domain Name
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM domains WHERE domain_id = $domain_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$domain_name = sanitizeInput($row['domain_name']);
|
||||
$client_id = intval($row['domain_client_id']);
|
||||
|
||||
mysqli_query($mysqli,"UPDATE domains SET domain_archived_at = NOW() WHERE domain_id = $domain_id");
|
||||
|
||||
//Logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Domain', log_action = 'Archive', log_description = '$session_name archived domain $domain_name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id");
|
||||
|
||||
$_SESSION['alert_type'] = "error";
|
||||
$_SESSION['alert_message'] = "Domain <strong>$domain_name archived";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
}
|
||||
|
||||
if(isset($_GET['unarchive_domain'])){
|
||||
|
||||
$domain_id = intval($_GET['unarchive_domain']);
|
||||
|
||||
// Get Name and Client ID for logging and alert message
|
||||
$sql = mysqli_query($mysqli,"SELECT domain_name, domain_client_id FROM domains WHERE domain_id = $domain_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$domain_name = sanitizeInput($row['domain_name']);
|
||||
$client_id = intval($row['domain_client_id']);
|
||||
|
||||
mysqli_query($mysqli,"UPDATE domains SET domain_archived_at = NULL WHERE domain_id = $domain_id");
|
||||
|
||||
//Logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'domain', log_action = 'Unarchive', log_description = '$session_name restored domain $domain_name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $domain_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Domain <strong>$domain_name</strong> restored";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
}
|
||||
|
||||
if (isset($_GET['delete_domain'])) {
|
||||
|
||||
validateAdminRole();
|
||||
|
|
@ -143,6 +183,83 @@ if (isset($_GET['delete_domain'])) {
|
|||
|
||||
}
|
||||
|
||||
if (isset($_POST['bulk_archive_domains'])) {
|
||||
validateAdminRole();
|
||||
validateCSRFToken($_POST['csrf_token']);
|
||||
|
||||
$count = 0; // Default 0
|
||||
$domain_ids = $_POST['domain_ids']; // Get array of IDs to be deleted
|
||||
|
||||
if (!empty($domain_ids)) {
|
||||
|
||||
// Cycle through array and archive each record
|
||||
foreach ($domain_ids as $domain_id) {
|
||||
|
||||
$domain_id = intval($domain_id);
|
||||
|
||||
// Get Name and Client ID for logging and alert message
|
||||
$sql = mysqli_query($mysqli,"SELECT domain_name, domain_client_id FROM domains WHERE domain_id = $domain_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$domain_name = sanitizeInput($row['domain_name']);
|
||||
$client_id = intval($row['domain_client_id']);
|
||||
|
||||
mysqli_query($mysqli,"UPDATE domains SET domain_archived_at = NOW() WHERE domain_id = $domain_id");
|
||||
|
||||
// Individual Contact logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Domain', log_action = 'Archive', log_description = '$session_name archived domain $domain_name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $domain_id");
|
||||
$count++;
|
||||
}
|
||||
|
||||
// Bulk Logging
|
||||
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Domain', log_action = 'Archive', log_description = '$session_name archived $count domains', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id");
|
||||
|
||||
$_SESSION['alert_type'] = "error";
|
||||
$_SESSION['alert_message'] = "Archived $count domain(s)";
|
||||
|
||||
}
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
}
|
||||
|
||||
if (isset($_POST['bulk_unarchive_domains'])) {
|
||||
validateAdminRole();
|
||||
validateCSRFToken($_POST['csrf_token']);
|
||||
|
||||
$count = 0; // Default 0
|
||||
$domain_ids = $_POST['domain_ids']; // Get array of IDs
|
||||
|
||||
if (!empty($domain_ids)) {
|
||||
|
||||
// Cycle through array and unarchive
|
||||
foreach ($domain_ids as $domain_id) {
|
||||
|
||||
$domain_id = intval($domain_id);
|
||||
|
||||
// Get Name and Client ID for logging and alert message
|
||||
$sql = mysqli_query($mysqli,"SELECT domain_name, domain_client_id FROM domains WHERE domain_id = $domain_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$domain_name = sanitizeInput($row['domain_name']);
|
||||
$client_id = intval($row['domain_client_id']);
|
||||
|
||||
mysqli_query($mysqli,"UPDATE domains SET domain_archived_at = NULL WHERE domain_id = $domain_id");
|
||||
|
||||
// Individual logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Domain', log_action = 'Unarchive', log_description = '$session_name Unarchived domain $domains_name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $domain_id");
|
||||
|
||||
|
||||
$count++;
|
||||
}
|
||||
|
||||
// Bulk Logging
|
||||
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Domain', log_action = 'Unarchive', log_description = '$session_name Unarchived $count domains', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Unarchived $count domain(s)";
|
||||
|
||||
}
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
}
|
||||
|
||||
if (isset($_POST['bulk_delete_domains'])) {
|
||||
validateAdminRole();
|
||||
validateCSRFToken($_POST['csrf_token']);
|
||||
|
|
@ -166,7 +283,7 @@ if (isset($_POST['bulk_delete_domains'])) {
|
|||
// Logging
|
||||
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Domain', log_action = 'Delete', log_description = '$session_name bulk deleted $count domains', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Deleted $count certificate(s)";
|
||||
$_SESSION['alert_message'] = "Deleted $count domain(s)";
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue