Stud.IP  4.0
 All Data Structures Namespaces Files Functions Variables Groups
ResourceBooking Class Reference
Inheritance diagram for ResourceBooking:
SimpleORMap PrivacyObject EventSource

Public Member Functions

 createStoreLogEntry ()
 
 createDeleteLogEntry ()
 
 store ($force_booking=false)
 
 validate ()
 
 updateIntervals ($keep_exceptions=true)
 
 deleteIfNoInterval ()
 
 deleteOverlappingBookings ()
 
 deleteOverlappingReservations ()
 
 endsWithSemester ()
 
 userIsOwner (User $user)
 
 isReadOnlyForUser (User $user)
 
 isRepetitionInTimeframe (DateTime $begin, DateTime $end)
 
 getRepetitionInterval ()
 
 getRepeatModeString ()
 
 hasOverlappingBookings ()
 
 getOverlappingBookings ()
 
 calculateTimeIntervals ($as_datetime=false)
 
 getTimeIntervals ($with_exceptions=true)
 
 getTimeIntervalsInTimeRange (DateTime $begin, DateTime $end)
 
 getAssignedUsers ($only_names=true)
 
 getAssignedUser ()
 
 getAssignedUserType ()
 
 getAssignedUserName ()
 
 isSimpleBooking ()
 
 hasExceptions ()
 
 __toString ()
 
 getTimeIntervalStrings ()
 
 convertToEventData (array $time_intervals, $user)
 
 getAllEventData ()
 
 getEventDataForTimeRange (DateTime $begin, DateTime $end)
 
 getFilteredEventData ($user_id=null, $range_id=null, $range_type=null, $begin=null, $end=null)
 
 getRepetitionType ()
 
 sendDeleteNotification ()
 
- Public Member Functions inherited from SimpleORMap
 __construct ($id=null)
 
 __clone ()
 
 getRelationOptions ($relation)
 
 getTableMetadata ()
 
 hasAutoIncrementColumn ()
 
 setId ($id)
 
 getId ()
 
 getNewId ()
 
 toArray ($only_these_fields=null)
 
 toRawArray ($only_these_fields=null)
 
 toArrayRecursive ($only_these_fields=null)
 
 getValue ($field)
 
 getRelationValue ($relation, $field)
 
 getDefaultValue ($field)
 
 setValue ($field, $value)
 
 __get ($field)
 
 __set ($field, $value)
 
 __isset ($field)
 
 offsetExists ($offset)
 
 offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 offsetUnset ($offset)
 
 getIterator ()
 
 count ()
 
 isField ($field)
 
 isAdditionalField ($field)
 
 isAliasField ($field)
 
 isI18nField ($field)
 
 setData ($data, $reset=false)
 
 isNew ()
 
 isDeleted ()
 
 setNew ($is_new)
 
 getWhereQuery ()
 
 restore ()
 
 store ()
 
 triggerChdate ()
 
 delete ()
 
 isDirty ()
 
 isFieldDirty ($field)
 
 revertValue ($field)
 
 getPristineValue ($field)
 
 initRelation ($relation)
 
 resetRelation ($relation)
 
 cleanup ()
 
- Public Member Functions inherited from EventSource
 getEventDataForTimeRange (\DateTime $begin,\DateTime $end)
 

Static Public Member Functions

static findByResourceAndTimeRanges (Resource $resource, $time_ranges=[], $booking_types=[], $excluded_booking_ids=[])
 
static countByResourceAndTimeRanges (Resource $resource, $time_ranges=[], $booking_types=[], $excluded_booking_ids=[])
 
static deleteByResourceAndTimeRanges (Resource $resource, $time_ranges=[], $booking_types=[], $excluded_booking_ids=[])
 
static exportUserData (StoredUserData $storage)
 
- Static Public Member Functions inherited from SimpleORMap
static tableScheme ($db_table)
 
static expireTableScheme ()
 
