|
| static | createCategory ( $name=null, $description=null, $class_name='Resource', $is_system_category=false, $iconnr='1', $properties=[]) |
| |
| static | createLocationCategory ( $name=null, $description=null, $additional_properties=[]) |
| |
| static | createBuildingCategory ( $name=null, $description=null, $additional_properties=[]) |
| |
| static | createRoomCategory ( $name=null, $description=null, $additional_properties=[]) |
| |
| static | copyResource (Resource $resource, $copy_hierarchy=true, $new_parent_id=null) |
| |
| static | moveResource (Resource $target, Resource $destination) |
| |
| static | countUserResources (User $user, $level='user', $time=null, $class_names=[]) |
| |
| static | getUserResources (User $user, $level='user', $time=null, $class_names=[], $convert_objects=true) |
| |
| static | getPositionArray (ResourceProperty $property) |
| |
| static | getPositionString (ResourceProperty $property, $with_altitude=false) |
| |
| static | getMapUrlForResourcePosition (ResourceProperty $property) |
| |
| static | getGlobalResourcePermission (User $user) |
| |
| static | userHasResourcePermissions (User $user, $level='admin', $time=null) |
| |
| static | getLowerPermissionLevels ($level='user') |
| |
| static | getHigherPermissionLevels ($level='user') |
| |
| static | comparePermissionLevels ( $level='user', $other_level='user') |
| |
| static | userHasGlobalPermission (User $user, $requested_permission='user') |
| |
| static | countResourcesWithPermissions (User $user, $requested_permission='user', $exclude_temporary_permissions=false) |
| |
| static | userHasSpecialPermissions (User $user, $requested_permission='user') |
| |
| static | getTimeRangesFromRangeId ($range_id=null) |
| |
| static | getUserInactivityInterval (User $user, DateTime $time) |
| |
| static | getBookingPlanObjects (Resource $resource, $time_ranges=[], $allowed_booking_types=[], $included_requests=null) |
| |
| static | getAllResourceClassNames ($excluded_classes=[]) |
| |
The ResourceManager class contains methods that simplify the use of Resources.
◆ comparePermissionLevels()
| static comparePermissionLevels |
( |
|
$level = 'user', |
|
|
|
$other_level = 'user' |
|
) |
| |
|
static |
Compares two resource permission levels and returns an integer telling if the first level is less than (-1), equal (0) or greater than (1) the second level.
- Parameters
-
| string | $level | The first permission level. |
| string | $other_level | The second permission level. |
- Exceptions
-
| InvalidArgumentException | if $level or $other_level are either not set or if they contain invalid permission level strings. |
- Returns
- integer -1 if $level is less than $other_level, 0 if both are equal, 1 if $level is greater than $other_level.
◆ copyResource()
| static copyResource |
( |
Resource |
$resource, |
|
|
|
$copy_hierarchy = true, |
|
|
|
$new_parent_id = null |
|
) |
| |
|
static |
Creates a copy of a resource and stores the copy in the database.
- Parameters
-
| Resource | $resource | The resource which shall be copied. |
| bool | $copy_hierarchy | True, if the resource's children shall also be copied (default). False otherwise. |
| string | $new_parent_id | If this is set the original parent_id will be overwritten with the ID in $new_parent_id. |
- Exceptions
-
- Returns
- Resource A copy of the resource.
◆ countResourcesWithPermissions()
| static countResourcesWithPermissions |
( |
User |
$user, |
|
|
|
$requested_permission = 'user', |
|
|
|
$exclude_temporary_permissions = false |
|
) |
| |
|
static |
Counts the resources where the specified user has explicit permissions set, optionally limiting the result to permanent permissions.
- Parameters
-
| User | $user | The user whose resource permissions shall be checked. |
| string | $requested_permission | The required minimum permission level for the user. |
- Returns
- int The amount of resources where the specified user has explicit permissions for.
◆ countUserResources()
| static countUserResources |
( |
User |
$user, |
|
|
|
$level = 'user', |
|
|
|
$time = null, |
|
|
|
$class_names = [] |
|
) |
| |
|
static |
Counts all resources for which the specified user has permanent or temporary permissions.
- Parameters
-
| User | $user | The user whose resources shall be retrieved. |
| string | $level | The minimum permission level the user must have on a resource so that it will be included in the result set. |
| DateTime | int | null | $time | The timestamp for the check on temporary permissions. If this parameter is not set the current timestamp will be used. |
| string[] | $class_names | A list of resource classes that will be used to filter the result set so that only resources being a member of one of the specified resource classes will be retrieved. |
◆ createBuildingCategory()
| static createBuildingCategory |
( |
|
$name = null, |
|
|
|
$description = null, |
|
|
|
$additional_properties = [] |
|
) |
| |
|
static |
Simplifies the creation of a building resource category.
- Parameters
-
| string | $name | The name of the new resource category. |
| string | $description | The description of the new resource category. |
| string[] | $additional_properties | A two-dimensional array with the names and requestable, protected and system flags. See ResourceManager::createCategory for a description of the format of the second array dimension. |
- Exceptions
-
| ResourceCategoryException | In case if no name is set or a resource property doesn't exist, if the category's name is ambigous or if the new category cannot be stored, a ResourceCategoryException is thrown. |
- Returns
- ResourceCategory A new ResourceCategory object.
◆ createCategory()
| static createCategory |
( |
|
$name = null, |
|
|
|
$description = null, |
|
|
|
$class_name = 'Resource', |
|
|
|
$is_system_category = false, |
|
|
|
$iconnr = '1', |
|
|
|
$properties = [] |
|
) |
| |
|
static |
Simplifies the creation of a resource category.
- Parameters
-
| string | $name | The name of the new resource category. |
| string | $description | The description of the new resource category. |
| string | $class_name | The class (derived from Resource) which shall be used for resources created with the new category. |
| bool | $is_system_category | True, if the category shall be a system category, false otherwise. |
| string | $iconnr | The number of the icon for the resource category. |
| mixed[] | $properties | A two-dimensional array with the names and requestable, protected and system flags. The second dimension of the array must have the following structure: [ property name (string), requestable flag (boolean), protected flag (boolean), system-flag (boolean) ]. |
- Exceptions
-
| ResourceCategoryException | In case if no name is set or a resource property doesn't exist, if the category's name is ambigous or if the new category cannot be stored, a ResourceCategoryException is thrown. |
- Returns
- ResourceCategory A new ResourceCategory object.
◆ createGlobalLock()
| createGlobalLock |
( |
User |
$user, |
|
|
DateTime |
$begin, |
|
|
DateTime |
$end, |
|
|
|
$ignore_bookings = false |
|
) |
| |
This method allows locking the resource management globally. The user who creates the lock must have admin permissions and the time interval must not lie in another global resource lock interval.
- Parameters
-
| User | $user | The user who wishes to lock the room and resource management globally. |
| DateTime | $begin | The begin timestamp of the lock. |
| DateTime | $end | The end timestamp of the lock. |
- Exceptions
-
- Returns
- GlobalResourceLock object.
◆ createLocationCategory()
| static createLocationCategory |
( |
|
$name = null, |
|
|
|
$description = null, |
|
|
|
$additional_properties = [] |
|
) |
| |
|
static |
Simplifies the creation of a location resource category.
- Parameters
-
| string | $name | The name of the new resource category. |
| string | $description | The description of the new resource category. |
| string[] | $additional_properties | A two-dimensional array with the names and requestable, protected and system flags. See ResourceManager::createCategory for a description of the format of the second array dimension. |
- Exceptions
-
| ResourceCategoryException | In case if no name is set or a resource property doesn't exist, if the category's name is ambigous or if the new category cannot be stored, a ResourceCategoryException is thrown. |
- Returns
- ResourceCategory A new ResourceCategory object.
◆ createRoomCategory()
| static createRoomCategory |
( |
|
$name = null, |
|
|
|
$description = null, |
|
|
|
$additional_properties = [] |
|
) |
| |
|
static |
Simplifies the creation of a room resource category.
- Parameters
-
| string | $name | The name of the new resource category. |
| string | $description | The description of the new resource category. |
| string[] | $additional_properties | A two-dimensional array with the names and requestable, protected and system flags. See ResourceManager::createCategory for a description of the format of the second array dimension. |
- Exceptions
-
| ResourceCategoryException | In case if no name is set or a resource property doesn't exist, if the category's name is ambigous or if the new category cannot be stored, a ResourceCategoryException is thrown. |
- Returns
- ResourceCategory A new ResourceCategory object.
◆ getAllResourceClassNames()
| static getAllResourceClassNames |
( |
|
$excluded_classes = [] | ) |
|
|
static |
◆ getBookingPlanObjects()
| static getBookingPlanObjects |
( |
Resource |
$resource, |
|
|
|
$time_ranges = [], |
|
|
|
$allowed_booking_types = [], |
|
|
|
$included_requests = null |
|
) |
| |
|
static |
Retrieves booking plan objects like resource bookings and requests.
- Parameters
-
| string | null | $included_request_types | If this parameter is a string, it can have the values 'all' for retrieving all requests or the ID of a user so that only requests of that user are retrieved. |
◆ getGlobalResourcePermission()
| static getGlobalResourcePermission |
( |
User |
$user | ) |
|
|
static |
Returns the resource management global permissions for a user, determined by the assigned roles and by the user's global permissions. This method does the mapping from the old resource management permissions to the new resource management permissions.
◆ getHigherPermissionLevels()
| static getHigherPermissionLevels |
( |
|
$level = 'user' | ) |
|
|
static |
Returns all permission levels higher than the specified level.
◆ getLowerPermissionLevels()
| static getLowerPermissionLevels |
( |
|
$level = 'user' | ) |
|
|
static |
Returns all permission levels lower than the specified level.
◆ getMapUrlForResourcePosition()
◆ getPositionArray()
◆ getPositionString()
◆ getTimeRangesFromRangeId()
| static getTimeRangesFromRangeId |
( |
|
$range_id = null | ) |
|
|
static |
Get time ranges by looking at the object specified by its ID. This method works with CourseDate, SeminarCycleDate and Course objects.
- Parameters
-
| string | $range_id | The ID of a Stud.IP object. |
- Returns
- Array An Array consisting of arrays of DateTime objects. The structure of the array is as follows: [ [ begin timestamp DateTime object end timestamp DateTime object ], ... ]
◆ getUserInactivityInterval()
| static getUserInactivityInterval |
( |
User |
$user, |
|
|
DateTime |
$time |
|
) |
| |
|
static |
Determines the last booking of the user and calculates the timespan from the last booking until now.
- Returns
- DateInterval|null|false Either a date interval from the last activity to the provided DateTime object or null in case the user has never been active. False is returned in case the timestamp comparison fails.
- See also
- DateTime::diff in the PHP Documentation.
◆ getUserResources()
| static getUserResources |
( |
User |
$user, |
|
|
|
$level = 'user', |
|
|
|
$time = null, |
|
|
|
$class_names = [], |
|
|
|
$convert_objects = true |
|
) |
| |
|
static |
Retrieves all resources for which the specified user has permanent or temporary permissions.
- Parameters
-
| User | $user | The user whose resources shall be retrieved. |
| string | $level | The minimum permission level the user must have on a resource so that it will be included in the result set. |
| DateTime | int | null | $time | The timestamp for the check on temporary permissions. If this parameter is not set the current timestamp will be used. |
| string[] | $class_names | A list of resource classes that will be used to filter the result set so that only resources being a member of one of the specified resource classes will be retrieved. |
| bool | $convert_objects | If the resource objects in the result set shall be converted to objects of the derived resource classes set this to true, otherwise false. Defaults to true. |
- Returns
- Resource[] An array of Resource objects or objects of derived resource classes.
◆ getUserResourcesSqlData()
| static getUserResourcesSqlData |
( |
User |
$user, |
|
|
|
$level = 'user', |
|
|
|
$time = null, |
|
|
|
$class_names = [] |
|
) |
| |
|
staticprotected |
Helper method that creates the identical SQL query for the countUserResources and findUserResources methods.
◆ moveResource()
Moves a resource below another resource and does checks to prevent resource hierarchies with misplaced resource objects. This is just a convenience method which calls the addChild method of the destination resource.
- Parameters
-
| Resource | $target | The resource which shall be moved. |
| Resource | $destination | The resource where $target shall be a new child. |
- Exceptions
-
- Returns
- bool True, if $target was successful placed below $destination.
◆ userHasGlobalPermission()
| static userHasGlobalPermission |
( |
User |
$user, |
|
|
|
$requested_permission = 'user' |
|
) |
| |
|
static |
Checks if the specified user has the specified permission level for the resource management system.
- Parameters
-
| User | $user | The user whose global resource permissions shall be checked. |
| string | $requested_permission | The required permission level for the user. |
- Returns
- bool True, if the user has the required permission level, false otherwise.
◆ userHasResourcePermissions()
| static userHasResourcePermissions |
( |
User |
$user, |
|
|
|
$level = 'admin', |
|
|
|
$time = null |
|
) |
| |
|
static |
Determines if the specified user has the specified permission level set for at least one resource.
- Parameters
-
| User | $user | The users whose resource permissions shall be retrieved. |
| string | $level | The permission level the user should have on at least one resource. |
| string | int | DateTime | null | $time | The timestamp for the temporary permission level check. If this is not set the current timestamp will be used. |
◆ userHasSpecialPermissions()
| static userHasSpecialPermissions |
( |
User |
$user, |
|
|
|
$requested_permission = 'user' |
|
) |
| |
|
static |
Checks if the specified user has the specified permission level on at least one specific resource.
- Parameters
-
| User | $user | The user whose resource permissions shall be checked. |
| string | $requested_permission | The required permission level for the user. |
- Returns
- bool True, if the user has the required permission level for at least one resource, false otherwise.
The documentation for this class was generated from the following file: