Skip to content
Open
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
1 change: 1 addition & 0 deletions lib/Backend/ApptDocProp.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down
16 changes: 14 additions & 2 deletions lib/Backend/BCSabreImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down
31 changes: 29 additions & 2 deletions lib/Backend/BackendUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"])) {
Expand All @@ -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
Expand Down Expand Up @@ -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');
}
Expand Down Expand Up @@ -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;
Expand All @@ -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());
Expand Down
5 changes: 5 additions & 0 deletions lib/Controller/StateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down