From 76e038762b7a2ca218a0a2a9a5491fbc27e2edf0 Mon Sep 17 00:00:00 2001 From: luxigo Date: Sun, 12 Apr 2026 23:01:05 +0200 Subject: [PATCH 1/4] Booking Appointments in other locations --- lib/Backend/ApptDocProp.php | 1 + lib/Backend/BCSabreImpl.php | 16 ++++++++++++++-- lib/Backend/BackendUtils.php | 29 +++++++++++++++++++++++++++-- lib/Controller/StateController.php | 5 +++++ 4 files changed, 47 insertions(+), 4 deletions(-) diff --git a/lib/Backend/ApptDocProp.php b/lib/Backend/ApptDocProp.php index 030903d1..84369620 100644 --- a/lib/Backend/ApptDocProp.php +++ b/lib/Backend/ApptDocProp.php @@ -21,6 +21,7 @@ class ApptDocProp extends PropEncoderBase public bool $inPersonType = false; public string $attendeeTimezone = 'UTC'; public string $description = ''; + public string $location = ''; public string $_evtUid = ''; private array $_defaults = []; diff --git a/lib/Backend/BCSabreImpl.php b/lib/Backend/BCSabreImpl.php index 0543c3fa..f7459246 100644 --- a/lib/Backend/BCSabreImpl.php +++ b/lib/Backend/BCSabreImpl.php @@ -880,6 +880,16 @@ function setAttendee($userId, $calId, $uri, $info) $settings = $this->utils->getUserSettings(); + $location=""; + foreach ($settings[BackendUtils::KEY_FORM_INPUTS_JSON] as $elem) { + foreach ($elem as $attr => $value) { + if ($attr === 'data-is_location') { + $location=$info[$elem['name']]; + break; + } + } + } + $ts_mode = $settings[BackendUtils::CLS_TS_MODE]; if ($ts_mode === BackendUtils::CLS_TS_MODE_TEMPLATE) { @@ -911,7 +921,8 @@ function setAttendee($userId, $calId, $uri, $info) (new \DateTime('now', new \DateTimeZone('UTC')))->format(self::TIME_FORMAT), isset($td[$info['tmpl_day']][$info['tmpl_idx']]['title']) ? '_' . $td[$info['tmpl_day']][$info['tmpl_idx']]['title'] - : '' + : '', + $location ); if (isset($parts['err'])) { $this->logErr($parts['err'] . " - template mode"); @@ -990,7 +1001,8 @@ function setAttendee($userId, $calId, $uri, $info) $parts = $this->utils->makeAppointmentParts( $userId, $tzi, (new \DateTime('now', new \DateTimeZone('UTC')))->format(self::TIME_FORMAT), - isset($evt->SUMMARY) ? '_' . $evt->SUMMARY->getValue() : '' + isset($evt->SUMMARY) ? '_' . $evt->SUMMARY->getValue() : '', + $location ); if (isset($parts['err'])) { $this->logErr($parts['err'] . " - calId: " . $srcId . ", uri: " . $srcUri); diff --git a/lib/Backend/BackendUtils.php b/lib/Backend/BackendUtils.php index a8cccfb6..bea93a7d 100644 --- a/lib/Backend/BackendUtils.php +++ b/lib/Backend/BackendUtils.php @@ -324,6 +324,7 @@ function dataSetAttendee(string $data, array $info, string $userId, string $uri) $title )); + /// ics text $dsr = $info['name'] . "\n" . (empty($info['phone']) ? "" : ($info['phone'] . "\n")) . $info['email'] . $info['_more_data']; if (isset($info["_more_ics_text"])) { @@ -350,6 +351,16 @@ function dataSetAttendee(string $data, array $info, string $userId, string $uri) $doc->description = $dsr; // ----- + $settings = $this->getUserSettings(); + foreach ($settings[BackendUtils::KEY_FORM_INPUTS_JSON] as $elem) { + foreach ($elem as $attr => $value) { + if ($attr === 'data-is_location') { + $doc->$location=$info[$elem['name']]; + break; + } + } + } + $this->setSEQ($evt); // this will save the apptDoc as well @@ -673,6 +684,16 @@ private function addEvtLocationOrVideoLink(string $userId, \Sabre\VObject\Compon : $r; } + // I'm OK with having chat enabled before a remote appointment regardless of conditions above + foreach ($settings[self::KEY_FORM_INPUTS_JSON] as $elem) { + foreach ($elem as $attr => $value) { + if ($attr === 'data-is_location') { + $location=$doc->location; + break; + } + } + } + if (!isset($evt->LOCATION)) { $evt->add('LOCATION'); } @@ -1695,7 +1716,7 @@ function getMainCalId(string $userId, IBackendConnector|null $bc, string|null &$ * @param string $title title is used when the appointment is being reset * @return string[] ['1_before_uid'=>'string...','2_before_dts'=>'string...','3_before_dte'=>'string...','4_last'=>'string...'] or ['err'=>'Error text...'] */ - function makeAppointmentParts(string $userId, string $tz_data_str, string $cr_date, string $title = ""): array + function makeAppointmentParts(string $userId, string $tz_data_str, string $cr_date, string $title = "", string $location = ""): array { $l10n = $this->l10n; @@ -1721,7 +1742,11 @@ function makeAppointmentParts(string $userId, string $tz_data_str, string $cr_da $settings = $this->getUserSettings(); $org_name = $settings[BackendUtils::ORG_NAME]; - $addr = $settings[BackendUtils::ORG_ADDR]; + + $addr = empty($location) + ? $settings[BackendUtils::ORG_ADDR] + : $location; + $email = $settings[self::ORG_EMAIL]; $name = trim($iUser->getDisplayName()); diff --git a/lib/Controller/StateController.php b/lib/Controller/StateController.php index 7bbed200..8ee3a23d 100644 --- a/lib/Controller/StateController.php +++ b/lib/Controller/StateController.php @@ -833,6 +833,11 @@ private function makeFormField(&$obj, $index = 0) ]; $applyAttrs = function (array $allowed) use ($obj) { $out = ''; + foreach ($obj as $attr => $value) { + if (preg_match("/^data\-[a-z0-9\-_]+$/",$attr)) { + $out .= ' ' . $attr . '="' . htmlspecialchars($value, ENT_QUOTES, 'UTF-8') . '"'; + } + } foreach ($allowed as $attr => $default) { if ($attr === 'required' && !empty($obj[$attr])) { $out .= ' required'; From 3c005cb709b756d67dcb38b87a8c7f00d4b16031 Mon Sep 17 00:00:00 2001 From: luxigo Date: Sun, 12 Apr 2026 23:49:52 +0200 Subject: [PATCH 2/4] break 2 --- lib/Backend/BCSabreImpl.php | 2 +- lib/Backend/BackendUtils.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Backend/BCSabreImpl.php b/lib/Backend/BCSabreImpl.php index f7459246..340a60de 100644 --- a/lib/Backend/BCSabreImpl.php +++ b/lib/Backend/BCSabreImpl.php @@ -885,7 +885,7 @@ function setAttendee($userId, $calId, $uri, $info) foreach ($elem as $attr => $value) { if ($attr === 'data-is_location') { $location=$info[$elem['name']]; - break; + break 2; } } } diff --git a/lib/Backend/BackendUtils.php b/lib/Backend/BackendUtils.php index bea93a7d..931dad87 100644 --- a/lib/Backend/BackendUtils.php +++ b/lib/Backend/BackendUtils.php @@ -356,7 +356,7 @@ function dataSetAttendee(string $data, array $info, string $userId, string $uri) foreach ($elem as $attr => $value) { if ($attr === 'data-is_location') { $doc->$location=$info[$elem['name']]; - break; + break 2; } } } @@ -689,7 +689,7 @@ private function addEvtLocationOrVideoLink(string $userId, \Sabre\VObject\Compon foreach ($elem as $attr => $value) { if ($attr === 'data-is_location') { $location=$doc->location; - break; + break 2; } } } From 5ab62f10d3cc4b94e02d8403c0802bc5036740d8 Mon Sep 17 00:00:00 2001 From: luxigo Date: Mon, 13 Apr 2026 00:19:48 +0200 Subject: [PATCH 3/4] fix code layout --- lib/Backend/BCSabreImpl.php | 2 +- lib/Backend/BackendUtils.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Backend/BCSabreImpl.php b/lib/Backend/BCSabreImpl.php index 340a60de..ee0e1d1a 100644 --- a/lib/Backend/BCSabreImpl.php +++ b/lib/Backend/BCSabreImpl.php @@ -884,7 +884,7 @@ function setAttendee($userId, $calId, $uri, $info) foreach ($settings[BackendUtils::KEY_FORM_INPUTS_JSON] as $elem) { foreach ($elem as $attr => $value) { if ($attr === 'data-is_location') { - $location=$info[$elem['name']]; + $location = $info[$elem['name']]; break 2; } } diff --git a/lib/Backend/BackendUtils.php b/lib/Backend/BackendUtils.php index 931dad87..25f3cd18 100644 --- a/lib/Backend/BackendUtils.php +++ b/lib/Backend/BackendUtils.php @@ -355,7 +355,7 @@ function dataSetAttendee(string $data, array $info, string $userId, string $uri) foreach ($settings[BackendUtils::KEY_FORM_INPUTS_JSON] as $elem) { foreach ($elem as $attr => $value) { if ($attr === 'data-is_location') { - $doc->$location=$info[$elem['name']]; + $doc->$location = $info[$elem['name']]; break 2; } } @@ -688,7 +688,7 @@ private function addEvtLocationOrVideoLink(string $userId, \Sabre\VObject\Compon foreach ($settings[self::KEY_FORM_INPUTS_JSON] as $elem) { foreach ($elem as $attr => $value) { if ($attr === 'data-is_location') { - $location=$doc->location; + $location = $doc->location; break 2; } } From a238f5c292ad5f827d611c7b335eb093ae7dfc45 Mon Sep 17 00:00:00 2001 From: luxigo Date: Mon, 13 Apr 2026 01:46:01 +0200 Subject: [PATCH 4/4] empty location reverts to old behaviour, fix typo --- lib/Backend/BCSabreImpl.php | 2 +- lib/Backend/BackendUtils.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Backend/BCSabreImpl.php b/lib/Backend/BCSabreImpl.php index ee0e1d1a..20050342 100644 --- a/lib/Backend/BCSabreImpl.php +++ b/lib/Backend/BCSabreImpl.php @@ -884,7 +884,7 @@ function setAttendee($userId, $calId, $uri, $info) foreach ($settings[BackendUtils::KEY_FORM_INPUTS_JSON] as $elem) { foreach ($elem as $attr => $value) { if ($attr === 'data-is_location') { - $location = $info[$elem['name']]; + $location = trim($info[$elem['name']]); break 2; } } diff --git a/lib/Backend/BackendUtils.php b/lib/Backend/BackendUtils.php index 25f3cd18..3e46f5f0 100644 --- a/lib/Backend/BackendUtils.php +++ b/lib/Backend/BackendUtils.php @@ -355,7 +355,7 @@ function dataSetAttendee(string $data, array $info, string $userId, string $uri) foreach ($settings[BackendUtils::KEY_FORM_INPUTS_JSON] as $elem) { foreach ($elem as $attr => $value) { if ($attr === 'data-is_location') { - $doc->$location = $info[$elem['name']]; + $doc->location = trim($info[$elem['name']]); break 2; } } @@ -688,7 +688,9 @@ private function addEvtLocationOrVideoLink(string $userId, \Sabre\VObject\Compon foreach ($settings[self::KEY_FORM_INPUTS_JSON] as $elem) { foreach ($elem as $attr => $value) { if ($attr === 'data-is_location') { - $location = $doc->location; + if (!empty($doc->location)) { + $location = $doc->location; + } break 2; } }