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..20050342 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 = trim($info[$elem['name']]); + break 2; + } + } + } + $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..3e46f5f0 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 = trim($info[$elem['name']]); + break 2; + } + } + } + $this->setSEQ($evt); // this will save the apptDoc as well @@ -673,6 +684,18 @@ 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') { + if (!empty($doc->location)) { + $location = $doc->location; + } + break 2; + } + } + } + if (!isset($evt->LOCATION)) { $evt->add('LOCATION'); } @@ -1695,7 +1718,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 +1744,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';