Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a bug with empty events #45

Merged
merged 2 commits into from
Nov 6, 2024
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
4 changes: 2 additions & 2 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
<name>Where am I ?</name>
<summary><![CDATA[Is a simple application to locate everybody in your company.]]></summary>
<description><![CDATA[Is a simple application to locate everybody in your company.]]></description>
<version>0.0.36</version>
<version>0.0.37</version>
<licence>agpl</licence>
<author mail="contact@adacis.net" homepage="https://www.adacis.net">ADACIS</author>
<namespace>Whereami</namespace>
<category>office</category>
<category>organization</category>
<bugs>https://github.com/Adacis/whereami/issues</bugs>
<dependencies>
<nextcloud min-version="29" max-version="29"/>
<nextcloud min-version="29" max-version="31"/>
</dependencies>
<settings>
<admin>OCA\Whereami\Settings\WhereamiAdmin</admin>
Expand Down
31 changes: 17 additions & 14 deletions lib/MyClass/MyEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

class MyEvent
{
public String $id;
public String $summary;
public String $dtStart;
public String $dtEnd;
public String $place;
public String $place2;
public String $nextcloud_users;
public string $id;
public string $summary;
public ?string $dtStart;
public ?string $dtEnd;
public string $place;
public string $place2;
public string $nextcloud_users;
public $quote;

public bool $valid;
Expand All @@ -31,12 +31,12 @@ public function __construct(
$this->log = $logger;
$this->myDb = $myDb;
$this->id = $e['id'];
$this->dtStart = $e["objects"][0]["DTSTART"][0]?->modify('+ 1 minute')?->format('Y-m-d H:i:s');
$this->dtEnd = $e["objects"][0]["DTEND"][0]?->modify('- 1 minute')?->format('Y-m-d H:i:s') ?? $this->dtStart;
$this->dtStart = ($e["objects"][0]["DTSTART"][0] ?? null)?->modify('+ 1 minute')?->format('Y-m-d H:i:s');
$this->dtEnd = ($e["objects"][0]["DTEND"][0] ?? null)?->modify('- 1 minute')?->format('Y-m-d H:i:s') ?? $this->dtStart;
$this->nextcloud_users = $this->getNameCalendar($this->id);
$this->summary = str_replace("@", "", $e["objects"][0]["SUMMARY"][0]);
$this->summary = str_replace("@", "", $e["objects"][0]["SUMMARY"][0] ?? '');

$tmp = $this->extractData(",", 0, $e["objects"][0]["SUMMARY"][0]);
$tmp = $this->extractData(",", 0, $e["objects"][0]["SUMMARY"][0] ?? '');
if (!is_null($this->dtStart) && count($tmp) > 0) {
$this->place = $tmp[0];
if (count($tmp) >= 2) {
Expand Down Expand Up @@ -108,9 +108,12 @@ public function extractData($separator, $position, $data): array
preg_match_all($re, strtolower($data), $matches, PREG_SET_ORDER, 0);

try {
$cls = [$matches[0][1]];
if (count($matches[0]) >= 4) {
array_push($cls, $matches[0][3]);
$cls = [];
if (isset($matches[0][1])) {
$cls[] = $matches[0][1];
}
if (count($matches[0] ?? []) >= 4) {
$cls[] = $matches[0][3];
}
} catch (\Throwable $th) {
$cls = [];
Expand Down
2 changes: 1 addition & 1 deletion templates/navigation/index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<ul class="app-navigation">
<li class="app-navigation-entry"><span class="app-title"></span><b>Where am I V 0.0.36</b></li>
<li class="app-navigation-entry"><span class="app-title"></span><b>Where am I V 0.0.37</b></li>
<li class="app-navigation-entry-link">
<ul class="app-navigation">
<li class="active app-navigation-entry-link button new btn-new-event"><span class="navmarg icon-add"></span><a
Expand Down