mirror of https://github.com/itflow-org/itflow
Merge pull request #956 from ssteeltm/notification-updates
Display notification when update is available
This commit is contained in:
commit
b2d529e783
|
|
@ -3,19 +3,12 @@ require_once "inc_all_admin.php";
|
||||||
|
|
||||||
require_once "database_version.php";
|
require_once "database_version.php";
|
||||||
|
|
||||||
require_once "config.php";
|
|
||||||
|
|
||||||
|
$updates = fetchUpdates();
|
||||||
|
|
||||||
// Fetch the latest code changes but don't apply them
|
$latest_version = $updates->latest_version;
|
||||||
exec("git fetch", $output, $result);
|
$current_version = $updates->current_version;
|
||||||
$latest_version = exec("git rev-parse origin/$repo_branch");
|
$result = $updates->result;
|
||||||
$current_version = exec("git rev-parse HEAD");
|
|
||||||
|
|
||||||
if ($current_version == $latest_version) {
|
|
||||||
$update_message = "No Updates available";
|
|
||||||
} else {
|
|
||||||
$update_message = "New Updates are Available [$latest_version]";
|
|
||||||
}
|
|
||||||
|
|
||||||
$git_log = shell_exec("git log $repo_branch..origin/$repo_branch --pretty=format:'<tr><td>%h</td><td>%ar</td><td>%s</td></tr>'");
|
$git_log = shell_exec("git log $repo_branch..origin/$repo_branch --pretty=format:'<tr><td>%h</td><td>%ar</td><td>%s</td></tr>'");
|
||||||
|
|
||||||
|
|
|
||||||
13
cron.php
13
cron.php
|
|
@ -979,6 +979,19 @@ if ($config_telemetry > 0 OR $config_telemetry = 2) {
|
||||||
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Cron', log_action = 'Telemetry', log_description = 'Cron sent telemetry results to ITFlow Developers'");
|
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Cron', log_action = 'Telemetry', log_description = 'Cron sent telemetry results to ITFlow Developers'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Fetch Updates
|
||||||
|
$updates = fetchUpdates();
|
||||||
|
|
||||||
|
$update_message = $updates->update_message;
|
||||||
|
|
||||||
|
if ($updates->current_version !== $updates->latest_version) {
|
||||||
|
// Send Alert to inform Updates Available
|
||||||
|
mysqli_query($mysqli, "INSERT INTO notifications SET notification_type = 'Update', notification = '$update_message', notification_action = 'admin_update.php'");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ###############################################################################################################
|
* ###############################################################################################################
|
||||||
* FINISH UP
|
* FINISH UP
|
||||||
|
|
|
||||||
|
|
@ -1186,3 +1186,34 @@ function getTicketStatusName($ticket_status) {
|
||||||
return "Unknown";
|
return "Unknown";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function fetchUpdates() {
|
||||||
|
|
||||||
|
global $repo_branch;
|
||||||
|
|
||||||
|
// Fetch the latest code changes but don't apply them
|
||||||
|
exec("git fetch", $output, $result);
|
||||||
|
$latest_version = exec("git rev-parse origin/$repo_branch");
|
||||||
|
$current_version = exec("git rev-parse HEAD");
|
||||||
|
|
||||||
|
if ($current_version == $latest_version) {
|
||||||
|
$update_message = "No Updates available";
|
||||||
|
} else {
|
||||||
|
$update_message = "New Updates are Available [$latest_version]";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$updates = new stdClass();
|
||||||
|
$updates->output = $output;
|
||||||
|
$updates->result = $result;
|
||||||
|
$updates->current_version = $current_version;
|
||||||
|
$updates->latest_version = $latest_version;
|
||||||
|
$updates->update_message = $update_message;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return $updates;
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue