Closed espaan closed 10 years ago
I'm not sure PC 7 supported multi day events? It's been so long since I looked at the code for this, I don't remember anything. :frowning:
In my own database I had events that for example went 5 days in a row (repeating days). So these would have been converted I think. But continuous events were not supported in PC7 I'm pretty sure.
which kind do you mean?
For me it doesn't matter, as long as I can add events that have a startdate and enddate days later. If that is continues or repeat does not matter that much in the view.
Hi, I have updated the installer for 701 to 801 to work in my case. duration was nonsense in my case, so when enddate was larger then startdate + duration I now ignore duration and taken the enddate as ruling. This to accommodate multi day events from 620.
Upgrade with this update now works good from 620 to 701 to 801.
I have now:
// select partial array of all events for later manipulation
$sql = "SELECT eid, hooked_area, eventDate, startTime, duration, endDate, recurrtype FROM postcalendar_events";
$objects = $connection->fetchAll($sql);
// add PostCalendar_Entity_RecurException and PostCalendar_Entity_EventCategory tables
DoctrineHelper::createSchema($this->entityManager, array('PostCalendar_Entity_EventCategory',
'PostCalendar_Entity_RecurException'));
// update the PostCalendar_Entity_CalendarEvent table
DoctrineHelper::updateSchema($this->entityManager, array('PostCalendar_Entity_CalendarEvent'));
// update every event with correct hooked_area and new eventStart and eventEnd values
$sqls = array();
foreach ($objects as $object) {
$hookedArea = isset($object['hooked_area']) ? $hookManager->getAreaId($object['hooked_area']) : 'null';
$eventStart = DateTime::createFromFormat('Y-m-d H:i:s', $object['eventDate'] . " " . $object['startTime']);
$endDate = DateTime::createFromFormat('Y-m-d', $object['endDate']);
if (($endDate->getTimestamp() - $eventStart->getTimestamp()) > $object['duration']) {
// take enddate as the reference and ignore duration
$eventEnd = clone $endDate;
$recurrtype = 3;
} else {
// take eventStart + duration
$eventEnd = clone $eventStart;
$eventEnd->modify("+" . $object['duration'] . " seconds");
$recurrtype = (int)$object['recurrtype'];
}
$eid = $object['eid'];
$sqls[] = "UPDATE `postcalendar_events`
SET `hooked_area` = $hookedArea,
`recurrtype` = $recurrtype,
`eventStart` = '{$eventStart->format('Y-m-d H:i:s')}',
`eventEnd` = '{$eventEnd->format('Y-m-d H:i:s')}'
WHERE `postcalendar_events`.`eid`=$eid";
if (count($sqls) > 20) {
// this only runs the sql on the server every 20 events
foreach ($sqls as $sql) {
$stmt = $connection->prepare($sql);
try {
$stmt->execute();
} catch (Exception $e) {
LogUtil::registerError($e->getMessage());
}
}
$sqls = array();
}
}
do you think this should be added to the PC8 development or is your case unique?
I think it is general if people used multi day events in PC 6.2, but I'm just not sure. I can make some test events in my 6.2 install to see what that does in the DB.
Hi I just checked in the 6.2 install. Adding events:
So for timed events the code in 8.0.1 works fine, but for all day repeating events the new code suggested above is needed, otherwise they will convert wrong and multi day events will get lost. Duration is clearly not relevant in the all-day repeating 1 day events in 6.2.
But when the code above is used the upgrade works perfect from 6.2 to 701 to 801 :+1:
PR please ;-)
Done :-D
whoops - did that PR fix this ticket?
Yes, works perfectly now. Thanks
Hi, I have updated a large set of events that (almost) all start on a certain date and go to a next date. All multi day events that last all-day. But int he edit event the end date is not reported correct.
In the database after import it looks ok AFAIS, the eventDate is 30 may and endDate is 20 June, however the eventStart and eventEnd are not correct. They both are 30 May 1 hour apart.
Did you take into acoutn multi day events during upgrade from 7 to 8 ?