diff options
| author | Moritz Strohm <strohm@data-quest.de> | 2022-09-28 12:32:56 +0000 |
|---|---|---|
| committer | Moritz Strohm <strohm@data-quest.de> | 2022-09-28 12:32:56 +0000 |
| commit | 9e13d2f5fa4726b54efe8ad046d0b53aadb543bf (patch) | |
| tree | b8fc0583b685de64575feca2cd4efe2663586d74 /lib/models/resources | |
| parent | 0d56653e17a283d918c6e4cb41468de1990e0331 (diff) | |
fix for BIESt #1104
Merge request studip/studip!674
Diffstat (limited to 'lib/models/resources')
| -rw-r--r-- | lib/models/resources/Location.class.php | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/lib/models/resources/Location.class.php b/lib/models/resources/Location.class.php index f380859..c543153 100644 --- a/lib/models/resources/Location.class.php +++ b/lib/models/resources/Location.class.php @@ -23,10 +23,10 @@ class Location extends Resource protected static $required_properties = [ 'geo_coordinates' ]; - + protected static function configure($config = []) { - if (!is_array($config['additional_fields'])) { + if (!isset($config['additional_fields'])) { $config['additional_fields'] = []; } foreach (self::$required_properties as $property) { @@ -35,18 +35,18 @@ class Location extends Resource 'set' => 'setProperty' ]; } - + $config['additional_fields']['buildings']['get'] = 'findBuildings'; - + $config['additional_fields']['director'] = [ 'get' => 'getPropertyRelatedObject', 'set' => 'setPropertyRelatedObject' ]; - + $config['registered_callbacks']['before_store'][] = 'cbValidate'; parent::configure($config); } - + public static function getTranslatedClassName($item_count = 1) { return ngettext( @@ -55,7 +55,7 @@ class Location extends Resource $item_count ); } - + /** * Returns all locations which are stored in the database. * @@ -70,7 +70,7 @@ class Location extends Resource ORDER BY sort_position DESC, name ASC, mkdate ASC" ); } - + /** * Returns the part of the URL for getLink and getURL which will be * placed inside the calls to URLHelper::getLink and URLHelper::getURL @@ -83,7 +83,7 @@ class Location extends Resource _('Zuer Erstellung der URL fehlt eine Standort-ID!') ); } - + switch ($action) { case 'show': return 'dispatch.php/resources/location/index/' . $id; @@ -99,7 +99,7 @@ class Location extends Resource return parent::buildPathForAction($action, $id); } } - + /** * Returns the appropriate link for the location action that shall be * executed on a location. @@ -124,8 +124,8 @@ class Location extends Resource $link_parameters ); } - - + + /** * Returns the appropriate URL for the location action that shall be * executed on a location. @@ -150,12 +150,12 @@ class Location extends Resource $url_parameters ); } - + public function getRequiredPropertyNames() { return self::$required_properties; } - + /** * @see StudipItem::__toString */ @@ -163,7 +163,7 @@ class Location extends Resource { return $this->getFullName(); } - + public function cbValidate() { if ($this->parent_id) { @@ -175,7 +175,7 @@ class Location extends Resource ) ); } - + if (!is_a($this->category->class_name, get_class($this), true)) { //Only resources with the Location category can be handled //with this class! @@ -187,7 +187,7 @@ class Location extends Resource ); } } - + /** * Returns the full (localised) name of the location. * @@ -200,30 +200,30 @@ class Location extends Resource $this->name ); } - + public function getDefaultPictureUrl() { return $this->getIcon()->asImagePath(); } - + public function getIcon($role = Icon::ROLE_INFO) { return Icon::create('place', $role); } - + public function checkHierarchy() { //We must check if this location has locations as children //or rooms, buildings or locations as parents. //In any of those cases the hierarchy is invalid! - + $children = $this->findChildrenByClassName('Location'); if (count($children) > 0) { //At least one child anywhere below this location //resource is a location, too. return false; } - + $parents = ResourceManager::getHierarchy($this); //We do not need to check this element: array_shift($parents); @@ -235,12 +235,12 @@ class Location extends Resource return false; } } - + //If code execution reaches this point then //the hierarchy around this location is valid. return true; } - + /** * Returns the link for an action for this building. * This is the non-static variant of Building::getLinkForAction. @@ -260,7 +260,7 @@ class Location extends Resource $link_parameters ); } - + /** * Returns the URL for an action for this location. * This is the non-static variant of Location::getURLForAction. @@ -279,9 +279,9 @@ class Location extends Resource $url_parameters ); } - + // Relation methods: - + /** * Retrieves the buildings which are associated to this location * by looking up the child resources of this location. @@ -292,14 +292,14 @@ class Location extends Resource public function findBuildings() { $buildings = parent::findChildrenByClassName('Building'); - + $result = []; foreach ($buildings as $building) { $result[] = Building::toObject($building); } return $result; } - + /** * Adds a child resource to this location. The child resource * must not be a resource of the Location class. @@ -320,7 +320,7 @@ class Location extends Resource } return parent::addChild($resource); } - + public function createSimpleBooking( User $user, DateTime $begin, @@ -333,7 +333,7 @@ class Location extends Resource { return null; } - + public function createBookingFromRequest( User $user, ResourceRequest $request, @@ -347,7 +347,7 @@ class Location extends Resource { return null; } - + public function createBooking( User $user, $range_id = null, @@ -364,7 +364,7 @@ class Location extends Resource { return null; } - + public function createSimpleRequest( User $user, DateTime $begin, @@ -375,7 +375,7 @@ class Location extends Resource { return null; } - + public function createRequest( User $user, $date_range_ids = null, @@ -386,7 +386,7 @@ class Location extends Resource { return null; } - + public function createLock( User $user, DateTime $begin, @@ -396,7 +396,7 @@ class Location extends Resource { return null; } - + public function isAssigned( DateTime $begin, DateTime $end, @@ -405,7 +405,7 @@ class Location extends Resource { return false; } - + public function isReserved( DateTime $begin, DateTime $end, @@ -414,7 +414,7 @@ class Location extends Resource { return false; } - + public function isLocked( DateTime $begin, DateTime $end, @@ -423,7 +423,7 @@ class Location extends Resource { return true; } - + public function isAvailable( DateTime $begin, DateTime $end, |
