Skip to content
Snippets Groups Projects
Commit 863020c9 authored by Moritz Strohm's avatar Moritz Strohm
Browse files

fixed errors when moving dates, fixes #4723

Closes #4723

Merge request studip/studip!3573
parent 9b30b876
No related branches found
No related tags found
No related merge requests found
......@@ -655,7 +655,30 @@ class Calendar_DateController extends AuthenticatedController
throw new InvalidArgumentException();
}
if ($this->date->repetition_type !== 'SINGLE') {
//In case the moved event is a repetition event, we must know the original date from where
//it was moved from to correctly move the whole date series:
$original_date = Request::getDateTime('original_date');
$real_begin = new DateTime();
$real_begin->setTimestamp($this->date->begin);
if (
$original_date
&& $original_date->format('Ymd') !== $real_begin->format('Ymd')
) {
//The original date is set. If it differs from the beginning, a repetition date
//of a date series has been moved. In this case, the difference of the beginning
//and the original date has to be calculated and the begin and end fields have
//to be updated.
$original_date->setTime(
$real_begin->format('H'),
$real_begin->format('i'),
$real_begin->format('s')
);
$diff = $real_begin->diff($original_date);
$this->begin = $this->begin->sub($diff);
$this->end = $this->end->sub($diff);
}
if ($this->date->repetition_type !== CalendarDate::REPETITION_SINGLE) {
PageLayout::setTitle(_('Verschieben eines Termins aus einer Terminserie'));
//Show the dialog to decide what shall be done with the repetition.
if (Request::submitted('move')) {
......@@ -696,29 +719,6 @@ class Calendar_DateController extends AuthenticatedController
}
$this->response->add_header('X-Dialog-Close', '1');
return;
} elseif ($repetition_handling === 'change_times') {
//Set the new time for begin and end:
$date_begin = new DateTime();
$date_begin->setTimestamp($this->date->begin);
$date_begin->setTime(
intval($this->begin->format('H')),
intval($this->begin->format('i')),
intval($this->begin->format('s'))
);
$this->date->begin = $date_begin->getTimestamp();
$date_end = new DateTime();
$date_end->setTimestamp($this->date->end);
$date_end->setTime(
intval($this->end->format('H')),
intval($this->end->format('i')),
intval($this->end->format('s'))
);
$this->date->end = $date_end->getTimestamp();
//Set the editor-ID:
$this->date->editor_id = $GLOBALS['user']->id;
$store_old_date = true;
} elseif ($repetition_handling === 'change_all') {
$this->date->begin = $this->begin->getTimestamp();
if ($this->date->repetition_end && intval($this->date->repetition_end) != pow(2,31) - 1) {
......
......@@ -128,7 +128,7 @@
<?= Studip\LinkButton::create(
_('Bearbeiten'),
$controller->url_for('calendar/date/edit/' . $date->id, array_merge($button_params, ['return_path' => '/calendar/calendar'])),
['data-dialog' => 'size=auto;reload-on-close']
['data-dialog' => 'size=auto']
) ?>
<?= \Studip\LinkButton::create(
_('Löschen'),
......
......@@ -8,13 +8,9 @@
<input type="radio" name="repetition_handling" value="create_single_date">
<?= _('Der Termin soll aus der Terminserie herausgelöst werden.') ?>
</label>
<label>
<input type="radio" name="repetition_handling" value="change_times">
<?= _('Start- und Enduhrzeit der gesamten Terminserie soll geändert werden.') ?>
</label>
<label>
<input type="radio" name="repetition_handling" value="change_all">
<?= _('Die gesamte Terminserie soll verschoben werden und erst am gewählten Datum beginnen.') ?>
<?= _('Die gesamte Terminserie soll verschoben werden.') ?>
</label>
<div data-dialog-button>
<?= \Studip\Button::create(_('Verschieben'), 'move') ?>
......
......@@ -25,6 +25,12 @@ class EventData
public $border_colour;
public $all_day;
/**
* @var string The ID in this field is used to group events when displayed
* in Fullcalendar so that they can be moved together.
*/
public string $group_id;
public function __construct(
\DateTime $begin,
\DateTime $end,
......@@ -43,7 +49,8 @@ class EventData
Array $api_urls = [],
string $icon = '',
string $border_colour = '',
bool $all_day = false
bool $all_day = false,
string $group_id = ''
)
{
$this->begin = $begin;
......@@ -64,6 +71,7 @@ class EventData
$this->icon = $icon;
$this->border_colour = $border_colour ?: $background_colour;
$this->all_day = $all_day;
$this->group_id = $group_id;
}
......@@ -109,6 +117,6 @@ class EventData
'studip_view_urls' => $this->view_urls,
'studip_api_urls' => $this->api_urls,
'icon' => $this->icon
];
] + ($this->group_id ? ['groupId' => $this->group_id] : []);
}
}
......@@ -676,11 +676,12 @@ class CalendarDateAssignment extends SimpleORMap implements Event
],
[
'resize_dialog' => URLHelper::getURL('dispatch.php/calendar/date/move/' . $this->calendar_date_id),
'move_dialog' => URLHelper::getURL('dispatch.php/calendar/date/move/' . $this->calendar_date_id)
'move_dialog' => URLHelper::getURL('dispatch.php/calendar/date/move/' . $this->calendar_date_id, ['original_date' => $begin->format('Y-m-d')])
],
$this->participation === 'DECLINED' ? 'decline-circle-full' : '',
$border_colour,
$all_day
$all_day,
$this->calendar_date_id
);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment