@@ -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; |
@@ -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 | } |
@@ -47,7 +47,10 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | static $func_overload = null; |
| 49 | 49 | |
| 50 | - if (is_null($func_overload)) $func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0; |
|
| 50 | + if (is_null($func_overload)) |
|
| 51 | + { |
|
| 52 | + $func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0; |
|
| 53 | + } |
|
| 51 | 54 | |
| 52 | 55 | return $func_overload & 2 ? mb_strlen($str,'ascii') : strlen($str); |
| 53 | 56 | } |
@@ -64,7 +67,10 @@ discard block |
||
| 64 | 67 | { |
| 65 | 68 | static $func_overload = null; |
| 66 | 69 | |
| 67 | - if (is_null($func_overload)) $func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0; |
|
| 70 | + if (is_null($func_overload)) |
|
| 71 | + { |
|
| 72 | + $func_overload = extension_loaded('mbstring') ? ini_get('mbstring.func_overload') : 0; |
|
| 73 | + } |
|
| 68 | 74 | |
| 69 | 75 | if (is_null($len)) |
| 70 | 76 | { |
@@ -130,7 +136,10 @@ discard block |
||
| 130 | 136 | { |
| 131 | 137 | $personal = str_replace('\\', '', substr($personal, 1, -1)); |
| 132 | 138 | } |
| 133 | - if (empty($host)) $host = $default_host; |
|
| 139 | + if (empty($host)) |
|
| 140 | + { |
|
| 141 | + $host = $default_host; |
|
| 142 | + } |
|
| 134 | 143 | |
| 135 | 144 | $addresses[] = (object)array_diff(array( |
| 136 | 145 | 'mailbox' => $mailbox, |
@@ -153,13 +162,19 @@ discard block |
||
| 153 | 162 | */ |
| 154 | 163 | function imap_rfc822_write_address($mailbox, $host, $personal) |
| 155 | 164 | { |
| 156 | - if (is_array($personal)) $personal = implode(' ', $personal); |
|
| 165 | + if (is_array($personal)) |
|
| 166 | + { |
|
| 167 | + $personal = implode(' ', $personal); |
|
| 168 | + } |
|
| 157 | 169 | |
| 158 | 170 | //if (!preg_match('/^[!#$%&\'*+/0-9=?A-Z^_`a-z{|}~-]+$/u', $personal)) // that's how I read the rfc(2)822 |
| 159 | - if ($personal && !preg_match('/^[0-9A-Z -]*$/iu', $personal)) // but quoting is never wrong, so quote more then necessary |
|
| 171 | + if ($personal && !preg_match('/^[0-9A-Z -]*$/iu', $personal)) |
|
| 172 | + { |
|
| 173 | + // but quoting is never wrong, so quote more then necessary |
|
| 160 | 174 | { |
| 161 | 175 | $personal = '"'.str_replace(array('\\', '"'),array('\\\\', '\\"'), $personal).'"'; |
| 162 | 176 | } |
| 177 | + } |
|
| 163 | 178 | return ($personal ? $personal.' <' : '').$mailbox.($host ? '@'.$host : '').($personal ? '>' : ''); |
| 164 | 179 | } |
| 165 | 180 | } |
@@ -366,7 +381,9 @@ discard block |
||
| 366 | 381 | return $_GET['menuaction'] ? $_GET['menuaction'] : str_replace(EGW_SERVER_ROOT,'',$_SERVER['SCRIPT_FILENAME']); |
| 367 | 382 | } |
| 368 | 383 | |
| 369 | -if (!function_exists('lang') || defined('NO_LANG')) // setup declares an own version |
|
| 384 | +if (!function_exists('lang') || defined('NO_LANG')) |
|
| 385 | +{ |
|
| 386 | + // setup declares an own version |
|
| 370 | 387 | { |
| 371 | 388 | /** |
| 372 | 389 | * function to handle multilanguage support |
@@ -380,6 +397,7 @@ discard block |
||
| 380 | 397 | if(!is_array($vars)) |
| 381 | 398 | { |
| 382 | 399 | $vars = func_get_args(); |
| 400 | +} |
|
| 383 | 401 | array_shift($vars); // remove $key |
| 384 | 402 | } |
| 385 | 403 | return Api\Translation::translate($key,$vars); |
@@ -24,7 +24,9 @@ discard block |
||
| 24 | 24 | { |
| 25 | 25 | static $preg=null; |
| 26 | 26 | //old: '/<\/?[^>]*\b(iframe|script|javascript|on(before)?(abort|blur|change|click|dblclick|error|focus|keydown|keypress|keyup|load|mousedown|mousemove|mouseout|mouseover|mouseup|reset|select|submit|unload))\b[^>]*>/i'; |
| 27 | - if (!isset($preg)) $preg = |
|
| 27 | + if (!isset($preg)) |
|
| 28 | + { |
|
| 29 | + $preg = |
|
| 28 | 30 | // forbidden tags like iframe or script |
| 29 | 31 | '/(<(\s*\/)?\s*(iframe|script|object|embed|math|meta)[^a-z0-9]|'. |
| 30 | 32 | // on* attributes |
@@ -33,6 +35,7 @@ discard block |
||
| 33 | 35 | '<[^>]+(href|src|dynsrc|lowsrc|background|style|poster|action)\s*=\s*("|\')?[^"\']*javascript|'. |
| 34 | 36 | // benavior:url and expression in style attribute |
| 35 | 37 | '<[^>]+style\s*=\s*("|\')[^>]*(behavior\s*:\s*url|expression)\s*\()/i'; |
| 38 | + } |
|
| 36 | 39 | if (is_array($var)) |
| 37 | 40 | { |
| 38 | 41 | foreach($var as $key => $val) |
@@ -41,7 +44,9 @@ discard block |
||
| 41 | 44 | { |
| 42 | 45 | _check_script_tag($var[$key],$name.'['.$key.']'); |
| 43 | 46 | } |
| 44 | - elseif(strpos($val, '<') !== false) // speedup: ignore everything without < |
|
| 47 | + elseif(strpos($val, '<') !== false) |
|
| 48 | + { |
|
| 49 | + // speedup: ignore everything without < |
|
| 45 | 50 | { |
| 46 | 51 | if (preg_match($preg,$val)) |
| 47 | 52 | { |
@@ -49,6 +54,7 @@ discard block |
||
| 49 | 54 | if ($name == '_POST' && $key == 'json_data' && ($json_data = json_decode($val, true))) |
| 50 | 55 | { |
| 51 | 56 | _check_script_tag($json_data, $name.'[json_data]'); |
| 57 | + } |
|
| 52 | 58 | $_REQUEST[$key] = $var[$key] = json_encode($json_data); |
| 53 | 59 | continue; |
| 54 | 60 | } |
@@ -142,7 +142,10 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | function search($filter,$order='history_id',$sort='DESC',$limit=null) |
| 144 | 144 | { |
| 145 | - if (!is_array($filter)) $filter = is_numeric($filter) ? array('history_record_id' => $filter) : array(); |
|
| 145 | + if (!is_array($filter)) |
|
| 146 | + { |
|
| 147 | + $filter = is_numeric($filter) ? array('history_record_id' => $filter) : array(); |
|
| 148 | + } |
|
| 146 | 149 | |
| 147 | 150 | if (!$order || !preg_match('/^[a-z0-9_]+$/i',$order) || !preg_match('/^(asc|desc)?$/i',$sort)) |
| 148 | 151 | { |
@@ -160,10 +163,16 @@ discard block |
||
| 160 | 163 | unset($filter[$col]); |
| 161 | 164 | } |
| 162 | 165 | } |
| 163 | - if (!isset($filter['history_appname'])) $filter['history_appname'] = $this->appname; |
|
| 166 | + if (!isset($filter['history_appname'])) |
|
| 167 | + { |
|
| 168 | + $filter['history_appname'] = $this->appname; |
|
| 169 | + } |
|
| 164 | 170 | |
| 165 | 171 | // do not try to read all history entries of an app |
| 166 | - if (!$filter['history_record_id']) return array(); |
|
| 172 | + if (!$filter['history_record_id']) |
|
| 173 | + { |
|
| 174 | + return array(); |
|
| 175 | + } |
|
| 167 | 176 | |
| 168 | 177 | $rows = array(); |
| 169 | 178 | foreach($this->db->select(self::TABLE, '*', $filter, __LINE__, __FILE__, |
@@ -188,8 +197,10 @@ discard block |
||
| 188 | 197 | $rows = array(); |
| 189 | 198 | $filter['history_appname'] = $query['appname']; |
| 190 | 199 | $filter['history_record_id'] = $query['record_id']; |
| 191 | - if(is_array($query['colfilter'])) { |
|
| 192 | - foreach($query['colfilter'] as $column => $value) { |
|
| 200 | + if(is_array($query['colfilter'])) |
|
| 201 | + { |
|
| 202 | + foreach($query['colfilter'] as $column => $value) |
|
| 203 | + { |
|
| 193 | 204 | $filter[$column] = $value; |
| 194 | 205 | } |
| 195 | 206 | } |
@@ -21,7 +21,10 @@ |
||
| 21 | 21 | { |
| 22 | 22 | function __construct($msg=null,$code=102) |
| 23 | 23 | { |
| 24 | - if (is_null($msg)) $msg = 'admin'; |
|
| 24 | + if (is_null($msg)) |
|
| 25 | + { |
|
| 26 | + $msg = 'admin'; |
|
| 27 | + } |
|
| 25 | 28 | |
| 26 | 29 | parent::__construct($msg,$code); |
| 27 | 30 | } |
@@ -19,4 +19,6 @@ |
||
| 19 | 19 | * User lacks a record level permission, eg. he's not the owner and has no grant from the owner |
| 20 | 20 | * |
| 21 | 21 | */ |
| 22 | -class Record extends Exception\NoPermission { } |
|
| 22 | +class Record extends Exception\NoPermission |
|
| 23 | +{ |
|
| 24 | +} |
|
@@ -28,7 +28,10 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | function __construct($msg=null,$code=2) |
| 30 | 30 | { |
| 31 | - if (is_null($msg)) $msg = lang('Entry not found!'); |
|
| 31 | + if (is_null($msg)) |
|
| 32 | + { |
|
| 33 | + $msg = lang('Entry not found!'); |
|
| 34 | + } |
|
| 32 | 35 | |
| 33 | 36 | parent::__construct($msg,$code); |
| 34 | 37 | } |
@@ -17,4 +17,6 @@ |
||
| 17 | 17 | * Wrong or missing required user input: message should be translated so it can be shown directly to the user |
| 18 | 18 | * |
| 19 | 19 | */ |
| 20 | -class WrongUserinput extends AssertionFailed { } |
|
| 20 | +class WrongUserinput extends AssertionFailed |
|
| 21 | +{ |
|
| 22 | +} |
|