diff options
Diffstat (limited to 'lib/models/resources')
| -rw-r--r-- | lib/models/resources/BrokenResource.class.php | 30 | ||||
| -rw-r--r-- | lib/models/resources/Building.class.php | 36 | ||||
| -rw-r--r-- | lib/models/resources/GlobalResourceLock.class.php | 12 | ||||
| -rw-r--r-- | lib/models/resources/Location.class.php | 36 | ||||
| -rw-r--r-- | lib/models/resources/Resource.class.php | 123 | ||||
| -rw-r--r-- | lib/models/resources/ResourceBooking.class.php | 19 | ||||
| -rw-r--r-- | lib/models/resources/ResourceCategory.class.php | 26 | ||||
| -rw-r--r-- | lib/models/resources/ResourceLabel.class.php | 35 | ||||
| -rw-r--r-- | lib/models/resources/ResourcePropertyDefinition.class.php | 5 | ||||
| -rw-r--r-- | lib/models/resources/ResourceRequest.class.php | 35 | ||||
| -rw-r--r-- | lib/models/resources/ResourceTemporaryPermission.class.php | 3 | ||||
| -rw-r--r-- | lib/models/resources/Room.class.php | 6 | ||||
| -rw-r--r-- | lib/models/resources/RoomRequest.class.php | 4 |
13 files changed, 151 insertions, 219 deletions
diff --git a/lib/models/resources/BrokenResource.class.php b/lib/models/resources/BrokenResource.class.php index d1014ef..1e16927 100644 --- a/lib/models/resources/BrokenResource.class.php +++ b/lib/models/resources/BrokenResource.class.php @@ -57,8 +57,7 @@ class BrokenResource extends Resource $description = '', $internal_comment = '', $booking_type = 0 - ) - { + ) { return null; } @@ -71,8 +70,7 @@ class BrokenResource extends Resource $booking_type = 0, $prepend_preparation_time = false, $notify_lecturers = false - ) - { + ) { return null; } @@ -98,8 +96,7 @@ class BrokenResource extends Resource DateTime $end, $comment = '', $preparation_time = 0 - ) - { + ) { return null; } @@ -110,8 +107,7 @@ class BrokenResource extends Resource $comment = '', $properties = [], $preparation_time = 0 - ) - { + ) { return null; } @@ -120,8 +116,7 @@ class BrokenResource extends Resource DateTime $begin, DateTime $end, $internal_comment = '' - ) - { + ) { return null; } @@ -159,8 +154,7 @@ class BrokenResource extends Resource public function setPropertyByDefinitionId( $property_definition_id = null, $state = null - ) - { + ) { return false; } @@ -183,8 +177,7 @@ class BrokenResource extends Resource DateTime $begin, DateTime $end, $excluded_booking_ids = [] - ) - { + ) { return false; } @@ -192,8 +185,7 @@ class BrokenResource extends Resource DateTime $begin, DateTime $end, $excluded_reservation_ids = [] - ) - { + ) { return false; } @@ -201,8 +193,7 @@ class BrokenResource extends Resource DateTime $begin, DateTime $end, $excluded_lock_ids = [] - ) - { + ) { return true; } @@ -210,8 +201,7 @@ class BrokenResource extends Resource DateTime $begin, DateTime $end, $excluded_booking_ids = [] - ) - { + ) { return false; } diff --git a/lib/models/resources/Building.class.php b/lib/models/resources/Building.class.php index f6bb5a1..7e5e7e1 100644 --- a/lib/models/resources/Building.class.php +++ b/lib/models/resources/Building.class.php @@ -167,8 +167,7 @@ class Building extends Resource $action = 'show', $id = null, $link_parameters = [] - ) - { + ) { return URLHelper::getLink( self::buildPathForAction($action, $id), $link_parameters @@ -191,8 +190,7 @@ class Building extends Resource $action = 'show', $id = null, $url_parameters = [] - ) - { + ) { return URLHelper::getURL( self::buildPathForAction($action, $id), $url_parameters @@ -408,8 +406,7 @@ class Building extends Resource $description = '', $internal_comment = '', $booking_type = 0 - ) - { + ) { return null; } @@ -422,8 +419,7 @@ class Building extends Resource $booking_type = 0, $prepend_preparation_time = false, $notify_lecturers = false - ) - { + ) { return null; } @@ -440,8 +436,7 @@ class Building extends Resource $internal_comment = '', $booking_type = 0, $force_booking = false - ) - { + ) { return null; } @@ -451,8 +446,7 @@ class Building extends Resource DateTime $end, $comment = '', $preparation_time = 0 - ) - { + ) { return null; } @@ -462,8 +456,7 @@ class Building extends Resource $comment = '', $properties = [], $preparation_time = 0 - ) - { + ) { return null; } @@ -472,8 +465,7 @@ class Building extends Resource DateTime $begin, DateTime $end, $internal_comment = '' - ) - { + ) { return null; } @@ -481,8 +473,7 @@ class Building extends Resource DateTime $begin, DateTime $end, $excluded_booking_ids = [] - ) - { + ) { return false; } @@ -490,8 +481,7 @@ class Building extends Resource DateTime $begin, DateTime $end, $excluded_reservation_ids = [] - ) - { + ) { return false; } @@ -499,8 +489,7 @@ class Building extends Resource DateTime $begin, DateTime $end, $excluded_lock_ids = [] - ) - { + ) { return true; } @@ -508,8 +497,7 @@ class Building extends Resource DateTime $begin, DateTime $end, $excluded_booking_ids = [] - ) - { + ) { return false; } } diff --git a/lib/models/resources/GlobalResourceLock.class.php b/lib/models/resources/GlobalResourceLock.class.php index 541cc0f..8b0d01b 100644 --- a/lib/models/resources/GlobalResourceLock.class.php +++ b/lib/models/resources/GlobalResourceLock.class.php @@ -28,13 +28,13 @@ class GlobalResourceLock extends SimpleORMap { protected static $defined_types = []; - + public function __construct($id = null) { self::initDefinedTypes(); parent::__construct($id); } - + protected static function initDefinedTypes() { if (empty(self::$defined_types)) { @@ -45,14 +45,14 @@ class GlobalResourceLock extends SimpleORMap ]; } } - + protected static function configure($config = []) { $config['db_table'] = 'global_resource_locks'; - + parent::configure($config); } - + public static function isLocked($begin, $end) { return self::countBySql('begin < :end AND end > :begin', compact('begin', 'end')) > 0; @@ -68,7 +68,7 @@ class GlobalResourceLock extends SimpleORMap self::initDefinedTypes(); return self::$defined_types; } - + /** * Returns a string representation of the type of this resource lock. * diff --git a/lib/models/resources/Location.class.php b/lib/models/resources/Location.class.php index c543153..088df2e 100644 --- a/lib/models/resources/Location.class.php +++ b/lib/models/resources/Location.class.php @@ -117,8 +117,7 @@ class Location extends Resource $action = 'show', $id = null, $link_parameters = [] - ) - { + ) { return URLHelper::getLink( self::buildPathForAction($action, $id), $link_parameters @@ -143,8 +142,7 @@ class Location extends Resource $action = 'show', $id = null, $url_parameters = [] - ) - { + ) { return URLHelper::getURL( self::buildPathForAction($action, $id), $url_parameters @@ -329,8 +327,7 @@ class Location extends Resource $description = '', $internal_comment = '', $booking_type = 0 - ) - { + ) { return null; } @@ -343,8 +340,7 @@ class Location extends Resource $booking_type = 0, $prepend_preparation_time = false, $notify_lecturers = false - ) - { + ) { return null; } @@ -360,8 +356,7 @@ class Location extends Resource $internal_comment = '', $booking_type = 0, $force_booking = false - ) - { + ) { return null; } @@ -371,8 +366,7 @@ class Location extends Resource DateTime $end, $comment = '', $preparation_time = 0 - ) - { + ) { return null; } @@ -382,8 +376,7 @@ class Location extends Resource $comment = '', $properties = [], $preparation_time = 0 - ) - { + ) { return null; } @@ -392,8 +385,7 @@ class Location extends Resource DateTime $begin, DateTime $end, $internal_comment = '' - ) - { + ) { return null; } @@ -401,8 +393,7 @@ class Location extends Resource DateTime $begin, DateTime $end, $excluded_booking_ids = [] - ) - { + ) { return false; } @@ -410,8 +401,7 @@ class Location extends Resource DateTime $begin, DateTime $end, $excluded_reservation_ids = [] - ) - { + ) { return false; } @@ -419,8 +409,7 @@ class Location extends Resource DateTime $begin, DateTime $end, $excluded_lock_ids = [] - ) - { + ) { return true; } @@ -428,8 +417,7 @@ class Location extends Resource DateTime $begin, DateTime $end, $excluded_booking_ids = [] - ) - { + ) { return false; } } diff --git a/lib/models/resources/Resource.class.php b/lib/models/resources/Resource.class.php index 9050734..76091fc 100644 --- a/lib/models/resources/Resource.class.php +++ b/lib/models/resources/Resource.class.php @@ -262,8 +262,7 @@ class Resource extends SimpleORMap implements StudipItem $action = 'show', $id = null, $link_parameters = [] - ) - { + ) { return URLHelper::getLink( self::buildPathForAction($action, $id), $link_parameters @@ -289,8 +288,7 @@ class Resource extends SimpleORMap implements StudipItem $action = 'show', $id = null, $url_parameters = [] - ) - { + ) { return URLHelper::getURL( self::buildPathForAction($action, $id), $url_parameters @@ -455,8 +453,7 @@ class Resource extends SimpleORMap implements StudipItem $description = '', $internal_comment = '', $booking_type = 0 - ) - { + ) { return $this->createBooking( $user, $user->id, @@ -508,8 +505,7 @@ class Resource extends SimpleORMap implements StudipItem $booking_type = 0, $prepend_preparation_time = false, $notify_lecturers = false - ) - { + ) { $course_dates = $request->getAffectedDates(); $bookings = []; @@ -521,7 +517,7 @@ class Resource extends SimpleORMap implements StudipItem [ [ 'begin' => ( - $prepend_preparation_time + $prepend_preparation_time ? $course_date->date - $preparation_time : $course_date->date ), @@ -546,7 +542,7 @@ class Resource extends SimpleORMap implements StudipItem //Such requests are resolved into multiple bookings. foreach ($request->appointments as $appointment) { $begin = ( - $prepend_preparation_time + $prepend_preparation_time ? $appointment->appointment->date - $preparation_time : $appointment->appointment->date ); @@ -583,7 +579,7 @@ class Resource extends SimpleORMap implements StudipItem [ [ 'begin' => ( - $prepend_preparation_time + $prepend_preparation_time ? $request->begin - $preparation_time : $request->begin ), @@ -686,8 +682,7 @@ class Resource extends SimpleORMap implements StudipItem $internal_comment = '', $booking_type = 0, $force_booking = false - ) - { + ) { if (!is_array($time_ranges)) { throw new InvalidArgumentException( _('Es wurden keine Zeitbereiche für die Buchung angegeben!') @@ -940,8 +935,7 @@ class Resource extends SimpleORMap implements StudipItem DateTime $end, $comment = '', $preparation_time = 0 - ) - { + ) { //All users are permitted to create a request, //if the resource is requestable. @@ -980,7 +974,7 @@ class Resource extends SimpleORMap implements StudipItem $request->begin = $begin->getTimestamp(); $request->end = $end->getTimestamp(); $request->preparation_time = ( - $preparation_time > 0 + $preparation_time > 0 ? $preparation_time : 0 ); @@ -1041,8 +1035,7 @@ class Resource extends SimpleORMap implements StudipItem $comment = '', $properties = [], $preparation_time = 0 - ) - { + ) { if (!$date_range_ids) { throw new InvalidArgumentException( _('Es wurde keine ID eines Objektes angegeben, welches Zeiträume für eine Ressourcenanfrage liefern kann!') @@ -1135,7 +1128,7 @@ class Resource extends SimpleORMap implements StudipItem $request->user_id = $user->id; $request->comment = $comment; $request->preparation_time = ( - $preparation_time > 0 + $preparation_time > 0 ? $preparation_time : 0 ); @@ -1252,8 +1245,7 @@ class Resource extends SimpleORMap implements StudipItem DateTime $begin, DateTime $end, $internal_comment = '' - ) - { + ) { if (!$this->userHasPermission($user, 'admin', [$begin, $end])) { throw new AccessDeniedException( sprintf( @@ -1398,7 +1390,8 @@ class Resource extends SimpleORMap implements StudipItem INNER JOIN resource_property_definitions rpd ON resource_properties.property_id = rpd.property_id WHERE resource_properties.resource_id = :resource_id - AND rpd.name = :name"); + AND rpd.name = :name" + ); $exists_stmt->execute( [ @@ -1469,8 +1462,10 @@ class Resource extends SimpleORMap implements StudipItem public function getInfolabelProperties() { return SimpleCollection::createFromArray( - ResourceProperty::findBySQL('INNER JOIN `resource_property_definitions` USING (`property_id`) - WHERE `info_label` = 1 AND `state` != "" AND `resource_id` = ?', [$this->id] + ResourceProperty::findBySQL( + 'INNER JOIN `resource_property_definitions` USING (`property_id`) + WHERE `info_label` = 1 AND `state` != "" AND `resource_id` = ?', + [$this->id] ) ); } @@ -1514,7 +1509,8 @@ class Resource extends SimpleORMap implements StudipItem INNER JOIN resource_property_definitions rpd ON resource_properties.property_id = rpd.property_id WHERE resource_properties.resource_id = :resource_id - AND rpd.name = :name"); + AND rpd.name = :name" + ); $value_stmt->execute( [ @@ -1829,23 +1825,23 @@ class Resource extends SimpleORMap implements StudipItem _("Eine Ressourceneigenschaft vom Typ 'user' benötigt ein Nutzer-Objekt zur Wertzuweisung!") ); } - break; + break; case 'institute': if (!($object instanceof Institute)) { throw new ResourcePropertyException( _("Eine Ressourceneigenschaft vom Typ 'institute' benötigt ein Institut-Objekt zur Wertzuweisung!") ); } - break; + break; case 'fileref': if (!($object instanceof FileRef)) { throw new ResourcePropertyException( _("Eine Ressourceneigenschaft vom Typ 'fileref' benötigt ein FileRef-Objekt zur Wertzuweisung!") ); } - break; + break; default: - break; + break; } //When no exception is thrown above we can set the object's ID @@ -2014,19 +2010,18 @@ class Resource extends SimpleORMap implements StudipItem DateTime $begin, DateTime $end, $excluded_booking_ids = [] - ) - { + ) { return ResourceBooking::countByResourceAndTimeRanges( - $this, - [ + $this, + [ [ 'begin' => $begin->getTimestamp(), 'end' => $end->getTimestamp() ] ], - [0], - $excluded_booking_ids - ) > 0; + [0], + $excluded_booking_ids + ) > 0; } /** @@ -2048,22 +2043,21 @@ class Resource extends SimpleORMap implements StudipItem DateTime $begin, DateTime $end, $excluded_reservation_ids = [] - ) - { + ) { //One second is added to the begin timestamp to avoid //getting "false" overlaps where another booking ends on exactly //the begin timestamp. return ResourceBooking::countByResourceAndTimeRanges( - $this, - [ + $this, + [ [ 'begin' => $begin->getTimestamp(), 'end' => $end->getTimestamp() ] ], - [1, 3], - $excluded_reservation_ids - ) > 0; + [1, 3], + $excluded_reservation_ids + ) > 0; } /** @@ -2085,22 +2079,21 @@ class Resource extends SimpleORMap implements StudipItem DateTime $begin, DateTime $end, $excluded_lock_ids = [] - ) - { + ) { //One second is added to the begin timestamp to avoid //getting "false" overlaps where another booking ends on exactly //the begin timestamp. return ResourceBooking::countByResourceAndTimeRanges( - $this, - [ + $this, + [ [ 'begin' => $begin->getTimestamp(), 'end' => $end->getTimestamp() ] ], - [2], - $excluded_lock_ids - ) > 0; + [2], + $excluded_lock_ids + ) > 0; } /** @@ -2120,19 +2113,18 @@ class Resource extends SimpleORMap implements StudipItem DateTime $begin, DateTime $end, $excluded_booking_ids = [] - ) - { + ) { return ResourceBooking::countByResourceAndTimeRanges( - $this, - [ + $this, + [ [ 'begin' => $begin->getTimestamp(), 'end' => $end->getTimestamp() ] ], - [0, 2], - $excluded_booking_ids - ) == 0; + [0, 2], + $excluded_booking_ids + ) == 0; } /** @@ -2410,8 +2402,7 @@ class Resource extends SimpleORMap implements StudipItem ?User $user, string $permission = 'user', array $time_range = [] - ) - { + ) { if (!in_array($permission, ['user', 'autor', 'tutor', 'admin']) || $user === null) { return false; } @@ -2520,8 +2511,7 @@ class Resource extends SimpleORMap implements StudipItem User $user, $begin = null, $end = null - ) - { + ) { if ($begin && $end) { $time_range = [$begin, $end]; } else { @@ -2621,8 +2611,7 @@ class Resource extends SimpleORMap implements StudipItem $depth = 0, $convert_objects = true, $order_by_name = true - ) - { + ) { $result = []; if ($this->children) { //this resource has children: iterate over them and @@ -2807,11 +2796,11 @@ class Resource extends SimpleORMap implements StudipItem //directly in the database. Since resource folders do not //have subfolders we will count any file of the resource: return FileRef::countBySql( - 'folder_id = :folder_id', - [ + 'folder_id = :folder_id', + [ 'folder_id' => $folder->id ] - ) > 0; + ) > 0; } /** @@ -2964,7 +2953,7 @@ class Resource extends SimpleORMap implements StudipItem } - public function getLink() : StudipLink + public function getLink(): StudipLink { return new StudipLink($this->getActionURL(), $this->name, Icon::create('resources')); } diff --git a/lib/models/resources/ResourceBooking.class.php b/lib/models/resources/ResourceBooking.class.php index 3d8ec28..63a5e9d 100644 --- a/lib/models/resources/ResourceBooking.class.php +++ b/lib/models/resources/ResourceBooking.class.php @@ -185,8 +185,7 @@ class ResourceBooking extends SimpleORMap implements PrivacyObject, Studip\Calen $time_ranges = [], $booking_types = [], $excluded_booking_ids = [] - ) - { + ) { if (!is_array($time_ranges)) { throw new InvalidArgumentException( _('Es wurde keine Liste mit Zeiträumen angegeben!') @@ -332,8 +331,7 @@ class ResourceBooking extends SimpleORMap implements PrivacyObject, Studip\Calen $time_ranges = [], $booking_types = [], $excluded_booking_ids = [] - ) - { + ) { //Build the SQL query and the parameter array. $sql_data = self::buildResourceAndTimeRangesSqlQuery( @@ -362,8 +360,7 @@ class ResourceBooking extends SimpleORMap implements PrivacyObject, Studip\Calen $time_ranges = [], $booking_types = [], $excluded_booking_ids = [] - ) - { + ) { //Build the SQL query and the parameter array. $sql_data = self::buildResourceAndTimeRangesSqlQuery( @@ -392,8 +389,7 @@ class ResourceBooking extends SimpleORMap implements PrivacyObject, Studip\Calen $time_ranges = [], $booking_types = [], $excluded_booking_ids = [] - ) - { + ) { //Build the SQL query and the parameter array. $sql_data = self::buildResourceAndTimeRangesSqlQuery( $resource, @@ -491,7 +487,9 @@ class ResourceBooking extends SimpleORMap implements PrivacyObject, Studip\Calen //(the moment this booking is saved). $derived_resource = $this->resource->getDerivedClassInstance(); $user_has_booking_rights = $derived_resource->userHasBookingRights( - $this->booking_user, $this->begin, $this->end + $this->booking_user, + $this->begin, + $this->end ); if (!$user_has_booking_rights) { throw new ResourcePermissionException( @@ -1766,8 +1764,7 @@ class ResourceBooking extends SimpleORMap implements PrivacyObject, Studip\Calen $range_type = null, $begin = null, $end = null - ) - { + ) { $sql = "booking_id = :booking_id AND takes_place = 1 "; $sql_array = [ 'booking_id' => $this->id diff --git a/lib/models/resources/ResourceCategory.class.php b/lib/models/resources/ResourceCategory.class.php index 9738cbc..e1b90ba 100644 --- a/lib/models/resources/ResourceCategory.class.php +++ b/lib/models/resources/ResourceCategory.class.php @@ -292,8 +292,7 @@ class ResourceCategory extends SimpleORMap $requestable = false, $protected = false, $write_permission_level = 'autor' - ) - { + ) { if (!$name) { throw new ResourcePropertyException( _('Es wurde kein Name für die Eigenschaft angegeben!') @@ -424,8 +423,7 @@ class ResourceCategory extends SimpleORMap $parent_id = '', $properties = [], $ignore_invalid = false - ) - { + ) { if (($this->class_name != 'Resource') and !is_subclass_of($this->class_name, 'Resource')) { //Invalid resource category specification: @@ -440,7 +438,7 @@ class ResourceCategory extends SimpleORMap ); } - $resource = new $this->class_name; + $resource = new $this->class_name(); $resource->parent_id = $parent_id; $resource->category_id = $this->id; $resource->name = $name; @@ -484,8 +482,7 @@ class ResourceCategory extends SimpleORMap */ protected function setPropertyDefaultState( ResourcePropertyDefinition $definition - ) - { + ) { switch ($definition->type) { case 'bool': return false; @@ -614,8 +611,7 @@ class ResourceCategory extends SimpleORMap ResourceRequest $request, $name, $state = null - ) - { + ) { if ($request->category_id != $this->id) { throw new InvalidResourceCategoryException( sprintf( @@ -710,7 +706,7 @@ class ResourceCategory extends SimpleORMap { if ($type) { return ResourceCategoryProperty::countBySql( - 'INNER JOIN resource_property_definitions + 'INNER JOIN resource_property_definitions USING (property_id) WHERE name = :name @@ -718,25 +714,25 @@ class ResourceCategory extends SimpleORMap type = :type AND category_id = :category_id', - [ + [ 'name' => $name, 'type' => $type, 'category_id' => $this->id ] - ) > 0; + ) > 0; } else { return ResourceCategoryProperty::countBySql( - 'INNER JOIN resource_property_definitions + 'INNER JOIN resource_property_definitions USING (property_id) WHERE name = :name AND category_id = :category_id', - [ + [ 'name' => $name, 'category_id' => $this->id ] - ) > 0; + ) > 0; } } diff --git a/lib/models/resources/ResourceLabel.class.php b/lib/models/resources/ResourceLabel.class.php index b75d047..00294f9 100644 --- a/lib/models/resources/ResourceLabel.class.php +++ b/lib/models/resources/ResourceLabel.class.php @@ -50,8 +50,7 @@ class ResourceLabel extends Resource $description = '', $internal_comment = '', $booking_type = 0 - ) - { + ) { return null; } @@ -64,8 +63,7 @@ class ResourceLabel extends Resource $booking_type = 0, $prepend_preparation_time = false, $notify_lecturers = false - ) - { + ) { return null; } @@ -81,8 +79,7 @@ class ResourceLabel extends Resource $internal_comment = '', $booking_type = 0, $force_booking = false - ) - { + ) { return null; } @@ -92,8 +89,7 @@ class ResourceLabel extends Resource DateTime $end, $comment = '', $preparation_time = 0 - ) - { + ) { return null; } @@ -103,8 +99,7 @@ class ResourceLabel extends Resource $comment = '', $properties = [], $preparation_time = 0 - ) - { + ) { return null; } @@ -113,8 +108,7 @@ class ResourceLabel extends Resource DateTime $begin, DateTime $end, $internal_comment = '' - ) - { + ) { return null; } @@ -152,8 +146,7 @@ class ResourceLabel extends Resource public function setPropertyByDefinitionId( $property_definition_id = null, $state = null - ) - { + ) { return false; } @@ -176,8 +169,7 @@ class ResourceLabel extends Resource DateTime $begin, DateTime $end, $excluded_booking_ids = [] - ) - { + ) { return false; } @@ -185,8 +177,7 @@ class ResourceLabel extends Resource DateTime $begin, DateTime $end, $excluded_reservation_ids = [] - ) - { + ) { return false; } @@ -194,8 +185,7 @@ class ResourceLabel extends Resource DateTime $begin, DateTime $end, $excluded_lock_ids = [] - ) - { + ) { return true; } @@ -203,8 +193,7 @@ class ResourceLabel extends Resource DateTime $begin, DateTime $end, $excluded_booking_ids = [] - ) - { + ) { return false; } @@ -245,6 +234,6 @@ class ResourceLabel extends Resource public function getItemAvatarURL() { - return Icon::create('info', Icon::ROLE_INFO)->asImagePath(); + return Icon::create('info', Icon::ROLE_INFO)->asImagePath(); } } diff --git a/lib/models/resources/ResourcePropertyDefinition.class.php b/lib/models/resources/ResourcePropertyDefinition.class.php index 37fa89b..5400732 100644 --- a/lib/models/resources/ResourcePropertyDefinition.class.php +++ b/lib/models/resources/ResourcePropertyDefinition.class.php @@ -49,7 +49,7 @@ class ResourcePropertyDefinition extends SimpleORMap * are always in a format as specified by the ISO-6709 * string representation. */ - const CRSWGS84_REGEX = '/[+-]\d{1,3}\.\d{1,10}[+-]\d{1,3}\.\d{1,10}[+-]\d{1,5}\.\d{1,10}CRSWGS_84\/$/'; + public const CRSWGS84_REGEX = '/[+-]\d{1,3}\.\d{1,10}[+-]\d{1,3}\.\d{1,10}[+-]\d{1,5}\.\d{1,10}CRSWGS_84\/$/'; protected static function configure($config = []) { @@ -141,8 +141,7 @@ class ResourcePropertyDefinition extends SimpleORMap $special_name = '', $with_label = false, $allow_boolean_false = true - ) - { + ) { $label_html_classes = ''; $type = $this->type; $input_name = $special_name diff --git a/lib/models/resources/ResourceRequest.class.php b/lib/models/resources/ResourceRequest.class.php index d521781..cb82528 100644 --- a/lib/models/resources/ResourceRequest.class.php +++ b/lib/models/resources/ResourceRequest.class.php @@ -69,7 +69,7 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen /** * The amount of defined marking states. */ - const MARKING_STATES = 4; + public const MARKING_STATES = 4; protected static function configure($config = []) { @@ -209,8 +209,7 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen $excluded_request_ids = [], $additional_conditions = '', $additional_parameters = [] - ) - { + ) { if (!is_array($time_ranges)) { throw new InvalidArgumentException( _('Es wurde keine Liste mit Zeiträumen angegeben!') @@ -403,8 +402,7 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen $excluded_request_ids = [], $additional_conditions = '', $additional_parameters = [] - ) - { + ) { //Build the SQL query and the parameter array. $sql_data = self::buildResourceAndTimeRangesSqlQuery( @@ -427,8 +425,7 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen $excluded_request_ids = [], $additional_conditions = '', $additional_parameters = [] - ) - { + ) { $sql_data = self::buildResourceAndTimeRangesSqlQuery( $resource, $time_ranges, @@ -1209,7 +1206,7 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen if ($with_range) { $interval['range'] = 'CourseDate'; $interval['range_id'] = $this->termin_id; - $interval['booked_room'] = $this->date->room_booking ? $this->date->room_booking->resource_id: null; + $interval['booked_room'] = $this->date->room_booking ? $this->date->room_booking->resource_id : null; $interval['booking_id'] = $this->date->room_booking ? $this->date->room_booking->id : null; } return [$interval]; @@ -1410,7 +1407,7 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen } if ((int)$this->closed === 0) { return _('Die Anfrage wurde noch nicht bearbeitet.'); - } else if ((int)$this->closed === 3) { + } elseif ((int)$this->closed === 3) { return _('Die Anfrage wurde bearbeitet und abgelehnt.'); } else { return _('Die Anfrage wurde bearbeitet.'); @@ -1453,15 +1450,16 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen } } elseif ($this->metadate_id) { if ($this->cycle) { - $this->cycle->dates->filter(function($date) use($with_past_intervals, $now) { + $this->cycle->dates->filter(function ($date) use ($with_past_intervals, $now) { return $with_past_intervals || $date->end_time >= $now; - })->map(function($date) use(&$strings) { + })->map(function ($date) use (&$strings) { $strings[] = $date->getFullname('include-room'); }); } } elseif ($this->course_id) { $course = new Seminar($this->course_id); - $strings[] = $course->getDatesTemplate('dates/seminar_html_roomplanning', + $strings[] = $course->getDatesTemplate( + 'dates/seminar_html_roomplanning', [ 'shrink' => false, 'show_room' => true, @@ -1639,7 +1637,8 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen INNER JOIN resource_property_definitions rpd ON resource_request_properties.property_id = rpd.property_id WHERE resource_request_properties.request_id = :request_id - AND rpd.name = :name"); + AND rpd.name = :name" + ); $exists_stmt->execute( [ @@ -1676,7 +1675,8 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen INNER JOIN resource_property_definitions rpd ON resource_request_properties.property_id = rpd.property_id WHERE resource_request_properties.request_id = :request_id - AND rpd.name = :name"); + AND rpd.name = :name" + ); $value_stmt->execute( [ @@ -1822,7 +1822,7 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen if ($range_object instanceof User) { if (get_visibility_by_id($range_object->id)) { $name = $range_object->getFullName(); - } else if ($this->user_id === $GLOBALS['user']->id) { + } elseif ($this->user_id === $GLOBALS['user']->id) { $name = $range_object->getFullName(); } else { $current_user = User::findCurrent(); @@ -1833,7 +1833,7 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen if ($this->resource_id && ($this->resource instanceof Resource) && $this->resource->userHasPermission($current_user, 'autor')) { $name = $range_object->getFullname(); - } else if (ResourceManager::userHasGlobalPermission($current_user, 'autor')) { + } elseif (ResourceManager::userHasGlobalPermission($current_user, 'autor')) { $name = $range_object->getFullname(); } else { return ''; @@ -2391,8 +2391,7 @@ class ResourceRequest extends SimpleORMap implements PrivacyObject, Studip\Calen $range_type = null, $begin = null, $end = null - ) - { + ) { $intervals = $this->getTimeIntervals(true); $time_intervals = []; diff --git a/lib/models/resources/ResourceTemporaryPermission.class.php b/lib/models/resources/ResourceTemporaryPermission.class.php index 1f0bedb..6e5e3b3 100644 --- a/lib/models/resources/ResourceTemporaryPermission.class.php +++ b/lib/models/resources/ResourceTemporaryPermission.class.php @@ -117,8 +117,7 @@ class ResourceTemporaryPermission extends SimpleORMap implements PrivacyObject string $resource_id, DateTime $begin, DateTime $end - ) - { + ) { //Query explaination: We want exactly one permission object //for the specified user and the resource. //The permission must exist during the whole specified time range diff --git a/lib/models/resources/Room.class.php b/lib/models/resources/Room.class.php index 1c9a0e4..c52b333 100644 --- a/lib/models/resources/Room.class.php +++ b/lib/models/resources/Room.class.php @@ -169,8 +169,7 @@ class Room extends Resource $limit = 0, $searchable_rooms = [], $properties = [] - ) - { + ) { //We have to check first if the user is permitted to search: //The user must have at least 'tutor' status in the //room and resource management: @@ -543,8 +542,7 @@ class Room extends Resource $comment = '', $properties = [], $preparation_time = 0 - ) - { + ) { $request = parent::createRequest( $user, $date_range_id, diff --git a/lib/models/resources/RoomRequest.class.php b/lib/models/resources/RoomRequest.class.php index c0898d7..a88855e 100644 --- a/lib/models/resources/RoomRequest.class.php +++ b/lib/models/resources/RoomRequest.class.php @@ -60,11 +60,11 @@ class RoomRequest extends ResourceRequest if ($this->termin_id) { $query = sprintf("SELECT id FROM resource_bookings WHERE range_id = %s ", $db->quote($this->termin_id)); $existing_assign = $db->query($query)->fetchColumn(); - //metadate request + //metadate request } elseif ($this->metadate_id) { $query = sprintf("SELECT count(termin_id)=count(resource_bookings.id) FROM termine LEFT JOIN resource_bookings ON(termin_id=resource_bookings.range_id) WHERE metadate_id=%s", $db->quote($this->metadate_id)); - //seminar request + //seminar request } else { $query = sprintf("SELECT count(termin_id)=count(resource_bookings.id) FROM termine LEFT JOIN resource_bookings ON(termin_id=resource_bookings.range_id) WHERE range_id='%s' AND date_typ IN" . getPresenceTypeClause(), $this->course_id); |
