Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# CHANGELOG

## v8.7

* Added automatic update check within the Settings page allowing to see the changelogs and a link to the new Release.
* Updated `README.md`

## v8.6

* Telemetry statistics page for environments using the Telemetry Server. Please check `README.md`

## v8.5.1

* Fixed undefined variable warning message <!-- [#133](https://github.com/Ente/timetrack/issues/133) -->
* Changed app.json.sample default values
* Changed `app.json.sample` default values
* Updated README.md <!-- [#134](https://github.com/Ente/timetrack/issues/134) -->
* Added `update.sh` script
* Internal plugin views can now be hidden
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ A demo is available here: [https://tt-demo.openducks.org](https://tt-demo.opendu
You can quickly get started with TimeTrack using Docker. Follow these steps:

* Ensure you have Docker and Docker Compose installed on your system.
* Clone the TimeTrack repository: `git clone https://github.com/Ente/timetrack.git` & `cd timetrack`
* Clone the TimeTrack repository: `git clone https://github.com/Ente/timetrack.git` & `cd timetrack` - **The develop branch should not be used unless you know what you are doing. Download the latest release [https://github.com/ente/timetrack/releases/latest](here)**
* Build the Docker image: `docker build -t openducks/timetrack .`
* Create a `app.json` configuration file based on the provided sample below: `cp api/v1/inc/app.json.sample api/v1/inc/app.json` and edit it to fit your needs.
* Adjust the database settings if needed (at least `db_password`)
Expand Down Expand Up @@ -56,7 +56,7 @@ This software has been tested on Debian 11/12, XAMPP, PHP internal server (e.g.
Simply install the software by following these steps:

- Install php and requirements: `sudo apt update && sudo apt install php8.2 php8.2-curl php8.2-gd php8.2-gmp php8.2-intl php8.2-mbstring php8.2-mysqli php8.2-pgsql php8.2-xsl php8.2-gettext php8.2-dom php8.2-ldap composer git mariadb-server apache2 -y` and enable the apache rewrite mod `a2enmod rewrite && service apache2 restart`. If you do not want to use apache2 you can skip this step.
- Git clone timetrack to e.g. `/var/www`: `cd /var/www && git clone https://github.com/Ente/timetrack.git && cd timetrack`
- Git clone timetrack to e.g. `/var/www`: `cd /var/www && git clone https://github.com/Ente/timetrack.git && cd timetrack` - **The develop branch should not be used unless you know what you are doing. Download the latest release [https://github.com/ente/timetrack/releases/latest](here)**
- Install requirements for composer `composer install`
- Create a new database, e.g. with the name `ab` and create a dedicated user, login (`mysql -u root -p`) then e.g. `timetool`: `CREATE DATABASE ab;` and `CREATE USER 'timetool'@'localhost' IDENTIFIED BY 'yourpassword';` and `GRANT ALL PRIVILEGES ON ab.* TO 'timetool'@'localhost';` don't forget to `FLUSH PRIVILEGES;`!
- Configure `app.json` (see below - required changes: `base_url`, `db_user`, `db_password`, `smtp` section and any other if your installation is different) then `mv api/v1/inc/app.json.sample app.json && cd /var/www/timetrack`
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.6
8.7
95 changes: 90 additions & 5 deletions api/v1/class/arbeitszeit.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,7 @@ public function renderUserWorktimeSelect(
?int $selectedWorktime = null,
string $placeholder = "—",
string $class = ""
): void
{
): void {
$userId = $this->benutzer()->get_user_from_id($userId)["username"];
$sql = "SELECT * FROM arbeitszeiten WHERE username = ?";
$stmt = $this->db->sendQuery($sql);
Expand All @@ -247,9 +246,9 @@ public function renderUserWorktimeSelect(
echo '<option value="' . $wt["id"] . '"' . $sel . '>'
. htmlspecialchars($label)
. '</option>';
}
}

echo '</select>';
echo '</select>';
}


Expand Down Expand Up @@ -404,7 +403,7 @@ public function add_worktime($start, $end, $location, $date, $username, $type, $

public function update_worktime($id, $array)
{
if(!$this->check_if_for_review($id)){
if (!$this->check_if_for_review($id)) {
return false;
}
$allowed = [
Expand Down Expand Up @@ -839,6 +838,92 @@ public function blockIfNotAdmin()
return false;
}

public function checkForUpdate()
{
$currentVersion = $this->getTimeTrackVersion();
$latestVersion = file_get_contents("https://raw.githubusercontent.com/Ente/timetrack/refs/heads/develop/VERSION");

$currentVersion = trim($currentVersion);
$latestVersion = trim($latestVersion);

if (version_compare($currentVersion, $latestVersion, '<')) {
return $latestVersion;
} else {
return false;
}
}

public function getChanges(string $version_tag = "latest")
{
if ($version_tag !== "latest") {
$url = "https://api.github.com/repos/ente/timetrack/releases/tags/v{$version_tag}";
} else {
$url = "https://api.github.com/repos/ente/timetrack/releases/latest";
}

$context = stream_context_create([
"http" => [
"method" => "GET",
"header" => [
"User-Agent: TimeTrack-Updater",
"Accept: application/vnd.github+json"
],
"timeout" => 10
]
]);

$json = @file_get_contents($url, false, $context);

if ($json === false) {
return null;
#throw new \RuntimeException("GitHub API request failed");
}

return json_decode($json, true);
}


public function renderGUIUpdateCheck()
{

$text = "";
$current = $this->getTimeTrackVersion();
$latest = $this->checkForUpdate();


if ($this->checkForUpdate() != false) {
$latestChanges = $this->getChanges($latest) ?? "NULL";
$fullChangelogUrl = "https://github.com/ente/timetrack/compare/v{$current}...v{$latest}";
$latestVersionLink = "https://github.com/ente/timetrack/releases/tag/v{$latest}";
$text .= "<div class='card v8-bordered log-box'>";
$text .= "<h2>Update available!</h2><br>";
$text .= "You are currently using TimeTrack version <strong>{$current}</strong>, the latest version is <strong><a href='{$latestVersionLink}' target='_blank'>{$latest}</a></strong>.<br>";
$text .= "Please check the <a href='{$fullChangelogUrl}' target='_blank'>changelog</a> for more information about the changes.<br>";
$text .= "It is recommended to update as soon as possible to benefit from the latest features and security improvements.";
## changelog + parsedown
$text .= "<hr>";
$text .= "<strong>Changelog for version {$latest}:</strong><br>";
$parsedown = new \Parsedown();
$text .= $parsedown->text($latestChanges["body"]);
$text .= "</div>";
return $text;
} else {
$text .= "<div class='card v8-bordered log-box'>";
$text .= "You are using the latest version of TimeTrack (<strong>{$current}</strong>). No update is required.";
## current changelog
$text .= "<hr>";
$text .= "<strong>Changelog for version {$current}:</strong><br>";
$parsedown = new \Parsedown();
$currentChanges = $this->getChanges($current);
if($currentChanges == null) {
$currentChanges["body"] = "**No changelogs found. Either you are using a custom build or something went wrong while fetching the changelogs.**";
}
$text .= $parsedown->text($currentChanges["body"]);
$text .= "</div>";
return $text;
}
}

public function global_dispatcher(): \Symfony\Component\EventDispatcher\EventDispatcher
{
return \Arbeitszeit\Events\EventDispatcherService::get();
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "TimeTrack is a PHP-written time recording tool for small businesses",
"type": "software",
"license": "GNU GPL",
"version": "8.6",
"version": "8.7",
"authors": [
{
"name": "Bryan Boehnke-Avan",
Expand Down
3 changes: 2 additions & 1 deletion suite/admin/users/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

DAT;

?>
?><br><br>
<?= $arbeit->renderGUIUpdateCheck(); ?><br><br>
<div class="card v8-bordered log-box">
<h2>Telemetry</h2>
<p>Here you can send anonymous telemetry data to help improve the application.
Expand Down
Loading