@@ -116,7 +116,10 @@ discard block |
||
| 116 | 116 | if (is_callable($callback)) |
| 117 | 117 | { |
| 118 | 118 | $this->callback = $callback; |
| 119 | - if ($add_container) $callback_params[] = $this; |
|
| 119 | + if ($add_container) |
|
| 120 | + { |
|
| 121 | + $callback_params[] = $this; |
|
| 122 | + } |
|
| 120 | 123 | $this->callback_params = $callback_params; |
| 121 | 124 | } |
| 122 | 125 | if (is_string($ical_file)) |
@@ -197,8 +200,14 @@ discard block |
||
| 197 | 200 | { |
| 198 | 201 | $ret = is_a($this->component,'Horde_Icalendar'); |
| 199 | 202 | do { |
| 200 | - if ($ret === false) $this->next(); |
|
| 201 | - if (!is_a($this->component,'Horde_Icalendar')) return false; |
|
| 203 | + if ($ret === false) |
|
| 204 | + { |
|
| 205 | + $this->next(); |
|
| 206 | + } |
|
| 207 | + if (!is_a($this->component,'Horde_Icalendar')) |
|
| 208 | + { |
|
| 209 | + return false; |
|
| 210 | + } |
|
| 202 | 211 | $params = $this->callback_params; |
| 203 | 212 | array_unshift($params,$this->component); |
| 204 | 213 | } |
@@ -231,9 +240,12 @@ discard block |
||
| 231 | 240 | { |
| 232 | 241 | // ignore it |
| 233 | 242 | } |
| 234 | - if ($line === false) // end-of-file or end-of-container |
|
| 243 | + if ($line === false) |
|
| 244 | + { |
|
| 245 | + // end-of-file or end-of-container |
|
| 235 | 246 | { |
| 236 | 247 | $this->component = false; |
| 248 | + } |
|
| 237 | 249 | return; |
| 238 | 250 | } |
| 239 | 251 | $type = substr(trim($line),6); |
@@ -309,7 +321,10 @@ discard block |
||
| 309 | 321 | //error_log(__METHOD__."() about to call this->parsevCalendar('$data','$this->base','$this->charset')"); |
| 310 | 322 | $this->parsevCalendar($data,$this->base,$this->charset); |
| 311 | 323 | } |
| 312 | - if ($line) $this->unread_line($line); |
|
| 324 | + if ($line) |
|
| 325 | + { |
|
| 326 | + $this->unread_line($line); |
|
| 327 | + } |
|
| 313 | 328 | |
| 314 | 329 | // advance to first element |
| 315 | 330 | $this->next(); |
@@ -438,7 +453,10 @@ discard block |
||
| 438 | 453 | '; |
| 439 | 454 | echo $GLOBALS['egw']->framework->header(); |
| 440 | 455 | //$ical_file = fopen('/tmp/KalenderFelicitasKubala.ics'); |
| 441 | - if (!is_resource($ical_file)) echo "<pre>$ical_file</pre>\n"; |
|
| 456 | + if (!is_resource($ical_file)) |
|
| 457 | + { |
|
| 458 | + echo "<pre>$ical_file</pre>\n"; |
|
| 459 | + } |
|
| 442 | 460 | //$calendar_ical = new calendar_ical(); |
| 443 | 461 | //$calendar_ical->setSupportedFields('file'); |
| 444 | 462 | $ical_it = new IcalIterator($ical_file);//,'VCALENDAR','iso-8859-1',array($calendar_ical,'_ical2egw_callback'),array('Europe/Berlin')); |
@@ -446,5 +464,8 @@ discard block |
||
| 446 | 464 | { |
| 447 | 465 | echo "$uid<pre>".print_r($vevent->toHash(), true)."</pre>\n"; |
| 448 | 466 | } |
| 449 | - if (is_resource($ical_file)) fclose($ical_file); |
|
| 450 | -} |
|
| 451 | 467 | \ No newline at end of file |
| 468 | + if (is_resource($ical_file)) |
|
| 469 | + { |
|
| 470 | + fclose($ical_file); |
|
| 471 | + } |
|
| 472 | + } |
|
| 452 | 473 | \ No newline at end of file |
@@ -123,7 +123,10 @@ discard block |
||
| 123 | 123 | function __construct($app, Api\CalDAV $caldav) |
| 124 | 124 | { |
| 125 | 125 | $this->app = $app; |
| 126 | - if (!is_null($caldav->debug)) $this->debug = $caldav->debug; |
|
| 126 | + if (!is_null($caldav->debug)) |
|
| 127 | + { |
|
| 128 | + $this->debug = $caldav->debug; |
|
| 129 | + } |
|
| 127 | 130 | $this->base_uri = $caldav->base_uri; |
| 128 | 131 | $this->caldav = $caldav; |
| 129 | 132 | |
@@ -282,11 +285,17 @@ discard block |
||
| 282 | 285 | */ |
| 283 | 286 | function _common_get_put_delete($method,&$options,&$id,&$return_no_access=false,$ignore_if_match=false) |
| 284 | 287 | { |
| 285 | - if (self::$path_extension) $id = basename($id,self::$path_extension); |
|
| 288 | + if (self::$path_extension) |
|
| 289 | + { |
|
| 290 | + $id = basename($id,self::$path_extension); |
|
| 291 | + } |
|
| 286 | 292 | |
| 287 | 293 | if ($this->app != 'principals' && !$GLOBALS['egw_info']['user']['apps'][$this->app]) |
| 288 | 294 | { |
| 289 | - if ($this->debug) error_log(__METHOD__."($method,,$id) 403 Forbidden: no app rights for '$this->app'"); |
|
| 295 | + if ($this->debug) |
|
| 296 | + { |
|
| 297 | + error_log(__METHOD__."($method,,$id) 403 Forbidden: no app rights for '$this->app'"); |
|
| 298 | + } |
|
| 290 | 299 | return '403 Forbidden'; // no app rights |
| 291 | 300 | } |
| 292 | 301 | $extra_acl = $this->method2acl[$method]; |
@@ -295,12 +304,18 @@ discard block |
||
| 295 | 304 | { |
| 296 | 305 | if ($return_no_access && !is_null($entry)) |
| 297 | 306 | { |
| 298 | - if ($this->debug) error_log(__METHOD__."($method,,$id,$return_no_access) \$entry=".array2string($entry).", \$return_no_access set to false"); |
|
| 307 | + if ($this->debug) |
|
| 308 | + { |
|
| 309 | + error_log(__METHOD__."($method,,$id,$return_no_access) \$entry=".array2string($entry).", \$return_no_access set to false"); |
|
| 310 | + } |
|
| 299 | 311 | $return_no_access = false; |
| 300 | 312 | } |
| 301 | 313 | else |
| 302 | 314 | { |
| 303 | - if ($this->debug) error_log(__METHOD__."($method,,$id) 403 Forbidden/404 Not Found: read($id)==".($entry===false?'false':'null')); |
|
| 315 | + if ($this->debug) |
|
| 316 | + { |
|
| 317 | + error_log(__METHOD__."($method,,$id) 403 Forbidden/404 Not Found: read($id)==".($entry===false?'false':'null')); |
|
| 318 | + } |
|
| 304 | 319 | return !is_null($entry) ? '403 Forbidden' : '404 Not Found'; |
| 305 | 320 | } |
| 306 | 321 | } |
@@ -313,11 +328,17 @@ discard block |
||
| 313 | 328 | { |
| 314 | 329 | $this->http_if_match = $_SERVER['HTTP_IF_MATCH']; |
| 315 | 330 | // strip of quotes around etag, if they exist, that way we allow etag with and without quotes |
| 316 | - if ($this->http_if_match[0] == '"') $this->http_if_match = substr($this->http_if_match, 1, -1); |
|
| 331 | + if ($this->http_if_match[0] == '"') |
|
| 332 | + { |
|
| 333 | + $this->http_if_match = substr($this->http_if_match, 1, -1); |
|
| 334 | + } |
|
| 317 | 335 | |
| 318 | 336 | if ($this->http_if_match !== $etag) |
| 319 | 337 | { |
| 320 | - if ($this->debug) error_log(__METHOD__."($method,path=$options[path],$id) HTTP_IF_MATCH='$_SERVER[HTTP_IF_MATCH]', etag='$etag': 412 Precondition failed".array2string($entry)); |
|
| 338 | + if ($this->debug) |
|
| 339 | + { |
|
| 340 | + error_log(__METHOD__."($method,path=$options[path],$id) HTTP_IF_MATCH='$_SERVER[HTTP_IF_MATCH]', etag='$etag': 412 Precondition failed".array2string($entry)); |
|
| 341 | + } |
|
| 321 | 342 | // honor Prefer: return=representation for 412 too (no need for client to explicitly reload) |
| 322 | 343 | $this->check_return_representation($options, $id); |
| 323 | 344 | return '412 Precondition Failed'; |
@@ -327,17 +348,26 @@ discard block |
||
| 327 | 348 | { |
| 328 | 349 | $if_none_match = $_SERVER['HTTP_IF_NONE_MATCH']; |
| 329 | 350 | // strip of quotes around etag, if they exist, that way we allow etag with and without quotes |
| 330 | - if ($if_none_match[0] == '"') $if_none_match = substr($if_none_match, 1, -1); |
|
| 351 | + if ($if_none_match[0] == '"') |
|
| 352 | + { |
|
| 353 | + $if_none_match = substr($if_none_match, 1, -1); |
|
| 354 | + } |
|
| 331 | 355 | |
| 332 | 356 | // if an IF_NONE_MATCH is given, check if we need to send a new export, or the current one is still up-to-date |
| 333 | 357 | if (in_array($method, array('GET','HEAD')) && $etag === $if_none_match) |
| 334 | 358 | { |
| 335 | - if ($this->debug) error_log(__METHOD__."($method,,$id) HTTP_IF_NONE_MATCH='$_SERVER[HTTP_IF_NONE_MATCH]', etag='$etag': 304 Not Modified"); |
|
| 359 | + if ($this->debug) |
|
| 360 | + { |
|
| 361 | + error_log(__METHOD__."($method,,$id) HTTP_IF_NONE_MATCH='$_SERVER[HTTP_IF_NONE_MATCH]', etag='$etag': 304 Not Modified"); |
|
| 362 | + } |
|
| 336 | 363 | return '304 Not Modified'; |
| 337 | 364 | } |
| 338 | 365 | if ($method == 'PUT' && ($if_none_match == '*' || $if_none_match == $etag)) |
| 339 | 366 | { |
| 340 | - if ($this->debug) error_log(__METHOD__."($method,,$id) HTTP_IF_NONE_MATCH='$_SERVER[HTTP_IF_NONE_MATCH]', etag='$etag': 412 Precondition failed"); |
|
| 367 | + if ($this->debug) |
|
| 368 | + { |
|
| 369 | + error_log(__METHOD__."($method,,$id) HTTP_IF_NONE_MATCH='$_SERVER[HTTP_IF_NONE_MATCH]', etag='$etag': 412 Precondition failed"); |
|
| 370 | + } |
|
| 341 | 371 | // honor Prefer: return=representation for 412 too (no need for client to explicitly reload) |
| 342 | 372 | $this->check_return_representation($options, $id); |
| 343 | 373 | return '412 Precondition Failed'; |
@@ -376,7 +406,10 @@ discard block |
||
| 376 | 406 | |
| 377 | 407 | if (($ret = $this->get($options, $id ? $id : $this->new_id, $user)) && !empty($options['data'])) |
| 378 | 408 | { |
| 379 | - if (!$this->caldav->use_compression()) header('Content-Length: '.$this->caldav->bytes($options['data'])); |
|
| 409 | + if (!$this->caldav->use_compression()) |
|
| 410 | + { |
|
| 411 | + header('Content-Length: '.$this->caldav->bytes($options['data'])); |
|
| 412 | + } |
|
| 380 | 413 | header('Content-Type: '.$options['mimetype']); |
| 381 | 414 | echo $options['data']; |
| 382 | 415 | } |
@@ -412,7 +445,10 @@ discard block |
||
| 412 | 445 | if (!array_key_exists($app,$handler_cache)) |
| 413 | 446 | { |
| 414 | 447 | $class = $app.'_groupdav'; |
| 415 | - if (!class_exists($class) && !class_exists($class = __NAMESPACE__.'\\'.ucfirst($app))) return null; |
|
| 448 | + if (!class_exists($class) && !class_exists($class = __NAMESPACE__.'\\'.ucfirst($app))) |
|
| 449 | + { |
|
| 450 | + return null; |
|
| 451 | + } |
|
| 416 | 452 | |
| 417 | 453 | $handler_cache[$app] = new $class($app, $groupdav); |
| 418 | 454 | } |
@@ -474,7 +510,10 @@ discard block |
||
| 474 | 510 | $matches = null; |
| 475 | 511 | if (preg_match('/address%20book\/([0-9.]+)/', $user_agent, $matches)) |
| 476 | 512 | { |
| 477 | - if ((int)$matches[1] < 868) $agent .= '_old'; |
|
| 513 | + if ((int)$matches[1] < 868) |
|
| 514 | + { |
|
| 515 | + $agent .= '_old'; |
|
| 516 | + } |
|
| 478 | 517 | } |
| 479 | 518 | break; |
| 480 | 519 | case 'kde': |
@@ -575,7 +614,10 @@ discard block |
||
| 575 | 614 | // --> as all clients dislike not getting an ETag for a PUT, we sending it again even not storing byte-by-byte |
| 576 | 615 | //if (get_class($this) == 'addressbook_groupdav' && in_array(self::get_agent(),array('thunderbird','lightning'))) |
| 577 | 616 | { |
| 578 | - if (is_null($etag)) $etag = $this->get_etag($entry); |
|
| 617 | + if (is_null($etag)) |
|
| 618 | + { |
|
| 619 | + $etag = $this->get_etag($entry); |
|
| 620 | + } |
|
| 579 | 621 | header('ETag: "'.$etag.'"'); |
| 580 | 622 | } |
| 581 | 623 | |
@@ -741,7 +783,10 @@ discard block |
||
| 741 | 783 | */ |
| 742 | 784 | public function get_sync_token($path, $user, $token=null) |
| 743 | 785 | { |
| 744 | - if (!isset($token)) $token = $this->getctag($path, $user); |
|
| 786 | + if (!isset($token)) |
|
| 787 | + { |
|
| 788 | + $token = $this->getctag($path, $user); |
|
| 789 | + } |
|
| 745 | 790 | |
| 746 | 791 | // never return current time, as more modifications might happen due to second granularity --> return 1sec less |
| 747 | 792 | if ($token >= (int)$GLOBALS['egw_info']['flags']['page_start_time']) |
@@ -49,7 +49,10 @@ discard block |
||
| 49 | 49 | { |
| 50 | 50 | parent::__construct($app, $caldav); |
| 51 | 51 | |
| 52 | - if (!isset(self::$resources)) self::$resources = new resources_bo(); |
|
| 52 | + if (!isset(self::$resources)) |
|
| 53 | + { |
|
| 54 | + self::$resources = new resources_bo(); |
|
| 55 | + } |
|
| 53 | 56 | } |
| 54 | 57 | |
| 55 | 58 | /** |
@@ -93,7 +96,10 @@ discard block |
||
| 93 | 96 | { |
| 94 | 97 | unset($path); // not used, but required by function signature |
| 95 | 98 | |
| 96 | - if (is_null($reports)) $reports = $this->supported_reports; |
|
| 99 | + if (is_null($reports)) |
|
| 100 | + { |
|
| 101 | + $reports = $this->supported_reports; |
|
| 102 | + } |
|
| 97 | 103 | |
| 98 | 104 | $supported = array(); |
| 99 | 105 | foreach($reports as $name => $data) |
@@ -264,7 +270,10 @@ discard block |
||
| 264 | 270 | $requested_props = $options['other']; |
| 265 | 271 | while(($requested_prop = array_shift($requested_props))) |
| 266 | 272 | { |
| 267 | - if ($requested_prop['name'] != 'property' || $requested_prop['depth'] != 1) continue; |
|
| 273 | + if ($requested_prop['name'] != 'property' || $requested_prop['depth'] != 1) |
|
| 274 | + { |
|
| 275 | + continue; |
|
| 276 | + } |
|
| 268 | 277 | |
| 269 | 278 | $prop_ns = $requested_prop['attrs']['namespace']; |
| 270 | 279 | $prop_name = $requested_prop['attrs']['name']; |
@@ -303,7 +312,10 @@ discard block |
||
| 303 | 312 | // find prop to expand |
| 304 | 313 | foreach($prop_files['files'][0]['props'] as $expand_prop) |
| 305 | 314 | { |
| 306 | - if ($expand_prop['name'] === $prop_name) break; |
|
| 315 | + if ($expand_prop['name'] === $prop_name) |
|
| 316 | + { |
|
| 317 | + break; |
|
| 318 | + } |
|
| 307 | 319 | } |
| 308 | 320 | if ($expand_prop['name'] !== $prop_name || !is_array($expand_prop['val']) || |
| 309 | 321 | $expand_prop['val'] && $expand_prop['val'][0]['name'] !== 'href') |
@@ -319,10 +331,13 @@ discard block |
||
| 319 | 331 | { |
| 320 | 332 | if ($prop['name'] == 'property' && $prop['depth'] == 2) |
| 321 | 333 | { |
| 322 | - if (!is_array($options2['props'])) // is "all" initially |
|
| 334 | + if (!is_array($options2['props'])) |
|
| 335 | + { |
|
| 336 | + // is "all" initially |
|
| 323 | 337 | { |
| 324 | 338 | $options2['props'] = array(); |
| 325 | 339 | } |
| 340 | + } |
|
| 326 | 341 | $options2['props'][] = array( |
| 327 | 342 | 'name' => $prop['attrs']['name'], |
| 328 | 343 | 'xmlns' => isset($prop['attrs']['namespace']) ? $prop['attrs']['namespace'] : $prop['xmlns'], |
@@ -330,7 +345,10 @@ discard block |
||
| 330 | 345 | } |
| 331 | 346 | } |
| 332 | 347 | // put back evtl. read top-level property |
| 333 | - if ($prop && $prop['depth'] == 1) array_unshift($requested_props, $prop); |
|
| 348 | + if ($prop && $prop['depth'] == 1) |
|
| 349 | + { |
|
| 350 | + array_unshift($requested_props, $prop); |
|
| 351 | + } |
|
| 334 | 352 | $this->caldav->options = $options2; // also modify global variable |
| 335 | 353 | |
| 336 | 354 | // run regular profind to get requested 2.-level properties for each href |
@@ -526,9 +544,12 @@ discard block |
||
| 526 | 544 | // now filter out not matching "files" |
| 527 | 545 | foreach($files['files'] as $n => $resource) |
| 528 | 546 | { |
| 529 | - if (count(explode('/', $resource['path'])) < 5) // hack to only return principals, not the collections itself |
|
| 547 | + if (count(explode('/', $resource['path'])) < 5) |
|
| 548 | + { |
|
| 549 | + // hack to only return principals, not the collections itself |
|
| 530 | 550 | { |
| 531 | 551 | unset($files['files'][$n]); |
| 552 | + } |
|
| 532 | 553 | continue; |
| 533 | 554 | } |
| 534 | 555 | // match with $search_props |
@@ -538,16 +559,26 @@ discard block |
||
| 538 | 559 | // search resource for $search_prop |
| 539 | 560 | foreach($resource['props'] as $prop) |
| 540 | 561 | { |
| 541 | - if ($prop['name'] === $search_prop['name']) break; |
|
| 562 | + if ($prop['name'] === $search_prop['name']) |
|
| 563 | + { |
|
| 564 | + break; |
|
| 565 | + } |
|
| 542 | 566 | } |
| 543 | - if ($prop['name'] === $search_prop['name']) // search_prop NOT found |
|
| 567 | + if ($prop['name'] === $search_prop['name']) |
|
| 568 | + { |
|
| 569 | + // search_prop NOT found |
|
| 544 | 570 | { |
| 545 | 571 | foreach((array)$prop['val'] as $value) |
| 546 | 572 | { |
| 547 | - if (is_array($value)) $value = $value['val']; // eg. href prop |
|
| 548 | - if (self::match($value, $search_prop['match'], $search_prop['match-type']) !== false) // prop does match |
|
| 573 | + if (is_array($value)) $value = $value['val']; |
|
| 574 | + } |
|
| 575 | + // eg. href prop |
|
| 576 | + if (self::match($value, $search_prop['match'], $search_prop['match-type']) !== false) |
|
| 577 | + { |
|
| 578 | + // prop does match |
|
| 549 | 579 | { |
| 550 | 580 | ++$matches; |
| 581 | + } |
|
| 551 | 582 | //error_log("$matches: $resource[path]: $search_prop[name]=".array2string($prop['name'] !== $search_prop['name'] ? null : $prop['val'])." does match '$search_prop[match]'"); |
| 552 | 583 | break; |
| 553 | 584 | } |
@@ -749,7 +780,10 @@ discard block |
||
| 749 | 780 | { |
| 750 | 781 | foreach($resource['props']['resourcetype']['val'] as $prop) |
| 751 | 782 | { |
| 752 | - if ($prop['name'] == 'principal') continue 2; |
|
| 783 | + if ($prop['name'] == 'principal') |
|
| 784 | + { |
|
| 785 | + continue 2; |
|
| 786 | + } |
|
| 753 | 787 | } |
| 754 | 788 | unset($files['files'][$n]); // not a principal --> do not return |
| 755 | 789 | } |
@@ -903,7 +937,11 @@ discard block |
||
| 903 | 937 | { |
| 904 | 938 | $addressbooks = array(); |
| 905 | 939 | $ab_home_set = $GLOBALS['egw_info']['user']['preferences']['groupdav']['addressbook-home-set']; |
| 906 | - if (empty($ab_home_set)) $ab_home_set = 'P'; // personal addressbook |
|
| 940 | + if (empty($ab_home_set)) |
|
| 941 | + { |
|
| 942 | + $ab_home_set = 'P'; |
|
| 943 | + } |
|
| 944 | + // personal addressbook |
|
| 907 | 945 | $addressbook_home_set = explode(',', $ab_home_set); |
| 908 | 946 | // replace symbolic id's with real nummeric id's |
| 909 | 947 | foreach(array( |
@@ -917,10 +955,13 @@ discard block |
||
| 917 | 955 | $addressbook_home_set[$key] = $id; |
| 918 | 956 | } |
| 919 | 957 | } |
| 920 | - if (in_array('O',$addressbook_home_set)) // "all in one" from groupdav.php/addressbook/ |
|
| 958 | + if (in_array('O',$addressbook_home_set)) |
|
| 959 | + { |
|
| 960 | + // "all in one" from groupdav.php/addressbook/ |
|
| 921 | 961 | { |
| 922 | 962 | $addressbooks[] = '/'; |
| 923 | 963 | } |
| 964 | + } |
|
| 924 | 965 | foreach(array_keys($GLOBALS['egw']->contacts->get_addressbooks(Api\Acl::READ)) as $id) |
| 925 | 966 | { |
| 926 | 967 | if ((in_array('A',$addressbook_home_set) || in_array((string)$id,$addressbook_home_set)) && |
@@ -999,7 +1040,10 @@ discard block |
||
| 999 | 1040 | */ |
| 1000 | 1041 | static public function url2uid($url, $only_type=null, $cn=null) |
| 1001 | 1042 | { |
| 1002 | - if (!$only_type) $only_type = array('users', 'groups', 'resources', 'locations', 'mailto'); |
|
| 1043 | + if (!$only_type) |
|
| 1044 | + { |
|
| 1045 | + $only_type = array('users', 'groups', 'resources', 'locations', 'mailto'); |
|
| 1046 | + } |
|
| 1003 | 1047 | |
| 1004 | 1048 | if ($url[0] == '/') |
| 1005 | 1049 | { |
@@ -1009,7 +1053,10 @@ discard block |
||
| 1009 | 1053 | { |
| 1010 | 1054 | list($schema, $rest) = explode(':', $url, 2); |
| 1011 | 1055 | } |
| 1012 | - if (empty($rest)) return false; |
|
| 1056 | + if (empty($rest)) |
|
| 1057 | + { |
|
| 1058 | + return false; |
|
| 1059 | + } |
|
| 1013 | 1060 | |
| 1014 | 1061 | switch(strtolower($schema)) |
| 1015 | 1062 | { |
@@ -1056,9 +1103,12 @@ discard block |
||
| 1056 | 1103 | case 'urn': |
| 1057 | 1104 | list($urn_type, $uid) = explode(':', $rest, 2); |
| 1058 | 1105 | list($type, $id, $install_id) = explode('-', $uid); |
| 1059 | - if ($type == 'accounts' && empty($id)) // groups have a negative id, eg. "urn:uuid:accounts--1-..." |
|
| 1106 | + if ($type == 'accounts' && empty($id)) |
|
| 1107 | + { |
|
| 1108 | + // groups have a negative id, eg. "urn:uuid:accounts--1-..." |
|
| 1060 | 1109 | { |
| 1061 | 1110 | list($type, , $id_abs, $install_id) = explode('-', $uid); |
| 1111 | + } |
|
| 1062 | 1112 | $id = -$id_abs; |
| 1063 | 1113 | } |
| 1064 | 1114 | // own urn |
@@ -1072,7 +1122,10 @@ discard block |
||
| 1072 | 1122 | else |
| 1073 | 1123 | { |
| 1074 | 1124 | static $calendar_bo=null; |
| 1075 | - if (is_null($calendar_bo)) $calendar_bo = new calendar_bo(); |
|
| 1125 | + if (is_null($calendar_bo)) |
|
| 1126 | + { |
|
| 1127 | + $calendar_bo = new calendar_bo(); |
|
| 1128 | + } |
|
| 1076 | 1129 | foreach($calendar_bo->resources as $letter => $info) |
| 1077 | 1130 | { |
| 1078 | 1131 | if ($info['app'] == $type || $info['app'] == 'resources' && $type == 'location') |
@@ -1179,7 +1232,10 @@ discard block |
||
| 1179 | 1232 | { |
| 1180 | 1233 | return null; |
| 1181 | 1234 | } |
| 1182 | - if (is_null($is_location)) $is_location = self::resource_is_location($resource); |
|
| 1235 | + if (is_null($is_location)) |
|
| 1236 | + { |
|
| 1237 | + $is_location = self::resource_is_location($resource); |
|
| 1238 | + } |
|
| 1183 | 1239 | |
| 1184 | 1240 | $displayname = Api\Translation::convert($resource['name'], Api\Translation::charset(), 'utf-8'); |
| 1185 | 1241 | |
@@ -1225,7 +1281,10 @@ discard block |
||
| 1225 | 1281 | |
| 1226 | 1282 | if (!isset($cache[$res_id])) |
| 1227 | 1283 | { |
| 1228 | - if (!isset(self::$resources)) self::$resources = new resources_bo(); |
|
| 1284 | + if (!isset(self::$resources)) |
|
| 1285 | + { |
|
| 1286 | + self::$resources = new resources_bo(); |
|
| 1287 | + } |
|
| 1229 | 1288 | |
| 1230 | 1289 | if (!($cache[$res_id] = self::$resources->read($res_id))) |
| 1231 | 1290 | { |
@@ -1262,7 +1321,10 @@ discard block |
||
| 1262 | 1321 | { |
| 1263 | 1322 | if (!isset(self::$all_resources)) |
| 1264 | 1323 | { |
| 1265 | - if (!isset(self::$resources)) self::$resources = new resources_bo($user); |
|
| 1324 | + if (!isset(self::$resources)) |
|
| 1325 | + { |
|
| 1326 | + self::$resources = new resources_bo($user); |
|
| 1327 | + } |
|
| 1266 | 1328 | |
| 1267 | 1329 | self::$all_resources = array(); |
| 1268 | 1330 | $query = array( |
@@ -1333,9 +1395,15 @@ discard block |
||
| 1333 | 1395 | // required props per WebDAV ACL |
| 1334 | 1396 | foreach(array('alternate-URI-set', 'group-membership') as $name) |
| 1335 | 1397 | { |
| 1336 | - if (!isset($props[$name])) $props[$name] = Api\CalDAV::mkprop($name,''); |
|
| 1398 | + if (!isset($props[$name])) |
|
| 1399 | + { |
|
| 1400 | + $props[$name] = Api\CalDAV::mkprop($name,''); |
|
| 1401 | + } |
|
| 1402 | + } |
|
| 1403 | + if (!$principal_url) |
|
| 1404 | + { |
|
| 1405 | + $principal_url = $principal; |
|
| 1337 | 1406 | } |
| 1338 | - if (!$principal_url) $principal_url = $principal; |
|
| 1339 | 1407 | |
| 1340 | 1408 | $props['principal-URL'] = array( |
| 1341 | 1409 | Api\CalDAV::mkprop('href',$this->base_uri.'/principals/'.$principal.'/')); |
@@ -1358,7 +1426,11 @@ discard block |
||
| 1358 | 1426 | { |
| 1359 | 1427 | list($app,,$what) = explode('-', $type); |
| 1360 | 1428 | |
| 1361 | - if (true) $proxys = array(); // ignore parameter! |
|
| 1429 | + if (true) |
|
| 1430 | + { |
|
| 1431 | + $proxys = array(); |
|
| 1432 | + } |
|
| 1433 | + // ignore parameter! |
|
| 1362 | 1434 | list($account_type,$account) = explode('/', $principal); |
| 1363 | 1435 | |
| 1364 | 1436 | switch($account_type) |
@@ -1440,16 +1512,22 @@ discard block |
||
| 1440 | 1512 | $set = array(); |
| 1441 | 1513 | foreach($accounts as $account_id => $account_lid) |
| 1442 | 1514 | { |
| 1443 | - if ($this->accounts->visible($account_lid)) // only add visible accounts, gives error in iCal otherwise |
|
| 1515 | + if ($this->accounts->visible($account_lid)) |
|
| 1516 | + { |
|
| 1517 | + // only add visible accounts, gives error in iCal otherwise |
|
| 1444 | 1518 | { |
| 1445 | 1519 | $set[] = Api\CalDAV::mkprop('href', $this->base_uri.'/principals/'.($account_id < 0 ? 'groups/' : 'users/').$account_lid.'/'); |
| 1446 | 1520 | } |
| 1521 | + } |
|
| 1447 | 1522 | } |
| 1448 | 1523 | if ($app_proxys) |
| 1449 | 1524 | { |
| 1450 | 1525 | foreach((array)$app_proxys as $app) |
| 1451 | 1526 | { |
| 1452 | - if (!isset($GLOBALS['egw_info']['user']['apps'][$app])) continue; |
|
| 1527 | + if (!isset($GLOBALS['egw_info']['user']['apps'][$app])) |
|
| 1528 | + { |
|
| 1529 | + continue; |
|
| 1530 | + } |
|
| 1453 | 1531 | |
| 1454 | 1532 | switch($app) |
| 1455 | 1533 | { |
@@ -1490,7 +1568,10 @@ discard block |
||
| 1490 | 1568 | if (($rights & (EGW_ACL_CALREAD|EGW_ACL_DIRECT_BOOKING)) && // we only care for these rights |
| 1491 | 1569 | ($account_id == $account || in_array($account_id, $memberships))) |
| 1492 | 1570 | { |
| 1493 | - if (!isset($location_grants[$location])) $location_grants[$location] = 0; |
|
| 1571 | + if (!isset($location_grants[$location])) |
|
| 1572 | + { |
|
| 1573 | + $location_grants[$location] = 0; |
|
| 1574 | + } |
|
| 1494 | 1575 | $location_grants[$location] |= $rights; |
| 1495 | 1576 | } |
| 1496 | 1577 | } |
@@ -1524,12 +1605,15 @@ discard block |
||
| 1524 | 1605 | { |
| 1525 | 1606 | if ($account_id != $account && ($rights & Api\Acl::READ) && |
| 1526 | 1607 | ($account_lid = $this->accounts->id2name($account_id)) && |
| 1527 | - $this->accounts->visible($account_lid)) // only add visible accounts, gives error in iCal otherwise |
|
| 1608 | + $this->accounts->visible($account_lid)) |
|
| 1609 | + { |
|
| 1610 | + // only add visible accounts, gives error in iCal otherwise |
|
| 1528 | 1611 | { |
| 1529 | 1612 | $set[] = Api\CalDAV::mkprop('href', $this->base_uri.'/principals/'. |
| 1530 | 1613 | ($account_id < 0 ? 'groups/' : 'users/'). |
| 1531 | 1614 | $account_lid.'/'.$app.'-proxy-'.($rights & Api\Acl::EDIT ? 'write' : 'read').'/'); |
| 1532 | 1615 | } |
| 1616 | + } |
|
| 1533 | 1617 | } |
| 1534 | 1618 | return $set; |
| 1535 | 1619 | } |
@@ -1621,7 +1705,10 @@ discard block |
||
| 1621 | 1705 | |
| 1622 | 1706 | if ($options['depth']) |
| 1623 | 1707 | { |
| 1624 | - if (is_numeric($options['depth'])) --$options['depth']; |
|
| 1708 | + if (is_numeric($options['depth'])) |
|
| 1709 | + { |
|
| 1710 | + --$options['depth']; |
|
| 1711 | + } |
|
| 1625 | 1712 | $files = array_merge($files, $this->propfind_users('','',$options), |
| 1626 | 1713 | $this->propfind_groups('','',$options)); |
| 1627 | 1714 | if ($GLOBALS['egw_info']['user']['apps']['resources']) |
@@ -126,17 +126,23 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | return $charsets[$lang]; |
| 128 | 128 | } |
| 129 | - if (self::$system_charset) // do we have a system-charset ==> return it |
|
| 129 | + if (self::$system_charset) |
|
| 130 | + { |
|
| 131 | + // do we have a system-charset ==> return it |
|
| 130 | 132 | { |
| 131 | 133 | $charset = self::$system_charset; |
| 132 | 134 | } |
| 135 | + } |
|
| 133 | 136 | else |
| 134 | 137 | { |
| 135 | 138 | // if no translations are loaded (system-startup) use a default, else lang('charset') |
| 136 | 139 | $charset = !self::$lang_arr ? 'utf-8' : strtolower(self::translate('charset')); |
| 137 | 140 | } |
| 138 | 141 | // in case no charset is set, default to utf-8 |
| 139 | - if (empty($charset) || $charset == 'charset') $charset = 'utf-8'; |
|
| 142 | + if (empty($charset) || $charset == 'charset') |
|
| 143 | + { |
|
| 144 | + $charset = 'utf-8'; |
|
| 145 | + } |
|
| 140 | 146 | |
| 141 | 147 | // we need to set our charset as mbstring.internal_encoding if mbstring.func_overlaod > 0 |
| 142 | 148 | // else we get problems for a charset is different from the default utf-8 |
@@ -195,8 +201,14 @@ discard block |
||
| 195 | 201 | } |
| 196 | 202 | $apps = array('common'); |
| 197 | 203 | // for eTemplate apps, load etemplate before app itself (allowing app to overwrite etemplate translations) |
| 198 | - if (class_exists('EGroupware\\Api\\Etemplate', false) || class_exists('etemplate', false)) $apps[] = 'etemplate'; |
|
| 199 | - if ($GLOBALS['egw_info']['flags']['currentapp']) $apps[] = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 204 | + if (class_exists('EGroupware\\Api\\Etemplate', false) || class_exists('etemplate', false)) |
|
| 205 | + { |
|
| 206 | + $apps[] = 'etemplate'; |
|
| 207 | + } |
|
| 208 | + if ($GLOBALS['egw_info']['flags']['currentapp']) |
|
| 209 | + { |
|
| 210 | + $apps[] = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 211 | + } |
|
| 200 | 212 | // load instance specific translations last, so they can overwrite everything |
| 201 | 213 | $apps[] = 'custom'; |
| 202 | 214 | self::add_app($apps); |
@@ -224,7 +236,10 @@ discard block |
||
| 224 | 236 | self::init(); |
| 225 | 237 | } |
| 226 | 238 | $ret = $key; // save key if we dont find a translation |
| 227 | - if ($not_found) $ret .= $not_found; |
|
| 239 | + if ($not_found) |
|
| 240 | + { |
|
| 241 | + $ret .= $not_found; |
|
| 242 | + } |
|
| 228 | 243 | |
| 229 | 244 | if (isset(self::$lang_arr[$key])) |
| 230 | 245 | { |
@@ -271,9 +286,15 @@ discard block |
||
| 271 | 286 | { |
| 272 | 287 | //error_log(__METHOD__."(".array2string($apps).", $lang) count(self::\$lang_arr)=".count(self::$lang_arr)); |
| 273 | 288 | //$start = microtime(true); |
| 274 | - if (!$lang) $lang = self::$userlang; |
|
| 289 | + if (!$lang) |
|
| 290 | + { |
|
| 291 | + $lang = self::$userlang; |
|
| 292 | + } |
|
| 275 | 293 | $tree_level = $instance_level = array(); |
| 276 | - if (!is_array($apps)) $apps = (array)$apps; |
|
| 294 | + if (!is_array($apps)) |
|
| 295 | + { |
|
| 296 | + $apps = (array)$apps; |
|
| 297 | + } |
|
| 277 | 298 | foreach($apps as $key => $app) |
| 278 | 299 | { |
| 279 | 300 | if (!isset(self::$loaded_apps[$app]) || self::$loaded_apps[$app] != $lang && $app != 'common') |
@@ -293,8 +314,14 @@ discard block |
||
| 293 | 314 | } |
| 294 | 315 | } |
| 295 | 316 | // load all translations from cache at once |
| 296 | - if ($tree_level) $tree_level = Cache::getTree(__CLASS__, $tree_level); |
|
| 297 | - if ($instance_level) $instance_level = Cache::getInstance(__CLASS__, $instance_level); |
|
| 317 | + if ($tree_level) |
|
| 318 | + { |
|
| 319 | + $tree_level = Cache::getTree(__CLASS__, $tree_level); |
|
| 320 | + } |
|
| 321 | + if ($instance_level) |
|
| 322 | + { |
|
| 323 | + $instance_level = Cache::getInstance(__CLASS__, $instance_level); |
|
| 324 | + } |
|
| 298 | 325 | |
| 299 | 326 | // merging loaded translations together |
| 300 | 327 | $updated_load_via = false; |
@@ -361,7 +388,10 @@ discard block |
||
| 361 | 388 | static function &load_app($app,$lang) |
| 362 | 389 | { |
| 363 | 390 | //$start = microtime(true); |
| 364 | - if (is_null(self::$db)) self::init(false); |
|
| 391 | + if (is_null(self::$db)) |
|
| 392 | + { |
|
| 393 | + self::init(false); |
|
| 394 | + } |
|
| 365 | 395 | $loaded = array(); |
| 366 | 396 | foreach(self::$db->select(self::LANG_TABLE,'message_id,content',array( |
| 367 | 397 | 'lang' => $lang, |
@@ -467,7 +497,10 @@ discard block |
||
| 467 | 497 | $cache['']['en'] = count($en_phrases); |
| 468 | 498 | foreach(array_keys(self::get_available_langs()) as $lang) |
| 469 | 499 | { |
| 470 | - if ($lang == 'en') continue; |
|
| 500 | + if ($lang == 'en') |
|
| 501 | + { |
|
| 502 | + continue; |
|
| 503 | + } |
|
| 471 | 504 | $lang_phrases = array_keys(self::load_app_files(null, $lang, 'all-apps')); |
| 472 | 505 | $valid_phrases = array_intersect($lang_phrases, $en_phrases); |
| 473 | 506 | $cache[''][$lang] = count($valid_phrases); |
@@ -484,7 +517,10 @@ discard block |
||
| 484 | 517 | continue; |
| 485 | 518 | } |
| 486 | 519 | $en_phrases = array_keys(self::load_app_files(null, 'en', $app)); |
| 487 | - if (count($en_phrases) <= 2) continue; |
|
| 520 | + if (count($en_phrases) <= 2) |
|
| 521 | + { |
|
| 522 | + continue; |
|
| 523 | + } |
|
| 488 | 524 | $cache['en'][$app] = count($en_phrases); |
| 489 | 525 | $lang_phrases = array_keys(self::load_app_files(null, $_lang, $app)); |
| 490 | 526 | $valid_phrases = array_intersect($lang_phrases, $en_phrases); |
@@ -516,7 +552,10 @@ discard block |
||
| 516 | 552 | // check if cache is NOT invalided by checking if we have a modification time for concerned lang-file |
| 517 | 553 | $time = Cache::getTree(__CLASS__, $file=self::get_lang_file($_app, $_lang)); |
| 518 | 554 | // if we dont have one, cache has been invalidated and we need to load translations |
| 519 | - if (!isset($time)) self::add_app($_app, $_lang); |
|
| 555 | + if (!isset($time)) |
|
| 556 | + { |
|
| 557 | + self::add_app($_app, $_lang); |
|
| 558 | + } |
|
| 520 | 559 | |
| 521 | 560 | $etag = self::max_lang_time(); |
| 522 | 561 | } |
@@ -568,7 +607,11 @@ discard block |
||
| 568 | 607 | $loaded = array(); |
| 569 | 608 | foreach($load_app == 'all-apps' ? scandir(EGW_SERVER_ROOT) : (array)$load_app as $app_dir) |
| 570 | 609 | { |
| 571 | - if ($load_app == 'all-apps' && $app_dir=='..') continue; // do not try to break out of egw server root |
|
| 610 | + if ($load_app == 'all-apps' && $app_dir=='..') |
|
| 611 | + { |
|
| 612 | + continue; |
|
| 613 | + } |
|
| 614 | + // do not try to break out of egw server root |
|
| 572 | 615 | if ($app_dir[0] == '.' || !is_dir(EGW_SERVER_ROOT.'/'.$app_dir) || |
| 573 | 616 | !@file_exists($file=self::get_lang_file($app_dir, $lang)) || |
| 574 | 617 | !($f = fopen($file, 'r'))) |
@@ -587,9 +630,15 @@ discard block |
||
| 587 | 630 | { |
| 588 | 631 | $line = explode("\t", trim($read)); |
| 589 | 632 | ++$line_nr; |
| 590 | - if (count($line) != 4) continue; |
|
| 633 | + if (count($line) != 4) |
|
| 634 | + { |
|
| 635 | + continue; |
|
| 636 | + } |
|
| 591 | 637 | list($l_id,$l_app,$l_lang,$l_translation) = $line; |
| 592 | - if ($l_lang != $lang) continue; |
|
| 638 | + if ($l_lang != $lang) |
|
| 639 | + { |
|
| 640 | + continue; |
|
| 641 | + } |
|
| 593 | 642 | if (!isset($just_app_file) && $l_app != $app) |
| 594 | 643 | { |
| 595 | 644 | // check if $l_app contained in file in $app_dir is mentioned in $load_via |
@@ -603,8 +652,14 @@ discard block |
||
| 603 | 652 | } |
| 604 | 653 | // if not update load_via accordingly and store it as config |
| 605 | 654 | //error_log(__METHOD__."() load_via does not contain $l_app => $app_dir"); |
| 606 | - if (!isset(self::$load_via[$l_app])) self::$load_via[$l_app] = array($l_app); |
|
| 607 | - if (!is_array(self::$load_via[$l_app])) self::$load_via[$l_app] = array(self::$load_via[$l_app]); |
|
| 655 | + if (!isset(self::$load_via[$l_app])) |
|
| 656 | + { |
|
| 657 | + self::$load_via[$l_app] = array($l_app); |
|
| 658 | + } |
|
| 659 | + if (!is_array(self::$load_via[$l_app])) |
|
| 660 | + { |
|
| 661 | + self::$load_via[$l_app] = array(self::$load_via[$l_app]); |
|
| 662 | + } |
|
| 608 | 663 | self::$load_via[$l_app][] = $app_dir; |
| 609 | 664 | $updated_load_via = true; |
| 610 | 665 | } |
@@ -671,7 +726,10 @@ discard block |
||
| 671 | 726 | |
| 672 | 727 | if ($translate) |
| 673 | 728 | { |
| 674 | - if (is_null(self::$db)) self::init(false); |
|
| 729 | + if (is_null(self::$db)) |
|
| 730 | + { |
|
| 731 | + self::init(false); |
|
| 732 | + } |
|
| 675 | 733 | |
| 676 | 734 | foreach(self::$langs as $lang => $name) |
| 677 | 735 | { |
@@ -704,10 +762,13 @@ discard block |
||
| 704 | 762 | */ |
| 705 | 763 | static function lang2language($lang) |
| 706 | 764 | { |
| 707 | - if (isset(self::$langs[$lang])) // no need to query the DB |
|
| 765 | + if (isset(self::$langs[$lang])) |
|
| 766 | + { |
|
| 767 | + // no need to query the DB |
|
| 708 | 768 | { |
| 709 | 769 | return self::$langs[$lang]; |
| 710 | 770 | } |
| 771 | + } |
|
| 711 | 772 | return self::$db->select(self::LANGUAGES_TABLE,'lang_name',array('lang_id' => $lang),__LINE__,__FILE__)->fetchColumn(); |
| 712 | 773 | } |
| 713 | 774 | |
@@ -746,7 +807,10 @@ discard block |
||
| 746 | 807 | */ |
| 747 | 808 | static function get_lang_file($app,$lang) |
| 748 | 809 | { |
| 749 | - if ($app == 'common') $app = 'phpgwapi'; |
|
| 810 | + if ($app == 'common') |
|
| 811 | + { |
|
| 812 | + $app = 'phpgwapi'; |
|
| 813 | + } |
|
| 750 | 814 | return EGW_SERVER_ROOT.'/'.$app.'/'.self::LANG_DIR.'/'.self::LANGFILE_PREFIX.$lang.self::LANGFILE_EXTENSION; |
| 751 | 815 | } |
| 752 | 816 | |
@@ -809,9 +873,15 @@ discard block |
||
| 809 | 873 | { |
| 810 | 874 | if ($check_to_from) |
| 811 | 875 | { |
| 812 | - if ($from) $from = strtolower($from); |
|
| 876 | + if ($from) |
|
| 877 | + { |
|
| 878 | + $from = strtolower($from); |
|
| 879 | + } |
|
| 813 | 880 | |
| 814 | - if ($to) $to = strtolower($to); |
|
| 881 | + if ($to) |
|
| 882 | + { |
|
| 883 | + $to = strtolower($to); |
|
| 884 | + } |
|
| 815 | 885 | |
| 816 | 886 | if (!$from) |
| 817 | 887 | { |
@@ -936,7 +1006,10 @@ discard block |
||
| 936 | 1006 | */ |
| 937 | 1007 | static function convert_jsonsafe($_data,$from=False) |
| 938 | 1008 | { |
| 939 | - if ($from===false) $from = self::detect_encoding($_data); |
|
| 1009 | + if ($from===false) |
|
| 1010 | + { |
|
| 1011 | + $from = self::detect_encoding($_data); |
|
| 1012 | + } |
|
| 940 | 1013 | |
| 941 | 1014 | $data = self::convert($_data, strtolower($from)); |
| 942 | 1015 | |
@@ -1035,15 +1108,22 @@ discard block |
||
| 1035 | 1108 | static function get_message_id($translation,$app=null,$lang=null) |
| 1036 | 1109 | { |
| 1037 | 1110 | $where = array('content '.self::$db->capabilities[Db::CAPABILITY_CASE_INSENSITIV_LIKE].' '.self::$db->quote($translation)); |
| 1038 | - if ($app) $where['app_name'] = $app; |
|
| 1039 | - if ($lang) $where['lang'] = $lang; |
|
| 1111 | + if ($app) |
|
| 1112 | + { |
|
| 1113 | + $where['app_name'] = $app; |
|
| 1114 | + } |
|
| 1115 | + if ($lang) |
|
| 1116 | + { |
|
| 1117 | + $where['lang'] = $lang; |
|
| 1118 | + } |
|
| 1040 | 1119 | |
| 1041 | 1120 | $id = self::$db->select(self::LANG_TABLE,'message_id',$where,__LINE__,__FILE__)->fetchColumn(); |
| 1042 | 1121 | |
| 1043 | 1122 | // Check cache, since most things aren't in the DB anymore |
| 1044 | 1123 | if(!$id) |
| 1045 | 1124 | { |
| 1046 | - $ids = array_filter(array_keys(self::$lang_arr), function($haystack) use($translation) { |
|
| 1125 | + $ids = array_filter(array_keys(self::$lang_arr), function($haystack) use($translation) |
|
| 1126 | + { |
|
| 1047 | 1127 | return stripos(self::$lang_arr[$haystack],$translation) !== false; |
| 1048 | 1128 | }); |
| 1049 | 1129 | $id = array_shift($ids); |
@@ -1060,10 +1140,17 @@ discard block |
||
| 1060 | 1140 | } |
| 1061 | 1141 | |
| 1062 | 1142 | // load all translations from cache at once |
| 1063 | - if ($tree_level) $lang_arr = Cache::getTree(__CLASS__, $tree_level); |
|
| 1064 | - if ($instance_level) $lang_arr = Cache::getInstance(__CLASS__, $instance_level); |
|
| 1143 | + if ($tree_level) |
|
| 1144 | + { |
|
| 1145 | + $lang_arr = Cache::getTree(__CLASS__, $tree_level); |
|
| 1146 | + } |
|
| 1147 | + if ($instance_level) |
|
| 1148 | + { |
|
| 1149 | + $lang_arr = Cache::getInstance(__CLASS__, $instance_level); |
|
| 1150 | + } |
|
| 1065 | 1151 | $lang_arr = $lang_arr[$app.':en']; |
| 1066 | - $ids = array_filter(array_keys($lang_arr), function($haystack) use($translation, $lang_arr) { |
|
| 1152 | + $ids = array_filter(array_keys($lang_arr), function($haystack) use($translation, $lang_arr) |
|
| 1153 | + { |
|
| 1067 | 1154 | return stripos($lang_arr[$haystack],$translation) !== false; |
| 1068 | 1155 | }); |
| 1069 | 1156 | $id = array_shift($ids); |
@@ -1087,7 +1174,10 @@ discard block |
||
| 1087 | 1174 | { |
| 1088 | 1175 | $list = array('utf-8', 'iso-8859-1', 'windows-1251'); // list may be extended |
| 1089 | 1176 | |
| 1090 | - if ($verify) array_unshift($list, $verify); |
|
| 1177 | + if ($verify) |
|
| 1178 | + { |
|
| 1179 | + array_unshift($list, $verify); |
|
| 1180 | + } |
|
| 1091 | 1181 | |
| 1092 | 1182 | foreach ($list as $item) |
| 1093 | 1183 | { |
@@ -92,16 +92,23 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | foreach(self::$configs[$this->appname] as $name => $value) |
| 94 | 94 | { |
| 95 | - if (!isset($this->config_data[$name])) // has been deleted |
|
| 95 | + if (!isset($this->config_data[$name])) |
|
| 96 | + { |
|
| 97 | + // has been deleted |
|
| 96 | 98 | { |
| 97 | 99 | self::save_value($name, null, $this->appname, false); |
| 100 | + } |
|
| 98 | 101 | //self::$db->delete(self::TABLE,array('config_app'=>$this->appname,'config_name'=>$name),__LINE__,__FILE__); |
| 99 | 102 | } |
| 100 | 103 | } |
| 101 | 104 | |
| 102 | - if ($this->appname == 'phpgwapi' && method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
| 105 | + if ($this->appname == 'phpgwapi' && method_exists($GLOBALS['egw'],'invalidate_session_cache')) |
|
| 106 | + { |
|
| 107 | + // egw object in setup is limited |
|
| 103 | 108 | { |
| 104 | - $GLOBALS['egw']->invalidate_session_cache(); // in case egw_info is cached in the session (phpgwapi is in egw_info[server]) |
|
| 109 | + $GLOBALS['egw']->invalidate_session_cache(); |
|
| 110 | + } |
|
| 111 | + // in case egw_info is cached in the session (phpgwapi is in egw_info[server]) |
|
| 105 | 112 | } |
| 106 | 113 | self::$configs[$this->appname] = $this->config_data; |
| 107 | 114 | |
@@ -145,20 +152,30 @@ discard block |
||
| 145 | 152 | |
| 146 | 153 | if (!isset($value) || $value === '') |
| 147 | 154 | { |
| 148 | - if (isset(self::$configs[$app])) unset(self::$configs[$app][$name]); |
|
| 155 | + if (isset(self::$configs[$app])) |
|
| 156 | + { |
|
| 157 | + unset(self::$configs[$app][$name]); |
|
| 158 | + } |
|
| 149 | 159 | self::$db->delete(self::TABLE,array('config_app'=>$app,'config_name'=>$name),__LINE__,__FILE__); |
| 150 | 160 | } |
| 151 | 161 | else |
| 152 | 162 | { |
| 153 | 163 | self::$configs[$app][$name] = $value; |
| 154 | - if(is_array($value)) $value = json_encode($value); |
|
| 164 | + if(is_array($value)) |
|
| 165 | + { |
|
| 166 | + $value = json_encode($value); |
|
| 167 | + } |
|
| 155 | 168 | self::$db->insert(self::TABLE,array('config_value'=>$value),array('config_app'=>$app,'config_name'=>$name),__LINE__,__FILE__); |
| 156 | 169 | } |
| 157 | 170 | if ($update_cache) |
| 158 | 171 | { |
| 159 | - if ($app == 'phpgwapi' && method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
| 172 | + if ($app == 'phpgwapi' && method_exists($GLOBALS['egw'],'invalidate_session_cache')) |
|
| 173 | + { |
|
| 174 | + // egw object in setup is limited |
|
| 160 | 175 | { |
| 161 | - $GLOBALS['egw']->invalidate_session_cache(); // in case egw_info is cached in the session (phpgwapi is in egw_info[server]) |
|
| 176 | + $GLOBALS['egw']->invalidate_session_cache(); |
|
| 177 | + } |
|
| 178 | + // in case egw_info is cached in the session (phpgwapi is in egw_info[server]) |
|
| 162 | 179 | } |
| 163 | 180 | Cache::setInstance(__CLASS__, 'configs', self::$configs); |
| 164 | 181 | } |
@@ -278,7 +295,10 @@ discard block |
||
| 278 | 295 | { |
| 279 | 296 | foreach($config as $name => $value) |
| 280 | 297 | { |
| 281 | - if (strpos($name, 'pass') !== false) continue; |
|
| 298 | + if (strpos($name, 'pass') !== false) |
|
| 299 | + { |
|
| 300 | + continue; |
|
| 301 | + } |
|
| 282 | 302 | |
| 283 | 303 | if (in_array($name, $white_list['all']) || isset($white_list[$app]) && in_array($name, $white_list[$app])) |
| 284 | 304 | { |
@@ -95,7 +95,11 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | public function __construct($time='now',DateTimeZone $tz=null,&$type=null) |
| 97 | 97 | { |
| 98 | - if (is_null($tz)) $tz = self::$user_timezone; // default user timezone |
|
| 98 | + if (is_null($tz)) |
|
| 99 | + { |
|
| 100 | + $tz = self::$user_timezone; |
|
| 101 | + } |
|
| 102 | + // default user timezone |
|
| 99 | 103 | |
| 100 | 104 | switch(($type = gettype($time))) |
| 101 | 105 | { |
@@ -108,7 +112,11 @@ discard block |
||
| 108 | 112 | if (!(is_numeric($time) && ($time > 21000000 || $time < 19000000))) |
| 109 | 113 | { |
| 110 | 114 | $t_str = $time; |
| 111 | - if (is_numeric($time) && strlen($time) == 8) $t_str .= 'T000000'; // 'Ymd' string used in calendar to represent a date |
|
| 115 | + if (is_numeric($time) && strlen($time) == 8) |
|
| 116 | + { |
|
| 117 | + $t_str .= 'T000000'; |
|
| 118 | + } |
|
| 119 | + // 'Ymd' string used in calendar to represent a date |
|
| 112 | 120 | // $time ending in a Z (Zulu or UTC time), is unterstood by DateTime class itself |
| 113 | 121 | try { |
| 114 | 122 | parent::__construct($t_str,$tz); |
@@ -116,7 +124,10 @@ discard block |
||
| 116 | 124 | } |
| 117 | 125 | catch(Exception $e) { |
| 118 | 126 | // if string is nummeric, ignore the exception and treat string as timestamp |
| 119 | - if (!is_numeric($time)) throw $e; |
|
| 127 | + if (!is_numeric($time)) |
|
| 128 | + { |
|
| 129 | + throw $e; |
|
| 130 | + } |
|
| 120 | 131 | } |
| 121 | 132 | } |
| 122 | 133 | $type = 'integer'; |
@@ -137,7 +148,9 @@ discard block |
||
| 137 | 148 | |
| 138 | 149 | case 'array': |
| 139 | 150 | parent::__construct('now',$tz); |
| 140 | - if (isset($time['Y'])) // array format used in eTemplate |
|
| 151 | + if (isset($time['Y'])) |
|
| 152 | + { |
|
| 153 | + // array format used in eTemplate |
|
| 141 | 154 | { |
| 142 | 155 | $time = array( |
| 143 | 156 | 'year' => $time['Y'], |
@@ -148,13 +161,17 @@ discard block |
||
| 148 | 161 | 'second' => $time['s'], |
| 149 | 162 | ); |
| 150 | 163 | } |
| 164 | + } |
|
| 151 | 165 | if (!empty($time['full']) && empty($time['year'])) |
| 152 | 166 | { |
| 153 | 167 | $time['year'] = (int)substr($time['full'],0,4); |
| 154 | 168 | $time['month'] = (int)substr($time['full'],4,2); |
| 155 | 169 | $time['day'] = (int)substr($time['full'],6,2); |
| 156 | 170 | } |
| 157 | - if (isset($time['year'])) $this->setDate((int)$time['year'],(int)$time['month'],isset($time['day']) ? (int)$time['day'] : (int)$time['mday']); |
|
| 171 | + if (isset($time['year'])) |
|
| 172 | + { |
|
| 173 | + $this->setDate((int)$time['year'],(int)$time['month'],isset($time['day']) ? (int)$time['day'] : (int)$time['mday']); |
|
| 174 | + } |
|
| 158 | 175 | $this->setTime((int)$time['hour'],(int)$time['minute'],(int)$time['second']); |
| 159 | 176 | break; |
| 160 | 177 | |
@@ -178,7 +195,10 @@ discard block |
||
| 178 | 195 | */ |
| 179 | 196 | public function add($interval) |
| 180 | 197 | { |
| 181 | - if (is_string($interval)) $interval = DateInterval::createFromDateString($interval); |
|
| 198 | + if (is_string($interval)) |
|
| 199 | + { |
|
| 200 | + $interval = DateInterval::createFromDateString($interval); |
|
| 201 | + } |
|
| 182 | 202 | |
| 183 | 203 | parent::add($interval); |
| 184 | 204 | } |
@@ -202,7 +222,10 @@ discard block |
||
| 202 | 222 | $wstart = -($wday ? $wday-1 : 6); |
| 203 | 223 | break; |
| 204 | 224 | } |
| 205 | - if ($wstart) $this->add($wstart.'days'); |
|
| 225 | + if ($wstart) |
|
| 226 | + { |
|
| 227 | + $this->add($wstart.'days'); |
|
| 228 | + } |
|
| 206 | 229 | } |
| 207 | 230 | |
| 208 | 231 | /** |
@@ -263,15 +286,27 @@ discard block |
||
| 263 | 286 | } |
| 264 | 287 | elseif ($sday || $eday) |
| 265 | 288 | { |
| 266 | - if ($sday) $start->add($sday.'days'); |
|
| 267 | - if ($eday) $end->add($eday.'days'); |
|
| 289 | + if ($sday) |
|
| 290 | + { |
|
| 291 | + $start->add($sday.'days'); |
|
| 292 | + } |
|
| 293 | + if ($eday) |
|
| 294 | + { |
|
| 295 | + $end->add($eday.'days'); |
|
| 296 | + } |
|
| 268 | 297 | } |
| 269 | 298 | elseif ($sweek || $eweek) |
| 270 | 299 | { |
| 271 | 300 | $start->setWeekstart(); |
| 272 | - if ($sweek) $start->add($sweek.'weeks'); |
|
| 301 | + if ($sweek) |
|
| 302 | + { |
|
| 303 | + $start->add($sweek.'weeks'); |
|
| 304 | + } |
|
| 273 | 305 | $end->setWeekstart(); |
| 274 | - if ($eweek) $end->add($eweek.'weeks'); |
|
| 306 | + if ($eweek) |
|
| 307 | + { |
|
| 308 | + $end->add($eweek.'weeks'); |
|
| 309 | + } |
|
| 275 | 310 | } |
| 276 | 311 | } |
| 277 | 312 | // convert start + end from user to servertime for the filter |
@@ -416,7 +451,10 @@ discard block |
||
| 416 | 451 | } |
| 417 | 452 | $time->setUser(); |
| 418 | 453 | |
| 419 | - if (is_null($type)) $type = $typeof; |
|
| 454 | + if (is_null($type)) |
|
| 455 | + { |
|
| 456 | + $type = $typeof; |
|
| 457 | + } |
|
| 420 | 458 | |
| 421 | 459 | //echo "<p>".__METHOD__."($time,$type) = ".print_r($format->format($type),true)."</p>\n"; |
| 422 | 460 | return $time->format($type); |
@@ -446,7 +484,10 @@ discard block |
||
| 446 | 484 | } |
| 447 | 485 | $time->setServer(); |
| 448 | 486 | |
| 449 | - if (is_null($type)) $type = $typeof; |
|
| 487 | + if (is_null($type)) |
|
| 488 | + { |
|
| 489 | + $type = $typeof; |
|
| 490 | + } |
|
| 450 | 491 | |
| 451 | 492 | //echo "<p>".__METHOD__."($time,$type) = ".print_r($format->format($type),true)."</p>\n"; |
| 452 | 493 | return $time->format($type); |
@@ -489,7 +530,10 @@ discard block |
||
| 489 | 530 | public static function setUserPrefs($tz,$dateformat='',$timeformat='') |
| 490 | 531 | { |
| 491 | 532 | //echo "<p>".__METHOD__."('$tz','$dateformat','$timeformat') ".function_backtrace()."</p>\n"; |
| 492 | - if (!empty($dateformat)) self::$user_dateformat = $dateformat; |
|
| 533 | + if (!empty($dateformat)) |
|
| 534 | + { |
|
| 535 | + self::$user_dateformat = $dateformat; |
|
| 536 | + } |
|
| 493 | 537 | |
| 494 | 538 | switch($timeformat) |
| 495 | 539 | { |
@@ -527,7 +571,10 @@ discard block |
||
| 527 | 571 | */ |
| 528 | 572 | public static function tz_offset_s($time='now') |
| 529 | 573 | { |
| 530 | - if (!($time instanceof DateTime)) $time = new DateTime($time); |
|
| 574 | + if (!($time instanceof DateTime)) |
|
| 575 | + { |
|
| 576 | + $time = new DateTime($time); |
|
| 577 | + } |
|
| 531 | 578 | |
| 532 | 579 | return self::$user_timezone->getOffset($time) - self::$server_timezone->getOffset($time); |
| 533 | 580 | } |
@@ -635,9 +682,17 @@ discard block |
||
| 635 | 682 | ); |
| 636 | 683 | foreach(DateTimeZone::listIdentifiers() as $name) |
| 637 | 684 | { |
| 638 | - if (in_array($name,$no_vtimezone)) continue; // do NOT allow to set in EGroupware, as we have not VTIMEZONE component for it |
|
| 685 | + if (in_array($name,$no_vtimezone)) |
|
| 686 | + { |
|
| 687 | + continue; |
|
| 688 | + } |
|
| 689 | + // do NOT allow to set in EGroupware, as we have not VTIMEZONE component for it |
|
| 639 | 690 | list($continent) = explode('/',$name,2); |
| 640 | - if (!isset($tzs[$continent])) continue; // old depricated timezones |
|
| 691 | + if (!isset($tzs[$continent])) |
|
| 692 | + { |
|
| 693 | + continue; |
|
| 694 | + } |
|
| 695 | + // old depricated timezones |
|
| 641 | 696 | $datetime = new DateTime('now',new DateTimeZone($name)); |
| 642 | 697 | $tzs[$continent][$name] = str_replace(array('_','/'),array(' ',' / '),$name)." ".$datetime->format(); |
| 643 | 698 | unset($datetime); |
@@ -676,10 +731,13 @@ discard block |
||
| 676 | 731 | { |
| 677 | 732 | $user_tzs = array_merge(array($tz),$user_tzs); |
| 678 | 733 | } |
| 679 | - if (!$user_tzs) // if we have no user timezones, eg. user set no pref --> use server default |
|
| 734 | + if (!$user_tzs) |
|
| 735 | + { |
|
| 736 | + // if we have no user timezones, eg. user set no pref --> use server default |
|
| 680 | 737 | { |
| 681 | 738 | $user_tzs = array($GLOBALS['egw_info']['server']['server_timezone']); |
| 682 | 739 | } |
| 740 | + } |
|
| 683 | 741 | if ($extra && !in_array($extra,$user_tzs)) |
| 684 | 742 | { |
| 685 | 743 | $user_tzs = array_merge(array($extra),$user_tzs); |
@@ -122,7 +122,10 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | function __construct($accountid='',$app_name = '') |
| 124 | 124 | { |
| 125 | - if (!$app_name) $app_name = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 125 | + if (!$app_name) |
|
| 126 | + { |
|
| 127 | + $app_name = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 128 | + } |
|
| 126 | 129 | |
| 127 | 130 | if ($accountid === self::GLOBAL_ACCOUNT || |
| 128 | 131 | $accountid < 0 && $GLOBALS['egw']->accounts->exists($accountid) == 2) |
@@ -138,10 +141,13 @@ discard block |
||
| 138 | 141 | $this->app_name = $app_name; |
| 139 | 142 | $this->db = $GLOBALS['egw']->db; |
| 140 | 143 | |
| 141 | - if (is_null(self::$cache)) // should not be necessary, as cache is load and restored by egw object |
|
| 144 | + if (is_null(self::$cache)) |
|
| 145 | + { |
|
| 146 | + // should not be necessary, as cache is load and restored by egw object |
|
| 142 | 147 | { |
| 143 | 148 | self::init_cache(); |
| 144 | 149 | } |
| 150 | + } |
|
| 145 | 151 | if (is_null(self::$global_marker)) |
| 146 | 152 | { |
| 147 | 153 | // as et2 adds options with .text(), it can't be entities, but php knows no string literals with utf-8 |
@@ -189,7 +195,9 @@ discard block |
||
| 189 | 195 | $cats = array(); |
| 190 | 196 | foreach(self::$cache as $cat) |
| 191 | 197 | { |
| 192 | - if ($filter) foreach($filter as $col => $val) |
|
| 198 | + if ($filter) |
|
| 199 | + { |
|
| 200 | + foreach($filter as $col => $val) |
|
| 193 | 201 | { |
| 194 | 202 | if (!is_array($val) && $val[0] === '!') |
| 195 | 203 | { |
@@ -197,10 +205,14 @@ discard block |
||
| 197 | 205 | if (($col == 'name' || $col == 'description') && is_string($cat[$col])) |
| 198 | 206 | { |
| 199 | 207 | if ($cat[$col] == substr($val,1) || trim($cat[$col]) == substr($val,1)) continue 2; |
| 208 | + } |
|
| 200 | 209 | } |
| 201 | 210 | else |
| 202 | 211 | { |
| 203 | - if ($cat[$col] == substr($val,1)) continue 2; |
|
| 212 | + if ($cat[$col] == substr($val,1)) |
|
| 213 | + { |
|
| 214 | + continue 2; |
|
| 215 | + } |
|
| 204 | 216 | } |
| 205 | 217 | } |
| 206 | 218 | elseif (is_array($val)) |
@@ -208,11 +220,17 @@ discard block |
||
| 208 | 220 | // also match against trimmed database entry on name and description fields |
| 209 | 221 | if (($col == 'name' || $col == 'description') && is_string($cat[$col])) |
| 210 | 222 | { |
| 211 | - if (!in_array($cat[$col],$val) && !in_array(trim($cat[$col]),$val)) continue 2; |
|
| 223 | + if (!in_array($cat[$col],$val) && !in_array(trim($cat[$col]),$val)) |
|
| 224 | + { |
|
| 225 | + continue 2; |
|
| 226 | + } |
|
| 212 | 227 | } |
| 213 | 228 | else |
| 214 | 229 | { |
| 215 | - if (!in_array($cat[$col],$val)) continue 2; |
|
| 230 | + if (!in_array($cat[$col],$val)) |
|
| 231 | + { |
|
| 232 | + continue 2; |
|
| 233 | + } |
|
| 216 | 234 | } |
| 217 | 235 | } |
| 218 | 236 | else |
@@ -220,16 +238,25 @@ discard block |
||
| 220 | 238 | // also match against trimmed database entry on name and description fields |
| 221 | 239 | if (($col == 'name' || $col == 'description') && is_string($cat[$col])) |
| 222 | 240 | { |
| 223 | - if ($cat[$col] != $val && trim($cat[$col]) != $val) continue 2; |
|
| 241 | + if ($cat[$col] != $val && trim($cat[$col]) != $val) |
|
| 242 | + { |
|
| 243 | + continue 2; |
|
| 244 | + } |
|
| 224 | 245 | } |
| 225 | 246 | else |
| 226 | 247 | { |
| 227 | - if ($cat[$col] != $val) continue 2; |
|
| 248 | + if ($cat[$col] != $val) |
|
| 249 | + { |
|
| 250 | + continue 2; |
|
| 251 | + } |
|
| 228 | 252 | } |
| 229 | 253 | } |
| 230 | 254 | } |
| 231 | 255 | // check if certain parent required |
| 232 | - if ($parent_id && !in_array($cat['parent'],(array)$parent_id)) continue; |
|
| 256 | + if ($parent_id && !in_array($cat['parent'],(array)$parent_id)) |
|
| 257 | + { |
|
| 258 | + continue; |
|
| 259 | + } |
|
| 233 | 260 | |
| 234 | 261 | // return global categories just if $globals is set |
| 235 | 262 | if (!$globals && $cat['appname'] == self::GLOBAL_APPNAME) |
@@ -247,30 +274,55 @@ discard block |
||
| 247 | 274 | switch ($type) |
| 248 | 275 | { |
| 249 | 276 | case 'subs': |
| 250 | - if (!$cat['parent']) continue 2; // 2 for switch AND foreach! |
|
| 277 | + if (!$cat['parent']) |
|
| 278 | + { |
|
| 279 | + continue 2; |
|
| 280 | + } |
|
| 281 | + // 2 for switch AND foreach! |
|
| 251 | 282 | break; |
| 252 | 283 | case 'mains': |
| 253 | - if ($cat['parent']) continue 2; |
|
| 284 | + if ($cat['parent']) |
|
| 285 | + { |
|
| 286 | + continue 2; |
|
| 287 | + } |
|
| 254 | 288 | break; |
| 255 | 289 | case 'appandmains': |
| 256 | - if ($cat['appname'] != $this->app_name || $cat['parent']) continue 2; |
|
| 290 | + if ($cat['appname'] != $this->app_name || $cat['parent']) |
|
| 291 | + { |
|
| 292 | + continue 2; |
|
| 293 | + } |
|
| 257 | 294 | break; |
| 258 | 295 | case 'appandsubs': |
| 259 | - if ($cat['appname'] != $this->app_name || !$cat['parent']) continue 2; |
|
| 296 | + if ($cat['appname'] != $this->app_name || !$cat['parent']) |
|
| 297 | + { |
|
| 298 | + continue 2; |
|
| 299 | + } |
|
| 260 | 300 | break; |
| 261 | 301 | case 'noglobal': |
| 262 | - if ($cat['appname'] == $this->app_name) continue 2; |
|
| 302 | + if ($cat['appname'] == $this->app_name) |
|
| 303 | + { |
|
| 304 | + continue 2; |
|
| 305 | + } |
|
| 263 | 306 | break; |
| 264 | 307 | case 'noglobalapp': |
| 265 | - if ($cat['appname'] != $this->app_name || $cat['owner'] == (int)$this->account_id) continue 2; |
|
| 308 | + if ($cat['appname'] != $this->app_name || $cat['owner'] == (int)$this->account_id) |
|
| 309 | + { |
|
| 310 | + continue 2; |
|
| 311 | + } |
|
| 266 | 312 | break; |
| 267 | 313 | } |
| 268 | 314 | |
| 269 | 315 | // check name and description for $query |
| 270 | - if ($query && stristr($cat['name'],$query) === false && stristr($cat['description'],$query) === false) continue; |
|
| 316 | + if ($query && stristr($cat['name'],$query) === false && stristr($cat['description'],$query) === false) |
|
| 317 | + { |
|
| 318 | + continue; |
|
| 319 | + } |
|
| 271 | 320 | |
| 272 | 321 | // check if last modified since |
| 273 | - if ($lastmod > 0 && $cat['last_mod'] <= $lastmod) continue; |
|
| 322 | + if ($lastmod > 0 && $cat['last_mod'] <= $lastmod) |
|
| 323 | + { |
|
| 324 | + continue; |
|
| 325 | + } |
|
| 274 | 326 | |
| 275 | 327 | $cat['data'] = $cat['data'] ? json_php_unserialize($cat['data'], true) : array(); |
| 276 | 328 | |
@@ -281,13 +333,23 @@ discard block |
||
| 281 | 333 | //error_log(__METHOD__."($type,$start,$limit,$query,$sort,$order,$globals,parent=$parent_id,$lastmod,$column) account_id=$this->account_id, appname=$this->app_name = FALSE"); |
| 282 | 334 | return array(); |
| 283 | 335 | } |
| 284 | - if (!$sort) $sort = 'ASC'; |
|
| 336 | + if (!$sort) |
|
| 337 | + { |
|
| 338 | + $sort = 'ASC'; |
|
| 339 | + } |
|
| 285 | 340 | // order the entries if necessary (cache is already ordered in or default order: cat_main, cat_level, cat_name ASC) |
| 286 | 341 | if ($this->total_records > 1 && !empty($order) && |
| 287 | 342 | preg_match('/^[a-zA-Z_(), ]+$/',$order) && preg_match('/^(ASC|DESC|asc|desc)$/',$sort)) |
| 288 | 343 | { |
| 289 | - if (strstr($order,'cat_data') !== false) $order = 'cat_data'; // sitemgr orders by round(cat_data)! |
|
| 290 | - if (substr($order,0,4) == 'cat_') $order = substr($order,4); |
|
| 344 | + if (strstr($order,'cat_data') !== false) |
|
| 345 | + { |
|
| 346 | + $order = 'cat_data'; |
|
| 347 | + } |
|
| 348 | + // sitemgr orders by round(cat_data)! |
|
| 349 | + if (substr($order,0,4) == 'cat_') |
|
| 350 | + { |
|
| 351 | + $order = substr($order,4); |
|
| 352 | + } |
|
| 291 | 353 | $sign = strtoupper($sort) == 'DESC' ? -1 : 1; |
| 292 | 354 | usort($cats, function($a, $b) use ($order, $sign) |
| 293 | 355 | { |
@@ -301,7 +363,10 @@ discard block |
||
| 301 | 363 | // limit the number of returned rows |
| 302 | 364 | if ($limit) |
| 303 | 365 | { |
| 304 | - if (!is_int($limit)) $limit = (int)$GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; |
|
| 366 | + if (!is_int($limit)) |
|
| 367 | + { |
|
| 368 | + $limit = (int)$GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; |
|
| 369 | + } |
|
| 305 | 370 | $cats = array_slice($cats,(int)$start,$limit); |
| 306 | 371 | } |
| 307 | 372 | // return only a certain column (why not return is as value?) |
@@ -334,15 +399,24 @@ discard block |
||
| 334 | 399 | */ |
| 335 | 400 | function return_sorted_array($start=0,$limit=True,$query='',$sort='ASC',$order='cat_name',$globals=False, $parent_id=0,$unserialize_data=true,$filter=null) |
| 336 | 401 | { |
| 337 | - if (!$sort) $sort = 'ASC'; |
|
| 338 | - if (!$order) $order = 'cat_name'; |
|
| 402 | + if (!$sort) |
|
| 403 | + { |
|
| 404 | + $sort = 'ASC'; |
|
| 405 | + } |
|
| 406 | + if (!$order) |
|
| 407 | + { |
|
| 408 | + $order = 'cat_name'; |
|
| 409 | + } |
|
| 339 | 410 | |
| 340 | 411 | //error_log(__METHOD__."($start,$limit,$query,$sort,$order,globals=$globals,parent=$parent_id,$unserialize_data) account_id=$this->account_id, appname=$this->app_name: ".function_backtrace()); |
| 341 | 412 | |
| 342 | 413 | $parents = $cats = array(); |
| 343 | 414 | |
| 344 | 415 | // Cast parent_id to array, but only if there is one |
| 345 | - if($parent_id !== false && $parent_id !== null) $parent_id = (array)$parent_id; |
|
| 416 | + if($parent_id !== false && $parent_id !== null) |
|
| 417 | + { |
|
| 418 | + $parent_id = (array)$parent_id; |
|
| 419 | + } |
|
| 346 | 420 | if (!($cats = $this->return_array('all',0,false,$query,$sort,$order,$globals,$parent_id,-1,'',$filter,$unserialize_data))) |
| 347 | 421 | { |
| 348 | 422 | $cats = array(); |
@@ -352,7 +426,9 @@ discard block |
||
| 352 | 426 | $parents[] = $cat['id']; |
| 353 | 427 | } |
| 354 | 428 | |
| 355 | - if($parent_id || !$cats) // Avoid wiping search results |
|
| 429 | + if($parent_id || !$cats) |
|
| 430 | + { |
|
| 431 | + // Avoid wiping search results |
|
| 356 | 432 | { |
| 357 | 433 | // Go find the children |
| 358 | 434 | while (count($parents)) |
@@ -360,6 +436,7 @@ discard block |
||
| 360 | 436 | if (!($subs = $this->return_array('all',0,false,$query,$sort,$order,$globals,$parents,-1,'',$filter,$unserialize_data))) |
| 361 | 437 | { |
| 362 | 438 | break; |
| 439 | + } |
|
| 363 | 440 | } |
| 364 | 441 | $parents = $children = array(); |
| 365 | 442 | foreach($subs as $cat) |
@@ -391,7 +468,10 @@ discard block |
||
| 391 | 468 | // limit the number of returned rows |
| 392 | 469 | if ($limit) |
| 393 | 470 | { |
| 394 | - if (!is_int($limit)) $limit = (int)$GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; |
|
| 471 | + if (!is_int($limit)) |
|
| 472 | + { |
|
| 473 | + $limit = (int)$GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']; |
|
| 474 | + } |
|
| 395 | 475 | $cats = array_slice($cats,(int)$start,$limit); |
| 396 | 476 | } |
| 397 | 477 | reset($cats); // some old code (eg. sitemgr) relies on the array-pointer! |
@@ -410,9 +490,15 @@ discard block |
||
| 410 | 490 | */ |
| 411 | 491 | static function read($id) |
| 412 | 492 | { |
| 413 | - if (is_null(self::$cache)) self::init_cache(); |
|
| 493 | + if (is_null(self::$cache)) |
|
| 494 | + { |
|
| 495 | + self::init_cache(); |
|
| 496 | + } |
|
| 414 | 497 | |
| 415 | - if (!isset(self::$cache[$id])) return false; |
|
| 498 | + if (!isset(self::$cache[$id])) |
|
| 499 | + { |
|
| 500 | + return false; |
|
| 501 | + } |
|
| 416 | 502 | |
| 417 | 503 | $cat = self::$cache[$id]; |
| 418 | 504 | $cat['data'] = $cat['data'] ? ((($arr=json_php_unserialize($cat['data'], true)) !== false || $cat['data'] === 'b:0;') ? |
@@ -475,8 +561,11 @@ discard block |
||
| 475 | 561 | * @return string truncated commaseparated list of category ids |
| 476 | 562 | */ |
| 477 | 563 | function check_list($needed, $cat_list) |
| 478 | - { |
|
| 479 | - if (empty($cat_list)) return $cat_list; |
|
| 564 | + { |
|
| 565 | + if (empty($cat_list)) |
|
| 566 | + { |
|
| 567 | + return $cat_list; |
|
| 568 | + } |
|
| 480 | 569 | if (is_array($cat_list)) |
| 481 | 570 | { |
| 482 | 571 | $cat_list = implode(',',$cat_list); |
@@ -487,10 +576,13 @@ discard block |
||
| 487 | 576 | { |
| 488 | 577 | foreach($cat_arr as $id=>$cat_id) |
| 489 | 578 | { |
| 490 | - if (!$this->check_perms($needed, $cat_id, false, $needed == Acl::READ)) // allow reading all global cats |
|
| 579 | + if (!$this->check_perms($needed, $cat_id, false, $needed == Acl::READ)) |
|
| 580 | + { |
|
| 581 | + // allow reading all global cats |
|
| 491 | 582 | { |
| 492 | 583 | unset($cat_arr[$id]); |
| 493 | 584 | } |
| 585 | + } |
|
| 494 | 586 | } |
| 495 | 587 | $cat_list = implode(',',$cat_arr); |
| 496 | 588 | } |
@@ -596,9 +688,15 @@ discard block |
||
| 596 | 688 | { |
| 597 | 689 | $update = array('cat_level' => $cat['level']-1); |
| 598 | 690 | |
| 599 | - if ($new_main) $update['cat_main'] = $new_main; |
|
| 691 | + if ($new_main) |
|
| 692 | + { |
|
| 693 | + $update['cat_main'] = $new_main; |
|
| 694 | + } |
|
| 600 | 695 | |
| 601 | - if ($cat['parent'] == $cat_id) $update['cat_parent'] = $new_parent; |
|
| 696 | + if ($cat['parent'] == $cat_id) |
|
| 697 | + { |
|
| 698 | + $update['cat_parent'] = $new_parent; |
|
| 699 | + } |
|
| 602 | 700 | |
| 603 | 701 | $this->db->update(self::TABLE,$update,array( |
| 604 | 702 | 'cat_id' => $cat['id'], |
@@ -624,9 +722,13 @@ discard block |
||
| 624 | 722 | 'modify_subs' => $modify_subs, |
| 625 | 723 | 'location' => 'delete_category' |
| 626 | 724 | ); |
| 627 | - if($this->is_global($cat_id, true)) // true = application global (otherwise eg. global addressbook categories call all apps) |
|
| 725 | + if($this->is_global($cat_id, true)) |
|
| 726 | + { |
|
| 727 | + // true = application global (otherwise eg. global addressbook categories call all apps) |
|
| 628 | 728 | { |
| 629 | - Hooks::process($GLOBALS['hook_values'],False,True); // called for every app now, not only enabled ones) |
|
| 729 | + Hooks::process($GLOBALS['hook_values'],False,True); |
|
| 730 | + } |
|
| 731 | + // called for every app now, not only enabled ones) |
|
| 630 | 732 | } |
| 631 | 733 | else |
| 632 | 734 | { |
@@ -682,12 +784,22 @@ discard block |
||
| 682 | 784 | // check if we try to move an element down its own subtree, which will fail |
| 683 | 785 | foreach ($this->return_sorted_array('',False,'','','',False, $values['id']) as $cat) |
| 684 | 786 | { |
| 685 | - if ($cat['id'] == $values['parent']) return lang('Cannot set a category as parent, which is part of this categorys subtree!'); |
|
| 787 | + if ($cat['id'] == $values['parent']) |
|
| 788 | + { |
|
| 789 | + return lang('Cannot set a category as parent, which is part of this categorys subtree!'); |
|
| 790 | + } |
|
| 686 | 791 | } |
| 687 | 792 | // check if we try to be our own parent |
| 688 | - if ($values['parent']==$values['id']) return lang('Cannot set this cat as its own parent!'); // deny to be our own parent |
|
| 793 | + if ($values['parent']==$values['id']) |
|
| 794 | + { |
|
| 795 | + return lang('Cannot set this cat as its own parent!'); |
|
| 796 | + } |
|
| 797 | + // deny to be our own parent |
|
| 689 | 798 | // check if parent still exists |
| 690 | - if ((int)$values['parent']>0 && !$this->read($values['parent'])) return lang('Chosen parent category no longer exists'); |
|
| 799 | + if ((int)$values['parent']>0 && !$this->read($values['parent'])) |
|
| 800 | + { |
|
| 801 | + return lang('Chosen parent category no longer exists'); |
|
| 802 | + } |
|
| 691 | 803 | return true; |
| 692 | 804 | } |
| 693 | 805 | |
@@ -704,7 +816,10 @@ discard block |
||
| 704 | 816 | if (isset($values['old_parent']) && (int)$values['old_parent'] != (int)$values['parent']) |
| 705 | 817 | { |
| 706 | 818 | $ret = $this->check_consistency4update($values); |
| 707 | - if ($ret !== true) throw new Exception\WrongUserinput($ret); |
|
| 819 | + if ($ret !== true) |
|
| 820 | + { |
|
| 821 | + throw new Exception\WrongUserinput($ret); |
|
| 822 | + } |
|
| 708 | 823 | // everything seems in order -> proceed |
| 709 | 824 | $values['level'] = ($values['parent'] ? $this->id2name($values['parent'],'level')+1:0); |
| 710 | 825 | $this->adapt_level_in_subtree($values); |
@@ -717,7 +832,10 @@ discard block |
||
| 717 | 832 | if ($values['parent'] > 0) |
| 718 | 833 | { |
| 719 | 834 | $ret = $this->check_consistency4update($values); |
| 720 | - if ($ret !== true) throw new Exception\WrongUserinput($ret); |
|
| 835 | + if ($ret !== true) |
|
| 836 | + { |
|
| 837 | + throw new Exception\WrongUserinput($ret); |
|
| 838 | + } |
|
| 721 | 839 | |
| 722 | 840 | // everything seems in order -> proceed |
| 723 | 841 | $values['main'] = $this->id2name($values['parent'],'main'); |
@@ -773,7 +891,10 @@ discard block |
||
| 773 | 891 | { |
| 774 | 892 | static $cache = array(); // a litle bit of caching |
| 775 | 893 | |
| 776 | - if (isset($cache[$cat_name])) return $cache[$cat_name]; |
|
| 894 | + if (isset($cache[$cat_name])) |
|
| 895 | + { |
|
| 896 | + return $cache[$cat_name]; |
|
| 897 | + } |
|
| 777 | 898 | |
| 778 | 899 | if ($strip === true) |
| 779 | 900 | { |
@@ -826,7 +947,11 @@ discard block |
||
| 826 | 947 | */ |
| 827 | 948 | static function is_global($cat,$application_global=false) |
| 828 | 949 | { |
| 829 | - if (!is_array($cat) && !($cat = self::read($cat))) return null; // cat not found |
|
| 950 | + if (!is_array($cat) && !($cat = self::read($cat))) |
|
| 951 | + { |
|
| 952 | + return null; |
|
| 953 | + } |
|
| 954 | + // cat not found |
|
| 830 | 955 | |
| 831 | 956 | $global_owner = false; |
| 832 | 957 | foreach(explode(',',$cat['owner']) as $owner) |
@@ -848,10 +973,19 @@ discard block |
||
| 848 | 973 | */ |
| 849 | 974 | static function id2name($cat_id=0, $item='name') |
| 850 | 975 | { |
| 851 | - if(!$cat_id) return '--'; |
|
| 852 | - if (!$item) $item = 'parent'; |
|
| 976 | + if(!$cat_id) |
|
| 977 | + { |
|
| 978 | + return '--'; |
|
| 979 | + } |
|
| 980 | + if (!$item) |
|
| 981 | + { |
|
| 982 | + $item = 'parent'; |
|
| 983 | + } |
|
| 853 | 984 | |
| 854 | - if (is_null(self::$cache)) self::init_cache(); |
|
| 985 | + if (is_null(self::$cache)) |
|
| 986 | + { |
|
| 987 | + self::init_cache(); |
|
| 988 | + } |
|
| 855 | 989 | |
| 856 | 990 | $cat = self::$cache[$cat_id]; |
| 857 | 991 | if ($item == 'path') |
@@ -892,7 +1026,10 @@ discard block |
||
| 892 | 1026 | if ($cat_name) |
| 893 | 1027 | { |
| 894 | 1028 | $filter['name'] = $cat_name; |
| 895 | - if ($cat_id) $filter['id'] = '!'.(int)$cat_id; |
|
| 1029 | + if ($cat_id) |
|
| 1030 | + { |
|
| 1031 | + $filter['id'] = '!'.(int)$cat_id; |
|
| 1032 | + } |
|
| 896 | 1033 | } |
| 897 | 1034 | elseif ($cat_id) |
| 898 | 1035 | { |
@@ -921,7 +1058,10 @@ discard block |
||
| 921 | 1058 | { |
| 922 | 1059 | $where = array('cat_owner' => $owner); |
| 923 | 1060 | |
| 924 | - if ($app) $where['cat_appname'] = $app; |
|
| 1061 | + if ($app) |
|
| 1062 | + { |
|
| 1063 | + $where['cat_appname'] = $app; |
|
| 1064 | + } |
|
| 925 | 1065 | |
| 926 | 1066 | if ((int)$to) |
| 927 | 1067 | { |
@@ -967,7 +1107,11 @@ discard block |
||
| 967 | 1107 | false,'ORDER BY cat_main, cat_level, cat_name ASC') as $cat) |
| 968 | 1108 | { |
| 969 | 1109 | $cat = Db::strip_array_keys($cat,'cat_'); |
| 970 | - if ($cat['appname'] == '*update*') continue; // --> ignore update marker |
|
| 1110 | + if ($cat['appname'] == '*update*') |
|
| 1111 | + { |
|
| 1112 | + continue; |
|
| 1113 | + } |
|
| 1114 | + // --> ignore update marker |
|
| 971 | 1115 | $cat['app_name'] = $cat['appname']; |
| 972 | 1116 | // backlink children to their parent |
| 973 | 1117 | if ($cat['parent']) |
@@ -1058,7 +1202,10 @@ discard block |
||
| 1058 | 1202 | // ACL check |
| 1059 | 1203 | $cats = $GLOBALS['egw']->categories->check_list(Acl::READ, $_cats); |
| 1060 | 1204 | |
| 1061 | - if (!$cats) return null; |
|
| 1205 | + if (!$cats) |
|
| 1206 | + { |
|
| 1207 | + return null; |
|
| 1208 | + } |
|
| 1062 | 1209 | |
| 1063 | 1210 | if (isset($cat2color[$cats])) |
| 1064 | 1211 | { |
@@ -1090,7 +1237,10 @@ discard block |
||
| 1090 | 1237 | */ |
| 1091 | 1238 | public static function delete_account($account_id, $new_owner=null) |
| 1092 | 1239 | { |
| 1093 | - if (is_null(self::$cache)) self::init_cache(); |
|
| 1240 | + if (is_null(self::$cache)) |
|
| 1241 | + { |
|
| 1242 | + self::init_cache(); |
|
| 1243 | + } |
|
| 1094 | 1244 | |
| 1095 | 1245 | $deleted = 0; |
| 1096 | 1246 | $cat = null; |
@@ -1110,7 +1260,10 @@ discard block |
||
| 1110 | 1260 | else |
| 1111 | 1261 | { |
| 1112 | 1262 | unset($owners[$owner_key]); |
| 1113 | - if ($new_owner && $account_id > 0) $owners[] = $new_owner; |
|
| 1263 | + if ($new_owner && $account_id > 0) |
|
| 1264 | + { |
|
| 1265 | + $owners[] = $new_owner; |
|
| 1266 | + } |
|
| 1114 | 1267 | $data['owner'] = implode(',', $owners); |
| 1115 | 1268 | // app_name have to match cat to update! |
| 1116 | 1269 | if (!isset($cat) || $cat->app_name != $data['appname']) |
@@ -1132,7 +1285,10 @@ discard block |
||
| 1132 | 1285 | */ |
| 1133 | 1286 | public static function delete_orphans() |
| 1134 | 1287 | { |
| 1135 | - if (is_null(self::$cache)) self::init_cache(); |
|
| 1288 | + if (is_null(self::$cache)) |
|
| 1289 | + { |
|
| 1290 | + self::init_cache(); |
|
| 1291 | + } |
|
| 1136 | 1292 | |
| 1137 | 1293 | $checked = array(); |
| 1138 | 1294 | $deleted = 0; |
@@ -114,7 +114,8 @@ discard block |
||
| 114 | 114 | echo "<p>next_run("; print_r($times); echo ",'$debug', " . date('Y-m-d H:i', $now) . ")</p>\n"; |
| 115 | 115 | $debug = True; // enable syntax-error messages too |
| 116 | 116 | } |
| 117 | - if(is_null($now)) { |
|
| 117 | + if(is_null($now)) |
|
| 118 | + { |
|
| 118 | 119 | $now = time(); |
| 119 | 120 | } |
| 120 | 121 | |
@@ -179,12 +180,17 @@ discard block |
||
| 179 | 180 | foreach($units as $u => $date_pattern) |
| 180 | 181 | { |
| 181 | 182 | ++$n; |
| 182 | - if ($this->debug) { echo "<p>n=$n, $u: isset(times[$u]="; print_r($times[$u]); echo ")=".(isset($times[$u])?'True':'False')."</p>\n"; } |
|
| 183 | + if ($this->debug) |
|
| 184 | + { |
|
| 185 | +echo "<p>n=$n, $u: isset(times[$u]="; print_r($times[$u]); echo ")=".(isset($times[$u])?'True':'False')."</p>\n"; } |
|
| 183 | 186 | if (isset($times[$u])) |
| 184 | 187 | { |
| 185 | - if(is_array($times[$u])) { |
|
| 188 | + if(is_array($times[$u])) |
|
| 189 | + { |
|
| 186 | 190 | $time = array_keys($times[$u]); |
| 187 | - } else { |
|
| 191 | + } |
|
| 192 | + else |
|
| 193 | + { |
|
| 188 | 194 | $time = explode(',',$times[$u]); |
| 189 | 195 | } |
| 190 | 196 | $times[$u] = array(); |
@@ -197,7 +203,10 @@ discard block |
||
| 197 | 203 | |
| 198 | 204 | if (count($arr) != 2 || !is_numeric($min) || !is_numeric($max) || $min > $max) |
| 199 | 205 | { |
| 200 | - if ($debug) echo "<p>Syntax error in $u='$t', allowed is 'min-max', min <= max, min='$min', max='$max'</p>\n"; |
|
| 206 | + if ($debug) |
|
| 207 | + { |
|
| 208 | + echo "<p>Syntax error in $u='$t', allowed is 'min-max', min <= max, min='$min', max='$max'</p>\n"; |
|
| 209 | + } |
|
| 201 | 210 | |
| 202 | 211 | return False; |
| 203 | 212 | } |
@@ -208,14 +217,20 @@ discard block |
||
| 208 | 217 | } |
| 209 | 218 | else |
| 210 | 219 | { |
| 211 | - if ((string)$t == '*') $t = '*/1'; |
|
| 220 | + if ((string)$t == '*') |
|
| 221 | + { |
|
| 222 | + $t = '*/1'; |
|
| 223 | + } |
|
| 212 | 224 | |
| 213 | 225 | list($one,$inc) = $arr = explode('/',$t); |
| 214 | 226 | |
| 215 | 227 | if (!(is_numeric($one) && count($arr) == 1 || |
| 216 | 228 | count($arr) == 2 && is_numeric($inc))) |
| 217 | 229 | { |
| 218 | - if ($debug) echo "<p>Syntax error in $u='$t', allowed is a number or '{*|range}/inc', inc='$inc'</p>\n"; |
|
| 230 | + if ($debug) |
|
| 231 | + { |
|
| 232 | + echo "<p>Syntax error in $u='$t', allowed is a number or '{*|range}/inc', inc='$inc'</p>\n"; |
|
| 233 | + } |
|
| 219 | 234 | |
| 220 | 235 | return False; |
| 221 | 236 | } |
@@ -233,7 +248,10 @@ discard block |
||
| 233 | 248 | } |
| 234 | 249 | elseif (count($arr) != 2 || $min > $max) |
| 235 | 250 | { |
| 236 | - if ($debug) echo "<p>Syntax error in $u='$t', allowed is '{*|min-max}/inc', min='$min',max='$max', inc='$inc'</p>\n"; |
|
| 251 | + if ($debug) |
|
| 252 | + { |
|
| 253 | + echo "<p>Syntax error in $u='$t', allowed is '{*|min-max}/inc', min='$min',max='$max', inc='$inc'</p>\n"; |
|
| 254 | + } |
|
| 237 | 255 | return False; |
| 238 | 256 | } |
| 239 | 257 | for ($i = $min; $i <= $max; $i += $inc) |
@@ -244,9 +262,13 @@ discard block |
||
| 244 | 262 | } |
| 245 | 263 | } |
| 246 | 264 | } |
| 247 | - elseif ($n < $last_set || $u == 'dow') // before last value set (or dow) => empty gets enumerated |
|
| 265 | + elseif ($n < $last_set || $u == 'dow') |
|
| 266 | + { |
|
| 267 | + // before last value set (or dow) => empty gets enumerated |
|
| 248 | 268 | { |
| 249 | - for ($i = $min_unit[$u]; $i <= $max_unit[$u]; ++$i) |
|
| 269 | + for ($i = $min_unit[$u]; |
|
| 270 | + } |
|
| 271 | + $i <= $max_unit[$u]; ++$i) |
|
| 250 | 272 | { |
| 251 | 273 | $times[$u][$i] = True; |
| 252 | 274 | } |
@@ -256,7 +278,9 @@ discard block |
||
| 256 | 278 | $times[$u][$min_unit[$u]] = True; |
| 257 | 279 | } |
| 258 | 280 | } |
| 259 | - if ($this->debug) { echo "enumerated times=<pre>"; print_r($times); echo "</pre>\n"; } |
|
| 281 | + if ($this->debug) |
|
| 282 | + { |
|
| 283 | +echo "enumerated times=<pre>"; print_r($times); echo "</pre>\n"; } |
|
| 260 | 284 | |
| 261 | 285 | // now we have the times enumerated, lets find the first not expired one |
| 262 | 286 | // |
@@ -274,7 +298,10 @@ discard block |
||
| 274 | 298 | if (isset($found[$u])) |
| 275 | 299 | { |
| 276 | 300 | $future = $future || $found[$u] > $unit_now; |
| 277 | - if ($this->debug) echo "--> already have a $u = ".$found[$u].", future='$future'<br>\n"; |
|
| 301 | + if ($this->debug) |
|
| 302 | + { |
|
| 303 | + echo "--> already have a $u = ".$found[$u].", future='$future'<br>\n"; |
|
| 304 | + } |
|
| 278 | 305 | continue; // already set |
| 279 | 306 | } |
| 280 | 307 | foreach(array_keys($times[$u]) as $unit_value) |
@@ -292,30 +319,44 @@ discard block |
||
| 292 | 319 | break; |
| 293 | 320 | |
| 294 | 321 | } |
| 295 | - if ($valid && ($u != $next || $unit_value > $over)) // valid and not over |
|
| 322 | + if ($valid && ($u != $next || $unit_value > $over)) |
|
| 323 | + { |
|
| 324 | + // valid and not over |
|
| 296 | 325 | { |
| 297 | 326 | $found[$u] = $unit_value; |
| 327 | + } |
|
| 298 | 328 | $future = $future || $unit_value > $unit_now; |
| 299 | 329 | break; |
| 300 | 330 | } |
| 301 | 331 | } |
| 302 | - if (!isset($found[$u])) // we have to try the next one, if it exists |
|
| 332 | + if (!isset($found[$u])) |
|
| 333 | + { |
|
| 334 | + // we have to try the next one, if it exists |
|
| 303 | 335 | { |
| 304 | 336 | $nexts = array_keys($units); |
| 337 | + } |
|
| 305 | 338 | if (!isset($nexts[count($found)-1])) |
| 306 | 339 | { |
| 307 | - if ($this->debug) echo "<p>Nothing found, exiting !!!</p>\n"; |
|
| 340 | + if ($this->debug) |
|
| 341 | + { |
|
| 342 | + echo "<p>Nothing found, exiting !!!</p>\n"; |
|
| 343 | + } |
|
| 308 | 344 | return False; |
| 309 | 345 | } |
| 310 | 346 | $next = $nexts[count($found)-1]; |
| 311 | 347 | $over = $found[$next]; |
| 312 | 348 | unset($found[$next]); |
| 313 | - if ($this->debug) echo "<p>Have to try the next $next, $u's are over for $next=$over !!!</p>\n"; |
|
| 349 | + if ($this->debug) |
|
| 350 | + { |
|
| 351 | + echo "<p>Have to try the next $next, $u's are over for $next=$over !!!</p>\n"; |
|
| 352 | + } |
|
| 314 | 353 | break; |
| 315 | 354 | } |
| 316 | 355 | } |
| 317 | 356 | } |
| 318 | - if ($this->debug) { echo "<p>next="; print_r($found); echo "</p>\n"; } |
|
| 357 | + if ($this->debug) |
|
| 358 | + { |
|
| 359 | +echo "<p>next="; print_r($found); echo "</p>\n"; } |
|
| 319 | 360 | |
| 320 | 361 | return mktime($found['hour'],$found['min'],0,$found['month'],$found['day'],$found['year']); |
| 321 | 362 | } |
@@ -377,7 +418,10 @@ discard block |
||
| 377 | 418 | ); |
| 378 | 419 | // as the async_next column is used as a semaphore we only update it, |
| 379 | 420 | // if it is 0 (semaphore released) or older then 10min to recover from failed or crashed attempts |
| 380 | - if ($exists) $where = array('async_next=0 OR async_next<'.(time()-600)); |
|
| 421 | + if ($exists) |
|
| 422 | + { |
|
| 423 | + $where = array('async_next=0 OR async_next<'.(time()-600)); |
|
| 424 | + } |
|
| 381 | 425 | } |
| 382 | 426 | //echo "last_run=<pre>"; print_r($last_run); echo "</pre>\n"; |
| 383 | 427 | return $this->write($last_run, !!$exists, $where) > 0; |
@@ -388,7 +432,10 @@ discard block |
||
| 388 | 432 | */ |
| 389 | 433 | function check_run($run_by='') |
| 390 | 434 | { |
| 391 | - if ($run_by === 'fallback') flush(); |
|
| 435 | + if ($run_by === 'fallback') |
|
| 436 | + { |
|
| 437 | + flush(); |
|
| 438 | + } |
|
| 392 | 439 | |
| 393 | 440 | if (!$this->last_check_run(True,False,$run_by)) |
| 394 | 441 | { |
@@ -410,7 +457,10 @@ discard block |
||
| 410 | 457 | // unset all objects in $GLOBALS, which are created and used by ExecMethod, as they can contain user-data |
| 411 | 458 | foreach($GLOBALS as $name => $value) |
| 412 | 459 | { |
| 413 | - if ($name !== 'egw' && is_object($value)) unset($GLOBALS[$name]); |
|
| 460 | + if ($name !== 'egw' && is_object($value)) |
|
| 461 | + { |
|
| 462 | + unset($GLOBALS[$name]); |
|
| 463 | + } |
|
| 414 | 464 | } |
| 415 | 465 | $domain = $GLOBALS['egw_info']['user']['domain']; |
| 416 | 466 | $lang = $GLOBALS['egw_info']['user']['preferences']['common']['lang']; |
@@ -480,7 +530,10 @@ discard block |
||
| 480 | 530 | */ |
| 481 | 531 | function read($id=0,$cols='*',$offset=False,$append='ORDER BY async_next',$num_rows=0) |
| 482 | 532 | { |
| 483 | - if (!is_a($this->db, 'EGroupware\\Api\\Db')) return false; |
|
| 533 | + if (!is_a($this->db, 'EGroupware\\Api\\Db')) |
|
| 534 | + { |
|
| 535 | + return false; |
|
| 536 | + } |
|
| 484 | 537 | |
| 485 | 538 | if ($id === '%') |
| 486 | 539 | { |
@@ -533,9 +586,15 @@ discard block |
||
| 533 | 586 | */ |
| 534 | 587 | function write($job, $exists = False, $where=array()) |
| 535 | 588 | { |
| 536 | - if (!is_a($this->db, 'EGroupware\\Api\\Db')) return 0; |
|
| 589 | + if (!is_a($this->db, 'EGroupware\\Api\\Db')) |
|
| 590 | + { |
|
| 591 | + return 0; |
|
| 592 | + } |
|
| 537 | 593 | |
| 538 | - if (is_array($job['data']) && isset($job['data']['next']) && isset($job['next'])) $job['data']['next'] = $job['next']; |
|
| 594 | + if (is_array($job['data']) && isset($job['data']['next']) && isset($job['next'])) |
|
| 595 | + { |
|
| 596 | + $job['data']['next'] = $job['next']; |
|
| 597 | + } |
|
| 539 | 598 | $data = array( |
| 540 | 599 | 'async_next' => $job['next'], |
| 541 | 600 | 'async_times' => json_encode($job['times']), |
@@ -600,9 +659,12 @@ discard block |
||
| 600 | 659 | { |
| 601 | 660 | echo '<p>'.lang('%1 is not executable by the webserver !!!',$this->$name)."</p>\n"; |
| 602 | 661 | $perms = fileperms($this->$name); |
| 603 | - if (!($perms & 0x0001) && ($perms & 0x0008) && function_exists('posix_getuid')) // only executable by group |
|
| 662 | + if (!($perms & 0x0001) && ($perms & 0x0008) && function_exists('posix_getuid')) |
|
| 663 | + { |
|
| 664 | + // only executable by group |
|
| 604 | 665 | { |
| 605 | 666 | $group = posix_getgrgid(filegroup($this->$name)); |
| 667 | + } |
|
| 606 | 668 | $webserver = posix_getpwuid(posix_getuid ()); |
| 607 | 669 | echo '<p>'.lang("You need to add the webserver user '%1' to the group '%2'.",$webserver['name'],$group['name'])."</p>\n"; } |
| 608 | 670 | } |
@@ -622,10 +684,13 @@ discard block |
||
| 622 | 684 | } |
| 623 | 685 | //echo "<p>$name = '".$this->$name."'</p>\n"; |
| 624 | 686 | } |
| 625 | - if ($this->php5[0] == '/') // we found a php5 binary |
|
| 687 | + if ($this->php5[0] == '/') |
|
| 688 | + { |
|
| 689 | + // we found a php5 binary |
|
| 626 | 690 | { |
| 627 | 691 | $this->php = $this->php5; |
| 628 | 692 | } |
| 693 | + } |
|
| 629 | 694 | } |
| 630 | 695 | } |
| 631 | 696 | |
@@ -637,7 +702,8 @@ discard block |
||
| 637 | 702 | */ |
| 638 | 703 | function installed() |
| 639 | 704 | { |
| 640 | - if ($this->only_fallback) { |
|
| 705 | + if ($this->only_fallback) |
|
| 706 | + { |
|
| 641 | 707 | return 0; |
| 642 | 708 | } |
| 643 | 709 | $this->find_binarys(); |
@@ -654,7 +720,10 @@ discard block |
||
| 654 | 720 | $n = 0; |
| 655 | 721 | while ($line = fgets($crontab,256)) |
| 656 | 722 | { |
| 657 | - if ($this->debug) echo 'line '.++$n.": $line<br>\n"; |
|
| 723 | + if ($this->debug) |
|
| 724 | + { |
|
| 725 | + echo 'line '.++$n.": $line<br>\n"; |
|
| 726 | + } |
|
| 658 | 727 | $parts = explode(' ',$line,6); |
| 659 | 728 | |
| 660 | 729 | if ($line{0} == '#' || count($parts) < 6 || ($parts[5]{0} != '/' && substr($parts[5],0,3) != 'php')) |
@@ -698,7 +767,8 @@ discard block |
||
| 698 | 767 | */ |
| 699 | 768 | function install($times) |
| 700 | 769 | { |
| 701 | - if ($this->only_fallback && $times !== False) { |
|
| 770 | + if ($this->only_fallback && $times !== False) |
|
| 771 | + { |
|
| 702 | 772 | return 0; |
| 703 | 773 | } |
| 704 | 774 | $this->installed(); // find other installed cronlines |
@@ -302,7 +302,10 @@ |
||
| 302 | 302 | } |
| 303 | 303 | if ($owner) |
| 304 | 304 | { |
| 305 | - if ($app) $where = array($where); |
|
| 305 | + if ($app) |
|
| 306 | + { |
|
| 307 | + $where = array($where); |
|
| 308 | + } |
|
| 306 | 309 | $where['link_owner'] = $owner; |
| 307 | 310 | } |
| 308 | 311 | } |