Stud.IP  5.4
ResourceRequest Class Reference
Inheritance diagram for ResourceRequest:
SimpleORMap PrivacyObject EventSource RoomRequest

Public Member Functions

 cbLogNewRequest ()
 
 cbAfterStore ()
 
 cbAfterDelete ()
 
 validate ()
 
 getDerivedClassInstance ()
 
 setRangeFields ($range_type='', $range_ids=[])
 
 closeRequest ($notify_lecturers=false, $bookings=[])
 
 getOverlappingRequests ()
 
 countOverlappingRequests ()
 
 getOverlappingBookings ()
 
 countOverlappingBookings ()
 
 getRepetitionInterval ()
 
 getStartDate ()
 
 getEndDate ()
 
 getStartSemester ()
 
 getEndSemester ()
 
 getRepetitionEndDate ()
 
 getGroupedTimeIntervals ($with_preparation_time=false, $with_past_intervals=true)
 
 getTimeIntervals ($with_preparation_time=false, $with_range=false, $with_past_intervals=true)
 
 getTimeIntervalStrings ()
 
 getTimeIntervalsInTimeRange (DateTime $begin, DateTime $end)
 
 getType ()
 
 getStatus ()
 
 getStatusText ()
 
 getDateString ($as_array=false, $with_past_intervals=true)
 
 getTypeString ($short=false)
 
 getAffectedDates ()
 
 getAvailableProperties ($excluded_property_names=[])
 
 getPropertyData ($excluded_property_names=[])
 
 propertyExists ($name)
 
 getProperty ($name)
 
 getPropertyObject ($name)
 
 setProperty ($name, $state='')
 
 updateProperties ($property_list=[], $accept_null_values=false)
 
 deletePropertyIfExists ($name='')
 
 getRangeName ()
 
 isSimpleRequest ()
 
 getRangeId ()
 
 getRangeType ()
 
 getRangeObject ()
 
 sendNewRequestMail ()
 
 sendCloseRequestMailToRequester ($bookings=[])
 
 sendCloseRequestMailToLecturers ($bookings=[])
 
 sendRequestDeniedMail ()
 
 isReadOnlyForUser (User $user)
 
 getAllEventData ()
 
 getEventDataForTimeRange (DateTime $begin, DateTime $end)
 
 getFilteredEventData ( $user_id=null, $range_id=null, $range_type=null, $begin=null, $end=null)
 
 getPriority ()
 
 getLoggingInfoText ()
 
- 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)
 
 isRelation ($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 exportUserdata (StoredUserData $storage)
 
static findAll ()
 
static findOpen ()
 
static findByResourceAndTimeRanges (Resource $resource, $time_ranges=[], $closed_status=null, $excluded_request_ids=[], $additional_conditions='', $additional_parameters=[])
 
static countByResourceAndTimeRanges (Resource $resource, $time_ranges=[], $closed_status=null, $excluded_request_ids=[], $additional_conditions='', $additional_parameters=[])
 
static findByCourse ($course_id)
 
static findByDate ($date_id)
 
static findByMetadate ($metadate_id)
 
static existsByCourse ($course_id, $request_is_open=false)
 
static existsByDate ($date_id, $request_is_open=false)
 
static existsByMetadate ($metadate_id, $request_is_open=false)
 
- 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 build ($data, $is_new=true)
 
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 (string $name, array $arguments)
 
- Static Public Member Functions inherited from PrivacyObject
static exportUserData (StoredUserData $storage)
 

Data Fields

const MARK_NONE = 0
 
const MARK_RED = 1
 
const MARK_YELLOW = 2
 
const MARK_GREEN = 3
 
const REPLY_REQUESTER = 'requester'
 
const REPLY_LECTURER = 'lecturer'
 
const STATE_OPEN = 0
 
const STATE_PENDING = 1
 
const STATE_CLOSED = 2
 
const STATE_DECLINED = 3
 
const MARKING_STATES = 4
 
- Data Fields inherited from SimpleORMap
const ID_SEPARATOR = '_'
 

Protected Member Functions

 convertToEventData (array $time_intervals, User $user)
 
- 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)
 
 cbNotificationMapper ($cb_type)
 
 cbAfterInitialize ($cb_type)
 
 setSerializedValue ($field, $value)
 
 setI18nValue ($field, $value)
 

Static Protected Member Functions

static configure ($config=[])
 
static buildResourceAndTimeRangesSqlQuery (Resource $resource, $time_ranges=[], $closed_status=null, $excluded_request_ids=[], $additional_conditions='', $additional_parameters=[])
 
- 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

- Static Public Attributes inherited from SimpleORMap
static $schemes = null
 
- 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

◆ buildResourceAndTimeRangesSqlQuery()

static buildResourceAndTimeRangesSqlQuery ( Resource  $resource,
  $time_ranges = [],
  $closed_status = null,
  $excluded_request_ids = [],
  $additional_conditions = '',
  $additional_parameters = [] 
)
staticprotected

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

See also
findByResourceAndTimeRanges

◆ cbAfterDelete()

cbAfterDelete ( )

◆ cbAfterStore()

cbAfterStore ( )

A callback method that send a mail when a new request has been udpated.

◆ cbLogNewRequest()

cbLogNewRequest ( )

A callback method that creates a Stud.IP log entry when a new request has been made.

◆ closeRequest()

closeRequest (   $notify_lecturers = false,
  $bookings = [] 
)

Closes the requests and sends out notification mails. If the request is closed and a resource has been booked, it can be passed as parameter to be included in the notification mails.

Parameters
bool$notify_lecturersWhether to notify lecturers of a course (true) or not (false). Defaults to false. Note that this parameter is only useful in case the request is bound to a course, either directly or via a course date or a course cycle date.
ResourceBooking$bookingsThe resource bookings that have been created from this request.
Returns
bool

◆ configure()

static configure (   $config = [])
staticprotected

◆ convertToEventData()

convertToEventData ( array  $time_intervals,
User  $user 
)
protected

◆ countByResourceAndTimeRanges()

static countByResourceAndTimeRanges ( Resource  $resource,
  $time_ranges = [],
  $closed_status = null,
  $excluded_request_ids = [],
  $additional_conditions = '',
  $additional_parameters = [] 
)
static

◆ countOverlappingBookings()

countOverlappingBookings ( )

Counts the resource bookings whose time ranges overlap with those of this resource request.

Returns
int The amount of overlapping resource bookings.

◆ countOverlappingRequests()

countOverlappingRequests ( )

Counts the resource requests whose time ranges overlap with those of this resource request.

Returns
int The amount of overlapping resource requests.

◆ deletePropertyIfExists()

deletePropertyIfExists (   $name = '')

◆ existsByCourse()

static existsByCourse (   $course_id,
  $request_is_open = false 
)
static

◆ existsByDate()

static existsByDate (   $date_id,
  $request_is_open = false 
)
static

◆ existsByMetadate()

static existsByMetadate (   $metadate_id,
  $request_is_open = false 
)
static

◆ exportUserdata()

static exportUserdata ( StoredUserData  $storage)
static

◆ findAll()

static findAll ( )
static

Retrieves all resource requests from the database.

Returns
ResourceRequest[] An array of ResourceRequests objects or an empty array, if no resource requests are stored in the database.

◆ findByCourse()

static findByCourse (   $course_id)
static

◆ findByDate()

static findByDate (   $date_id)
static

◆ findByMetadate()

static findByMetadate (   $metadate_id)
static

◆ findByResourceAndTimeRanges()

static findByResourceAndTimeRanges ( Resource  $resource,
  $time_ranges = [],
  $closed_status = null,
  $excluded_request_ids = [],
  $additional_conditions = '',
  $additional_parameters = [] 
)
static

Retrieves all resource requests for the given resource and time range. By default, all requests are returned. To get only open or closed requests set the $closed_status 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 ], ... ]
mixed$closed_statusAn optional status for the closed column in the database. By default this is set to null which means that resource requests are not filtered by the status column field. A value of 0 means only open requests are retrived. A value of 1 means only closed requests are retrieved.
array$excluded_request_idsAn array of strings representing resource request IDs. IDs specified in this array are excluded from the search.
Returns
ResourceRequest[] 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

◆ findOpen()

static findOpen ( )
static

Retrieves all open resource requests from the database.

Returns
ResourceRequest[] An array of ResourceRequests objects or an empty array, if no open resource requests are stored in the database.

◆ getAffectedDates()

getAffectedDates ( )

Returns an array of date objects which are affected by this ResourceRequest.

◆ getAllEventData()

getAllEventData ( )

Returns all event data this event source can provide.

Returns
EventData[] An array of Studip objects.

Implements EventSource.

◆ getAvailableProperties()

getAvailableProperties (   $excluded_property_names = [])
Parameters
array$excluded_property_namesReturns all resource property definitions for all properties which can be applied for this ResourceRequest by looking at the Resource category. If no resource category ID is set for the request an empty array is returned.

◆ getDateString()

getDateString (   $as_array = false,
  $with_past_intervals = true 
)

Returns a textual representation of the dates for which the request has been created.

Parameters
bool$as_arrayTrue, if an array with a string for each date (single or cycle date) shall be returned, false otherwise.
Returns
string|array Depending on the parameter $as_array, the text is returned as one string or as an array of strings for each date (single or cycle date).

◆ getDerivedClassInstance()

getDerivedClassInstance ( )

◆ getEndDate()

getEndDate ( )

◆ getEndSemester()

getEndSemester ( )

◆ getEventDataForTimeRange()

getEventDataForTimeRange ( DateTime  $begin,
DateTime  $end 
)

◆ 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 objects.

Implements EventSource.

◆ getGroupedTimeIntervals()

getGroupedTimeIntervals (   $with_preparation_time = false,
  $with_past_intervals = true 
)

Retrieves the time intervals by looking at metadate objects and other time interval sources and returns them grouped by metadate.

Parameters
bool$with_preparation_time
Returns
mixed[][][] A three-dimensional array with the following structure:
  • The first dimension has the metadate-id as index. For single dates an empty string is used as index.
  • The second dimension contains two elements:
    • 'metadate' => The metadate object. This is only set, if the request is for a metadate.
    • 'intervals' => The time intervals.
  • The third dimension contains a time interval in the following format: [ 'begin' => The begin timestamp 'end' => The end timestamp 'range' => The name of the range class that provides the range_id. This is usually the name of the SORM class. 'range_id' => The ID of the single date or ResourceRequestAppointment. ]

◆ getLoggingInfoText()

getLoggingInfoText ( )

◆ getOverlappingBookings()

getOverlappingBookings ( )

Returns the resource bookings whose time ranges overlap with those of this resource request.

Returns
ResourceBooking[] An array of ResourceBooking objects.

◆ getOverlappingRequests()

getOverlappingRequests ( )

Returns the resource requests whose time ranges overlap with those of this resource request.

Returns
ResourceRequest[] An array of ResourceRequest objects.

◆ getPriority()

getPriority ( )

◆ getProperty()

getProperty (   $name)
Parameters
$nameReturns the state of the property specified by $name.

◆ getPropertyData()

getPropertyData (   $excluded_property_names = [])

Returns a "compressed" array of resource request properties.

Parameters
array$excluded_property_names
Returns
array An associative array where the keys represent the property names and the values represent the property states. Note that the value can be an array in case of range properties.

◆ getPropertyObject()

getPropertyObject (   $name)
Parameters
$name
Returns
ResourceRequestProperty
Exceptions
InvalidResourceCategoryExceptionIf this resource category doesn't match the category of the resource request object.
ResourcePropertyExceptionIf the name of the resource request property is not defined for this resource category.

◆ getRangeId()

getRangeId ( )

◆ getRangeName()

getRangeName ( )

◆ getRangeObject()

getRangeObject ( )

◆ getRangeType()

getRangeType ( )

◆ getRepetitionEndDate()

getRepetitionEndDate ( )

◆ getRepetitionInterval()

getRepetitionInterval ( )

Returns the repetion interval if regular appointments are used for this request.

Returns
DateInterval|null In case regular appointments are used for this request a DateInterval is returned. Otherwise null is returned.

◆ getStartDate()

getStartDate ( )

◆ getStartSemester()

getStartSemester ( )

◆ getStatus()

getStatus ( )

Returns a string representation of the status of the ResourceRequest.

◆ getStatusText()

getStatusText ( )

Returns a textual representation of the status of the ResourceRequest.

◆ getTimeIntervals()

getTimeIntervals (   $with_preparation_time = false,
  $with_range = false,
  $with_past_intervals = true 
)

Retrieves the time intervals for this request.

Parameters
bool$with_preparation_timeWhether the preparation time of the request shall be prepended to the begin timestamp (true) or whether it should not be included at all (false). Defaults to false.
bool$with_rangeWhether to include data of the Stud.IP range and its corresponding ID to the request (true) or not (false). Defaults to false.
bool$with_past_intervalsWhether to include past intervals (true) or only include intervals from the current time and the future (false). Defaults to true.
Returns
string[][] A two-dimensional array of unix timestamps. The first dimension contains one entry for each date, the second dimension contains the start and end timestamp for the date. The second dimension uses the array keys 'begin' and 'end' for start and end date. If the parameter is set to true, the second array dimension also contains the key 'range' for specifying the range type and 'range_id' for specifying the ID of the range object. The range can be "CourseDate", "ResourceRequestAppointment" or "User". The last two can only be present for simple requests that are not bound to a course. The range "CourseDate" can only occur on course-bound requests.

◆ getTimeIntervalsInTimeRange()

getTimeIntervalsInTimeRange ( DateTime  $begin,
DateTime  $end 
)

Filters the time intervals for this request by a specified time range.

See also
ResourceRequest::getTimeIntervals for the return format.

◆ getTimeIntervalStrings()

getTimeIntervalStrings ( )

Returns a string representation of the time intervals for this request.

◆ getType()

getType ( )

Returns a string representation of the ResourceRequest's type.

◆ getTypeString()

getTypeString (   $short = false)

Returns a human-readable string describing the type of the request.

Parameters
bool$shortIf this parameter is set to true, only the type of the request is returned without any information about the appointments. Otherwise, appointment information like the date or the repetition are appended. Defaults to false.
Returns
string

◆ isReadOnlyForUser()

isReadOnlyForUser ( User  $user)

◆ isSimpleRequest()

isSimpleRequest ( )

◆ propertyExists()

propertyExists (   $name)
Parameters
$name
Returns
bool

◆ sendCloseRequestMailToLecturers()

sendCloseRequestMailToLecturers (   $bookings = [])
Parameters
array$bookingsThis method sends mails to the lecurers of the course (if any) where this request has been assigned to. The sent mail informs them about the closing of the request.

◆ sendCloseRequestMailToRequester()

sendCloseRequestMailToRequester (   $bookings = [])
Parameters
array$bookingsThis method sends a mail to inform the requester that the request has been closed.

◆ sendNewRequestMail()

sendNewRequestMail ( )

This method sends a notification mail to all room administrators that informs them of this new request.

◆ sendRequestDeniedMail()

sendRequestDeniedMail ( )

This method sends a mail to inform the requester about the denial of the request.

◆ setProperty()

setProperty (   $name,
  $state = '' 
)
Parameters
string$name
string$state
Returns
bool True, if the property state could be set, false otherwise.

◆ setRangeFields()

setRangeFields (   $range_type = '',
  $range_ids = [] 
)

Sets the range fields (termin_id, metadate_id, course_id) or the ResourceRequestAppointment objects related to this request according to the range type and its range-IDs specified as parameters for this method. The ResourceRequest object is not stored after setting the fields / related objects.

Parameters
string$range_typeThe range type for this request. One of the following: 'date', 'cycle', 'course' or 'date-multiple'.
array$range_idsAn array of range-IDs to be set for the specified range type. This is mostly an array of size one since the fields termin_id, metadate_id and course_id only accept one ID. The range type 'date-multiple' accepts multiple IDs.
Returns
void No return value.

◆ updateProperties()

updateProperties (   $property_list = [],
  $accept_null_values = false 
)

Sets or unsets the properties for this resource request.

Parameters
array$property_listThe properties which shall be set or unset. The array has the following structure: [ property_name => property_value ]
bool$accept_null_valuesTrue, if a value of null shall be used when setting the property. If $accept_null_values is set to false all properties with a value equal to null will be deleted.
Returns
null

◆ validate()

validate ( )

This validation method is called before storing an object.

Field Documentation

◆ MARK_GREEN

const MARK_GREEN = 3

◆ MARK_NONE

const MARK_NONE = 0

◆ MARK_RED

const MARK_RED = 1

◆ MARK_YELLOW

const MARK_YELLOW = 2

◆ MARKING_STATES

const MARKING_STATES = 4

The amount of defined marking states.

◆ REPLY_LECTURER

const REPLY_LECTURER = 'lecturer'

◆ REPLY_REQUESTER

const REPLY_REQUESTER = 'requester'

◆ STATE_CLOSED

const STATE_CLOSED = 2

◆ STATE_DECLINED

const STATE_DECLINED = 3

◆ STATE_OPEN

const STATE_OPEN = 0

◆ STATE_PENDING

const STATE_PENDING = 1

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