@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | private function apply_constraints(midcom_core_query $query, array $constraints) |
| 77 | 77 | { |
| 78 | 78 | foreach ($constraints as $key => $data) { |
| 79 | - if ( !array_key_exists('value', $data) |
|
| 79 | + if (!array_key_exists('value', $data) |
|
| 80 | 80 | || empty($data['field']) |
| 81 | 81 | || empty($data['op'])) { |
| 82 | 82 | debug_add("Constraint #{$key} is not correctly defined, skipping", MIDCOM_LOG_WARN); |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | { |
| 138 | 138 | $query = $this->request["term"]; |
| 139 | 139 | $wildcard_query = $query; |
| 140 | - if ( isset($this->request['auto_wildcards']) |
|
| 140 | + if (isset($this->request['auto_wildcards']) |
|
| 141 | 141 | && !str_contains($query, '%')) { |
| 142 | 142 | switch ($this->request['auto_wildcards']) { |
| 143 | 143 | case 'start': |
@@ -245,9 +245,7 @@ discard block |
||
| 245 | 245 | return $label; |
| 246 | 246 | } |
| 247 | 247 | } |
| 248 | - return midcom_helper_reflector::get($object)->get_object_label($object) ?: |
|
| 249 | - self::build_label($object, array_column($result_headers, 'name')) ?: |
|
| 250 | - $object::class . ' #' . $object->id; |
|
| 248 | + return midcom_helper_reflector::get($object)->get_object_label($object) ?: self::build_label($object, array_column($result_headers, 'name')) ?: $object::class . ' #' . $object->id; |
|
| 251 | 249 | } |
| 252 | 250 | |
| 253 | 251 | private static function build_label($object, array $fields) : string |
@@ -282,7 +280,7 @@ discard block |
||
| 282 | 280 | } |
| 283 | 281 | return self::sanitize_label($value); |
| 284 | 282 | } |
| 285 | - if ( $field == 'username' |
|
| 283 | + if ($field == 'username' |
|
| 286 | 284 | && $object instanceof midcom_db_person) { |
| 287 | 285 | $account = new midcom_core_account($object); |
| 288 | 286 | return self::sanitize_label($account->get_username()); |
@@ -119,14 +119,14 @@ discard block |
||
| 119 | 119 | if ($parent = $object->get_parent()) { |
| 120 | 120 | // Attachments are a special case |
| 121 | 121 | if ($object instanceof midcom_db_attachment) { |
| 122 | - if ( !$parent->can_do('midgard:attachments') |
|
| 122 | + if (!$parent->can_do('midgard:attachments') |
|
| 123 | 123 | || !$parent->can_do('midgard:update')) { |
| 124 | 124 | debug_add("Failed to create attachment, update or attachments privilege on the parent " . $parent::class . " {$parent->guid} not granted for the current user.", |
| 125 | 125 | MIDCOM_LOG_ERROR); |
| 126 | 126 | midcom_connection::set_error(MGD_ERR_ACCESS_DENIED); |
| 127 | 127 | return false; |
| 128 | 128 | } |
| 129 | - } elseif ( !$parent->can_do('midgard:create') |
|
| 129 | + } elseif (!$parent->can_do('midgard:create') |
|
| 130 | 130 | && !midcom::get()->auth->can_user_do('midgard:create', class: $object::class)) { |
| 131 | 131 | debug_add("Failed to create object, create privilege on the parent " . $parent::class . " {$parent->guid} or the actual object class not granted for the current user.", |
| 132 | 132 | MIDCOM_LOG_ERROR); |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | // Default the owner to first group of current user |
| 241 | - if ( empty($object->metadata->owner) |
|
| 241 | + if (empty($object->metadata->owner) |
|
| 242 | 242 | && $first_group = midcom::get()->auth->user->get_first_group_guid()) { |
| 243 | 243 | $object->metadata->set('owner', $first_group); |
| 244 | 244 | } |
@@ -462,7 +462,7 @@ discard block |
||
| 462 | 462 | */ |
| 463 | 463 | public static function get_by_guid(midcom_core_dbaobject $object, string $guid) : bool |
| 464 | 464 | { |
| 465 | - if ( !midcom::get()->auth->admin |
|
| 465 | + if (!midcom::get()->auth->admin |
|
| 466 | 466 | && !midcom::get()->auth->acl->can_do_byguid('midgard:read', $guid, $object::class, midcom::get()->auth->acl->get_user_id())) { |
| 467 | 467 | debug_add("Failed to load object, read privilege on the " . $object::class . " {$guid} not granted for the current user.", MIDCOM_LOG_ERROR); |
| 468 | 468 | return false; |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | public function get_object_name(?string $name_property = null) : ?string |
| 33 | 33 | { |
| 34 | 34 | $name_property ??= midcom_helper_reflector::get_name_property($this->_object); |
| 35 | - if ( empty($name_property) |
|
| 35 | + if (empty($name_property) |
|
| 36 | 36 | || !midcom_helper_reflector::get($this->_object)->property_exists($name_property)) { |
| 37 | 37 | // Could not resolve valid property |
| 38 | 38 | return null; |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | $qb->add_constraint($child_name_property, '=', $name); |
| 126 | 126 | if ($qb->count()) { |
| 127 | - debug_add("Name clash in sibling class {$schema_type} for " . $this->_object::class . " #{$this->_object->id} (path '" . midcom_helper_reflector_tree::resolve_path($this->_object, '/') . "')" ); |
|
| 127 | + debug_add("Name clash in sibling class {$schema_type} for " . $this->_object::class . " #{$this->_object->id} (path '" . midcom_helper_reflector_tree::resolve_path($this->_object, '/') . "')"); |
|
| 128 | 128 | return false; |
| 129 | 129 | } |
| 130 | 130 | } |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | } while (!$this->name_is_unique()); |
| 200 | 200 | |
| 201 | 201 | // Get a copy of the current, usable name |
| 202 | - $ret = (string)$this->_object->{$name_prop}; |
|
| 202 | + $ret = (string) $this->_object->{$name_prop}; |
|
| 203 | 203 | // Restore the original name |
| 204 | 204 | $this->_object->{$name_prop} = $original_name; |
| 205 | 205 | return $ret; |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @return static |
| 54 | 54 | */ |
| 55 | - public static function get(string|object $src) : self |
|
| 55 | + public static function get(string | object $src) : self |
|
| 56 | 56 | { |
| 57 | 57 | $identifier = static::class . (is_object($src) ? $src::class : $src); |
| 58 | 58 | |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | |
| 285 | 285 | $label_prop = $this->get_label_property(); |
| 286 | 286 | |
| 287 | - if ( $label_prop != 'guid' |
|
| 287 | + if ($label_prop != 'guid' |
|
| 288 | 288 | && $this->property_exists($label_prop)) { |
| 289 | 289 | $search_properties[$label_prop] = true; |
| 290 | 290 | } |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | continue; |
| 335 | 335 | } |
| 336 | 336 | |
| 337 | - if ( !$this->is_link($property) |
|
| 337 | + if (!$this->is_link($property) |
|
| 338 | 338 | && $this->get_midgard_type($property) != MGD_TYPE_GUID) { |
| 339 | 339 | continue; |
| 340 | 340 | } |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | protected static function class_rewrite(string $schema_type) : string |
| 369 | 369 | { |
| 370 | 370 | $extends = midcom_baseclasses_components_configuration::get('midcom.helper.reflector', 'config')->get_array('class_extends'); |
| 371 | - if ( isset($extends[$schema_type]) |
|
| 371 | + if (isset($extends[$schema_type]) |
|
| 372 | 372 | && class_exists($extends[$schema_type])) { |
| 373 | 373 | return $extends[$schema_type]; |
| 374 | 374 | } |
@@ -388,7 +388,7 @@ discard block |
||
| 388 | 388 | /** |
| 389 | 389 | * Get the MgdSchema classname for given class |
| 390 | 390 | */ |
| 391 | - public static function resolve_baseclass(string|object $classname) : string |
|
| 391 | + public static function resolve_baseclass(string | object $classname) : string |
|
| 392 | 392 | { |
| 393 | 393 | static $cached = []; |
| 394 | 394 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | throw new midcom_error_midgard($e, $guid); |
| 57 | 57 | } |
| 58 | - if ( $tmp::class == 'midgard_person' |
|
| 58 | + if ($tmp::class == '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 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | $object = new $classname($src); |
| 84 | 84 | $cache[$classname][$object->guid] = $object; |
| 85 | - $cache[$classname][$object->id] =& $cache[$classname][$object->guid]; |
|
| 85 | + $cache[$classname][$object->id] = & $cache[$classname][$object->guid]; |
|
| 86 | 86 | return $cache[$classname][$object->guid]; |
| 87 | 87 | } |
| 88 | 88 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | return true; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - if ( isset($object->__object) |
|
| 132 | + if (isset($object->__object) |
|
| 133 | 133 | && is_object($object->__object) |
| 134 | 134 | && $object->__object instanceof $class) { |
| 135 | 135 | // Decorator whose MgdSchema object matches |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | return $this->get_parent_data_uncached($object); |
| 153 | 153 | }); |
| 154 | 154 | |
| 155 | - if ( empty($parent_guid) |
|
| 155 | + if (empty($parent_guid) |
|
| 156 | 156 | || $parent_guid === $object->guid) { |
| 157 | 157 | return null; |
| 158 | 158 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | { |
| 47 | 47 | $this->object = $this->load_object($guid); |
| 48 | 48 | |
| 49 | - if ( !midcom::get()->config->get('midcom_services_rcs_enable') |
|
| 49 | + if (!midcom::get()->config->get('midcom_services_rcs_enable') |
|
| 50 | 50 | || !$this->object->_use_rcs) { |
| 51 | 51 | throw new midcom_error_notfound("Revision control not supported for " . $this->object::class . "."); |
| 52 | 52 | } |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | throw new midcom_error_notfound("Revision {$args[1]} does not exist."); |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | - $data['preview'] = array_filter($this->backend->get_revision($revision), function ($value, $key) { |
|
| 260 | + $data['preview'] = array_filter($this->backend->get_revision($revision), function($value, $key) { |
|
| 261 | 261 | return !is_array($value) |
| 262 | 262 | && !in_array($value, ['', '0000-00-00']) |
| 263 | 263 | && midcom_services_rcs::is_field_showable($key); |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | $this->object->require_do('midgard:update'); |
| 286 | 286 | // TODO: set another privilege for restoring? |
| 287 | 287 | |
| 288 | - if ( $this->backend->get_history()->version_exists($args[1]) |
|
| 288 | + if ($this->backend->get_history()->version_exists($args[1]) |
|
| 289 | 289 | && $this->backend->restore_to_revision($args[1])) { |
| 290 | 290 | midcom::get()->uimessages->add($this->_l10n->get('midcom.admin.rcs'), sprintf($this->_l10n->get('restore to version %s successful'), $args[1])); |
| 291 | 291 | return new midcom_response_relocate($this->get_object_url()); |
@@ -185,10 +185,10 @@ |
||
| 185 | 185 | * |
| 186 | 186 | * @param array $link The necessary link information |
| 187 | 187 | */ |
| 188 | - private function _render_line(array $link, midcom_core_dbaobject &$other_obj) |
|
| 188 | + private function _render_line(array $link, midcom_core_dbaobject & $other_obj) |
|
| 189 | 189 | { |
| 190 | 190 | $this->_request_data['link'] = $link; |
| 191 | - $this->_request_data['other_obj'] =& $other_obj; |
|
| 191 | + $this->_request_data['other_obj'] = & $other_obj; |
|
| 192 | 192 | $this->_request_data['icon'] = midcom_helper_reflector::get_object_icon($other_obj); |
| 193 | 193 | |
| 194 | 194 | if ($other_obj::class != $link['class']) { |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if ( empty($link->toComponent) |
|
| 55 | + if (empty($link->toComponent) |
|
| 56 | 56 | && !empty($link->fromComponent)) { |
| 57 | 57 | debug_add("Setting property 'toComponent' to '{$component}'"); |
| 58 | 58 | $link->toComponent = $component; |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | $link->fromComponent = $component; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - if ( empty($link->toGuid) |
|
| 64 | + if (empty($link->toGuid) |
|
| 65 | 65 | && !empty($link->fromGuid)) { |
| 66 | 66 | $link->toClass = $obj::class; |
| 67 | 67 | $link->toGuid = $obj->guid; |