@@ -27,7 +27,7 @@ |
||
27 | 27 | $prefix = $nap->get_node($this->_topic->id)[MIDCOM_NAV_ABSOLUTEURL]; |
28 | 28 | |
29 | 29 | $tree = new org_openpsa_widgets_tree(org_openpsa_contacts_group_dba::class, 'owner'); |
30 | - $tree->link_callback = function ($guid) use ($prefix) { |
|
30 | + $tree->link_callback = function($guid) use ($prefix) { |
|
31 | 31 | return $prefix . 'group/' . $guid . '/'; |
32 | 32 | }; |
33 | 33 | $tree->constraints[] = ['orgOpenpsaObtype', '<', org_openpsa_contacts_group_dba::ORGANIZATION]; |
@@ -171,7 +171,7 @@ |
||
171 | 171 | if (!empty($field->vars['value'])) { |
172 | 172 | //only index the first attachment for now |
173 | 173 | $attachment = array_shift($field->vars['value']); |
174 | - if ( !$attachment instanceof \midcom_db_attachment |
|
174 | + if (!$attachment instanceof \midcom_db_attachment |
|
175 | 175 | && !empty($attachment['object'])) { |
176 | 176 | //This is the form edit case |
177 | 177 | //@todo: In create case, nothing is found currently |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | |
341 | 341 | $item = array_replace($defaults, $item); |
342 | 342 | |
343 | - if ( !empty($item[MIDCOM_TOOLBAR_ACCESSKEY]) |
|
343 | + if (!empty($item[MIDCOM_TOOLBAR_ACCESSKEY]) |
|
344 | 344 | && !array_key_exists($item[MIDCOM_TOOLBAR_ACCESSKEY], $used_access_keys)) { |
345 | 345 | // We have valid access key, add it to help text |
346 | 346 | $prefix = 'Alt-'; |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | private function set_url(array &$item, string $url) |
366 | 366 | { |
367 | 367 | $item[MIDCOM_TOOLBAR__ORIGINAL_URL] = $url; |
368 | - if ( ( empty($item[MIDCOM_TOOLBAR_OPTIONS]["rel"]) |
|
368 | + if ((empty($item[MIDCOM_TOOLBAR_OPTIONS]["rel"]) |
|
369 | 369 | // Some items may want to keep their links unmutilated |
370 | 370 | || $item[MIDCOM_TOOLBAR_OPTIONS]["rel"] != "directlink") |
371 | 371 | && !str_starts_with($url, '/') |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | |
391 | 391 | if ($index == 0) { |
392 | 392 | array_shift($this->items); |
393 | - } elseif ($index == count($this->items) -1) { |
|
393 | + } elseif ($index == count($this->items) - 1) { |
|
394 | 394 | array_pop($this->items); |
395 | 395 | } else { |
396 | 396 | $this->items = array_merge(array_slice($this->items, 0, $index), |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | */ |
514 | 514 | public function render() : string |
515 | 515 | { |
516 | - $visible_items = array_filter($this->items, function ($item) { |
|
516 | + $visible_items = array_filter($this->items, function($item) { |
|
517 | 517 | return !$item[MIDCOM_TOOLBAR_HIDDEN]; |
518 | 518 | }); |
519 | 519 | $this->rendered = true; |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | // Try finding uppercase version of the accesskey first |
577 | 577 | $accesskey = strtoupper($item[MIDCOM_TOOLBAR_ACCESSKEY]); |
578 | 578 | $position = strpos($label, $accesskey); |
579 | - if ( $position === false |
|
579 | + if ($position === false |
|
580 | 580 | && midcom::get()->i18n->get_current_language() == 'en') { |
581 | 581 | // Try lowercase, too |
582 | 582 | $accesskey = strtolower($accesskey); |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | $attributes['title'] = $item[MIDCOM_TOOLBAR_HELPTEXT]; |
637 | 637 | } |
638 | 638 | |
639 | - if ( $item[MIDCOM_TOOLBAR_ENABLED] |
|
639 | + if ($item[MIDCOM_TOOLBAR_ENABLED] |
|
640 | 640 | && $item[MIDCOM_TOOLBAR_ACCESSKEY] !== null) { |
641 | 641 | $attributes['class'] = 'accesskey'; |
642 | 642 | $attributes['accesskey'] = $item[MIDCOM_TOOLBAR_ACCESSKEY]; |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | public function get_index_from_url(string $url) : ?int |
700 | 700 | { |
701 | 701 | foreach ($this->items as $i => $item) { |
702 | - if ( $item[MIDCOM_TOOLBAR_URL] == $url |
|
702 | + if ($item[MIDCOM_TOOLBAR_URL] == $url |
|
703 | 703 | || $item[MIDCOM_TOOLBAR__ORIGINAL_URL] == $url) { |
704 | 704 | return $i; |
705 | 705 | } |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | * |
718 | 718 | * @param mixed $index The integer index or URL to check |
719 | 719 | */ |
720 | - protected function _check_index($index, bool $raise_error = true) :?int |
|
720 | + protected function _check_index($index, bool $raise_error = true) : ?int |
|
721 | 721 | { |
722 | 722 | if (is_string($index)) { |
723 | 723 | $url = $index; |
@@ -55,11 +55,11 @@ |
||
55 | 55 | foreach (array_filter($csv_line) as $field => $value) { |
56 | 56 | // Process the row accordingly |
57 | 57 | $field_matching = $this->_settings['fields'][$field]; |
58 | - if ( $field_matching |
|
58 | + if ($field_matching |
|
59 | 59 | && str_contains($field_matching, ':')) { |
60 | 60 | [$schemadb, $schema_field] = explode(':', $field_matching); |
61 | 61 | |
62 | - if ( !array_key_exists($schemadb, $this->_schemadbs) |
|
62 | + if (!array_key_exists($schemadb, $this->_schemadbs) |
|
63 | 63 | || !$this->_schemadbs[$schemadb]->get('default')->has_field($schema_field)) { |
64 | 64 | // Invalid matching, skip |
65 | 65 | continue; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | private function apply_constraints(midcom_core_query $query, array $constraints) |
84 | 84 | { |
85 | 85 | foreach ($constraints as $key => $data) { |
86 | - if ( !array_key_exists('value', $data) |
|
86 | + if (!array_key_exists('value', $data) |
|
87 | 87 | || empty($data['field']) |
88 | 88 | || empty($data['op'])) { |
89 | 89 | debug_add("Constraint #{$key} is not correctly defined, skipping", MIDCOM_LOG_WARN); |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | { |
145 | 145 | $query = $this->request["term"]; |
146 | 146 | $wildcard_query = $query; |
147 | - if ( isset($this->request['auto_wildcards']) |
|
147 | + if (isset($this->request['auto_wildcards']) |
|
148 | 148 | && !str_contains($query, '%')) { |
149 | 149 | switch ($this->request['auto_wildcards']) { |
150 | 150 | case 'start': |
@@ -252,9 +252,7 @@ discard block |
||
252 | 252 | return $label; |
253 | 253 | } |
254 | 254 | } |
255 | - return midcom_helper_reflector::get($object)->get_object_label($object) ?: |
|
256 | - self::build_label($object, array_column($result_headers, 'name')) ?: |
|
257 | - get_class($object) . ' #' . $object->id; |
|
255 | + return midcom_helper_reflector::get($object)->get_object_label($object) ?: self::build_label($object, array_column($result_headers, 'name')) ?: get_class($object) . ' #' . $object->id; |
|
258 | 256 | } |
259 | 257 | |
260 | 258 | private static function build_label($object, array $fields) : string |
@@ -289,7 +287,7 @@ discard block |
||
289 | 287 | } |
290 | 288 | return self::sanitize_label($value); |
291 | 289 | } |
292 | - if ( $field == 'username' |
|
290 | + if ($field == 'username' |
|
293 | 291 | && $object instanceof midcom_db_person) { |
294 | 292 | $account = new midcom_core_account($object); |
295 | 293 | return self::sanitize_label($account->get_username()); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public function set_privilege($privilege, $assignee = null, int $value = MIDCOM_PRIVILEGE_ALLOW, string $classname = '') : bool |
66 | 66 | { |
67 | - if ( !$this->can_do('midgard:update') |
|
67 | + if (!$this->can_do('midgard:update') |
|
68 | 68 | || !$this->can_do('midgard:privileges')) { |
69 | 69 | debug_add("Failed to set a privilege, midgard:update or midgard:privileges on " . static::class . " {$this->guid} not granted for the current user.", |
70 | 70 | MIDCOM_LOG_ERROR); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function unset_privilege($privilege, $assignee = null, string $classname = '') : bool |
96 | 96 | { |
97 | - if ( !$this->can_do('midgard:update') |
|
97 | + if (!$this->can_do('midgard:update') |
|
98 | 98 | || !$this->can_do('midgard:privileges')) { |
99 | 99 | debug_add("Failed to unset a privilege, midgard:update or midgard:privileges on " . static::class . " {$this->guid} not granted for the current user.", |
100 | 100 | MIDCOM_LOG_ERROR); |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | if ( !$this->can_do('midgard:update') |
205 | 205 | || !$this->can_do('midgard:parameters')) { |
206 | 206 | debug_add("Failed to set parameters, midgard:update or midgard:parameters on " . static::class . " {$this->guid} not granted for the current user.", |
207 | - MIDCOM_LOG_ERROR); |
|
207 | + MIDCOM_LOG_ERROR); |
|
208 | 208 | midcom_connection::set_error(MGD_ERR_ACCESS_DENIED); |
209 | 209 | return false; |
210 | 210 | } |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | if ( !$this->can_do('midgard:update') |
249 | 249 | || !$this->can_do('midgard:parameters')) { |
250 | 250 | debug_add("Failed to delete parameters, midgard:update or midgard:parameters on " . static::class . " {$this->guid} not granted for the current user.", |
251 | - MIDCOM_LOG_ERROR); |
|
251 | + MIDCOM_LOG_ERROR); |
|
252 | 252 | midcom_connection::set_error(MGD_ERR_ACCESS_DENIED); |
253 | 253 | return false; |
254 | 254 | } |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | return false; |
202 | 202 | } |
203 | 203 | |
204 | - if ( !$this->can_do('midgard:update') |
|
204 | + if (!$this->can_do('midgard:update') |
|
205 | 205 | || !$this->can_do('midgard:parameters')) { |
206 | 206 | debug_add("Failed to set parameters, midgard:update or midgard:parameters on " . static::class . " {$this->guid} not granted for the current user.", |
207 | 207 | MIDCOM_LOG_ERROR); |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | return false; |
246 | 246 | } |
247 | 247 | |
248 | - if ( !$this->can_do('midgard:update') |
|
248 | + if (!$this->can_do('midgard:update') |
|
249 | 249 | || !$this->can_do('midgard:parameters')) { |
250 | 250 | debug_add("Failed to delete parameters, midgard:update or midgard:parameters on " . static::class . " {$this->guid} not granted for the current user.", |
251 | 251 | MIDCOM_LOG_ERROR); |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | return false; |
52 | 52 | } |
53 | 53 | |
54 | - if ( !$this->can_do('midgard:update') |
|
54 | + if (!$this->can_do('midgard:update') |
|
55 | 55 | || !$this->can_do('midgard:attachments')) { |
56 | 56 | debug_add("Failed to set parameters, midgard:update or midgard:attachments on " . static::class . " {$this->guid} not granted for the current user.", |
57 | 57 | MIDCOM_LOG_ERROR); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | return null; |
72 | 72 | } |
73 | 73 | |
74 | - if ( !$this->can_do('midgard:update') |
|
74 | + if (!$this->can_do('midgard:update') |
|
75 | 75 | || !$this->can_do('midgard:attachments')) { |
76 | 76 | debug_add("Failed to set parameters, midgard:update or midgard:attachments on the " . static::class . " {$this->guid} not granted for the current user.", |
77 | 77 | MIDCOM_LOG_ERROR); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $attachment->parentguid = $this->guid; |
86 | 86 | |
87 | 87 | if (!$attachment->create()) { |
88 | - debug_add("Could not create the attachment '{$name}' for " . static::class . " {$this->guid}: " . midcom_connection::get_error_string(), |
|
88 | + debug_add("Could not create the attachment '{$name}' for " . static::class . " {$this->guid}: " . midcom_connection::get_error_string(), |
|
89 | 89 | MIDCOM_LOG_INFO); |
90 | 90 | return null; |
91 | 91 | } |
@@ -226,7 +226,7 @@ |
||
226 | 226 | private function error(string $message, string $filename, int $line) : midcom_error |
227 | 227 | { |
228 | 228 | $line++; // Array is 0-indexed |
229 | - return new midcom_error('L10n DB SYNTAX ERROR: ' . $message . ' at ' . $filename . ' ' . $line); |
|
229 | + return new midcom_error('L10n DB SYNTAX ERROR: ' . $message . ' at ' . $filename . ' ' . $line); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |