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

Public Member Functions

 __toString ()
 
 cbValidate ()
 
 getFullName ()
 
 getDefaultPictureUrl ()
 
 getIcon ($role='info')
 
 checkHierarchy ()
 
 getLink ($action='show', $link_parameters=[])
 
 getURL ($action='show', $url_parameters=[])
 
 findBuildings ()
 
 addChild (Resource $resource)
 
 createSimpleBooking (User $user, DateTime $begin, DateTime $end, $preparation_time=0, $description='', $internal_comment='', $booking_type=0)
 
 createBookingFromRequest (User $user, ResourceRequest $request, $preparation_time=0, $description='', $internal_comment='', $booking_type=0, $prepend_preparation_time=false, $notify_lecturers=false)
 
 createBooking (User $user, $range_id=null, $time_ranges=[], $repetition_interval=null, $repetition_amount=0, $repetition_end_date=null, $preparation_time=0, $description='', $internal_comment='', $booking_type=0, $force_booking=false)
 
 createSimpleRequest (User $user, DateTime $begin, DateTime $end, $comment='', $preparation_time=0)
 
 createRequest (User $user, $date_range_ids=null, $comment='', $properties=[], $preparation_time=0)
 
 createLock (User $user, DateTime $begin, DateTime $end, $internal_comment='')
 
 isAssigned (DateTime $begin, DateTime $end, $excluded_booking_ids=[])
 
 isReserved (DateTime $begin, DateTime $end, $excluded_reservation_ids=[])
 
 isLocked (DateTime $begin, DateTime $end, $excluded_lock_ids=[])
 
 isAvailable (DateTime $begin, DateTime $end, $excluded_booking_ids=[])
 
- Public Member Functions inherited from Resource
 store ()
 
 delete ()
 
 cbValidate ()
 
 __toString ()
 
 getFolder ()
 
 setFolder (ResourceFolder $folder)
 
 createFolder ()
 
 createSimpleBooking (User $user, DateTime $begin, DateTime $end, $preparation_time=0, $description='', $internal_comment='', $booking_type=0)
 
 createBookingFromRequest (User $user, ResourceRequest $request, $preparation_time=0, $description='', $internal_comment='', $booking_type=0, $prepend_preparation_time=false, $notify_lecturers=false)
 
 createBooking (User $user, $range_id=null, $time_ranges=[], $repetition_interval=null, $repetition_amount=0, $repetition_end_date=null, $preparation_time=0, $description='', $internal_comment='', $booking_type=0, $force_booking=false)
 
 createSimpleRequest (User $user, DateTime $begin, DateTime $end, $comment='', $preparation_time=0)
 
 createRequest (User $user, $date_range_ids=null, $comment='', $properties=[], $preparation_time=0)
 
 createLock (User $user, DateTime $begin, DateTime $end, $internal_comment='')
 
 getGroupedProperties ($excluded_properties=[])
 
 propertyExists ($name='')
 
 getPropertyObject ($name='')
 
 getProperty ($name='')
 
 getPropertyRelatedObject ($name='')
 
 setProperty ($name='', $state='', $user=null)
 
 setPropertiesByName ($properties=[], $user)
 
 setPropertiesById ($properties=[], $user=null)
 
 isPropertyEditable ($name='', User $user)
 
 setPropertyByDefinitionId ( $property_definition_id=null, $state=null)
 
 setPropertyRelatedObject ($name='', $object=null)
 
 deleteProperty ($name='', User $user)
 
 getPictureUrl ()
 
 getDefaultPictureUrl ()
 
 getIcon ($role='info')
 
 getPropertyArray ($only_requestable_properties=false)
 
 isAssigned (DateTime $begin, DateTime $end, $excluded_booking_ids=[])
 
 isReserved (DateTime $begin, DateTime $end, $excluded_reservation_ids=[])
 
 isLocked (DateTime $begin, DateTime $end, $excluded_lock_ids=[])
 
 isAvailable (DateTime $begin, DateTime $end, $excluded_booking_ids=[])
 
 isAvailableForRequest (ResourceRequest $request)
 
 getFullName ()
 
 setUserPermission (User $user, $perm='autor')
 
 deleteUserPermission (User $user)
 
 deleteAllPermissions ()
 
 getUserPermission (User $user, $time_range=[], $permanent_only=false)
 
 userHasPermission (User $user, $permission='user', $time_range=[], $permanent_only=false)
 
 userMayCreateChild (User $user)
 
 userHasBookingRights (User $user, $begin=null, $end=null)
 
 bookingPlanVisibleForUser (User $user, $time_range=[])
 
 findParentByClassName ($class_name='Resource')
 
 findChildrenByClassName ( $class_name='Resource', $depth=0, $convert_objects=true, $order_by_name=true)
 
 addChild (Resource $resource)
 
 getOpenResourceRequests (DateTime $begin, DateTime $end)
 
 getResourceBookings (DateTime $begin, DateTime $end)
 
 getResourceLocks (DateTime $begin, DateTime $end)
 
 hasFiles ()
 
 getDerivedClassInstance ()
 
 checkHierarchy ()
 
 getHierarchyPath ($separator='/', $prepend_root=true)
 
 getLink ($action='show', $link_parameters=[])
 
 getURL ($action='show', $url_parameters=[])
 
 getItemName ($long_format=true)
 
 getItemURL ()
 
 getItemAvatarURL ()
 
- 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 ()
 
 getItemName ($long_format=true)
 
 getItemURL ()
 
 getItemAvatarURL ()
 

Static Public Member Functions

static getTranslatedClassName ($item_count=1)
 
static findAll ()
 
static getLinkForAction ( $action='show', $id=null, $link_parameters=[])
 
static getURLForAction ( $action='show', $id=null, $url_parameters=[])
 
- Static Public Member Functions inherited from Resource
static getTranslatedClassName ($item_count=1)
 
static getRootResources ()
 
static getRequiredProperties ()
 
static getLinkForAction ( $action='show', $id=null, $link_parameters=[])
 
static getURLForAction ( $action='show', $id=null, $url_parameters=[])
 
- 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 Protected Member Functions

static configure ($config=[])
 
static buildPathForAction ($action='show', $id=null)
 
static configure ($config=[])
 
static buildPathForAction ($action='show', $id=null)
 
- 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 Resource
static $permission_cache
 
- 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 ( )

Reimplemented from Resource.

Here is the call graph for this function:

◆ addChild()

addChild ( Resource  $resource)

Adds a child resource to this location. The child resource must not be a resource of the Location class.

Parameters
Resource$resourceThe resource which shall be added as child.
Exceptions
InvalidResourceExceptionIf the specified resource belongs to the Location resource class.
Returns
True, if the resource could be added as child, false otherwise.

Reimplemented from Resource.

◆ buildPathForAction()

static buildPathForAction (   $action = 'show',
  $id = null 
)
staticprotected

Returns the part of the URL for getLink and getURL which will be placed inside the calls to URLHelper::getLink and URLHelper::getURL in these methods.

Reimplemented from Resource.

◆ cbValidate()

cbValidate ( )

Reimplemented from Resource.

◆ checkHierarchy()

checkHierarchy ( )

Checks if the place in the resource hierarchy (resource tree) is correct for this resource. This method has no function in this class but can be filled with logic in one of the classes derived from Resource.

Exceptions
NoResourceClassExceptionif the class name of this resource is not a derived class of the Resource class.
Returns
bool True, if this resource is correctly placed, false otherwise.

Reimplemented from Resource.

Here is the call graph for this function:

◆ configure()

static configure (   $config = [])
staticprotected

set configuration data from subclass

Parameters
array$configconfiguration data
Returns
void

Reimplemented from Resource.

◆ createBooking()

createBooking ( User  $user,
  $range_id = null,
  $time_ranges = [],
  $repetition_interval = null,
  $repetition_amount = 0,
  $repetition_end_date = null,
  $preparation_time = 0,
  $description = '',
  $internal_comment = '',
  $booking_type = 0,
  $force_booking = false 
)

A factory method for creating a ResourceBooking object for this resource.

Parameters
User$userThe user who wishes to create a resource booking.
string$range_idThe ID of the user (or the Stud.IP object) which owns the ResourceBooking.
Array[][]$time_rangesThe time ranges for the booking. At least one time range has to be specified using unix timestamps or DateTime objects. This array has the following structure: [ [ 'begin' => The begin timestamp or DateTime object. 'end' => The end timestamp or DateTime object. ] ]
DateInterval | null$repetition_intervalThe repetition interval for the new booking. This must be a DateInterval object if repetitions shall be stored. Otherwise this parameter must be set to null.
int$repeat_amountThe amount of repetitions. This parameter is only regarded if $repetition_interval contains a DateInterval object. In case repetitions are specified by their end date set this parameter to 0.
DateTime | string | null$repetition_end_dateThe end date of the repetition. This can either be an unix timestamp or a DateTime object and will only be regarded if $repetition_interval contains a DateInterval object. In case repetitions are specified by their amount set this parameter to null.
int$preparation_timeThe preparation time which is needed before the real start time. This will be substracted from the begin timestamp and stored in an extra column of the resource_bookings table.
string$descriptionAn optional description for the booking. This fields was previously known as "user_free_name".
string$internal_commentAn optional comment for the booking which is intended to be used internally in the room and resource administration staff.
int$booking_typeThe booking type. 0 = normal booking 1 = reservation 2 = lock booking
bool$force_bookingIf this parameter is set to true, overlapping bookings are removed before storing this booking.
Exceptions
InvalidArgumentExceptionIf no time ranges are specified or if there is an error regarding the time ranges.
ResourceBookingRangeExceptionIf $range_id is not set.
ResourceBookingOverlapExceptionIf the booking overlaps with another booking or a resource lock.
ResourcePermissionExceptionIf the specified user does not have sufficient permissions to create a resource booking.
ResourceBookingExceptionIf the repetition interval is invalid or if the resource booking cannot be stored.
Returns
ResourceBooking object.

Reimplemented from Resource.

◆ createBookingFromRequest()

createBookingFromRequest ( User  $user,
ResourceRequest  $request,
  $preparation_time = 0,
  $description = '',
  $internal_comment = '',
  $booking_type = 0,
  $prepend_preparation_time = false,
  $notify_lecturers = false 
)

Creates bookings from a request.

Parameters
ResourceRequest$requestThe request from which a resource booking shall be built.
bool$prepend_preparation_time,.If this is set to true, the preparation time will end before the start of the requested time. If $prepend_preparation_time is set to false (the default) the preparation time starts with the start of the requested time.
Exceptions
ResourceUnavailableExceptionif the resource cannot be assigned in at least one of the time ranges specified by the resource request.
ResourceRequestExceptionif the request could not be marked as resolved.
Returns
ResourceBooking[] A list of resource bookings matching the request.

Reimplemented from Resource.

◆ createLock()

createLock ( User  $user,
DateTime  $begin,
DateTime  $end,
  $internal_comment = '' 
)

Creates a lock booking for this resource.

Parameters
User$userThe user who wishes to create a lock booking.
DateTime$beginThe begin of the lock time range.
DateTime$endThe end of the lock time range.
string$internal_commentAn optional comment for the lock booking which is intended to be used internally in the room and resource administration staff.
Exceptions
AccessDeniedExceptionIf the user does not have sufficient permissions to lock this resource.
ResourceUnavailableExceptionIf a lock booking already exists in the specified time range.
Returns
ResourceBooking A ResourceBooking object.

Reimplemented from Resource.

◆ createRequest()

createRequest ( User  $user,
  $date_range_ids = null,
  $comment = '',
  $properties = [],
  $preparation_time = 0 
)

This method creates a resource request for this resource.

Parameters
User$userThe user who wishes to create a request.
string | Array$date_range_idsOne or more IDs of Stud.IP objects which can provide at least one time range. Objects which fulfill this requirement are course dates (CourseDate objects), cycle dates (SeminarCycleDate objects) and courses (Course objects). If only one ID is provided it can be passed as string. If multiple IDs are provided they have to be passed as array.
string$commentA comment for the resource request.
mixed[]$propertiesThe wishable properties for the resource request. The format of the array is as follows: [ 'property name' => 'property state' ]
int$preparation_timeThe requested preparation time before the begin of the requested time range. This parameter must be specified in seconds. Only positive values are accepted.
Exceptions
InvalidArgumentExceptionIf $date_range_id is not set. or no object which can provide at least one time range can be found with the specified ID.
ResourceNoTimeRangeExceptionIf no time range can be found by looking at the object, specified by its ID in $date_range_id.
ResourceUnavailableExceptionIf the resource is not available in the selected time range.
ResourceRequestExceptionIf the resource request cannot be stored.
Returns
ResourceRequest A resource request object.

Reimplemented from Resource.

◆ createSimpleBooking()

createSimpleBooking ( User  $user,
DateTime  $begin,
DateTime  $end,
  $preparation_time = 0,
  $description = '',
  $internal_comment = '',
  $booking_type = 0 
)

This is a simplified version of the createBooking method.

See also
Resource::createBooking

Reimplemented from Resource.

◆ createSimpleRequest()

createSimpleRequest ( User  $user,
DateTime  $begin,
DateTime  $end,
  $comment = '',
  $preparation_time = 0 
)

This method creates a simple request for this resource. A simple request is not bound to a date, metadate or course object and its time ranges. Instead the time range is specified directly. Note that simple resource requests do not support recurrence.

Parameters
User$userThe user who wishes to create a simple request.
DateTime$beginThe begin timestamp of the request.
DateTime$endThe end timestamp of the request.
string$commentA comment for the resource request.
int$preparation_timeThe requested preparation time before the begin of the requested time range. This parameter must be specified in seconds. Only positive values are accepted.
Exceptions
AccessDeniedExceptionIf the user is not permitted to request this resource.
InvalidArgumentExceptionIf the the timestamps provided by $begin and $end are invalid or if $begin is greater than or equal to $end which results in an invalid time range.
ResourceUnavailableExceptionIf the resource is not available in the selected time range.
ResourceRequestExceptionIf the resource request cannot be stored.
Returns
ResourceRequest A resource request object.

Reimplemented from Resource.

◆ findAll()

static findAll ( )
static

Returns all locations which are stored in the database.

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

◆ findBuildings()

findBuildings ( )

Retrieves the buildings which are associated to this location by looking up the child resources of this location.

Returns
Building[] An array with Building objects or an empty array if no buildings can be found.
Here is the call graph for this function:

◆ getDefaultPictureUrl()

getDefaultPictureUrl ( )

Returns the default picture for the resource class.

Classes derived from Resource should re-implement this method if they want to get a different default picture than the resource icon. The call to getPictureUrl will call the getDefaultPictureUrl method from the derived class.

Returns
string The URL to the picture.

Reimplemented from Resource.

Here is the call graph for this function:

◆ getFullName()

getFullName ( )

Returns the full (localised) name of the location.

Returns
string The full name of the location.

Reimplemented from Resource.

Here is the caller graph for this function:

◆ getIcon()

getIcon (   $role = 'info')

Returns the Icon for the resource class.

Classes derived from Resource should re-implement this method if they want to get a different icon than the resource icon.

Returns
Icon The icon for the resource.

Reimplemented from Resource.

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

◆ getLink()

getLink (   $action = 'show',
  $link_parameters = [] 
)

Returns the link for an action for this building. This is the non-static variant of Building::getLinkForAction.

Parameters
string$actionThe action which shall be executed. For locations the actions 'show', 'add', 'edit' and 'delete' are defined.
array$link_parametersOptional parameters for the link.
Returns
string The Link for the building action.

Reimplemented from Resource.

Here is the call graph for this function:

◆ getLinkForAction()

static getLinkForAction (   $action = 'show',
  $id = null,
  $link_parameters = [] 
)
static

Returns the appropriate link for the location action that shall be executed on a location.

Parameters
string$actionThe action which shall be executed. For locations the actions 'show', 'add', 'edit' and 'delete' are defined.
string$idThe ID of the location on which the specified action shall be executed.
array$link_parametersOptional parameters for the link.
Returns
string The Link for the location action.

Reimplemented from Resource.

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

◆ getTranslatedClassName()

static getTranslatedClassName (   $item_count = 1)
static

Returns a translation of the resource class name. The translated name can be singular or plural, depending on the value of the parameter $item_count.

Parameters
int$item_countThe amount of items the translation shall be made for. This is only used to determine, if a singular or a plural form shall be returned.
Returns
string The translated form of the class name, either in singular or plural.

Reimplemented from Resource.

◆ getURL()

getURL (   $action = 'show',
  $url_parameters = [] 
)

Returns the URL for an action for this location. This is the non-static variant of Location::getURLForAction.

Parameters
string$actionThe action which shall be executed. For locations the actions 'show', 'add', 'edit' and 'delete' are defined.
array$url_parametersOptional parameters for the URL.

Reimplemented from Resource.

Here is the call graph for this function:

◆ getURLForAction()

static getURLForAction (   $action = 'show',
  $id = null,
  $url_parameters = [] 
)
static

Returns the appropriate URL for the location action that shall be executed on a location.

Parameters
string$actionThe action which shall be executed. For locations the actions 'show', 'add', 'edit' and 'delete' are defined.
string$idThe ID of the location on which the specified action shall be executed.
array$url_parametersOptional parameters for the URL.
Returns
string The URL for the location action.

Reimplemented from Resource.

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

◆ isAssigned()

isAssigned ( DateTime  $begin,
DateTime  $end,
  $excluded_booking_ids = [] 
)

Shortcut method for ResourceBooking::countByResourceAndTimeRanges. Determines whether normal resource bookings exist in the specified time range.

Parameters
DateTime$beginTime range start timestamp.
DateTime$endTime range end timestamp.
$excluded_lock_idsThe IDs of bookings that shall be excluded from the determination of the "assigned" status.
Returns
bool True, if the resource is assigned in the specified time range, false otherwise.

Reimplemented from Resource.

◆ isAvailable()

isAvailable ( DateTime  $begin,
DateTime  $end,
  $excluded_booking_ids = [] 
)

Determines, if the resource is available (not assigned or locked) in a specified time range.

Parameters
DateTime$beginTime range start timestamp.
DateTime$endTime range end timestamp.
$excluded_booking_idsThe IDs of available bookings that shall be excluded from the determination of the "available" status.
Returns
bool True, if the resource is available in the specified time range, false otherwise.

Reimplemented from Resource.

◆ isLocked()

isLocked ( DateTime  $begin,
DateTime  $end,
  $excluded_lock_ids = [] 
)

Shortcut method for ResourceBooking::countByResourceAndTimeRanges. Determines whether resource locks exist in the specified time range.

Parameters
DateTime$beginTime range start timestamp.
DateTime$endTime range end timestamp.
$excluded_lock_idsThe IDs of lock bookings that shall be excluded from the determination of the "locked" status.
Returns
bool True, if the resource is locked in the specified time range, false otherwise.

Reimplemented from Resource.

◆ isReserved()

isReserved ( DateTime  $begin,
DateTime  $end,
  $excluded_reservation_ids = [] 
)

Shortcut method for ResourceBooking::countByResourceAndTimeRanges. Determines whether resource reservations exist in the specified time range.

Parameters
DateTime$beginTime range start timestamp.
DateTime$endTime range end timestamp.
$excluded_lock_idsThe IDs of reservation bookings that shall be excluded from the determination of the "reserved" status.
Returns
bool True, if the resource is reserved in the specified time range, false otherwise.

Reimplemented from Resource.


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