Stud.IP  jlu_4.3 Revision 64286
ResourceBooking Class Reference
Inheritance diagram for ResourceBooking:
Inheritance graph
Collaboration diagram for ResourceBooking:
Collaboration graph

Public Member Functions

 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 ($time_intervals=[], $user)
 
 getAllEventData ()
 
 getEventDataForTimeRange (DateTime $begin, DateTime $end)
 
 getFilteredEventData ( $user_id=null, $range_id=null, $range_type=null, $begin=null, $end=null)
 
 getRepetitionType ()
 
- 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
 getAllEventData ()
 
 getEventDataForTimeRange (\DateTime $begin, \DateTime $end)
 
 getFilteredEventData ( $user_id=null, $range_id=null, $range_type=null, $begin=null, $end=null)
 

Static Public Member Functions

static findByCourse (Course $course)
 
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 $user_data)
 
- Static Public Member Functions inherited from SimpleORMap
static tableScheme ($db_table)
 
static expireTableScheme ()
 
static find ($id)
 
static exists ($id)
 
static countBySql ($sql=1, $params=array())
 
static create ($data)
 
static build ($data, $is_new=true)
 
static buildExisting ($data)
 
static import ($data)
 
static findBySQL ($sql, $params=array())
 
static findOneBySQL ($where, $params=array())
 
static findThru ($foreign_key_value, $options)
 
static findEachBySQL ($callable, $sql, $params=array())
 
static findMany ($pks=array(), $order='', $order_params=array())
 
static findEachMany ($callable, $pks=array(), $order='', $order_params=array())
 
static findAndMapBySQL ($callable, $where, $params=array())
 
static findAndMapMany ($callable, $pks=array(), $order='', $order_params=array())
 
static deleteBySQL ($where, $params=array())
 
static toObject ($id_or_object)
 
static __callStatic ($name, $arguments)
 
static exportUserData (StoredUserData $storage)
 

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 configure ($config=array())
 
static config ($key)
 

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)
 
 registerCallback ($types, $cb)
 
 unregisterCallback ($types, $cb)
 
 cbAutoIncrementColumn ($type)
 
 cbAutoKeyCreation ()
 
 cbNotificationMapper ($cb_type)
 
 cbAfterInitialize ($cb_type)
 
 setSerializedValue ($field, $value)
 
 setI18nValue ($field, $value)
 
 cbI18N ($type)
 
- Protected Attributes inherited from SimpleORMap
 $content = array()
 
 $content_db = array()
 
 $is_new = true
 
 $is_deleted = false
 
 $db_table = ''
 
 $db_fields = null
 
 $pk = null
 
 $default_values = array()
 
 $serialized_fields = array()
 
 $alias_fields = array()
 
 $i18n_fields = array()
 
 $additional_fields = array()
 
 $relations = array()
 
 $has_many = array()
 
 $has_one = array()
 
 $belongs_to = array()
 
 $has_and_belongs_to_many = array()
 
 $registered_callbacks = array()
 
 $known_slots = array()
 
 $notification_map = array()
 
 $additional_data = array()
 
 $getter_setter_map = array()
 
- Static Protected Attributes inherited from SimpleORMap
static $config = array()
 
static $reserved_slots = array('value','newid','iterator','tablemetadata', 'relationvalue','wherequery','relationoptions','data','new','id')
 

Member Function Documentation

◆ __toString()

__toString ( )

◆ buildResourceAndTimeRangesSqlQuery()

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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculateTimeIntervals()

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. ] ]
Here is the call graph for this function:
Here is the caller graph for this function:

◆ configure()

static configure (   $config = [])
staticprotected

set configuration data from subclass

Parameters
array$configconfiguration data
Returns
void

Reimplemented from SimpleORMap.

◆ convertToEventData()

convertToEventData (   $time_intervals = [],
  $user 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ countByResourceAndTimeRanges()

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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ deleteByResourceAndTimeRanges()

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
Here is the call graph for this function:

◆ deleteIfNoInterval()

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.
Here is the call graph for this function:

◆ deleteOverlappingBookings()

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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ deleteOverlappingReservations()

deleteOverlappingReservations ( )

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

Returns
int The amount of deleted reservations.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ endsWithSemester()

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.
Here is the call graph for this function:

◆ exportUserData()

static exportUserData ( StoredUserData  $storage)
static

Export available data of a given user into a storage object (an instance of the StoredUserData class) for that user.

Parameters
StoredUserData$storageobject to store data into

Implements PrivacyObject.

Here is the call graph for this function:

◆ findByCourse()

static findByCourse ( Course  $course)
static

Returns all resource bookings for a course by looking at all dates that are assigned to the course (regular and single dates).

Parameters
Course$courseThe course whose resource bookings shall be fetched.
Returns
ResourceBooking[] An array of resource booking objects if bookings can be found or an empty array, if no resource bookings can be found.
Here is the call graph for this function:

◆ findByResourceAndTimeRanges()

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
SimpleORMapCollection A SimpleORMapCollection of ResourceRequest objects. If no requests can be found the collection 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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAllEventData()

getAllEventData ( )

Returns all event data this event source can provide.

Returns
EventData[] An array of Studip\Calendar\EventData objects.

Implements EventSource.

Here is the call graph for this function:

◆ getAssignedUser()

getAssignedUser ( )
Here is the call graph for this function:

◆ getAssignedUserName()

getAssignedUserName ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAssignedUsers()

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.

Deprecated:
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.
Here is the call graph for this function:

◆ getAssignedUserType()

getAssignedUserType ( )
Here is the caller graph for this function:

◆ getEventDataForTimeRange()

getEventDataForTimeRange ( DateTime  $begin,
DateTime  $end 
)
Here is the call graph for this function:

◆ getFilteredEventData()

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\Calendar\EventData objects.

Implements EventSource.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getOverlappingBookings()

getOverlappingBookings ( )

Gets the bookings that overlap with this booking.

Returns
SimpleORMapCollection Collection of ResourceBooking objects
Here is the call graph for this function:

◆ getRepeatModeString()

getRepeatModeString ( )
Here is the call graph for this function:

◆ getRepetitionInterval()

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.
Here is the caller graph for this function:

◆ getRepetitionType()

getRepetitionType ( )
Returns
string
Here is the call graph for this function:

◆ getTimeIntervals()

getTimeIntervals (   $with_exceptions = true)

Retrieves all time intervals for this resource booking.

Returns
ResourceBookingInterval[] An array of ResourceBookingInterval objects.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTimeIntervalsInTimeRange()

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()

getTimeIntervalStrings ( )
Here is the call graph for this function:

◆ hasExceptions()

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.
Here is the call graph for this function:

◆ hasOverlappingBookings()

hasOverlappingBookings ( )

Determines if the resource booking overlaps with another resource booking.

Returns
True, if there are other bookings which overlap with this one, false otherwise.
Here is the call graph for this function:

◆ isReadOnlyForUser()

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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isRepetitionInTimeframe()

isRepetitionInTimeframe ( DateTime  $begin,
DateTime  $end 
)

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

Returns
bool True, if the booking has repetitions in the timeframe specified by $begin and $end, false otherwise.
Here is the call graph for this function:

◆ isSimpleBooking()

isSimpleBooking ( )

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ store()

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.
Here is the call graph for this function:

◆ updateIntervals()

updateIntervals (   $keep_exceptions = true)

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

Here is the call graph for this function:

◆ userIsOwner()

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.
Here is the caller graph for this function:

◆ validate()

validate ( )

This validation method is called before storing an object.

Here is the call graph for this function:

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