@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | * @see midcom_helper_toolbar::_check_index() |
| 224 | 224 | * @see midcom_helper_toolbar::clean_item() |
| 225 | 225 | */ |
| 226 | - public function add_item(array $item, string|int $before = -1) |
|
| 226 | + public function add_item(array $item, string | int $before = -1) |
|
| 227 | 227 | { |
| 228 | 228 | if ($before != -1) { |
| 229 | 229 | $before = $this->_check_index($before, false); |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | * it before a URL, an integer will insert it before a |
| 250 | 250 | * given index. |
| 251 | 251 | */ |
| 252 | - public function add_items(array $items, string|int $before = -1) |
|
| 252 | + public function add_items(array $items, string | int $before = -1) |
|
| 253 | 253 | { |
| 254 | 254 | foreach ($items as $item) { |
| 255 | 255 | $this->add_item($item, $before); |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | |
| 280 | 280 | $item = array_replace($defaults, $item); |
| 281 | 281 | |
| 282 | - if ( !empty($item[MIDCOM_TOOLBAR_ACCESSKEY]) |
|
| 282 | + if (!empty($item[MIDCOM_TOOLBAR_ACCESSKEY]) |
|
| 283 | 283 | && !array_key_exists($item[MIDCOM_TOOLBAR_ACCESSKEY], $used_access_keys)) { |
| 284 | 284 | // We have valid access key, add it to help text |
| 285 | 285 | $prefix = 'Alt-'; |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | private function set_url(array &$item, string $url) |
| 305 | 305 | { |
| 306 | 306 | $item[MIDCOM_TOOLBAR__ORIGINAL_URL] = $url; |
| 307 | - if ( ( empty($item[MIDCOM_TOOLBAR_OPTIONS]["rel"]) |
|
| 307 | + if ((empty($item[MIDCOM_TOOLBAR_OPTIONS]["rel"]) |
|
| 308 | 308 | // Some items may want to keep their links unmutilated |
| 309 | 309 | || $item[MIDCOM_TOOLBAR_OPTIONS]["rel"] != "directlink") |
| 310 | 310 | && !str_starts_with($url, '/') |
@@ -323,13 +323,13 @@ discard block |
||
| 323 | 323 | * @see midcom_helper_toolbar::get_index_from_url() |
| 324 | 324 | * @see midcom_helper_toolbar::_check_index() |
| 325 | 325 | */ |
| 326 | - public function remove_item(string|int $index) |
|
| 326 | + public function remove_item(string | int $index) |
|
| 327 | 327 | { |
| 328 | 328 | $index = $this->_check_index($index); |
| 329 | 329 | |
| 330 | 330 | if ($index == 0) { |
| 331 | 331 | array_shift($this->items); |
| 332 | - } elseif ($index == count($this->items) -1) { |
|
| 332 | + } elseif ($index == count($this->items) - 1) { |
|
| 333 | 333 | array_pop($this->items); |
| 334 | 334 | } else { |
| 335 | 335 | $this->items = array_merge(array_slice($this->items, 0, $index), |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | * |
| 351 | 351 | * @param string|int $index The integer index or URL of the item to enable. |
| 352 | 352 | */ |
| 353 | - public function enable_item(string|int $index) |
|
| 353 | + public function enable_item(string | int $index) |
|
| 354 | 354 | { |
| 355 | 355 | $index = $this->_check_index($index); |
| 356 | 356 | $this->items[$index][MIDCOM_TOOLBAR_ENABLED] = true; |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | * |
| 362 | 362 | * @param string|int $index The integer index or URL of the item to disable. |
| 363 | 363 | */ |
| 364 | - public function disable_item(string|int $index) |
|
| 364 | + public function disable_item(string | int $index) |
|
| 365 | 365 | { |
| 366 | 366 | $index = $this->_check_index($index, false); |
| 367 | 367 | |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | * |
| 376 | 376 | * @param string|int $index The integer index or URL of the item to hide. |
| 377 | 377 | */ |
| 378 | - public function hide_item(string|int $index) |
|
| 378 | + public function hide_item(string | int $index) |
|
| 379 | 379 | { |
| 380 | 380 | $index = $this->_check_index($index, false); |
| 381 | 381 | |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | * |
| 390 | 390 | * @param string|int $index The integer index or URL of the item to show. |
| 391 | 391 | */ |
| 392 | - public function show_item(string|int $index) |
|
| 392 | + public function show_item(string | int $index) |
|
| 393 | 393 | { |
| 394 | 394 | $index = $this->_check_index($index); |
| 395 | 395 | $this->items[$index][MIDCOM_TOOLBAR_HIDDEN] = false; |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | * @see midcom_helper_toolbar::_check_index() |
| 404 | 404 | * @see midcom_helper_toolbar::add_item() |
| 405 | 405 | */ |
| 406 | - public function update_item_url(string|int $index, string $url) |
|
| 406 | + public function update_item_url(string | int $index, string $url) |
|
| 407 | 407 | { |
| 408 | 408 | $index = $this->_check_index($index); |
| 409 | 409 | $this->set_url($this->items[$index], $url); |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | */ |
| 415 | 415 | public function render() : string |
| 416 | 416 | { |
| 417 | - $visible_items = array_filter($this->items, function ($item) { |
|
| 417 | + $visible_items = array_filter($this->items, function($item) { |
|
| 418 | 418 | return !$item[MIDCOM_TOOLBAR_HIDDEN]; |
| 419 | 419 | }); |
| 420 | 420 | $this->rendered = true; |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | // Try finding uppercase version of the accesskey first |
| 481 | 481 | $accesskey = strtoupper($item[MIDCOM_TOOLBAR_ACCESSKEY]); |
| 482 | 482 | $position = strpos($label, $accesskey); |
| 483 | - if ( $position === false |
|
| 483 | + if ($position === false |
|
| 484 | 484 | && midcom::get()->i18n->get_current_language() == 'en') { |
| 485 | 485 | // Try lowercase, too |
| 486 | 486 | $accesskey = strtolower($accesskey); |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | $attributes['title'] = $item[MIDCOM_TOOLBAR_HELPTEXT]; |
| 541 | 541 | } |
| 542 | 542 | |
| 543 | - if ( $item[MIDCOM_TOOLBAR_ENABLED] |
|
| 543 | + if ($item[MIDCOM_TOOLBAR_ENABLED] |
|
| 544 | 544 | && $item[MIDCOM_TOOLBAR_ACCESSKEY] !== null) { |
| 545 | 545 | $attributes['class'] = 'accesskey'; |
| 546 | 546 | $attributes['accesskey'] = $item[MIDCOM_TOOLBAR_ACCESSKEY]; |
@@ -591,7 +591,7 @@ discard block |
||
| 591 | 591 | public function get_index_from_url(string $url) : ?int |
| 592 | 592 | { |
| 593 | 593 | foreach ($this->items as $i => $item) { |
| 594 | - if ( $item[MIDCOM_TOOLBAR_URL] == $url |
|
| 594 | + if ($item[MIDCOM_TOOLBAR_URL] == $url |
|
| 595 | 595 | || $item[MIDCOM_TOOLBAR__ORIGINAL_URL] == $url) { |
| 596 | 596 | return $i; |
| 597 | 597 | } |
@@ -609,7 +609,7 @@ discard block |
||
| 609 | 609 | * |
| 610 | 610 | * @param string|int $index The integer index or URL to check |
| 611 | 611 | */ |
| 612 | - protected function _check_index(string|int $index, bool $raise_error = true) :?int |
|
| 612 | + protected function _check_index(string | int $index, bool $raise_error = true) : ?int |
|
| 613 | 613 | { |
| 614 | 614 | if (is_string($index)) { |
| 615 | 615 | $url = $index; |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @return static |
| 53 | 53 | */ |
| 54 | - public static function get(string|object $src) : self |
|
| 54 | + public static function get(string | object $src) : self |
|
| 55 | 55 | { |
| 56 | 56 | $identifier = get_called_class() . (is_object($src) ? get_class($src) : $src); |
| 57 | 57 | |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | |
| 287 | 287 | $label_prop = $this->get_label_property(); |
| 288 | 288 | |
| 289 | - if ( $label_prop != 'guid' |
|
| 289 | + if ($label_prop != 'guid' |
|
| 290 | 290 | && $this->property_exists($label_prop)) { |
| 291 | 291 | $search_properties[$label_prop] = true; |
| 292 | 292 | } |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | continue; |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | - if ( !$this->is_link($property) |
|
| 339 | + if (!$this->is_link($property) |
|
| 340 | 340 | && $this->get_midgard_type($property) != MGD_TYPE_GUID) { |
| 341 | 341 | continue; |
| 342 | 342 | } |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | protected static function class_rewrite(string $schema_type) : string |
| 371 | 371 | { |
| 372 | 372 | $extends = midcom_baseclasses_components_configuration::get('midcom.helper.reflector', 'config')->get_array('class_extends'); |
| 373 | - if ( isset($extends[$schema_type]) |
|
| 373 | + if (isset($extends[$schema_type]) |
|
| 374 | 374 | && class_exists($extends[$schema_type])) { |
| 375 | 375 | return $extends[$schema_type]; |
| 376 | 376 | } |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | /** |
| 391 | 391 | * Get the MgdSchema classname for given class |
| 392 | 392 | */ |
| 393 | - public static function resolve_baseclass(string|object $classname) : string |
|
| 393 | + public static function resolve_baseclass(string | object $classname) : string |
|
| 394 | 394 | { |
| 395 | 395 | static $cached = []; |
| 396 | 396 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | throw new midcom_error_midgard($e, $guid); |
| 57 | 57 | } |
| 58 | - if ( get_class($tmp) == 'midgard_person' |
|
| 58 | + if (get_class($tmp) == 'midgard_person' |
|
| 59 | 59 | && $this->person_class != 'midgard_person') { |
| 60 | 60 | $tmp = new $this->person_class($guid); |
| 61 | 61 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @param string $classname Which DBA are we dealing with |
| 69 | 69 | */ |
| 70 | - public function get_cached(string $classname, string|int $src) : midcom_core_dbaobject |
|
| 70 | + public function get_cached(string $classname, string | int $src) : midcom_core_dbaobject |
|
| 71 | 71 | { |
| 72 | 72 | static $cache = []; |
| 73 | 73 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | } |
| 85 | 85 | $object = new $classname($src); |
| 86 | 86 | $cache[$classname][$object->guid] = $object; |
| 87 | - $cache[$classname][$object->id] =& $cache[$classname][$object->guid]; |
|
| 87 | + $cache[$classname][$object->id] = & $cache[$classname][$object->guid]; |
|
| 88 | 88 | return $cache[$classname][$object->guid]; |
| 89 | 89 | } |
| 90 | 90 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | return true; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - if ( isset($object->__object) |
|
| 134 | + if (isset($object->__object) |
|
| 135 | 135 | && is_object($object->__object) |
| 136 | 136 | && $object->__object instanceof $class) { |
| 137 | 137 | // Decorator whose MgdSchema object matches |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | return $this->get_parent_data_uncached($object); |
| 155 | 155 | }); |
| 156 | 156 | |
| 157 | - if ( empty($parent_guid) |
|
| 157 | + if (empty($parent_guid) |
|
| 158 | 158 | || $parent_guid === $object->guid) { |
| 159 | 159 | return null; |
| 160 | 160 | } |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | * |
| 72 | 72 | * @return boolean Indicating success. |
| 73 | 73 | */ |
| 74 | - public function index(midcom_services_indexer_document|array $documents) : bool |
|
| 74 | + public function index(midcom_services_indexer_document | array $documents) : bool |
|
| 75 | 75 | { |
| 76 | 76 | if ($this->_disabled) { |
| 77 | 77 | return true; |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | return true; |
| 204 | 204 | } |
| 205 | 205 | if ($user === null) { |
| 206 | - $user =& $this->user; |
|
| 206 | + $user = & $this->user; |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | if ($user == 'EVERYONE') { |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | * |
| 275 | 275 | * It always returns true for administrative users. |
| 276 | 276 | */ |
| 277 | - public function is_group_member(midcom_core_group|string $group, midcom_core_user $user = null) : bool |
|
| 277 | + public function is_group_member(midcom_core_group | string $group, midcom_core_user $user = null) : bool |
|
| 278 | 278 | { |
| 279 | 279 | if ($this->is_admin($user)) { |
| 280 | 280 | // Administrators always have access. |
@@ -519,7 +519,7 @@ discard block |
||
| 519 | 519 | * (group:...), any valid identifier for the midcom_core_group |
| 520 | 520 | * constructor or a valid object of that type. |
| 521 | 521 | */ |
| 522 | - public function get_group(string|int|midcom_db_group|midgard_group $id) : ?midcom_core_group |
|
| 522 | + public function get_group(string | int | midcom_db_group | midgard_group $id) : ?midcom_core_group |
|
| 523 | 523 | { |
| 524 | 524 | $param = $id; |
| 525 | 525 | |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * Get a MidCOM DB class name for a MgdSchema Object. |
| 108 | 108 | * We also ensure that the corresponding component has been loaded. |
| 109 | 109 | */ |
| 110 | - public function get_midcom_class_name_for_mgdschema_object(string|object $classname) : ?string |
|
| 110 | + public function get_midcom_class_name_for_mgdschema_object(string | object $classname) : ?string |
|
| 111 | 111 | { |
| 112 | 112 | static $dba_classes_by_mgdschema = []; |
| 113 | 113 | |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * Simple helper to check whether we are dealing with a MidCOM Database object |
| 158 | 158 | * or a subclass thereof. |
| 159 | 159 | */ |
| 160 | - public function is_midcom_db_object(object|string $object) : bool |
|
| 160 | + public function is_midcom_db_object(object | string $object) : bool |
|
| 161 | 161 | { |
| 162 | 162 | return is_subclass_of($object, midcom_core_dbaobject::class) |
| 163 | 163 | || is_a($object, midcom_core_dbaproxy::class, true); |
@@ -417,7 +417,7 @@ discard block |
||
| 417 | 417 | * 2. A group string identifier, matching the regex ^group: |
| 418 | 418 | * 3. A valid midcom group name |
| 419 | 419 | */ |
| 420 | - public function is_in_group(midcom_core_group|string $group) : bool |
|
| 420 | + public function is_in_group(midcom_core_group | string $group) : bool |
|
| 421 | 421 | { |
| 422 | 422 | if ($this->_all_groups === null) { |
| 423 | 423 | $this->_load_all_groups(); |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | |
| 476 | 476 | $timeout = midcom::get()->config->get('auth_login_session_timeout', 0); |
| 477 | 477 | $last_seen = $person->get_parameter('midcom', 'online'); |
| 478 | - if ( !$last_seen |
|
| 478 | + if (!$last_seen |
|
| 479 | 479 | || ($timeout > 0 && time() - $timeout > $last_seen)) { |
| 480 | 480 | return 'offline'; |
| 481 | 481 | } |
@@ -22,11 +22,11 @@ |
||
| 22 | 22 | /** |
| 23 | 23 | * MidCOM DBA object identifier, can be ID or GUID |
| 24 | 24 | */ |
| 25 | - private string|int $__identifier; |
|
| 25 | + private string | int $__identifier; |
|
| 26 | 26 | |
| 27 | 27 | private bool $__tried_to_load = false; |
| 28 | 28 | |
| 29 | - public function __construct(string|int $identifier, string $classname) |
|
| 29 | + public function __construct(string | int $identifier, string $classname) |
|
| 30 | 30 | { |
| 31 | 31 | $this->__midcom_class_name__ = $classname; |
| 32 | 32 | $this->__identifier = $identifier; |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * The Default constructor creates an empty privilege, if you specify |
| 76 | 76 | * another privilege object in the constructor, a copy is constructed. |
| 77 | 77 | */ |
| 78 | - public function __construct(midcom_core_privilege_db|array|string $src = null) |
|
| 78 | + public function __construct(midcom_core_privilege_db | array | string $src = null) |
|
| 79 | 79 | { |
| 80 | 80 | if (is_array($src)) { |
| 81 | 81 | // Store given values to our privilege array |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | * - Any midcom_core_user or midcom_core_group object or subtype thereof. |
| 211 | 211 | * - Any string identifier which can be resolved using midcom_services_auth::get_assignee(). |
| 212 | 212 | */ |
| 213 | - public function set_assignee(midcom_core_group|midcom_core_user|string $assignee) : bool |
|
| 213 | + public function set_assignee(midcom_core_group | midcom_core_user | string $assignee) : bool |
|
| 214 | 214 | { |
| 215 | 215 | if (is_string($assignee)) { |
| 216 | 216 | if ($this->is_magic_assignee($assignee)) { |
@@ -266,12 +266,12 @@ discard block |
||
| 266 | 266 | } |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - if ( !$this->is_magic_assignee() |
|
| 269 | + if (!$this->is_magic_assignee() |
|
| 270 | 270 | && !$this->get_assignee()) { |
| 271 | 271 | debug_add("The assignee identifier '{$this->assignee}' is invalid.", MIDCOM_LOG_INFO); |
| 272 | 272 | return false; |
| 273 | 273 | } |
| 274 | - if ( $this->assignee == 'OWNER' |
|
| 274 | + if ($this->assignee == 'OWNER' |
|
| 275 | 275 | && $this->privilegename == 'midgard:owner') { |
| 276 | 276 | debug_add("Tried to assign midgard:owner to the OWNER magic assignee, this is invalid.", MIDCOM_LOG_INFO); |
| 277 | 277 | return false; |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | MIDCOM_LOG_INFO); |
| 284 | 284 | return false; |
| 285 | 285 | } |
| 286 | - if ( !$object->can_do('midgard:update') |
|
| 286 | + if (!$object->can_do('midgard:update') |
|
| 287 | 287 | || !$object->can_do('midgard:privileges')) { |
| 288 | 288 | debug_add("Insufficient privileges on the content object with the GUID '{$this->__guid}', midgard:update and midgard:privileges required.", |
| 289 | 289 | MIDCOM_LOG_INFO); |