static exists ($id)
 
static countBySql ($sql= '1', $params=[])
 
static create ($data)
 
static buildExisting ($data)
 
static import ($data)
 
static findBySQL ($sql, $params=[])
 
static findOneBySQL ($where, $params=[])
 
static findThru ($foreign_key_value, $options)
 
static findEachBySQL ($callable, $sql, $params=[])
 
static findMany ($pks=[], $order= '', $order_params=[])
 
static findEachMany ($callable, $pks=[], $order= '', $order_params=[])
 
static findAndMapBySQL ($callable, $where, $params=[])
 
static findAndMapMany ($callable, $pks=[], $order= '', $order_params=[])
 
static deleteBySQL ($where, $params=[])
 
static toObject ($id_or_object)
 
static __callStatic ($name, $arguments)
 

Static Protected Member Functions

static configure ($config=[])
 
static buildResourceAndTimeRangesSqlQuery (Resource $resource, $time_ranges=[], $booking_types=[], $excluded_booking_ids=[])
 
- Static Protected Member Functions inherited from SimpleORMap
static db_table ()
 
static db_fields ()
 
static pk ()
 
static default_values ()
 
static serialized_fields ()
 
static alias_fields ()
 
static i18n_fields ()
 
static additional_fields ()
 
static has_many ()
 
static has_one ()
 
static belongs_to ()
 
static has_and_belongs_to_many ()
 
static registered_callbacks ()
 
static known_slots ()
 
static notification_map ()
 
static getter_setter_map ()
 
static configure ($config=[])
 
static config ($key)
 
static registerCallback ($types, $cb)
 
static unregisterCallback ($types, $cb)
 

Additional Inherited Members

- Data Fields inherited from SimpleORMap
const ID_SEPARATOR = '_'
 
- Static Public Attributes inherited from SimpleORMap
static $schemes = null
 
- Protected Member Functions inherited from SimpleORMap
 _getId ($field)
 
 _setId ($field, $value)
 
 _getAdditionalValueFromRelation ($field)
 
 _setAdditionalValueFromRelation ($field, $value)
 
 _getAdditionalValue ($field)
 
 _setAdditionalValue ($field, $value)
 
 parseRelationOptions ($type, $name, $options)
 
 storeRelations ($only_these=null)
 
 deleteRelations ()
 
 initializeContent ()
 
 applyCallbacks ($type)
 
 cbAutoIncrementColumn ($type)
 
 cbAutoKeyCreation ()
 
 cbNotificationMapper ($cb_type)
 
 cbAfterInitialize ($cb_type)
 
 setSerializedValue ($field, $value)
 
 setI18nValue ($field, $value)
 
- Protected Attributes inherited from SimpleORMap
 $content = []
 
 $content_db = []
 
 $is_new = true
 
 $is_deleted = false
 
 $relations = []
 
 $additional_data = []
 
- Static Protected Attributes inherited from SimpleORMap
static $config = []
 
static $reserved_slots = ['value','newid','iterator','tablemetadata', 'relationvalue','wherequery','relationoptions','data','new','id']
 
static $performs_batch_operation = false
 

Member Function Documentation

__toString ( )
static buildResourceAndTimeRangesSqlQuery ( Resource  $resource,
  $time_ranges = [],
  $booking_types = [],
  $excluded_booking_ids = [] 
)
staticprotected

Internal method that generated the SQL query used in findByResourceAndTimeRanges and countByResourceAndTimeRanges.

See Also
findByResourceAndTimeRanges
calculateTimeIntervals (   $as_datetime = false)

Calculates all time intervals as begin and end timestamps by looking at the repetition settings, if any.

Parameters
bool$as_datetimeWhether to return the timestamps as DateTime objects (true) or not (false). Defaults to false.
Returns
array A two-dimensional array with each time interval for this booking. The array has the following structure: [ [ 'begin' => Begin timestamp. 'end' => End timestamp. ] ]
static configure (   $config = [])
staticprotected
convertToEventData ( array  $time_intervals,
  $user 
)
static countByResourceAndTimeRanges ( Resource  $resource,
  $time_ranges = [],
  $booking_types = [],
  $excluded_booking_ids = [] 
)
static

Counts all resource bookings for the specified resource and time range. By default, all bookings are counted. To count only bookings of a certain type set the $booking_type parameter.

See Also
findByResourceAndTimeRanges
createDeleteLogEntry ( )
createStoreLogEntry ( )
static deleteByResourceAndTimeRanges ( Resource  $resource,
  $time_ranges = [],
  $booking_types = [],
  $excluded_booking_ids = [] 
)
static

Deletes all resource bookings for the specified resource and time range. By default, all bookings are counted. To count only bookings of a certain type set the $booking_type parameter.

See Also
findByResourceAndTimeRanges
deleteIfNoInterval ( )

Deletes the ResourceBooking object if there are no ResourceBookingInterval objects attachted to it.

Returns
null|bool If the ResourceBooking object still has ResourceBookingInterval objects attachted to it, null is returned. Otherwise the return value of the SimpleORMap::delete method for the ResourceBooking object is returned.
deleteOverlappingBookings ( )

Deletes all bookings in the time ranges of this resource booking. Such bookings would prevent saving this booking.

Returns
int The amount of deleted bookings.
deleteOverlappingReservations ( )

Deletes all reservations in the time ranges of this resource booking.

Returns
int The amount of deleted reservations.
endsWithSemester ( )

Determines whether the resource booking ends on the same timestamp like the lecture time of one of the defined semesters.

Returns
True, if the resource booking ends with a semester, false otherwise.
static exportUserData ( StoredUserData  $storage)
static

Implements PrivacyObject.

static findByResourceAndTimeRanges ( Resource  $resource,
  $time_ranges = [],
  $booking_types = [],
  $excluded_booking_ids = [] 
)
static

Retrieves all resource booking for the given resource and time range. By default, all booking are returned. To get only bookings of a certain type set the $booking_type parameter.

Parameters
Resource$resourceThe resource whose requests shall be retrieved.
array$time_rangesAn array with time ranges as DateTime objects. The array has the following structure: [ [ 'begin' => begin timestamp, 'end' => end timestamp ], ... ]
array$booking_typesAn optional specification for the booking_type column in the database. More than one booking type can be specified. By default this is set to an empty array which means that resource booking are not filtered by the type column. The allowed resource booking types are specified in the class documentation.
array$excluded_booking_idsAn array of strings representing resource booking IDs. IDs specified in this array are excluded from the search.
Returns
ResourceBooking[] An array of ResourceRequest objects. If no requests can be found, the array is empty.
Exceptions
InvalidArgumentException,ifthe time ranges are either not in an array matching the format description from above or if one of the following conditions is met in one of the time ranges:
  • begin > end
  • begin == end
getAllEventData ( )

Returns all event data this event source can provide.

Returns
EventData[] An array of Studip objects.

Implements EventSource.

getAssignedUser ( )
getAssignedUserName ( )
getAssignedUsers (   $only_names = true)

Returns all allocating users: Users who are associated with this booking through a request or a course date for which this booking has been made (all allocating users). If no user could be determined but the booking is bound to a course, the course name is returned instead.

Parameters
bool$only_namesWhether only the names of these users shall be returned (true) or user objects shall be returned (false).
Returns
string[]|User[] Depending on the value of the $only_names parameter a string array or an user object array is returned. In case no user can be found, the array is empty. In case the parameter $only_names is set to true, the result may also contain a course name, if no users can be found but the booking is bound to a course.
getAssignedUserType ( )
getEventDataForTimeRange ( DateTime  $begin,
DateTime  $end 
)
getFilteredEventData (   $user_id = null,
  $range_id = null,
  $range_type = null,
  $begin = null,
  $end = null 
)

Allows a filtered output of event data based on a specified user, a specified range-ID and range type (must be supported by the Context class) or a specified time range. If no filters are applied the result should be the same as if the getAllEventData method from this interface is called.

Parameters
string$user_idThe user for whom the event data shall be retrieved. Depending on the implementation, this parameter might be necessary to check permissions for event objects.
string$range_idAn optional range-ID that may be necessary for an implementation to check for permissions.
string$range_typeAn optional range type that may be necessary for an implementation to check for permissions.
DateTime | int | string$beginThe begin date as DateTime object or unix timestamp.
DateTime | int | string$endThe end date as DateTime object or unix timestamp.
Returns
EventData[] An array of Studip objects.

Implements EventSource.

getOverlappingBookings ( )

Gets the bookings that overlap with this booking.

Returns
array Array of ResourceBooking objects
getRepeatModeString ( )
getRepetitionInterval ( )

Returns the DateInterval object according to the set repetition interval of this resource booking object.

Returns
DateInterval|null A DateInterval object or null, if this booking has no repetition interval.
getRepetitionType ( )
Returns
string
getTimeIntervals (   $with_exceptions = true)

Retrieves all time intervals for this resource booking.

Returns
ResourceBookingInterval[] An array of ResourceBookingInterval objects.
getTimeIntervalsInTimeRange ( DateTime  $begin,
DateTime  $end 
)

Retrieves all time intervals for this resource booking in a specified time range.

Parameters
DateTime$beginThe begin of the time range.
DateTime$endThe end of the time range.
Returns
ResourceBookingInterval[] An array of ResourceBookingInterval objects.
getTimeIntervalStrings ( )
hasExceptions ( )

Determins whether the booking has exceptions in repetitions or not. When the booking is bound to a course via a CourseDate instance, the exceptions are looked up using the corresponding metadate (if any). If a metadate exists to the course date and it has cancelled dates (metadate has CourseExDate instances assigned) then the booking has exceptions. If the booking is a simple booking, the exception status is determined by checking if the booking has ResourceBookingInterval instances that don't take place assigned to it. This is only checked, if a repetition interval is set for the booking so that such instances can exist.

Returns
bool True, if the booking has exceptions in the repetition, false otherwise.
hasOverlappingBookings ( )

Determines if the resource booking overlaps with another resource booking.

Returns
bool True, if there are other bookings which overlap with this one, false otherwise.
isReadOnlyForUser ( User  $user)

Determines wheter the booking is read only for a specified user.

Parameters
User$userThe user whose permissions shall be checked.
Returns
bool True, if the specified user may only perform reading actions on the booking, false otherwise.
isRepetitionInTimeframe ( DateTime  $begin,
DateTime  $end 
)

Determines whether this resource booking has a repetition in the specified time range.

Parameters
DateTime$begin
DateTime$end
Returns
bool True, if the booking has repetitions in the timeframe specified by $begin and $end, false otherwise.
isSimpleBooking ( )

Determines whether the booking is a simple booking that is not bound to course dates or similar Stud.IP objects.

sendDeleteNotification ( )

Sends a notification that the booking has been deleted to the user that created the booking.

store (   $force_booking = false)

The SimpleORMap::store method is overloaded to allow forced booking of resource bookings, meaning that all other bookings of the resource of a booking are deleted when they overlap with this booking.

Parameters
bool$force_bookingWhether booking shall be forced (true) or not (false). Defaults to false.
Returns
bool
updateIntervals (   $keep_exceptions = true)

This method updates the intervals of this resource booking which are stored in the resource_booking_intervals table.

userIsOwner ( User  $user)

Check if the specified user is the owner of the booking.

Parameters
User$userThe user whose ownership shall be tested.
Returns
bool True, if the specified user is the owner of the booking, false otherwise.
validate ( )

This validation method is called before storing an object.


The documentation for this class was generated from the following file: