Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan-Hendrik Willms
Stud.IP
Commits
9a21789a
Commit
9a21789a
authored
2 years ago
by
Moritz Strohm
Committed by
David Siegfried
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
added missing $real_begin to ResourceBooking::validate, fixes #1221
Closes #1221 Merge request
studip/studip!748
parent
d5292127
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/models/resources/ResourceBooking.class.php
+31
-21
31 additions, 21 deletions
lib/models/resources/ResourceBooking.class.php
with
31 additions
and
21 deletions
lib/models/resources/ResourceBooking.class.php
+
31
−
21
View file @
9a21789a
...
...
@@ -30,17 +30,18 @@
* @property string booking_user_id database column
* The user who created the booking (booking).
* @property string description database column
* @property string begin database column
* @property string end database column
* @property string booking_type database column: The booking type.
* @property int begin database column
* @property int end database column
* @property int $preparation_time database column
* @property int booking_type database column: The booking type.
* The following types are defined:
* 0 = normal booking
* 1 = reservation
* 2 = lock
* 3 = planned booking (reservation from external tools)
*
* @property
str
in
g
repeat_end database column
* @property
str
in
g
repeat_quantity database column
* @property in
t
repeat_end database column
* @property in
t
repeat_quantity database column
* @property string repetition_interval database column
* The repetition_interval column contains a date interval string in a
* format that is accepted by the DateInterval class constructor.
...
...
@@ -51,11 +52,14 @@
* https://secure.php.net/manual/en/class.dateinterval.php
*
* @property string internal_comment database column
* @property
str
in
g
mkdate database column
* @property
str
in
g
chdate database column
* @property in
t
mkdate database column
* @property in
t
chdate database column
* @property Resource resource belongs_to Resource
* @property User assigned_user belongs_to User
* @property CourseDate assigned_course_date belongs_to CourseDate
*
* @property-read int $real_begin
* @property-read DateTime $real_begin_dt
*/
class
ResourceBooking
extends
SimpleORMap
implements
PrivacyObject
,
Studip\Calendar\EventSource
{
...
...
@@ -92,6 +96,19 @@ class ResourceBooking extends SimpleORMap implements PrivacyObject, Studip\Calen
$config
[
'additional_fields'
][
'course_id'
]
=
[
'assigned_course_date'
,
'range_id'
];
$config
[
'additional_fields'
][
'room_name'
]
=
[
'resource'
,
'name'
];
$config
[
'additional_fields'
][
'real_begin'
]
=
[
'get'
=>
function
(
ResourceBooking
$booking
)
{
return
$booking
->
begin
-
$booking
->
preparation_time
;
}
];
$config
[
'additional_fields'
][
'real_begin_dt'
]
=
[
'get'
=>
function
(
ResourceBooking
$booking
)
{
$real_begin
=
new
DateTime
();
$real_begin
->
setTimestamp
(
$booking
->
real_begin
);
return
$real_begin
;
}
];
$config
[
'registered_callbacks'
][
'after_store'
][]
=
'updateIntervals'
;
$config
[
'registered_callbacks'
][
'after_store'
][]
=
'createStoreLogEntry'
;
$config
[
'registered_callbacks'
][
'after_delete'
][]
=
'sendDeleteNotification'
;
...
...
@@ -457,7 +474,7 @@ class ResourceBooking extends SimpleORMap implements PrivacyObject, Studip\Calen
_
(
'Es wurde ein Wiederholungsintervall ohne Begrenzung angegeben!'
)
);
}
if
((
!
$this
->
repeat_quantity
)
&&
(
$real_begin
>
$this
->
repeat_end
))
{
if
((
!
$this
->
repeat_quantity
)
&&
(
$
this
->
real_begin
>
$this
->
repeat_end
))
{
throw
new
InvalidArgumentException
(
_
(
'Der Startzeitpunkt darf nicht hinter dem Ende der Wiederholungen liegen!'
)
);
...
...
@@ -691,8 +708,6 @@ class ResourceBooking extends SimpleORMap implements PrivacyObject, Studip\Calen
*/
public
function
deleteOverlappingBookings
()
{
$real_begin
=
new
DateTime
();
$real_begin
->
setTimestamp
(
$this
->
begin
-
$this
->
preparation_time
);
$end
=
new
DateTime
();
$end
->
setTimestamp
(
$this
->
end
);
$repetition_end
=
new
DateTime
();
...
...
@@ -707,14 +722,14 @@ class ResourceBooking extends SimpleORMap implements PrivacyObject, Studip\Calen
_
(
'Es wurde ein Wiederholungsintervall ohne Begrenzung angegeben!'
)
);
}
if
((
!
$this
->
repeat_quantity
)
&&
(
$real_begin
>
$this
->
repeat_end
))
{
if
((
!
$this
->
repeat_quantity
)
&&
(
$
this
->
real_begin
>
$this
->
repeat_end
))
{
throw
new
InvalidArgumentException
(
_
(
'Der Startzeitpunkt darf nicht hinter dem Ende der Wiederholungen liegen!'
)
);
}
//Look in each repetition for overlapping bookings and delete them.
$current_date
=
clone
$
real_begin
;
$current_date
=
$this
->
real_begin
_dt
;
while
(
$current_date
<=
$repetition_end
)
{
$current_begin
=
clone
$current_date
;
$current_end
=
clone
$current_date
;
...
...
@@ -758,10 +773,10 @@ class ResourceBooking extends SimpleORMap implements PrivacyObject, Studip\Calen
}
}
else
{
$derived_resource
=
$this
->
resource
->
getDerivedClassInstance
();
if
(
$derived_resource
->
userHasPermission
(
$this
->
booking_user
,
'autor'
,
[
$real_begin
,
$end
]))
{
if
(
$derived_resource
->
userHasPermission
(
$this
->
booking_user
,
'autor'
,
[
$
this
->
real_begin
_dt
,
$end
]))
{
$delete_sql
=
'begin < :end AND end > :begin AND resource_id = :resource_id '
;
$sql_params
=
[
'begin'
=>
$real_begin
->
getTimestamp
()
,
'begin'
=>
$
this
->
real_begin
,
'end'
=>
$end
->
getTimestamp
(),
'resource_id'
=>
$this
->
resource
->
id
];
...
...
@@ -804,11 +819,6 @@ class ResourceBooking extends SimpleORMap implements PrivacyObject, Studip\Calen
$booking_resource
=
Resource
::
find
(
$this
->
resource_id
);
$booking_user
=
User
::
find
(
$this
->
booking_user_id
);
$real_begin
=
new
DateTime
();
$real_begin
->
setTimestamp
(
$this
->
begin
-
$this
->
preparation_time
);
$end
=
new
DateTime
();
$end
->
setTimestamp
(
$this
->
end
);
$deleted_c
=
0
;
$template_factory
=
new
Flexi_TemplateFactory
(
...
...
@@ -819,8 +829,8 @@ class ResourceBooking extends SimpleORMap implements PrivacyObject, Studip\Calen
$booking_resource
,
[
[
'begin'
=>
$real_begin
->
getTimestamp
()
,
'end'
=>
$
end
->
getTimestamp
()
,
'begin'
=>
$
this
->
real_begin
,
'end'
=>
$
this
->
end
,
]
],
[
1
,
3
],
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment