Stud.IP  5.4
RoomManager Class Reference

Static Public Member Functions

static findRoomsByRequest (ResourceRequest $request, $excluded_room_ids=[])
 
static userHasRooms (User $user, $level='user', $permanent_only=false, $time=null, $sql_conditions='', $sql_condition_parameters=[])
 
static countUserRooms (User $user, $level='user', $permanent_only=false, $time=null, $sql_conditions='', $sql_condition_parameters=[])
 
static getUserRooms (User $user, $level='user', $permanent_only=false, $time=null, $sql_conditions='', $sql_condition_parameters=[])
 
static createRoomBookingsByRequest (Room $room, RoomRequest $room_request, User $user, $notify_teachers=true)
 
static getBookingIntervalsForRoom (Room $room, DateTime $begin, DateTime $end, $booking_types=[ResourceBooking::TYPE_NORMAL, ResourceBooking::TYPE_RESERVATION, ResourceBooking::TYPE_LOCK, ResourceBooking::TYPE_PLANNED,], $building_booking_types=[ResourceBooking::TYPE_NORMAL, ResourceBooking::TYPE_RESERVATION, ResourceBooking::TYPE_LOCK, ResourceBooking::TYPE_PLANNED,], $exclude_canceled_intervals=true)
 
static findRooms ( $room_name='', $location_id=null, $building_id=null, $properties=[], $time_ranges=[], $order_by=null, $only_requestable_rooms=true, $excluded_room_ids=[], $only_fully_available=true)
 
static findOverbookedRoomBookings (DateTime $begin, DateTime $end)
 
static getAllRoomPropertyDefinitions ( $only_searchable=false, $excluded_properties=[])
 
static getHierarchyNames (Room $room, $all_items=false)
 
static groupRooms ($rooms=[])
 
static getAllRoomClassNames ()
 
static countRequestableRooms (array $time_ranges=[])
 
static findRequestableRooms (array $time_ranges=[])
 

Static Protected Member Functions

static getUserRoomsSqlData (User $user, $level='user', $permanent_only=false, $time=null, $sql_conditions='', $sql_condition_parameters=[], $sql_order_by='ORDER BY resources.sort_position DESC, resources.name ASC')
 
static getRequestableRoomsSqlData (array $time_ranges=[])
 

Detailed Description

The RoomManager class contains methods that simplify the handling of rooms which are one type of resources.

Member Function Documentation

◆ countRequestableRooms()

static countRequestableRooms ( array  $time_ranges = [])
static

◆ countUserRooms()

static countUserRooms ( User  $user,
  $level = 'user',
  $permanent_only = false,
  $time = null,
  $sql_conditions = '',
  $sql_condition_parameters = [] 
)
static

Counts all rooms for which the specified user has permanent or temporary permissions. Root users and global resource admins get the amount of rooms in the Stud.IP system as result.

Parameters
User$userThe user whose rooms shall be retrieved.
string$levelThe minimum permission level the user must have on a room so that it will be included in the result set. Defaults to the "user" permission level.
bool$permanent_onlyWhether to count only rooms with permanent permissions (true) or rooms with permanent and temporary permissions (false). Defaults to false.
DateTime | int | null$timeThe timestamp for the check on temporary permissions. If this parameter is not set the current timestamp will be used.
string$sql_conditionsAn optional SQL condition that will be placed in the WHERE block of the SQL query to filter the result set.
array$sql_condition_parametersAn optional associative array for the sql condition parameter containing variable parameters that shall be used in the SQL query.

◆ createRoomBookingsByRequest()

static createRoomBookingsByRequest ( Room  $room,
RoomRequest  $room_request,
User  $user,
  $notify_teachers = true 
)
static
Parameters
bool$notify_teachersTrue, if the teachers of the course where the room request belongs to shall be notified, false otherwise. This parameter is only useful for room requests made for courses and their dates.

◆ findOverbookedRoomBookings()

static findOverbookedRoomBookings ( DateTime  $begin,
DateTime  $end 
)
static

Searches for room bookings where the room is overbooked in the specified time range. A room is overbooked if a resource booking exists for that room which is associated with a course and the amount of course participants is higher than the amount of seats in the room.

Parameters
DateTime$beginThe begin of the time range.
DateTime$endThe end of the time range.
Returns
SimpleORMapCollection A collection of overbooked room bookings as ResourceBooking objects.

◆ findRequestableRooms()

static findRequestableRooms ( array  $time_ranges = [])
static

◆ findRooms()

static findRooms (   $room_name = '',
  $location_id = null,
  $building_id = null,
  $properties = [],
  $time_ranges = [],
  $order_by = null,
  $only_requestable_rooms = true,
  $excluded_room_ids = [],
  $only_fully_available = true 
)
static

Finds rooms by name, time range and which (at your option) meet the requirements specified by other properties. If a property isn't specified it won't be searched for.

Parameters
string$room_nameThe name of the room.
string$location_idThe ID of the location where the room shall lie in.
string$building_id
string[]$properties An array of properties and their desired states. This array has the following structure: $properties['property_name'] = 'property_state'; The array keys specify the property names, the entries of the array specify the desired state. Only the seats property may be a single value or an array with two entries. In the first case the room must have at least $seats seats. In the latter case the room must have between $seats[0] and $seats[1] seats. There are special pseudo properties that are handled by this array:
  • room_category_id: The id of a resource category that has 'Room' as class name.
array$time_rangesOptional time ranges where the rooms have to be available. The format of the array is the following: [ [ 'begin' => (begin timestamp or DateTime object), 'end' => (end timestamp or DateTime object) ] ]
string$order_byAn optional SQL snippet specifying the order of the results. Defaults to null (no sorting).
bool$only_requestable_roomsWhether the search shall be limited to requestable rooms only (true) or not (false).
array$excluded_room_ids
bool$only_fully_availableWhether only rooms shall be added to the result set that are fully available in the requested time ranges (true) or whether rooms shall be added that are only partially available in those time ranges (false). Defaults to true.
Returns
array

◆ findRoomsByRequest()

static findRoomsByRequest ( ResourceRequest  $request,
  $excluded_room_ids = [] 
)
static

◆ getAllRoomClassNames()

static getAllRoomClassNames ( )
static
Returns
string[] A list containing class names of all classes that are derived from the Room class and the Room class itself.

◆ getAllRoomPropertyDefinitions()

static getAllRoomPropertyDefinitions (   $only_searchable = false,
  $excluded_properties = [] 
)
static

Retrieves all properties that are bound to room resource categories or room resources directly.

Parameters
bool$only_searchableWhether only searchable properties shall be returned (true) or all properties shall be returned (false). Defaults to false.
string[]$excluded_properties An array containing the names of the properties that shall be excluded from the result set.
Returns
ResourcePropertyDefinition[] An array of ResourcePropertyDefinition objects.

◆ getBookingIntervalsForRoom()

static getBookingIntervalsForRoom ( Room  $room,
DateTime  $begin,
DateTime  $end,
  $booking_types = ResourceBooking::TYPE_NORMAL,
ResourceBooking::TYPE_RESERVATION  ,
ResourceBooking::TYPE_LOCK  ,
ResourceBooking::TYPE_PLANNED  ,
,
  $building_booking_types = ResourceBooking::TYPE_NORMAL,
ResourceBooking::TYPE_RESERVATION  ,
ResourceBooking::TYPE_LOCK  ,
ResourceBooking::TYPE_PLANNED  ,
,
  $exclude_canceled_intervals = true 
)
static

◆ getHierarchyNames()

static getHierarchyNames ( Room  $room,
  $all_items = false 
)
static

Returns the names of all hierarchy elements from the location to the specified room.

Parameters
Room$roomThe room to start with.
bool$all_itemsWhether to include all resource item names while traversing the tree upwards (true) or to only include the names of the room, the building and the location (false).
Returns
string[] An array with the names of the hierarchy elements, starting with the location name.

◆ getRequestableRoomsSqlData()

static getRequestableRoomsSqlData ( array  $time_ranges = [])
staticprotected

This method creates the SQL data for the methods countRequestableRooms and findRequestableRooms.

Parameters
arraytime_ranges[][] The time ranges in which a requestable room must be available to be included in the result set. This is a two-dimensional array where the second dimension is an associative array with two indexes: "begin" and "end". These can either be timestamps or DateTime objects representing the begin and end of the time range, respectively.
Returns
array An associative array with two indexes:
  • sql: The SQL query as string.
  • sql_params: An associative array with all parameters for the query.

◆ getUserRooms()

static getUserRooms ( User  $user,
  $level = 'user',
  $permanent_only = false,
  $time = null,
  $sql_conditions = '',
  $sql_condition_parameters = [] 
)
static

Retrieves all rooms for which the specified user has permanent or temporary permissions. Root users and global resource admins get a list of all rooms stored in the Stud.IP system.

Parameters
User$userThe user whose rooms shall be retrieved.
bool$permanent_onlyWhether to retrieve only rooms with permanent permissions (true) or rooms with permanent and temporary permissions (false). Defaults to false.
string$levelThe minimum permission level the user must have on a room so that it will be included in the result set.
string$sql_conditionsAn optional SQL condition that will be placed in the WHERE block of the SQL query to filter the result set.
array$sql_condition_parametersAn optional associative array for the sql condition parameter containing variable parameters that shall be used in the SQL query.
DateTime | int | null$timeThe timestamp for the check on temporary permissions. If this parameter is not set the current timestamp will be used.
Returns
Room[]

◆ getUserRoomsSqlData()

static getUserRoomsSqlData ( User  $user,
  $level = 'user',
  $permanent_only = false,
  $time = null,
  $sql_conditions = '',
  $sql_condition_parameters = [],
  $sql_order_by = 'ORDER BY resources.sort_position DESC,
resources.name ASC'   
)
staticprotected

Helper method that creates the identical SQL query for the countUserRooms and findUserRooms methods.

◆ groupRooms()

static groupRooms (   $rooms = [])
static

Groups rooms by their location and building.

Parameters
Room[]$rooms An array of rooms that shall be grouped.
Returns
Array[][][] A three dimensional array with the whole hierarchy for the specified rooms. The array structure is as follows: [ [ 'location' => Location object 'buildings' => [ 'building' => Building object 'rooms' => Array of room objects. ] ] ]

◆ userHasRooms()

static userHasRooms ( User  $user,
  $level = 'user',
  $permanent_only = false,
  $time = null,
  $sql_conditions = '',
  $sql_condition_parameters = [] 
)
static

Checks whether the specified user has at least one permanent or temporary permission on at least one room. Root users and global resource admins always have permanent permissions.

Parameters
User$userThe user whose permissions shall be checkec.
string$levelThe minimum permission level the user must have on a room so that it will be accepted for the check. Defaults to the "user" permission level.
bool$permanent_onlyWhether to count only rooms with permanent permissions (true) or rooms with permanent and temporary permissions (false). Defaults to false.
string$sql_conditionsAn optional SQL condition that will be placed in the WHERE block of the SQL query to filter the result set.
array$sql_condition_parametersAn optional associative array for the sql condition parameter containing variable parameters that shall be used in the SQL query.
DateTime | int | null$timeThe timestamp for the check on temporary permissions. If this parameter is not set the current timestamp will be used.
Returns
bool True, when the user has permissions for at least one room, false otherwise.

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