Skip to content

Commit

Permalink
Remove sorting from calendar import because it's quite useless and le…
Browse files Browse the repository at this point in the history
…ads to errors on some ics files.
  • Loading branch information
cgoIT committed Aug 31, 2023
1 parent 86ebdfc commit 8b477ef
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Resources/contao/classes/CalendarImport.php
Expand Up @@ -691,7 +691,7 @@ protected function importFromICSFile(
\Message::addError($e->getMessage());
$this->redirect(str_replace('&key=import', '', \Environment::get('request')));
}
$tz = $this->cal->getProperty(Vcalendar::X_WR_TIMEZONE);
$tz = $this->cal->getXprop(Vcalendar::X_WR_TIMEZONE);

if ($timeshift == 0) {
if (is_array($tz) && strlen($tz[1]) && strcmp($tz[1], $GLOBALS['TL_CONFIG']['timeZone']) != 0) {
Expand All @@ -702,7 +702,7 @@ protected function importFromICSFile(
} else {
if (!is_array($tz) || strlen($tz[1]) == 0) {
if ($manualTZ === null) {
return $this->getConfirmationForm($dc, $filename, $startDate->date, $endDate->date, $tz[1],
return $this->getConfirmationForm($dc, $filename, $startDate->date, $endDate->date, null,
$GLOBALS['TL_CONFIG']['timeZone'], $deleteCalendar);
}
}
Expand All @@ -724,7 +724,9 @@ protected function importFromICS(
$deleteCalendar = false,
$timeshift = 0
) {
$this->cal->sort();
// $this->cal->sort() was previously in the code. This is quite useless because without arguments this methods
// sorts by UID which doesn't give us any benefit.
//$this->cal->sort();
$this->loadDataContainer('tl_calendar_events');
$fields = $this->Database->listFields('tl_calendar_events');
$fieldNames = array();
Expand Down Expand Up @@ -793,7 +795,7 @@ protected function importFromICS(

$title = $summary;
if (!empty($this->patternEventTitle) && !empty($this->replacementEventTitle)) {
$title = preg_replace($this->patternEventTitle, $this->replacementEventTitle, $title);
$title = preg_replace($this->patternEventTitle, $this->replacementEventTitle, $summary);
}

// set values from vevent
Expand Down Expand Up @@ -1005,6 +1007,8 @@ protected function importFromICS(
}
$foundevents[$uid]++;

$arrFields['description'] = $uid;

This comment has been minimized.

Copy link
@kroerig

kroerig Nov 27, 2023

Hat diese Zeile einen besonderen Grund?

This comment has been minimized.

Copy link
@cgoIT

cgoIT Nov 28, 2023

Author Owner

Fällt mir jetzt erst mal nichts ein und ich wundere mich auch gerade, warum die Zeile da reingerutscht ist. Ich denke ich nehme sie mal wieder raus. ;)


if ($foundevents[$uid] <= 1) {
if (array_key_exists('singleSRC', $arrFields) && $arrFields['singleSRC'] == "") {
$arrFields['singleSRC'] = null;
Expand Down Expand Up @@ -1117,6 +1121,7 @@ public function importCalendar(DataContainer $dc) {
$objUploader = new $class();

$this->loadLanguageFile("tl_calendar_events");
$this->loadLanguageFile("tl_files");
$this->Template = new BackendTemplate('be_import_calendar');

$class = $this->User->uploader;
Expand Down

0 comments on commit 8b477ef

Please sign in to comment.