@@ -64,7 +64,8 @@ discard block |
||
64 | 64 | { |
65 | 65 | try { |
66 | 66 | $this->_object = midcom::get()->dbfactory->get_object_by_guid($guid); |
67 | - } catch (midcom_error $e) { |
|
67 | + } |
|
68 | + catch (midcom_error $e) { |
|
68 | 69 | if (midcom_connection::get_error() == MGD_ERR_OBJECT_DELETED) { |
69 | 70 | $relocate = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX) . '__mfa/asgard/object/deleted/' . $guid . '/'; |
70 | 71 | midcom::get()->relocate($relocate); |
@@ -232,8 +233,7 @@ discard block |
||
232 | 233 | $this->_new_object = new $create_type(); |
233 | 234 | $mgd_type = midcom::get()->dbclassloader->get_mgdschema_class_name_for_midcom_class($create_type); |
234 | 235 | |
235 | - if ($parent_property = midgard_object_class::get_property_parent($mgd_type)) |
|
236 | - { |
|
236 | + if ($parent_property = midgard_object_class::get_property_parent($mgd_type)) { |
|
237 | 237 | $this->_new_object->$parent_property = $controller->formmanager->get_value($parent_property); |
238 | 238 | } |
239 | 239 |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | |
168 | 168 | $this->_load_schemadb(); |
169 | 169 | $this->_controller = midcom_helper_datamanager2_controller::create('simple'); |
170 | - $this->_controller->schemadb =& $this->_schemadb; |
|
170 | + $this->_controller->schemadb = & $this->_schemadb; |
|
171 | 171 | $this->_controller->set_storage($this->_object, 'object'); |
172 | 172 | if (!$this->_controller->initialize()) { |
173 | 173 | throw new midcom_error("Failed to initialize a DM2 controller instance for object {$this->_object->guid}."); |
@@ -184,11 +184,11 @@ discard block |
||
184 | 184 | return $this->_prepare_relocate($this->_object); |
185 | 185 | |
186 | 186 | case 'edit': |
187 | - $qf =& $this->_controller->formmanager->form; |
|
188 | - if ( $qf->isSubmitted() |
|
187 | + $qf = & $this->_controller->formmanager->form; |
|
188 | + if ($qf->isSubmitted() |
|
189 | 189 | && !$qf->validate()) { |
190 | 190 | foreach ($qf->_errors as $field => $error) { |
191 | - $element =& $qf->getElement($field); |
|
191 | + $element = & $qf->getElement($field); |
|
192 | 192 | $message = sprintf($this->_l10n->get('validation error in field %s: %s'), $element->getLabel(), $error); |
193 | 193 | midcom::get()->uimessages->add( |
194 | 194 | $this->_l10n->get('midgard.admin.asgard'), |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | |
232 | 232 | if (!$this->_new_object->create()) { |
233 | 233 | debug_print_r('We operated on this object:', $this->_new_object); |
234 | - throw new midcom_error('Failed to create a new object. Last Midgard error was: '. midcom_connection::get_error_string()); |
|
234 | + throw new midcom_error('Failed to create a new object. Last Midgard error was: ' . midcom_connection::get_error_string()); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | return $this->_new_object; |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | midcom::get()->auth->require_user_do('midgard.admin.asgard:manage_objects', null, 'midgard_admin_asgard_plugin'); |
261 | 261 | |
262 | 262 | $data['defaults'] = array(); |
263 | - if ( $handler_id == '____mfa-asgard-object_create_toplevel' |
|
263 | + if ($handler_id == '____mfa-asgard-object_create_toplevel' |
|
264 | 264 | || $handler_id == '____mfa-asgard-object_create_chooser') { |
265 | 265 | midcom::get()->auth->require_user_do('midgard:create', null, $this->_new_type); |
266 | 266 | |
@@ -278,9 +278,9 @@ discard block |
||
278 | 278 | } |
279 | 279 | |
280 | 280 | $this->_controller = midcom_helper_datamanager2_controller::create('create'); |
281 | - $this->_controller->schemadb =& $this->_schemadb; |
|
281 | + $this->_controller->schemadb = & $this->_schemadb; |
|
282 | 282 | $this->_controller->schema = 'object'; |
283 | - $this->_controller->callback_object =& $this; |
|
283 | + $this->_controller->callback_object = & $this; |
|
284 | 284 | $this->_controller->defaults = $this->_get_defaults(); |
285 | 285 | if (!$this->_controller->initialize()) { |
286 | 286 | throw new midcom_error("Failed to initialize a DM2 create controller."); |
@@ -321,11 +321,11 @@ discard block |
||
321 | 321 | $parent_property = null; |
322 | 322 | $new_type_reflector = midcom_helper_reflector::get($this->_new_type); |
323 | 323 | $link_properties = $new_type_reflector->get_link_properties(); |
324 | - $type_to_link_to = midcom_helper_reflector::class_rewrite(get_class($this->_object)); |
|
324 | + $type_to_link_to = midcom_helper_reflector::class_rewrite(get_class($this->_object)); |
|
325 | 325 | foreach ($link_properties as $child_property => $link) { |
326 | 326 | $linked_type = midcom_helper_reflector::class_rewrite($link['class']); |
327 | 327 | if (midcom_helper_reflector::is_same_class($linked_type, $type_to_link_to) |
328 | - || ( $link['type'] == MGD_TYPE_GUID |
|
328 | + || ($link['type'] == MGD_TYPE_GUID |
|
329 | 329 | && is_null($link['class']))) { |
330 | 330 | $parent_property = $link['target']; |
331 | 331 | break; |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | } |
339 | 339 | |
340 | 340 | // Allow setting defaults from query string, useful for things like "create event for today" and chooser |
341 | - if ( isset($_GET['defaults']) |
|
341 | + if (isset($_GET['defaults']) |
|
342 | 342 | && is_array($_GET['defaults'])) { |
343 | 343 | $get_defaults = array_intersect_key($_GET['defaults'], $this->_schemadb['object']->fields); |
344 | 344 | $defaults = array_merge($defaults, array_map('trim', $get_defaults)); |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | { |
357 | 357 | if ($handler_id == '____mfa-asgard-object_create_chooser') { |
358 | 358 | midcom_show_style('midgard_admin_asgard_popup_header'); |
359 | - if ( $this->_new_object |
|
359 | + if ($this->_new_object |
|
360 | 360 | || isset($data['cancelled'])) { |
361 | 361 | $data['jsdata'] = $this->_object_to_jsdata($this->_new_object); |
362 | 362 | midcom_show_style('midgard_admin_asgard_object_create_after'); |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | $url = $type; |
408 | 408 | |
409 | 409 | $class_extends = $this->_config->get('class_extends'); |
410 | - if ( is_array($class_extends) |
|
410 | + if (is_array($class_extends) |
|
411 | 411 | && array_key_exists($type, $class_extends)) { |
412 | 412 | $url = $class_extends[$type]; |
413 | 413 | } |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | |
507 | 507 | // Load the nullstorage controller |
508 | 508 | $this->_controller = midcom_helper_datamanager2_controller::create('nullstorage'); |
509 | - $this->_controller->schemadb =& $this->_schemadb; |
|
509 | + $this->_controller->schemadb = & $this->_schemadb; |
|
510 | 510 | |
511 | 511 | if (!$this->_controller->initialize()) { |
512 | 512 | throw new midcom_error('Failed to initialize the controller'); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | // Skip components beginning with midcom or midgard |
85 | - if ( preg_match('/^(midcom|midgard)\./', $manifest->name) |
|
85 | + if (preg_match('/^(midcom|midgard)\./', $manifest->name) |
|
86 | 86 | && $manifest->name != 'midcom.helper.search') { |
87 | 87 | continue; |
88 | 88 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | asort($components); |
100 | 100 | |
101 | 101 | // Set the parent component to be the first if applicable |
102 | - if ( $parent_component !== '' |
|
102 | + if ($parent_component !== '' |
|
103 | 103 | && array_key_exists($parent_component, $components)) { |
104 | 104 | $temp = array(); |
105 | 105 | $temp[$parent_component] = $components[$parent_component]; |
@@ -128,14 +128,14 @@ discard block |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | foreach (self::get_component_list() as $component => $details) { |
131 | - if ( $component !== $parent_component |
|
131 | + if ($component !== $parent_component |
|
132 | 132 | && !$all) { |
133 | - if ( is_array(midcom::get()->config->get('component_listing_allowed')) |
|
133 | + if (is_array(midcom::get()->config->get('component_listing_allowed')) |
|
134 | 134 | && !in_array($component, midcom::get()->config->get('component_listing_allowed'))) { |
135 | 135 | continue; |
136 | 136 | } |
137 | 137 | |
138 | - if ( is_array(midcom::get()->config->get('component_listing_excluded')) |
|
138 | + if (is_array(midcom::get()->config->get('component_listing_excluded')) |
|
139 | 139 | && in_array($component, midcom::get()->config->get('component_listing_excluded'))) { |
140 | 140 | continue; |
141 | 141 | } |
@@ -14,7 +14,7 @@ |
||
14 | 14 | class midcom_config_test |
15 | 15 | { |
16 | 16 | const OK = 0; |
17 | - const WARNING = 1; |
|
17 | + const WARNING = 1; |
|
18 | 18 | const ERROR = 2; |
19 | 19 | |
20 | 20 | private $messages = array( |
@@ -104,7 +104,7 @@ |
||
104 | 104 | $this->add('Setting: upload_max_filesize', self::OK, ini_get('upload_max_filesize')); |
105 | 105 | } else { |
106 | 106 | $this->add('Setting: upload_max_filesize', |
107 | - self::WARNING, "To make bulk uploads (for exampe in the Image Gallery) useful, you should increase the Upload limit to something above 50 MB. (Current setting: {$upload_limit})"); |
|
107 | + self::WARNING, "To make bulk uploads (for exampe in the Image Gallery) useful, you should increase the Upload limit to something above 50 MB. (Current setting: {$upload_limit})"); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | $post_limit = $this->ini_get_filesize('post_max_size'); |
@@ -74,7 +74,8 @@ |
||
74 | 74 | $config = new midcom_services_rcs_config($config); |
75 | 75 | $config->test_rcs_config(); |
76 | 76 | $this->add("MidCOM RCS", self::OK); |
77 | - } catch (midcom_error $e) { |
|
77 | + } |
|
78 | + catch (midcom_error $e) { |
|
78 | 79 | $this->add("MidCOM RCS", self::ERROR, $e->getMessage()); |
79 | 80 | } |
80 | 81 | } else { |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | { |
53 | 53 | $qb = call_user_func(array($this->_request['class'], 'new_query_builder')); |
54 | 54 | |
55 | - if ( !empty($this->_request['constraints']) |
|
55 | + if (!empty($this->_request['constraints']) |
|
56 | 56 | && is_array($this->_request['constraints'])) { |
57 | 57 | $this->_apply_constraints($qb, $this->_request['constraints']); |
58 | 58 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $qb->end_group(); |
65 | 65 | } |
66 | 66 | |
67 | - if ( !empty($this->_request['orders']) |
|
67 | + if (!empty($this->_request['orders']) |
|
68 | 68 | && is_array($this->_request['orders'])) { |
69 | 69 | ksort($this->_request['orders']); |
70 | 70 | foreach ($this->_request['orders'] as $data) { |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | |
84 | 84 | ksort($constraints); |
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); |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | { |
157 | 157 | $query = $this->_request["term"]; |
158 | 158 | $wildcard_query = $query; |
159 | - if ( isset($this->_request['auto_wildcards']) |
|
159 | + if (isset($this->_request['auto_wildcards']) |
|
160 | 160 | && strpos($query, '%') === false) { |
161 | 161 | switch ($this->_request['auto_wildcards']) { |
162 | 162 | case 'start': |
@@ -275,11 +275,11 @@ discard block |
||
275 | 275 | self::$_data = self::$_defaults; |
276 | 276 | } |
277 | 277 | |
278 | - if ( null === $subkey |
|
278 | + if (null === $subkey |
|
279 | 279 | && isset(self::$_data[$key])) { |
280 | 280 | return self::$_data[$key]; |
281 | 281 | } |
282 | - if ( null !== $subkey |
|
282 | + if (null !== $subkey |
|
283 | 283 | && isset(self::$_data[$key][$subkey])) { |
284 | 284 | return self::$_data[$key][$subkey]; |
285 | 285 | } |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | if ($part === '') { |
342 | 342 | continue; |
343 | 343 | } |
344 | - if ( midcom::get()->config->get('theme') |
|
344 | + if (midcom::get()->config->get('theme') |
|
345 | 345 | && !$args_started |
346 | 346 | && midcom_helper_misc::check_page_exists($part)) { |
347 | 347 | $page_style .= '/' . $part; |
@@ -136,7 +136,8 @@ |
||
136 | 136 | |
137 | 137 | try { |
138 | 138 | $user = new midgard_user($login_tokens); |
139 | - } catch (midgard_error_exception $e) { |
|
139 | + } |
|
140 | + catch (midgard_error_exception $e) { |
|
140 | 141 | return false; |
141 | 142 | } |
142 | 143 |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | $counter = 0; |
135 | 135 | |
136 | 136 | foreach ($result as $object_guid => $empty_copy) { |
137 | - if ( $this->_user_id |
|
137 | + if ($this->_user_id |
|
138 | 138 | && !midcom::get()->auth->acl->can_do_byguid('midgard:read', $object_guid, $classname, $this->_user_id)) { |
139 | 139 | debug_add("Failed to load result, read privilege on {$object_guid} not granted for the current user.", MIDCOM_LOG_INFO); |
140 | 140 | continue; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | if ($counter <= $this->_offset) { |
146 | 146 | continue; |
147 | 147 | } |
148 | - if ( $this->_limit |
|
148 | + if ($this->_limit |
|
149 | 149 | && $counter > ($this->_offset + $this->_limit)) { |
150 | 150 | break; |
151 | 151 | } |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | |
224 | 224 | public function get_subkey($key, $property) |
225 | 225 | { |
226 | - if ( $this->_user_id |
|
226 | + if ($this->_user_id |
|
227 | 227 | && !midcom::get()->auth->acl->can_do_byguid('midgard:read', $key, $this->_real_class, $this->_user_id)) { |
228 | 228 | midcom_connection::set_error(MGD_ERR_ACCESS_DENIED); |
229 | 229 | return false; |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | |
234 | 234 | public function get($key) |
235 | 235 | { |
236 | - if ( $this->_user_id |
|
236 | + if ($this->_user_id |
|
237 | 237 | && !midcom::get()->auth->acl->can_do_byguid('midgard:read', $key, $this->_real_class, $this->_user_id)) { |
238 | 238 | midcom_connection::set_error(MGD_ERR_ACCESS_DENIED); |
239 | 239 | return false; |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | } |
301 | 301 | |
302 | 302 | // Sanity check expires |
303 | - if ( !is_int($expires) |
|
303 | + if (!is_int($expires) |
|
304 | 304 | || $expires < -1) { |
305 | 305 | throw new midcom_error("\$expires has to be a positive integer or zero or -1, is now {$expires}."); |
306 | 306 | } |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | $etag = md5("{$last_modified}{$attachment->name}{$attachment->mimetype}{$attachment->guid}"); |
314 | 314 | |
315 | 315 | // Check etag and return 304 if necessary |
316 | - if ( $expires <> 0 |
|
316 | + if ($expires <> 0 |
|
317 | 317 | && $this->cache->content->_check_not_modified($last_modified, $etag)) { |
318 | 318 | if (!_midcom_headers_sent()) { |
319 | 319 | $this->cache->content->cache_control_headers(); |
@@ -491,8 +491,8 @@ discard block |
||
491 | 491 | function get_host_name() |
492 | 492 | { |
493 | 493 | if (!$this->_cached_host_name) { |
494 | - if ( array_key_exists("SSL_PROTOCOL", $_SERVER) |
|
495 | - || ( array_key_exists('HTTPS', $_SERVER) |
|
494 | + if (array_key_exists("SSL_PROTOCOL", $_SERVER) |
|
495 | + || (array_key_exists('HTTPS', $_SERVER) |
|
496 | 496 | && $_SERVER['HTTPS'] == 'on') |
497 | 497 | || $_SERVER["SERVER_PORT"] == 443) { |
498 | 498 | $protocol = "https"; |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | |
503 | 503 | $port = ""; |
504 | 504 | if (strpos($_SERVER['SERVER_NAME'], ':') === false) { |
505 | - if ( ($protocol == "http" && $_SERVER["SERVER_PORT"] != 80) |
|
505 | + if (($protocol == "http" && $_SERVER["SERVER_PORT"] != 80) |
|
506 | 506 | || ($protocol == "https" && $_SERVER["SERVER_PORT"] != 443)) { |
507 | 507 | $port = ":" . $_SERVER["SERVER_PORT"]; |
508 | 508 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | private function _process_cache($value) |
127 | 127 | { |
128 | 128 | if ($value == 'invalidate') { |
129 | - if ( !is_array(midcom::get()->config->get('indexer_reindex_allowed_ips')) |
|
129 | + if (!is_array(midcom::get()->config->get('indexer_reindex_allowed_ips')) |
|
130 | 130 | || !in_array($_SERVER['REMOTE_ADDR'], midcom::get()->config->get('indexer_reindex_allowed_ips'))) { |
131 | 131 | midcom::get()->auth->require_valid_user('basic'); |
132 | 132 | midcom::get()->auth->require_admin_user(); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | private function _get_remaining_url($value) |
174 | 174 | { |
175 | 175 | $redirect_to = ''; |
176 | - if ( !empty($value) |
|
176 | + if (!empty($value) |
|
177 | 177 | || !empty($this->_context->parser->argv)) { |
178 | 178 | $redirect_to = "{$value}/" . implode($this->_context->parser->argv, '/'); |
179 | 179 | $redirect_to = preg_replace('%^(.*?):/([^/])%', '\\1://\\2', $redirect_to); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | public function get_parent_guid_uncached() |
83 | 83 | { |
84 | - if ( $this->up |
|
84 | + if ($this->up |
|
85 | 85 | || $this->title != '__org_openpsa_calendar') { |
86 | 86 | $root_event = org_openpsa_calendar_interface::find_root_event(); |
87 | 87 | if ($this->id != $root_event->id) { |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | } |
142 | 142 | |
143 | 143 | //Check up |
144 | - if ( !$this->up |
|
144 | + if (!$this->up |
|
145 | 145 | && $this->title != '__org_openpsa_calendar') { |
146 | 146 | $root_event = org_openpsa_calendar_interface::find_root_event(); |
147 | 147 | $this->up = $root_event->id; |
@@ -173,9 +173,9 @@ discard block |
||
173 | 173 | private function _check_timerange() |
174 | 174 | { |
175 | 175 | //Force types |
176 | - $this->start = (int)$this->start; |
|
177 | - $this->end = (int)$this->end; |
|
178 | - if ( !$this->start |
|
176 | + $this->start = (int) $this->start; |
|
177 | + $this->end = (int) $this->end; |
|
178 | + if (!$this->start |
|
179 | 179 | || !$this->end) { |
180 | 180 | debug_add('Event must have start and end timestamps'); |
181 | 181 | midcom_connection::set_error(MGD_ERR_RANGE); |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * Force start and end seconds to 1 and 0 respectively |
187 | 187 | * (to avoid stupid one second overlaps) |
188 | 188 | */ |
189 | - $this->start = mktime( date('G', $this->start), |
|
189 | + $this->start = mktime(date('G', $this->start), |
|
190 | 190 | date('i', $this->start), |
191 | 191 | 1, |
192 | 192 | date('n', $this->start), |