@@ -95,15 +95,13 @@ discard block |
||
| 95 | 95 | { |
| 96 | 96 | $this->_schemadb = midcom_helper_datamanager2_schema::load_database($this->_config->get('schemadb')); |
| 97 | 97 | |
| 98 | - if ( $this->_config->get('use_captcha') |
|
| 99 | - || ( !midcom::get()->auth->user |
|
| 98 | + if ($this->_config->get('use_captcha') |
|
| 99 | + || (!midcom::get()->auth->user |
|
| 100 | 100 | && $this->_config->get('use_captcha_if_anonymous'))) |
| 101 | 101 | { |
| 102 | - $this->_schemadb['comment']->append_field |
|
| 103 | - ( |
|
| 102 | + $this->_schemadb['comment']->append_field( |
|
| 104 | 103 | 'captcha', |
| 105 | - array |
|
| 106 | - ( |
|
| 104 | + array( |
|
| 107 | 105 | 'title' => $this->_l10n_midcom->get('captcha field title'), |
| 108 | 106 | 'storage' => null, |
| 109 | 107 | 'type' => 'captcha', |
@@ -113,7 +111,7 @@ discard block |
||
| 113 | 111 | ); |
| 114 | 112 | } |
| 115 | 113 | |
| 116 | - if ( $this->_config->get('ratings_enable') |
|
| 114 | + if ($this->_config->get('ratings_enable') |
|
| 117 | 115 | && array_key_exists('rating', $this->_schemadb['comment']->fields)) |
| 118 | 116 | { |
| 119 | 117 | $this->_schemadb['comment']->fields['rating']['hidden'] = false; |
@@ -135,12 +133,12 @@ discard block |
||
| 135 | 133 | } |
| 136 | 134 | |
| 137 | 135 | $this->_post_controller = midcom_helper_datamanager2_controller::create('create'); |
| 138 | - $this->_post_controller->schemadb =& $this->_schemadb; |
|
| 136 | + $this->_post_controller->schemadb = & $this->_schemadb; |
|
| 139 | 137 | $this->_post_controller->schema = 'comment'; |
| 140 | 138 | $this->_post_controller->defaults = $defaults; |
| 141 | - $this->_post_controller->callback_object =& $this; |
|
| 139 | + $this->_post_controller->callback_object = & $this; |
|
| 142 | 140 | |
| 143 | - if (! $this->_post_controller->initialize()) |
|
| 141 | + if (!$this->_post_controller->initialize()) |
|
| 144 | 142 | { |
| 145 | 143 | throw new midcom_error('Failed to initialize a DM2 create controller.'); |
| 146 | 144 | } |
@@ -149,7 +147,7 @@ discard block |
||
| 149 | 147 | /** |
| 150 | 148 | * DM2 creation callback, binds the new object directly to the _objectguid. |
| 151 | 149 | */ |
| 152 | - function & dm2_create_callback (&$controller) |
|
| 150 | + function & dm2_create_callback(&$controller) |
|
| 153 | 151 | { |
| 154 | 152 | $this->_new_comment = new net_nehmer_comments_comment(); |
| 155 | 153 | $this->_new_comment->objectguid = $this->_objectguid; |
@@ -178,13 +176,13 @@ discard block |
||
| 178 | 176 | $this->_new_comment->_send_notification = true; |
| 179 | 177 | } |
| 180 | 178 | |
| 181 | - if (! $this->_new_comment->create()) |
|
| 179 | + if (!$this->_new_comment->create()) |
|
| 182 | 180 | { |
| 183 | 181 | debug_print_r('We operated on this object:', $this->_new_comment); |
| 184 | - throw new midcom_error('Failed to create a new comment, cannot continue. Last Midgard error was: '. midcom_connection::get_error_string()); |
|
| 182 | + throw new midcom_error('Failed to create a new comment, cannot continue. Last Midgard error was: ' . midcom_connection::get_error_string()); |
|
| 185 | 183 | } |
| 186 | 184 | |
| 187 | - if ( isset($_POST['subscribe']) |
|
| 185 | + if (isset($_POST['subscribe']) |
|
| 188 | 186 | && midcom::get()->auth->user) |
| 189 | 187 | { |
| 190 | 188 | // User wants to subscribe to receive notifications about this comments thread |
@@ -216,7 +214,7 @@ discard block |
||
| 216 | 214 | */ |
| 217 | 215 | public function _handler_comments($handler_id, array $args, array &$data) |
| 218 | 216 | { |
| 219 | - if (! mgd_is_guid($args[0])) |
|
| 217 | + if (!mgd_is_guid($args[0])) |
|
| 220 | 218 | { |
| 221 | 219 | throw new midcom_error("The GUID '{$args[0]}' is invalid. Cannot continue."); |
| 222 | 220 | } |
@@ -249,7 +247,7 @@ discard block |
||
| 249 | 247 | $this->_comments = $this->_comments->execute(); |
| 250 | 248 | } |
| 251 | 249 | |
| 252 | - if ( midcom::get()->auth->user |
|
| 250 | + if (midcom::get()->auth->user |
|
| 253 | 251 | || $this->_config->get('allow_anonymous')) |
| 254 | 252 | { |
| 255 | 253 | $this->_init_post_controller(); |
@@ -264,7 +262,7 @@ discard block |
||
| 264 | 262 | $this->_process_admintoolbar(); |
| 265 | 263 | // This might exit. |
| 266 | 264 | |
| 267 | - if ( $handler_id == 'view-comments-custom' |
|
| 265 | + if ($handler_id == 'view-comments-custom' |
|
| 268 | 266 | && count($args) > 1) |
| 269 | 267 | { |
| 270 | 268 | midcom::get()->skip_page_style = true; |
@@ -274,7 +272,7 @@ discard block |
||
| 274 | 272 | $this->_prepare_request_data(); |
| 275 | 273 | midcom::get()->metadata->set_request_metadata($this->_get_last_modified(), $this->_objectguid); |
| 276 | 274 | |
| 277 | - if ( isset($_SERVER['HTTP_X_REQUESTED_WITH']) |
|
| 275 | + if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) |
|
| 278 | 276 | && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') |
| 279 | 277 | { |
| 280 | 278 | midcom::get()->skip_page_style = true; |
@@ -313,7 +311,7 @@ discard block |
||
| 313 | 311 | */ |
| 314 | 312 | private function _process_post() |
| 315 | 313 | { |
| 316 | - if ( !midcom::get()->auth->user |
|
| 314 | + if (!midcom::get()->auth->user |
|
| 317 | 315 | && !midcom::get()->auth->request_sudo('net.nehmer.comments')) |
| 318 | 316 | { |
| 319 | 317 | throw new midcom_error('We were anonymous but could not acquire SUDO privileges, aborting'); |
@@ -329,7 +327,7 @@ discard block |
||
| 329 | 327 | // Fall-through intentional |
| 330 | 328 | |
| 331 | 329 | case 'cancel': |
| 332 | - if (! midcom::get()->auth->user) |
|
| 330 | + if (!midcom::get()->auth->user) |
|
| 333 | 331 | { |
| 334 | 332 | midcom::get()->auth->drop_sudo(); |
| 335 | 333 | } |
@@ -346,7 +344,7 @@ discard block |
||
| 346 | 344 | */ |
| 347 | 345 | private function _get_last_modified() |
| 348 | 346 | { |
| 349 | - if (! $this->_comments) |
|
| 347 | + if (!$this->_comments) |
|
| 350 | 348 | { |
| 351 | 349 | return 0; |
| 352 | 350 | } |
@@ -398,8 +396,8 @@ discard block |
||
| 398 | 396 | $data['comment_toolbar'] = $this->_master->_populate_post_toolbar($comment); |
| 399 | 397 | midcom_show_style('comments-item'); |
| 400 | 398 | |
| 401 | - if ( midcom::get()->auth->admin |
|
| 402 | - || ( midcom::get()->auth->user |
|
| 399 | + if (midcom::get()->auth->admin |
|
| 400 | + || (midcom::get()->auth->user |
|
| 403 | 401 | && $comment->can_do('midgard:delete'))) |
| 404 | 402 | { |
| 405 | 403 | midcom_show_style('comments-admintoolbar'); |
@@ -412,7 +410,7 @@ discard block |
||
| 412 | 410 | midcom_show_style('comments-nonefound'); |
| 413 | 411 | } |
| 414 | 412 | |
| 415 | - if ( midcom::get()->auth->user |
|
| 413 | + if (midcom::get()->auth->user |
|
| 416 | 414 | || $this->_config->get('allow_anonymous')) |
| 417 | 415 | { |
| 418 | 416 | midcom_show_style('post-comment'); |
@@ -29,8 +29,7 @@ discard block |
||
| 29 | 29 | if ($unit == "K") |
| 30 | 30 | { |
| 31 | 31 | $dist *= 1.609344; |
| 32 | - } |
|
| 33 | - else if ($unit == "N") |
|
| 32 | + } else if ($unit == "N") |
|
| 34 | 33 | { |
| 35 | 34 | $dist *= 0.8684; |
| 36 | 35 | } |
@@ -54,13 +53,11 @@ discard block |
||
| 54 | 53 | if ($from['latitude'] < $to['latitude']) |
| 55 | 54 | { |
| 56 | 55 | $bearing = 0; |
| 57 | - } |
|
| 58 | - else |
|
| 56 | + } else |
|
| 59 | 57 | { |
| 60 | 58 | $bearing = 180; |
| 61 | 59 | } |
| 62 | - } |
|
| 63 | - else |
|
| 60 | + } else |
|
| 64 | 61 | { |
| 65 | 62 | $dist = org_routamc_positioning_utils::get_distance($from, $to, 'N'); |
| 66 | 63 | $arad = acos((sin(deg2rad($to['latitude'])) - sin(deg2rad($from['latitude'])) * cos(deg2rad($dist / 60))) / (sin(deg2rad($dist / 60)) * cos(deg2rad($from['latitude'])))); |
@@ -77,8 +74,7 @@ discard block |
||
| 77 | 74 | if (($rounded % 4) == 0) |
| 78 | 75 | { |
| 79 | 76 | $dir = $dirs[$rounded / 4]; |
| 80 | - } |
|
| 81 | - else |
|
| 77 | + } else |
|
| 82 | 78 | { |
| 83 | 79 | $dir = $dirs[2 * floor(((floor($rounded / 4) + 1) % 4) / 2)]; |
| 84 | 80 | $dir .= $dirs[1 + 2 * floor($rounded / 8)]; |
@@ -178,8 +174,7 @@ discard block |
||
| 178 | 174 | if ($city_distance <= 4) |
| 179 | 175 | { |
| 180 | 176 | $city_string = "{$city->city}, {$city->country}"; |
| 181 | - } |
|
| 182 | - else |
|
| 177 | + } else |
|
| 183 | 178 | { |
| 184 | 179 | $bearing = org_routamc_positioning_utils::get_bearing($city_coordinates, $coordinates); |
| 185 | 180 | $city_string = sprintf(midcom::get()->i18n->get_string('%skm %s of %s', 'org.routamc.positioning'), $city_distance, $bearing, "{$city->city}, {$city->country}"); |
@@ -241,8 +236,7 @@ discard block |
||
| 241 | 236 | if ($city_distance <= 4) |
| 242 | 237 | { |
| 243 | 238 | $city_string .= $city_label; |
| 244 | - } |
|
| 245 | - else |
|
| 239 | + } else |
|
| 246 | 240 | { |
| 247 | 241 | $bearing = org_routamc_positioning_utils::get_bearing($city_coordinates, $coordinates); |
| 248 | 242 | $city_string .= sprintf(midcom::get()->i18n->get_string('%skm %s of %s', 'org.routamc.positioning'), $city_distance, $bearing, $city_label); |