@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | } |
| 95 | 95 | $this->set_object($id); |
| 96 | 96 | } else { |
| 97 | - if ( is_int($id) |
|
| 97 | + if (is_int($id) |
|
| 98 | 98 | && $id < 1) { |
| 99 | 99 | throw new midcom_error($id . ' is not a valid database ID'); |
| 100 | 100 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | //Some useful information for performance tuning |
| 111 | - if ( midcom::get()->config->get('log_level') >= MIDCOM_LOG_DEBUG |
|
| 111 | + if (midcom::get()->config->get('log_level') >= MIDCOM_LOG_DEBUG |
|
| 112 | 112 | && $this->__object->guid) { |
| 113 | 113 | static $guids = []; |
| 114 | 114 | static $total = 0; |
@@ -102,7 +102,8 @@ |
||
| 102 | 102 | try { |
| 103 | 103 | $mgdschemaclass = $this->__mgdschema_class_name__; |
| 104 | 104 | $this->set_object(new $mgdschemaclass($id)); |
| 105 | - } catch (mgd_exception $e) { |
|
| 105 | + } |
|
| 106 | + catch (mgd_exception $e) { |
|
| 106 | 107 | debug_add('Constructing ' . $this->__mgdschema_class_name__ . ' object ' . $id . ' failed, reason: ' . $e->getMessage(), MIDCOM_LOG_WARN); |
| 107 | 108 | throw new midcom_error_midgard($e, $id); |
| 108 | 109 | } |
@@ -405,7 +405,7 @@ |
||
| 405 | 405 | { |
| 406 | 406 | // Complete fields |
| 407 | 407 | $this->indexed = time(); |
| 408 | - if ( $this->author == '' |
|
| 408 | + if ($this->author == '' |
|
| 409 | 409 | && isset($this->creator->name)) { |
| 410 | 410 | $this->author = $this->creator->name; |
| 411 | 411 | } |
@@ -579,7 +579,8 @@ |
||
| 579 | 579 | { |
| 580 | 580 | try { |
| 581 | 581 | return midcom_db_person::get_cached($guid); |
| 582 | - } catch (midcom_error $e) { |
|
| 582 | + } |
|
| 583 | + catch (midcom_error $e) { |
|
| 583 | 584 | return null; |
| 584 | 585 | } |
| 585 | 586 | } |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | $dup = $this->check_duplicate($results, $result, $conf['duplicate_check']); |
| 89 | 89 | |
| 90 | 90 | if ($dup !== true) { |
| 91 | - if ( !is_object($dup) |
|
| 91 | + if (!is_object($dup) |
|
| 92 | 92 | || !array_key_exists($dup->id, $todelete)) { |
| 93 | 93 | $todelete[$result->id] = $result; |
| 94 | 94 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | - if ( $needs_update |
|
| 100 | + if ($needs_update |
|
| 101 | 101 | && !$result->update()) { |
| 102 | 102 | throw new midcom_error("Failed to update {$classname} #{$result->id}, errstr: " . midcom_connection::get_error_string()); |
| 103 | 103 | } |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | foreach ($results as $result) { |
| 148 | - if ( $result->$field === $object->$field |
|
| 148 | + if ($result->$field === $object->$field |
|
| 149 | 149 | && $result->id !== $object->id) { |
| 150 | 150 | return $result; |
| 151 | 151 | } |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | $changed = false; |
| 164 | 164 | foreach ($person2 as $property => $value) { |
| 165 | 165 | // Copy only simple properties not marked to be skipped missing from person1 |
| 166 | - if ( !empty($person2->$property) |
|
| 166 | + if (!empty($person2->$property) |
|
| 167 | 167 | && empty($person1->$property) |
| 168 | 168 | && !isset($skip_properties[$property]) |
| 169 | 169 | && is_scalar($value)) { |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | |
| 29 | 29 | public function is_readable_by(string $user_id) : bool |
| 30 | 30 | { |
| 31 | - return ( !$user_id |
|
| 31 | + return (!$user_id |
|
| 32 | 32 | || !$this->guid |
| 33 | 33 | || midcom::get()->auth->acl->can_do_byguid('midgard:read', $this->guid, midcom_db_topic::class, $user_id)); |
| 34 | 34 | } |
@@ -351,11 +351,11 @@ discard block |
||
| 351 | 351 | |
| 352 | 352 | $item = array_replace($defaults, $item); |
| 353 | 353 | |
| 354 | - if ( !empty($item[MIDCOM_TOOLBAR_ACCESSKEY]) |
|
| 354 | + if (!empty($item[MIDCOM_TOOLBAR_ACCESSKEY]) |
|
| 355 | 355 | && !array_key_exists($item[MIDCOM_TOOLBAR_ACCESSKEY], $used_access_keys)) { |
| 356 | 356 | // We have valid access key, add it to help text |
| 357 | 357 | $prefix = 'Alt-'; |
| 358 | - if ( isset($_SERVER['HTTP_USER_AGENT']) |
|
| 358 | + if (isset($_SERVER['HTTP_USER_AGENT']) |
|
| 359 | 359 | && strstr($_SERVER['HTTP_USER_AGENT'], 'Macintosh')) { |
| 360 | 360 | // Mac users |
| 361 | 361 | $prefix = 'Ctrl-Alt-'; |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | private function set_url(array &$item, string $url) |
| 378 | 378 | { |
| 379 | 379 | $item[MIDCOM_TOOLBAR__ORIGINAL_URL] = $url; |
| 380 | - if ( ( empty($item[MIDCOM_TOOLBAR_OPTIONS]["rel"]) |
|
| 380 | + if ((empty($item[MIDCOM_TOOLBAR_OPTIONS]["rel"]) |
|
| 381 | 381 | // Some items may want to keep their links unmutilated |
| 382 | 382 | || $item[MIDCOM_TOOLBAR_OPTIONS]["rel"] != "directlink") |
| 383 | 383 | && !str_starts_with($url, '/') |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | |
| 403 | 403 | if ($index == 0) { |
| 404 | 404 | array_shift($this->items); |
| 405 | - } elseif ($index == count($this->items) -1) { |
|
| 405 | + } elseif ($index == count($this->items) - 1) { |
|
| 406 | 406 | array_pop($this->items); |
| 407 | 407 | } else { |
| 408 | 408 | $this->items = array_merge(array_slice($this->items, 0, $index - 1), |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | */ |
| 526 | 526 | public function render() : string |
| 527 | 527 | { |
| 528 | - $visible_items = array_filter($this->items, function ($item) { |
|
| 528 | + $visible_items = array_filter($this->items, function($item) { |
|
| 529 | 529 | return !$item[MIDCOM_TOOLBAR_HIDDEN]; |
| 530 | 530 | }); |
| 531 | 531 | $this->rendered = true; |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | // Try finding uppercase version of the accesskey first |
| 589 | 589 | $accesskey = strtoupper($item[MIDCOM_TOOLBAR_ACCESSKEY]); |
| 590 | 590 | $position = strpos($label, $accesskey); |
| 591 | - if ( $position === false |
|
| 591 | + if ($position === false |
|
| 592 | 592 | && midcom::get()->i18n->get_current_language() == 'en') { |
| 593 | 593 | // Try lowercase, too |
| 594 | 594 | $accesskey = strtolower($accesskey); |
@@ -649,7 +649,7 @@ discard block |
||
| 649 | 649 | $attributes['title'] = $item[MIDCOM_TOOLBAR_HELPTEXT]; |
| 650 | 650 | } |
| 651 | 651 | |
| 652 | - if ( $item[MIDCOM_TOOLBAR_ENABLED] |
|
| 652 | + if ($item[MIDCOM_TOOLBAR_ENABLED] |
|
| 653 | 653 | && $item[MIDCOM_TOOLBAR_ACCESSKEY] !== null) { |
| 654 | 654 | $attributes['class'] = 'accesskey'; |
| 655 | 655 | $attributes['accesskey'] = $item[MIDCOM_TOOLBAR_ACCESSKEY]; |
@@ -712,7 +712,7 @@ discard block |
||
| 712 | 712 | public function get_index_from_url(string $url) : ?int |
| 713 | 713 | { |
| 714 | 714 | foreach ($this->items as $i => $item) { |
| 715 | - if ( $item[MIDCOM_TOOLBAR_URL] == $url |
|
| 715 | + if ($item[MIDCOM_TOOLBAR_URL] == $url |
|
| 716 | 716 | || $item[MIDCOM_TOOLBAR__ORIGINAL_URL] == $url) { |
| 717 | 717 | return $i; |
| 718 | 718 | } |
@@ -730,7 +730,7 @@ discard block |
||
| 730 | 730 | * |
| 731 | 731 | * @param mixed $index The integer index or URL to check |
| 732 | 732 | */ |
| 733 | - protected function _check_index($index, bool $raise_error = true) :?int |
|
| 733 | + protected function _check_index($index, bool $raise_error = true) : ?int |
|
| 734 | 734 | { |
| 735 | 735 | if (is_string($index)) { |
| 736 | 736 | $url = $index; |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | { |
| 138 | 138 | debug_add("task->start() called with user #" . midcom_connection::get_user()); |
| 139 | 139 | //PONDER: Check actual status objects for more accurate logic ? |
| 140 | - if ( $task->status >= org_openpsa_projects_task_status_dba::STARTED |
|
| 140 | + if ($task->status >= org_openpsa_projects_task_status_dba::STARTED |
|
| 141 | 141 | && $task->status <= org_openpsa_projects_task_status_dba::APPROVED) { |
| 142 | 142 | //We already have started status |
| 143 | 143 | debug_add('Task has already been started'); |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | |
| 319 | 319 | private static function is_manager(org_openpsa_projects_task_dba $task) : bool |
| 320 | 320 | { |
| 321 | - return ( $task->manager == 0 |
|
| 321 | + return ($task->manager == 0 |
|
| 322 | 322 | || midcom_connection::get_user() == $task->manager); |
| 323 | 323 | } |
| 324 | 324 | } |
@@ -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 the " . get_class($this) . " {$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 the " . get_class($this) . " {$this->guid} not granted for the current user.", |
| 100 | 100 | MIDCOM_LOG_ERROR); |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | { |
| 16 | 16 | public function write_acls(midcom_core_dbaobject $object, $owner_id, int $accesstype) : bool |
| 17 | 17 | { |
| 18 | - if ( empty($owner_id) |
|
| 18 | + if (empty($owner_id) |
|
| 19 | 19 | || empty($accesstype)) { |
| 20 | 20 | return false; |
| 21 | 21 | } |
@@ -63,14 +63,14 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | if ($privileges) { |
| 65 | 65 | foreach ($privileges as $privilege) { |
| 66 | - if ( !empty($needed_privileges[$privilege->privilegename]) |
|
| 66 | + if (!empty($needed_privileges[$privilege->privilegename]) |
|
| 67 | 67 | && $needed_privileges[$privilege->privilegename]['assignee'] == $privilege->assignee |
| 68 | 68 | && $needed_privileges[$privilege->privilegename]['value'] == $privilege->value) { |
| 69 | 69 | unset($needed_privileges[$privilege->privilegename]); |
| 70 | 70 | continue; |
| 71 | 71 | } |
| 72 | 72 | // Clear old ACLs applying to others than current user or selected owner group |
| 73 | - if ( $privilege->assignee != midcom::get()->auth->user->id |
|
| 73 | + if ($privilege->assignee != midcom::get()->auth->user->id |
|
| 74 | 74 | && $privilege->assignee != $owner_id) { |
| 75 | 75 | debug_add("Removing privilege {$privilege->privilegename} from {$privilege->assignee}"); |
| 76 | 76 | $object->unset_privilege($privilege->privilegename, $privilege->assignee); |
@@ -318,7 +318,7 @@ |
||
| 318 | 318 | public function update_cache() |
| 319 | 319 | { |
| 320 | 320 | // Check if the attachment can be read anonymously |
| 321 | - if ( midcom::get()->config->get('attachment_cache_enabled') |
|
| 321 | + if (midcom::get()->config->get('attachment_cache_enabled') |
|
| 322 | 322 | && !$this->can_do('midgard:read', 'EVERYONE')) { |
| 323 | 323 | // Not public file, ensure it is removed |
| 324 | 324 | $this->remove_from_cache(); |