@@ -47,15 +47,15 @@ discard block |
||
| 47 | 47 | /** |
| 48 | 48 | * Constants for acl rights, like old EGW_ACL_* defines |
| 49 | 49 | */ |
| 50 | - const READ = 1; // EGW_ACL_READ |
|
| 51 | - const ADD = 2; // EGW_ACL_ADD |
|
| 52 | - const EDIT = 4; // EGW_ACL_EDIT |
|
| 53 | - const DELETE = 8; // EGW_ACL_DELETE |
|
| 54 | - const PRIVAT = 16; // EGW_ACL_PRIVATE can NOT use PRIVATE as it is a PHP keyword, using German PRIVAT instead! |
|
| 55 | - const GROUPMGRS = 32; // EGW_ACL_GROUP_MANAGERS |
|
| 56 | - const CUSTOM1 = 64; // EGW_ACL_CUSTOM_1 |
|
| 57 | - const CUSTOM2 = 128; // EGW_ACL_CUSTOM_2 |
|
| 58 | - const CUSTOM3 = 256; // EGW_ACL_CUSTOM_3 |
|
| 50 | + const READ = 1; // EGW_ACL_READ |
|
| 51 | + const ADD = 2; // EGW_ACL_ADD |
|
| 52 | + const EDIT = 4; // EGW_ACL_EDIT |
|
| 53 | + const DELETE = 8; // EGW_ACL_DELETE |
|
| 54 | + const PRIVAT = 16; // EGW_ACL_PRIVATE can NOT use PRIVATE as it is a PHP keyword, using German PRIVAT instead! |
|
| 55 | + const GROUPMGRS = 32; // EGW_ACL_GROUP_MANAGERS |
|
| 56 | + const CUSTOM1 = 64; // EGW_ACL_CUSTOM_1 |
|
| 57 | + const CUSTOM2 = 128; // EGW_ACL_CUSTOM_2 |
|
| 58 | + const CUSTOM3 = 256; // EGW_ACL_CUSTOM_3 |
|
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * ACL constructor for setting account id |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | } |
| 79 | 79 | if ((int)$this->account_id != (int)$account_id) |
| 80 | 80 | { |
| 81 | - $this->account_id = get_account_id((int)$account_id,@$GLOBALS['egw_info']['user']['account_id']); |
|
| 81 | + $this->account_id = get_account_id((int)$account_id, @$GLOBALS['egw_info']['user']['account_id']); |
|
| 82 | 82 | } |
| 83 | 83 | $this->data = array(); |
| 84 | 84 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | */ |
| 92 | 92 | function __sleep() |
| 93 | 93 | { |
| 94 | - return array('account_id','db'); |
|
| 94 | + return array('account_id', 'db'); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /**************************************************************************\ |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * @param boolean|array $no_groups = false if true, do not use memberships, if array do not use given groups |
| 105 | 105 | * @return array along with storing it in $acl->data. <br> |
| 106 | 106 | */ |
| 107 | - function read_repository($no_groups=false) |
|
| 107 | + function read_repository($no_groups = false) |
|
| 108 | 108 | { |
| 109 | 109 | // For some reason, calling this via XML-RPC doesn't call the constructor. |
| 110 | 110 | // Here is yet another work around(tm) (jengo) |
@@ -119,14 +119,14 @@ discard block |
||
| 119 | 119 | else |
| 120 | 120 | { |
| 121 | 121 | $acl_acc_list = (array)$GLOBALS['egw']->accounts->memberships($this->account_id, true); |
| 122 | - if (is_array($no_groups)) $acl_acc_list = array_diff($acl_acc_list,$no_groups); |
|
| 123 | - array_unshift($acl_acc_list,$this->account_id); |
|
| 122 | + if (is_array($no_groups)) $acl_acc_list = array_diff($acl_acc_list, $no_groups); |
|
| 123 | + array_unshift($acl_acc_list, $this->account_id); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | $this->data = Array(); |
| 127 | - foreach($this->db->select(self::TABLE,'*',array('acl_account' => $acl_acc_list ),__LINE__,__FILE__) as $row) |
|
| 127 | + foreach ($this->db->select(self::TABLE, '*', array('acl_account' => $acl_acc_list), __LINE__, __FILE__) as $row) |
|
| 128 | 128 | { |
| 129 | - $this->data[$row['acl_appname'].'-'.$row['acl_location'].'-'.$row['acl_account']] = Db::strip_array_keys($row,'acl_'); |
|
| 129 | + $this->data[$row['acl_appname'].'-'.$row['acl_location'].'-'.$row['acl_account']] = Db::strip_array_keys($row, 'acl_'); |
|
| 130 | 130 | } |
| 131 | 131 | return $this->data; |
| 132 | 132 | } |
@@ -155,15 +155,15 @@ discard block |
||
| 155 | 155 | * @param int $rights rights |
| 156 | 156 | * @return array all ACL records from $this->data. |
| 157 | 157 | */ |
| 158 | - function add($appname,$location,$rights) |
|
| 158 | + function add($appname, $location, $rights) |
|
| 159 | 159 | { |
| 160 | 160 | if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
| 161 | 161 | |
| 162 | 162 | $row = array( |
| 163 | 163 | 'appname' => $appname, |
| 164 | 164 | 'location' => $location, |
| 165 | - 'account' => (int) $this->account_id, |
|
| 166 | - 'rights' => (int) $rights |
|
| 165 | + 'account' => (int)$this->account_id, |
|
| 166 | + 'rights' => (int)$rights |
|
| 167 | 167 | ); |
| 168 | 168 | $this->data[$row['appname'].'-'.$row['location'].'-'.$row['account']] = $row; |
| 169 | 169 | |
@@ -177,11 +177,11 @@ discard block |
||
| 177 | 177 | * @param string/boolean $location location or false for all locations |
| 178 | 178 | * @return array all ACL records from $this->data. |
| 179 | 179 | */ |
| 180 | - function delete($appname,$location) |
|
| 180 | + function delete($appname, $location) |
|
| 181 | 181 | { |
| 182 | 182 | if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
| 183 | 183 | |
| 184 | - foreach($this->data as $idx => $value) |
|
| 184 | + foreach ($this->data as $idx => $value) |
|
| 185 | 185 | { |
| 186 | 186 | if ($value['appname'] == $appname && |
| 187 | 187 | ($location === false || $value['location'] == $location) && |
@@ -200,24 +200,24 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | function save_repository() |
| 202 | 202 | { |
| 203 | - $this->db->delete(self::TABLE,array( |
|
| 203 | + $this->db->delete(self::TABLE, array( |
|
| 204 | 204 | 'acl_account' => $this->account_id, |
| 205 | - ),__LINE__,__FILE__); |
|
| 205 | + ), __LINE__, __FILE__); |
|
| 206 | 206 | |
| 207 | - foreach($this->data as $value) |
|
| 207 | + foreach ($this->data as $value) |
|
| 208 | 208 | { |
| 209 | 209 | if ($value['account'] == $this->account_id) |
| 210 | 210 | { |
| 211 | - $this->db->insert(self::TABLE,array( |
|
| 211 | + $this->db->insert(self::TABLE, array( |
|
| 212 | 212 | 'acl_appname' => $value['appname'], |
| 213 | 213 | 'acl_location' => $value['location'], |
| 214 | 214 | 'acl_account' => $this->account_id, |
| 215 | 215 | 'acl_rights' => $value['rights'], |
| 216 | - ),false,__LINE__,__FILE__); |
|
| 216 | + ), false, __LINE__, __FILE__); |
|
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | if ($this->account_id == $GLOBALS['egw_info']['user']['account_id'] && |
| 220 | - method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
| 220 | + method_exists($GLOBALS['egw'], 'invalidate_session_cache')) // egw object in setup is limited |
|
| 221 | 221 | { |
| 222 | 222 | $GLOBALS['egw']->invalidate_session_cache(); |
| 223 | 223 | } |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | * @param string $appname optional defaults to $GLOBALS['egw_info']['flags']['currentapp']; |
| 236 | 236 | * @return int all rights or'ed together |
| 237 | 237 | */ |
| 238 | - function get_rights($location,$appname = '') |
|
| 238 | + function get_rights($location, $appname = '') |
|
| 239 | 239 | { |
| 240 | 240 | // For XML-RPC, change this once its working correctly for passing parameters (jengo) |
| 241 | 241 | if (is_array($location)) |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | return True; |
| 256 | 256 | } |
| 257 | 257 | $rights = 0; |
| 258 | - foreach($this->data as $value) |
|
| 258 | + foreach ($this->data as $value) |
|
| 259 | 259 | { |
| 260 | 260 | if ($value['appname'] == $appname) |
| 261 | 261 | { |
@@ -282,9 +282,9 @@ discard block |
||
| 282 | 282 | */ |
| 283 | 283 | function check($location, $required, $appname = False) |
| 284 | 284 | { |
| 285 | - $rights = $this->get_rights($location,$appname); |
|
| 285 | + $rights = $this->get_rights($location, $appname); |
|
| 286 | 286 | |
| 287 | - return !!($rights & $required); |
|
| 287 | + return !!($rights&$required); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | /** |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | * @param array $memberships = array() additional account_id, eg. memberships to match beside $this->account_id, default none |
| 296 | 296 | * @return int $rights |
| 297 | 297 | */ |
| 298 | - function get_specific_rights($location, $appname = '', $memberships=array()) |
|
| 298 | + function get_specific_rights($location, $appname = '', $memberships = array()) |
|
| 299 | 299 | { |
| 300 | 300 | if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
| 301 | 301 | |
@@ -305,10 +305,10 @@ discard block |
||
| 305 | 305 | } |
| 306 | 306 | $rights = 0; |
| 307 | 307 | |
| 308 | - foreach($this->data as $value) |
|
| 308 | + foreach ($this->data as $value) |
|
| 309 | 309 | { |
| 310 | 310 | if ($value['appname'] == $appname && |
| 311 | - ($value['location'] == $location || $value['location'] == 'everywhere') && |
|
| 311 | + ($value['location'] == $location || $value['location'] == 'everywhere') && |
|
| 312 | 312 | ($value['account'] == $this->account_id || $memberships && in_array($value['account'], $memberships))) |
| 313 | 313 | { |
| 314 | 314 | if ($value['rights'] == 0) |
@@ -331,9 +331,9 @@ discard block |
||
| 331 | 331 | */ |
| 332 | 332 | function check_specific($location, $required, $appname = '') |
| 333 | 333 | { |
| 334 | - $rights = $this->get_specific_rights($location,$appname); |
|
| 334 | + $rights = $this->get_specific_rights($location, $appname); |
|
| 335 | 335 | |
| 336 | - return !!($rights & $required); |
|
| 336 | + return !!($rights&$required); |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | /**************************************************************************\ |
@@ -350,19 +350,19 @@ discard block |
||
| 350 | 350 | * @param boolean $invalidate_session =true false: do NOT invalidate session |
| 351 | 351 | * @return boolean allways true |
| 352 | 352 | */ |
| 353 | - function add_repository($app, $location, $account_id, $rights, $invalidate_session=true) |
|
| 353 | + function add_repository($app, $location, $account_id, $rights, $invalidate_session = true) |
|
| 354 | 354 | { |
| 355 | 355 | //echo "<p>self::add_repository('$app','$location',$account_id,$rights);</p>\n"; |
| 356 | - $this->db->insert(self::TABLE,array( |
|
| 356 | + $this->db->insert(self::TABLE, array( |
|
| 357 | 357 | 'acl_rights' => $rights, |
| 358 | - ),array( |
|
| 358 | + ), array( |
|
| 359 | 359 | 'acl_appname' => $app, |
| 360 | 360 | 'acl_location' => $location, |
| 361 | 361 | 'acl_account' => $account_id, |
| 362 | - ),__LINE__,__FILE__); |
|
| 362 | + ), __LINE__, __FILE__); |
|
| 363 | 363 | |
| 364 | 364 | if ($invalidate_session && $account_id == $GLOBALS['egw_info']['user']['account_id'] && |
| 365 | - method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
| 365 | + method_exists($GLOBALS['egw'], 'invalidate_session_cache')) // egw object in setup is limited |
|
| 366 | 366 | { |
| 367 | 367 | $GLOBALS['egw']->invalidate_session_cache(); |
| 368 | 368 | } |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | * @param boolean $invalidate_session =true false: do NOT invalidate session |
| 379 | 379 | * @return int number of rows deleted |
| 380 | 380 | */ |
| 381 | - function delete_repository($app, $location, $accountid='', $invalidate_session=true) |
|
| 381 | + function delete_repository($app, $location, $accountid = '', $invalidate_session = true) |
|
| 382 | 382 | { |
| 383 | 383 | static $cache_accountid = array(); |
| 384 | 384 | |
@@ -388,22 +388,22 @@ discard block |
||
| 388 | 388 | ); |
| 389 | 389 | if ($accountid !== false) |
| 390 | 390 | { |
| 391 | - if(isset($cache_accountid[$accountid]) && $cache_accountid[$accountid]) |
|
| 391 | + if (isset($cache_accountid[$accountid]) && $cache_accountid[$accountid]) |
|
| 392 | 392 | { |
| 393 | 393 | $where['acl_account'] = $cache_accountid[$accountid]; |
| 394 | 394 | } |
| 395 | 395 | else |
| 396 | 396 | { |
| 397 | - $where['acl_account'] = $cache_accountid[$accountid] = get_account_id($accountid,$this->account_id); |
|
| 397 | + $where['acl_account'] = $cache_accountid[$accountid] = get_account_id($accountid, $this->account_id); |
|
| 398 | 398 | } |
| 399 | 399 | } |
| 400 | 400 | if ($app == '%' || $app == '%%') unset($where['acl_appname']); |
| 401 | 401 | |
| 402 | - $this->db->delete(self::TABLE,$where,__LINE__,__FILE__); |
|
| 402 | + $this->db->delete(self::TABLE, $where, __LINE__, __FILE__); |
|
| 403 | 403 | |
| 404 | 404 | $deleted = $this->db->affected_rows(); |
| 405 | 405 | |
| 406 | - if ($invalidate_session && $deleted && method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
| 406 | + if ($invalidate_session && $deleted && method_exists($GLOBALS['egw'], 'invalidate_session_cache')) // egw object in setup is limited |
|
| 407 | 407 | { |
| 408 | 408 | $GLOBALS['egw']->invalidate_session_cache(); |
| 409 | 409 | } |
@@ -418,15 +418,15 @@ discard block |
||
| 418 | 418 | * @param string $appname = '' defaults to current app |
| 419 | 419 | * @return int/boolean rights or false if none exist |
| 420 | 420 | */ |
| 421 | - function get_specific_rights_for_account($account_id,$location,$appname='') |
|
| 421 | + function get_specific_rights_for_account($account_id, $location, $appname = '') |
|
| 422 | 422 | { |
| 423 | 423 | if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
| 424 | 424 | |
| 425 | - return $this->db->select(self::TABLE,'acl_rights',array( |
|
| 425 | + return $this->db->select(self::TABLE, 'acl_rights', array( |
|
| 426 | 426 | 'acl_location' => $location, |
| 427 | 427 | 'acl_account' => $account_id, |
| 428 | 428 | 'acl_appname' => $appname, |
| 429 | - ),__LINE__,__FILE__)->fetchColumn(); |
|
| 429 | + ), __LINE__, __FILE__)->fetchColumn(); |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | /** |
@@ -436,15 +436,15 @@ discard block |
||
| 436 | 436 | * @param string $appname = '' defaults to current app |
| 437 | 437 | * @return array with account => rights pairs |
| 438 | 438 | */ |
| 439 | - function get_all_rights($location,$appname='') |
|
| 439 | + function get_all_rights($location, $appname = '') |
|
| 440 | 440 | { |
| 441 | 441 | if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
| 442 | 442 | |
| 443 | 443 | $rights = array(); |
| 444 | - foreach($this->db->select(self::TABLE,'acl_account,acl_rights',array( |
|
| 444 | + foreach ($this->db->select(self::TABLE, 'acl_account,acl_rights', array( |
|
| 445 | 445 | 'acl_location' => $location, |
| 446 | 446 | 'acl_appname' => $appname, |
| 447 | - ),__LINE__,__FILE__) as $row) |
|
| 447 | + ), __LINE__, __FILE__) as $row) |
|
| 448 | 448 | { |
| 449 | 449 | $rights[$row['acl_account']] = $row['acl_rights']; |
| 450 | 450 | } |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | * @param boolean $use_memberships = true |
| 460 | 460 | * @return array with location => rights pairs |
| 461 | 461 | */ |
| 462 | - function get_all_location_rights($account_id,$appname='',$use_memberships=true) |
|
| 462 | + function get_all_location_rights($account_id, $appname = '', $use_memberships = true) |
|
| 463 | 463 | { |
| 464 | 464 | if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
| 465 | 465 | |
@@ -470,10 +470,10 @@ discard block |
||
| 470 | 470 | $accounts[] = $account_id; |
| 471 | 471 | } |
| 472 | 472 | $rights = array(); |
| 473 | - foreach($this->db->select(self::TABLE,'acl_location,acl_rights',array( |
|
| 473 | + foreach ($this->db->select(self::TABLE, 'acl_location,acl_rights', array( |
|
| 474 | 474 | 'acl_account' => $accounts, |
| 475 | 475 | 'acl_appname' => $appname, |
| 476 | - ),__LINE__,__FILE__) as $row) |
|
| 476 | + ), __LINE__, __FILE__) as $row) |
|
| 477 | 477 | { |
| 478 | 478 | $rights[$row['acl_location']] |= $row['acl_rights']; |
| 479 | 479 | } |
@@ -492,28 +492,28 @@ discard block |
||
| 492 | 492 | { |
| 493 | 493 | static $cache_accountid = array(); |
| 494 | 494 | |
| 495 | - if(isset($cache_accountid[$accountid])) |
|
| 495 | + if (isset($cache_accountid[$accountid])) |
|
| 496 | 496 | { |
| 497 | 497 | $account_id = $cache_accountid[$accountid]; |
| 498 | 498 | } |
| 499 | 499 | else |
| 500 | 500 | { |
| 501 | - $account_id = get_account_id($accountid,$this->account_id); |
|
| 501 | + $account_id = get_account_id($accountid, $this->account_id); |
|
| 502 | 502 | $cache_accountid[$accountid] = $account_id; |
| 503 | 503 | } |
| 504 | 504 | $rights = 0; |
| 505 | 505 | $apps = false; |
| 506 | - foreach($this->db->select(self::TABLE,array('acl_appname','acl_rights'),array( |
|
| 506 | + foreach ($this->db->select(self::TABLE, array('acl_appname', 'acl_rights'), array( |
|
| 507 | 507 | 'acl_location' => $location, |
| 508 | 508 | 'acl_account' => $account_id, |
| 509 | - ),__LINE__,__FILE__) as $row) |
|
| 509 | + ), __LINE__, __FILE__) as $row) |
|
| 510 | 510 | { |
| 511 | 511 | if ($row['acl_rights'] == 0) |
| 512 | 512 | { |
| 513 | 513 | return False; |
| 514 | 514 | } |
| 515 | 515 | $rights |= $row['acl_rights']; |
| 516 | - if (!!($rights & $required)) |
|
| 516 | + if (!!($rights&$required)) |
|
| 517 | 517 | { |
| 518 | 518 | $apps[] = $row['acl_appname']; |
| 519 | 519 | } |
@@ -533,21 +533,21 @@ discard block |
||
| 533 | 533 | { |
| 534 | 534 | static $cache_accountid = array(); |
| 535 | 535 | |
| 536 | - if(isset($cache_accountid[$accountid])) |
|
| 536 | + if (isset($cache_accountid[$accountid])) |
|
| 537 | 537 | { |
| 538 | 538 | $accountid = $cache_accountid[$accountid]; |
| 539 | 539 | } |
| 540 | 540 | else |
| 541 | 541 | { |
| 542 | - $accountid = $cache_accountid[$accountid] = get_account_id($accountid,$this->account_id); |
|
| 542 | + $accountid = $cache_accountid[$accountid] = get_account_id($accountid, $this->account_id); |
|
| 543 | 543 | } |
| 544 | 544 | $locations = false; |
| 545 | - foreach($this->db->select(self::TABLE,'acl_location,acl_rights',array( |
|
| 545 | + foreach ($this->db->select(self::TABLE, 'acl_location,acl_rights', array( |
|
| 546 | 546 | 'acl_appname' => $app, |
| 547 | 547 | 'acl_account' => $accountid, |
| 548 | - ),__LINE__,__FILE__) as $row) |
|
| 548 | + ), __LINE__, __FILE__) as $row) |
|
| 549 | 549 | { |
| 550 | - if ($row['acl_rights'] & $required) |
|
| 550 | + if ($row['acl_rights']&$required) |
|
| 551 | 551 | { |
| 552 | 552 | $locations[] = $row['acl_location']; |
| 553 | 553 | } |
@@ -568,14 +568,14 @@ discard block |
||
| 568 | 568 | if (!$app) $app = $GLOBALS['egw_info']['flags']['currentapp']; |
| 569 | 569 | |
| 570 | 570 | $accounts = false; |
| 571 | - foreach($this->db->select(self::TABLE,array('acl_account','acl_rights'),array( |
|
| 571 | + foreach ($this->db->select(self::TABLE, array('acl_account', 'acl_rights'), array( |
|
| 572 | 572 | 'acl_appname' => $app, |
| 573 | 573 | 'acl_location' => $location, |
| 574 | - ),__LINE__,__FILE__) as $row) |
|
| 574 | + ), __LINE__, __FILE__) as $row) |
|
| 575 | 575 | { |
| 576 | - if (!!($row['acl_rights'] & $required)) |
|
| 576 | + if (!!($row['acl_rights']&$required)) |
|
| 577 | 577 | { |
| 578 | - $accounts[] = (int) $row['acl_account']; |
|
| 578 | + $accounts[] = (int)$row['acl_account']; |
|
| 579 | 579 | } |
| 580 | 580 | } |
| 581 | 581 | return $accounts; |
@@ -587,14 +587,14 @@ discard block |
||
| 587 | 587 | * @param string $app app optional defaults to $GLOBALS['egw_info']['flags']['currentapp']; |
| 588 | 588 | * @return boolean/array false if there are no matching location in the db or array of locations |
| 589 | 589 | */ |
| 590 | - function get_locations_for_app($app='') |
|
| 590 | + function get_locations_for_app($app = '') |
|
| 591 | 591 | { |
| 592 | 592 | if (!$app) $app = $GLOBALS['egw_info']['flags']['currentapp']; |
| 593 | 593 | |
| 594 | 594 | $locations = false; |
| 595 | - foreach($this->db->select(self::TABLE,'DISTINCT '.'acl_location',array( |
|
| 595 | + foreach ($this->db->select(self::TABLE, 'DISTINCT '.'acl_location', array( |
|
| 596 | 596 | 'acl_appname' => $app, |
| 597 | - ),__LINE__,__FILE__) as $row) |
|
| 597 | + ), __LINE__, __FILE__) as $row) |
|
| 598 | 598 | { |
| 599 | 599 | if (($location = $row['acl_location']) != 'run') |
| 600 | 600 | { |
@@ -612,38 +612,38 @@ discard block |
||
| 612 | 612 | * @param boolean $add_implicit_apps = true true: add apps every user has implicit rights |
| 613 | 613 | * @return array containing list of apps |
| 614 | 614 | */ |
| 615 | - function get_user_applications($accountid = '', $use_memberships=true, $add_implicit_apps=true) |
|
| 615 | + function get_user_applications($accountid = '', $use_memberships = true, $add_implicit_apps = true) |
|
| 616 | 616 | { |
| 617 | 617 | static $cache_accountid = array(); |
| 618 | 618 | |
| 619 | - if(isset($cache_accountid[$accountid])) |
|
| 619 | + if (isset($cache_accountid[$accountid])) |
|
| 620 | 620 | { |
| 621 | 621 | $account_id = $cache_accountid[$accountid]; |
| 622 | 622 | } |
| 623 | 623 | else |
| 624 | 624 | { |
| 625 | - $account_id = get_account_id($accountid,$this->account_id); |
|
| 625 | + $account_id = get_account_id($accountid, $this->account_id); |
|
| 626 | 626 | $cache_accountid[$accountid] = $account_id; |
| 627 | 627 | } |
| 628 | 628 | if ($use_memberships && (int)$account_id > 0) $memberships = $GLOBALS['egw']->accounts->memberships($account_id, true); |
| 629 | 629 | $memberships[] = (int)$account_id; |
| 630 | 630 | |
| 631 | 631 | $apps = array(); |
| 632 | - foreach($this->db->select(self::TABLE,array('acl_appname','acl_rights'),array( |
|
| 632 | + foreach ($this->db->select(self::TABLE, array('acl_appname', 'acl_rights'), array( |
|
| 633 | 633 | 'acl_location' => 'run', |
| 634 | 634 | 'acl_account' => $memberships, |
| 635 | - ),__LINE__,__FILE__) as $row) |
|
| 635 | + ), __LINE__, __FILE__) as $row) |
|
| 636 | 636 | { |
| 637 | 637 | $app = $row['acl_appname']; |
| 638 | - if(!isset($apps[$app])) |
|
| 638 | + if (!isset($apps[$app])) |
|
| 639 | 639 | { |
| 640 | 640 | $apps[$app] = 0; |
| 641 | 641 | } |
| 642 | - $apps[$app] |= (int) $row['acl_rights']; |
|
| 642 | + $apps[$app] |= (int)$row['acl_rights']; |
|
| 643 | 643 | } |
| 644 | 644 | if ($add_implicit_apps) |
| 645 | 645 | { |
| 646 | - $apps['api'] = 1; // give everyone implicit rights for the home app |
|
| 646 | + $apps['api'] = 1; // give everyone implicit rights for the home app |
|
| 647 | 647 | } |
| 648 | 648 | return $apps; |
| 649 | 649 | } |
@@ -657,29 +657,29 @@ discard block |
||
| 657 | 657 | * @param int $user = null user whos grants to return, default current user |
| 658 | 658 | * @return array with account-ids (of owners) and granted rights as values |
| 659 | 659 | */ |
| 660 | - function get_grants($app='',$enum_group_acls=true,$user=null) |
|
| 660 | + function get_grants($app = '', $enum_group_acls = true, $user = null) |
|
| 661 | 661 | { |
| 662 | 662 | if (!$app) $app = $GLOBALS['egw_info']['flags']['currentapp']; |
| 663 | 663 | if (!$user) $user = $this->account_id; |
| 664 | 664 | |
| 665 | - static $cache = array(); // some caching withing the request |
|
| 665 | + static $cache = array(); // some caching withing the request |
|
| 666 | 666 | |
| 667 | - $grants =& $cache[$app][$user]; |
|
| 667 | + $grants = & $cache[$app][$user]; |
|
| 668 | 668 | if (!isset($grants)) |
| 669 | 669 | { |
| 670 | 670 | if ((int)$user > 0) $memberships = $GLOBALS['egw']->accounts->memberships($user, true); |
| 671 | 671 | $memberships[] = $user; |
| 672 | 672 | |
| 673 | 673 | $grants = $accounts = Array(); |
| 674 | - foreach($this->db->select(self::TABLE,array('acl_account','acl_rights','acl_location'),array( |
|
| 674 | + foreach ($this->db->select(self::TABLE, array('acl_account', 'acl_rights', 'acl_location'), array( |
|
| 675 | 675 | 'acl_appname' => $app, |
| 676 | 676 | 'acl_location' => $memberships, |
| 677 | - ),__LINE__,__FILE__) as $row) |
|
| 677 | + ), __LINE__, __FILE__) as $row) |
|
| 678 | 678 | { |
| 679 | 679 | $grantor = $row['acl_account']; |
| 680 | 680 | $rights = $row['acl_rights']; |
| 681 | 681 | |
| 682 | - if(!isset($grants[$grantor])) |
|
| 682 | + if (!isset($grants[$grantor])) |
|
| 683 | 683 | { |
| 684 | 684 | $grants[$grantor] = 0; |
| 685 | 685 | } |
@@ -687,17 +687,17 @@ discard block |
||
| 687 | 687 | |
| 688 | 688 | // if the right is granted from a group and we enummerated group ACL's |
| 689 | 689 | if ($GLOBALS['egw']->accounts->get_type($grantor) == 'g' && $enum_group_acls && |
| 690 | - (!is_array($enum_group_acls) || !in_array($grantor,$enum_group_acls))) |
|
| 690 | + (!is_array($enum_group_acls) || !in_array($grantor, $enum_group_acls))) |
|
| 691 | 691 | { |
| 692 | 692 | // return the grant for each member of the group (false = also for no longer active users) |
| 693 | - foreach((array)$GLOBALS['egw']->accounts->members($grantor, true, false) as $grantor) |
|
| 693 | + foreach ((array)$GLOBALS['egw']->accounts->members($grantor, true, false) as $grantor) |
|
| 694 | 694 | { |
| 695 | - if (!$grantor) continue; // can happen if group has no members |
|
| 695 | + if (!$grantor) continue; // can happen if group has no members |
|
| 696 | 696 | |
| 697 | 697 | // Don't allow to override private with group ACL's! |
| 698 | 698 | $rights &= ~self::PRIVAT; |
| 699 | 699 | |
| 700 | - if(!isset($grants[$grantor])) |
|
| 700 | + if (!isset($grants[$grantor])) |
|
| 701 | 701 | { |
| 702 | 702 | $grants[$grantor] = 0; |
| 703 | 703 | } |
@@ -719,21 +719,21 @@ discard block |
||
| 719 | 719 | */ |
| 720 | 720 | function delete_account($account_id) |
| 721 | 721 | { |
| 722 | - if ((int) $account_id) |
|
| 722 | + if ((int)$account_id) |
|
| 723 | 723 | { |
| 724 | 724 | // Delete all grants from this account |
| 725 | - $this->db->delete(self::TABLE,array( |
|
| 725 | + $this->db->delete(self::TABLE, array( |
|
| 726 | 726 | 'acl_account' => $account_id |
| 727 | - ),__LINE__,__FILE__); |
|
| 727 | + ), __LINE__, __FILE__); |
|
| 728 | 728 | // Delete all grants to this account |
| 729 | - $this->db->delete(self::TABLE,array( |
|
| 729 | + $this->db->delete(self::TABLE, array( |
|
| 730 | 730 | 'acl_location' => $account_id |
| 731 | - ),__LINE__, __FILE__); |
|
| 731 | + ), __LINE__, __FILE__); |
|
| 732 | 732 | // delete all memberships in account_id (if it is a group) |
| 733 | - $this->db->delete(self::TABLE,array( |
|
| 733 | + $this->db->delete(self::TABLE, array( |
|
| 734 | 734 | 'acl_appname' => 'phpgw_group', |
| 735 | 735 | 'acl_location' => $account_id, |
| 736 | - ),__LINE__,__FILE__); |
|
| 736 | + ), __LINE__, __FILE__); |
|
| 737 | 737 | } |
| 738 | 738 | } |
| 739 | 739 | |
@@ -744,15 +744,15 @@ discard block |
||
| 744 | 744 | * @param string $app app optional defaults to $GLOBALS['egw_info']['flags']['currentapp']; |
| 745 | 745 | * @return array with location => array(account => rights) pairs |
| 746 | 746 | */ |
| 747 | - function get_location_grants($location,$app='') |
|
| 747 | + function get_location_grants($location, $app = '') |
|
| 748 | 748 | { |
| 749 | 749 | if (!$app) $app = $GLOBALS['egw_info']['flags']['currentapp']; |
| 750 | 750 | |
| 751 | 751 | $locations = array(); |
| 752 | - foreach($this->db->select(self::TABLE,'acl_location,acl_account,acl_rights',array( |
|
| 752 | + foreach ($this->db->select(self::TABLE, 'acl_location,acl_account,acl_rights', array( |
|
| 753 | 753 | 'acl_appname' => $app, |
| 754 | 754 | 'acl_location LIKE '.$this->db->quote($location), |
| 755 | - ),__LINE__,__FILE__) as $row) |
|
| 755 | + ), __LINE__, __FILE__) as $row) |
|
| 756 | 756 | { |
| 757 | 757 | if (($location = $row['acl_location']) != 'run') |
| 758 | 758 | { |
@@ -119,7 +119,10 @@ discard block |
||
| 119 | 119 | else |
| 120 | 120 | { |
| 121 | 121 | $acl_acc_list = (array)$GLOBALS['egw']->accounts->memberships($this->account_id, true); |
| 122 | - if (is_array($no_groups)) $acl_acc_list = array_diff($acl_acc_list,$no_groups); |
|
| 122 | + if (is_array($no_groups)) |
|
| 123 | + { |
|
| 124 | + $acl_acc_list = array_diff($acl_acc_list,$no_groups); |
|
| 125 | + } |
|
| 123 | 126 | array_unshift($acl_acc_list,$this->account_id); |
| 124 | 127 | } |
| 125 | 128 | |
@@ -157,7 +160,10 @@ discard block |
||
| 157 | 160 | */ |
| 158 | 161 | function add($appname,$location,$rights) |
| 159 | 162 | { |
| 160 | - if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 163 | + if (!$appname) |
|
| 164 | + { |
|
| 165 | + $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 166 | + } |
|
| 161 | 167 | |
| 162 | 168 | $row = array( |
| 163 | 169 | 'appname' => $appname, |
@@ -179,7 +185,10 @@ discard block |
||
| 179 | 185 | */ |
| 180 | 186 | function delete($appname,$location) |
| 181 | 187 | { |
| 182 | - if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 188 | + if (!$appname) |
|
| 189 | + { |
|
| 190 | + $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 191 | + } |
|
| 183 | 192 | |
| 184 | 193 | foreach($this->data as $idx => $value) |
| 185 | 194 | { |
@@ -217,10 +226,13 @@ discard block |
||
| 217 | 226 | } |
| 218 | 227 | } |
| 219 | 228 | if ($this->account_id == $GLOBALS['egw_info']['user']['account_id'] && |
| 220 | - method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
| 229 | + method_exists($GLOBALS['egw'],'invalidate_session_cache')) |
|
| 230 | + { |
|
| 231 | + // egw object in setup is limited |
|
| 221 | 232 | { |
| 222 | 233 | $GLOBALS['egw']->invalidate_session_cache(); |
| 223 | 234 | } |
| 235 | + } |
|
| 224 | 236 | return $this->data; |
| 225 | 237 | } |
| 226 | 238 | |
@@ -248,7 +260,10 @@ discard block |
||
| 248 | 260 | { |
| 249 | 261 | $this->read_repository(); |
| 250 | 262 | } |
| 251 | - if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 263 | + if (!$appname) |
|
| 264 | + { |
|
| 265 | + $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 266 | + } |
|
| 252 | 267 | |
| 253 | 268 | if (!count($this->data) && $GLOBALS['egw_info']['server']['acl_default'] != 'deny') |
| 254 | 269 | { |
@@ -297,7 +312,10 @@ discard block |
||
| 297 | 312 | */ |
| 298 | 313 | function get_specific_rights($location, $appname = '', $memberships=array()) |
| 299 | 314 | { |
| 300 | - if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 315 | + if (!$appname) |
|
| 316 | + { |
|
| 317 | + $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 318 | + } |
|
| 301 | 319 | |
| 302 | 320 | if (!count($this->data) && $GLOBALS['egw_info']['server']['acl_default'] != 'deny') |
| 303 | 321 | { |
@@ -362,10 +380,13 @@ discard block |
||
| 362 | 380 | ),__LINE__,__FILE__); |
| 363 | 381 | |
| 364 | 382 | if ($invalidate_session && $account_id == $GLOBALS['egw_info']['user']['account_id'] && |
| 365 | - method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
| 383 | + method_exists($GLOBALS['egw'],'invalidate_session_cache')) |
|
| 384 | + { |
|
| 385 | + // egw object in setup is limited |
|
| 366 | 386 | { |
| 367 | 387 | $GLOBALS['egw']->invalidate_session_cache(); |
| 368 | 388 | } |
| 389 | + } |
|
| 369 | 390 | return True; |
| 370 | 391 | } |
| 371 | 392 | |
@@ -397,16 +418,22 @@ discard block |
||
| 397 | 418 | $where['acl_account'] = $cache_accountid[$accountid] = get_account_id($accountid,$this->account_id); |
| 398 | 419 | } |
| 399 | 420 | } |
| 400 | - if ($app == '%' || $app == '%%') unset($where['acl_appname']); |
|
| 421 | + if ($app == '%' || $app == '%%') |
|
| 422 | + { |
|
| 423 | + unset($where['acl_appname']); |
|
| 424 | + } |
|
| 401 | 425 | |
| 402 | 426 | $this->db->delete(self::TABLE,$where,__LINE__,__FILE__); |
| 403 | 427 | |
| 404 | 428 | $deleted = $this->db->affected_rows(); |
| 405 | 429 | |
| 406 | - if ($invalidate_session && $deleted && method_exists($GLOBALS['egw'],'invalidate_session_cache')) // egw object in setup is limited |
|
| 430 | + if ($invalidate_session && $deleted && method_exists($GLOBALS['egw'],'invalidate_session_cache')) |
|
| 431 | + { |
|
| 432 | + // egw object in setup is limited |
|
| 407 | 433 | { |
| 408 | 434 | $GLOBALS['egw']->invalidate_session_cache(); |
| 409 | 435 | } |
| 436 | + } |
|
| 410 | 437 | return $deleted; |
| 411 | 438 | } |
| 412 | 439 | |
@@ -420,7 +447,10 @@ discard block |
||
| 420 | 447 | */ |
| 421 | 448 | function get_specific_rights_for_account($account_id,$location,$appname='') |
| 422 | 449 | { |
| 423 | - if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 450 | + if (!$appname) |
|
| 451 | + { |
|
| 452 | + $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 453 | + } |
|
| 424 | 454 | |
| 425 | 455 | return $this->db->select(self::TABLE,'acl_rights',array( |
| 426 | 456 | 'acl_location' => $location, |
@@ -438,7 +468,10 @@ discard block |
||
| 438 | 468 | */ |
| 439 | 469 | function get_all_rights($location,$appname='') |
| 440 | 470 | { |
| 441 | - if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 471 | + if (!$appname) |
|
| 472 | + { |
|
| 473 | + $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 474 | + } |
|
| 442 | 475 | |
| 443 | 476 | $rights = array(); |
| 444 | 477 | foreach($this->db->select(self::TABLE,'acl_account,acl_rights',array( |
@@ -461,7 +494,10 @@ discard block |
||
| 461 | 494 | */ |
| 462 | 495 | function get_all_location_rights($account_id,$appname='',$use_memberships=true) |
| 463 | 496 | { |
| 464 | - if (!$appname) $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 497 | + if (!$appname) |
|
| 498 | + { |
|
| 499 | + $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 500 | + } |
|
| 465 | 501 | |
| 466 | 502 | $accounts = array($account_id); |
| 467 | 503 | if ($use_memberships && (int)$account_id > 0) |
@@ -565,7 +601,10 @@ discard block |
||
| 565 | 601 | */ |
| 566 | 602 | function get_ids_for_location($location, $required, $app = '') |
| 567 | 603 | { |
| 568 | - if (!$app) $app = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 604 | + if (!$app) |
|
| 605 | + { |
|
| 606 | + $app = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 607 | + } |
|
| 569 | 608 | |
| 570 | 609 | $accounts = false; |
| 571 | 610 | foreach($this->db->select(self::TABLE,array('acl_account','acl_rights'),array( |
@@ -589,7 +628,10 @@ discard block |
||
| 589 | 628 | */ |
| 590 | 629 | function get_locations_for_app($app='') |
| 591 | 630 | { |
| 592 | - if (!$app) $app = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 631 | + if (!$app) |
|
| 632 | + { |
|
| 633 | + $app = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 634 | + } |
|
| 593 | 635 | |
| 594 | 636 | $locations = false; |
| 595 | 637 | foreach($this->db->select(self::TABLE,'DISTINCT '.'acl_location',array( |
@@ -625,7 +667,10 @@ discard block |
||
| 625 | 667 | $account_id = get_account_id($accountid,$this->account_id); |
| 626 | 668 | $cache_accountid[$accountid] = $account_id; |
| 627 | 669 | } |
| 628 | - if ($use_memberships && (int)$account_id > 0) $memberships = $GLOBALS['egw']->accounts->memberships($account_id, true); |
|
| 670 | + if ($use_memberships && (int)$account_id > 0) |
|
| 671 | + { |
|
| 672 | + $memberships = $GLOBALS['egw']->accounts->memberships($account_id, true); |
|
| 673 | + } |
|
| 629 | 674 | $memberships[] = (int)$account_id; |
| 630 | 675 | |
| 631 | 676 | $apps = array(); |
@@ -659,15 +704,24 @@ discard block |
||
| 659 | 704 | */ |
| 660 | 705 | function get_grants($app='',$enum_group_acls=true,$user=null) |
| 661 | 706 | { |
| 662 | - if (!$app) $app = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 663 | - if (!$user) $user = $this->account_id; |
|
| 707 | + if (!$app) |
|
| 708 | + { |
|
| 709 | + $app = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 710 | + } |
|
| 711 | + if (!$user) |
|
| 712 | + { |
|
| 713 | + $user = $this->account_id; |
|
| 714 | + } |
|
| 664 | 715 | |
| 665 | 716 | static $cache = array(); // some caching withing the request |
| 666 | 717 | |
| 667 | 718 | $grants =& $cache[$app][$user]; |
| 668 | 719 | if (!isset($grants)) |
| 669 | 720 | { |
| 670 | - if ((int)$user > 0) $memberships = $GLOBALS['egw']->accounts->memberships($user, true); |
|
| 721 | + if ((int)$user > 0) |
|
| 722 | + { |
|
| 723 | + $memberships = $GLOBALS['egw']->accounts->memberships($user, true); |
|
| 724 | + } |
|
| 671 | 725 | $memberships[] = $user; |
| 672 | 726 | |
| 673 | 727 | $grants = $accounts = Array(); |
@@ -692,7 +746,11 @@ discard block |
||
| 692 | 746 | // return the grant for each member of the group (false = also for no longer active users) |
| 693 | 747 | foreach((array)$GLOBALS['egw']->accounts->members($grantor, true, false) as $grantor) |
| 694 | 748 | { |
| 695 | - if (!$grantor) continue; // can happen if group has no members |
|
| 749 | + if (!$grantor) |
|
| 750 | + { |
|
| 751 | + continue; |
|
| 752 | + } |
|
| 753 | + // can happen if group has no members |
|
| 696 | 754 | |
| 697 | 755 | // Don't allow to override private with group ACL's! |
| 698 | 756 | $rights &= ~self::PRIVAT; |
@@ -746,7 +804,10 @@ discard block |
||
| 746 | 804 | */ |
| 747 | 805 | function get_location_grants($location,$app='') |
| 748 | 806 | { |
| 749 | - if (!$app) $app = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 807 | + if (!$app) |
|
| 808 | + { |
|
| 809 | + $app = $GLOBALS['egw_info']['flags']['currentapp']; |
|
| 810 | + } |
|
| 750 | 811 | |
| 751 | 812 | $locations = array(); |
| 752 | 813 | foreach($this->db->select(self::TABLE,'acl_location,acl_account,acl_rights',array( |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | /** |
| 68 | 68 | * mode-bits, which have to be set for directories |
| 69 | 69 | */ |
| 70 | - const MODE_DIR = 040000; |
|
| 70 | + const MODE_DIR = 040000; |
|
| 71 | 71 | /** |
| 72 | 72 | * mode-bits, which have to be set for links |
| 73 | 73 | */ |
@@ -164,10 +164,10 @@ discard block |
||
| 164 | 164 | * |
| 165 | 165 | * @param string $path ='/' |
| 166 | 166 | */ |
| 167 | - public static function clearstatcache($path='/') |
|
| 167 | + public static function clearstatcache($path = '/') |
|
| 168 | 168 | { |
| 169 | 169 | //error_log(__METHOD__."('$path')"); |
| 170 | - unset($path); // not used |
|
| 170 | + unset($path); // not used |
|
| 171 | 171 | |
| 172 | 172 | self::$stat_cache = array(); |
| 173 | 173 | |
@@ -187,32 +187,32 @@ discard block |
||
| 187 | 187 | * @param array $overwrite_new =null if set create new file with values overwriten by the given ones |
| 188 | 188 | * @return boolean true if the ressource was opened successful, otherwise false |
| 189 | 189 | */ |
| 190 | - function stream_open ( $url, $mode, $options, &$opened_path, array $overwrite_new=null ) |
|
| 190 | + function stream_open($url, $mode, $options, &$opened_path, array $overwrite_new = null) |
|
| 191 | 191 | { |
| 192 | 192 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$mode,$options)"); |
| 193 | 193 | |
| 194 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
| 194 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
| 195 | 195 | $this->operation = self::url2operation($url); |
| 196 | 196 | $dir = Vfs::dirname($url); |
| 197 | 197 | |
| 198 | 198 | $this->opened_path = $opened_path = $path; |
| 199 | - $this->opened_mode = $mode = str_replace('b','',$mode); // we are always binary, like every Linux system |
|
| 199 | + $this->opened_mode = $mode = str_replace('b', '', $mode); // we are always binary, like every Linux system |
|
| 200 | 200 | $this->opened_stream = null; |
| 201 | 201 | |
| 202 | 202 | parse_str(parse_url($url, PHP_URL_QUERY), $this->dir_url_params); |
| 203 | 203 | |
| 204 | - if (!is_null($overwrite_new) || !($stat = $this->url_stat($path,STREAM_URL_STAT_QUIET)) || $mode[0] == 'x') // file not found or file should NOT exist |
|
| 204 | + if (!is_null($overwrite_new) || !($stat = $this->url_stat($path, STREAM_URL_STAT_QUIET)) || $mode[0] == 'x') // file not found or file should NOT exist |
|
| 205 | 205 | { |
| 206 | - if (!$dir || $mode[0] == 'r' || // does $mode require the file to exist (r,r+) |
|
| 207 | - $mode[0] == 'x' && $stat || // or file should not exist, but does |
|
| 208 | - !($dir_stat=$this->url_stat($dir,STREAM_URL_STAT_QUIET)) || // or parent dir does not exist create it |
|
| 209 | - !Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat)) // or we are not allowed to create it |
|
| 206 | + if (!$dir || $mode[0] == 'r' || // does $mode require the file to exist (r,r+) |
|
| 207 | + $mode[0] == 'x' && $stat || // or file should not exist, but does |
|
| 208 | + !($dir_stat = $this->url_stat($dir, STREAM_URL_STAT_QUIET)) || // or parent dir does not exist create it |
|
| 209 | + !Vfs::check_access($dir, Vfs::WRITABLE, $dir_stat)) // or we are not allowed to create it |
|
| 210 | 210 | { |
| 211 | 211 | self::_remove_password($url); |
| 212 | 212 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) file does not exist or can not be created!"); |
| 213 | - if (($options & STREAM_REPORT_ERRORS)) |
|
| 213 | + if (($options&STREAM_REPORT_ERRORS)) |
|
| 214 | 214 | { |
| 215 | - trigger_error(__METHOD__."($url,$mode,$options) file does not exist or can not be created!",E_USER_WARNING); |
|
| 215 | + trigger_error(__METHOD__."($url,$mode,$options) file does not exist or can not be created!", E_USER_WARNING); |
|
| 216 | 216 | } |
| 217 | 217 | $this->opened_stream = $this->opened_path = $this->opened_mode = null; |
| 218 | 218 | return false; |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | 'fs_name' => self::limit_filename(Vfs::basename($path)), |
| 228 | 228 | 'fs_dir' => $dir_stat['ino'], |
| 229 | 229 | // we use the mode of the dir, so files in group dirs stay accessible by all members |
| 230 | - 'fs_mode' => $dir_stat['mode'] & 0666, |
|
| 230 | + 'fs_mode' => $dir_stat['mode']&0666, |
|
| 231 | 231 | // for the uid we use the uid of the dir if not 0=root or the current user otherwise |
| 232 | 232 | 'fs_uid' => $dir_stat['uid'] ? $dir_stat['uid'] : Vfs::$user, |
| 233 | 233 | // we allways use the group of the dir |
@@ -235,11 +235,11 @@ discard block |
||
| 235 | 235 | 'fs_created' => self::_pdo_timestamp(time()), |
| 236 | 236 | 'fs_modified' => self::_pdo_timestamp(time()), |
| 237 | 237 | 'fs_creator' => Vfs::$user, |
| 238 | - 'fs_mime' => 'application/octet-stream', // required NOT NULL! |
|
| 238 | + 'fs_mime' => 'application/octet-stream', // required NOT NULL! |
|
| 239 | 239 | 'fs_size' => 0, |
| 240 | 240 | 'fs_active' => self::_pdo_boolean(true), |
| 241 | 241 | ); |
| 242 | - if ($overwrite_new) $values = array_merge($values,$overwrite_new); |
|
| 242 | + if ($overwrite_new) $values = array_merge($values, $overwrite_new); |
|
| 243 | 243 | if (!$stmt->execute($values) || !($this->opened_fs_id = self::$pdo->lastInsertId('egw_sqlfs_fs_id_seq'))) |
| 244 | 244 | { |
| 245 | 245 | $this->opened_stream = $this->opened_path = $this->opened_mode = null; |
@@ -252,35 +252,35 @@ discard block |
||
| 252 | 252 | $this->opened_stream = tmpfile(); |
| 253 | 253 | } |
| 254 | 254 | // create the hash-dirs, if they not yet exist |
| 255 | - elseif(!file_exists($fs_dir=Vfs::dirname(self::_fs_path($this->opened_fs_id)))) |
|
| 255 | + elseif (!file_exists($fs_dir = Vfs::dirname(self::_fs_path($this->opened_fs_id)))) |
|
| 256 | 256 | { |
| 257 | 257 | $umaskbefore = umask(); |
| 258 | 258 | if (self::LOG_LEVEL > 1) error_log(__METHOD__." about to call mkdir for $fs_dir # Present UMASK:".decoct($umaskbefore)." called from:".function_backtrace()); |
| 259 | - self::mkdir_recursive($fs_dir,0700,true); |
|
| 259 | + self::mkdir_recursive($fs_dir, 0700, true); |
|
| 260 | 260 | } |
| 261 | 261 | } |
| 262 | 262 | // check if opend file is a directory |
| 263 | - elseif($stat && ($stat['mode'] & self::MODE_DIR) == self::MODE_DIR) |
|
| 263 | + elseif ($stat && ($stat['mode']&self::MODE_DIR) == self::MODE_DIR) |
|
| 264 | 264 | { |
| 265 | 265 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) Is a directory!"); |
| 266 | - if (($options & STREAM_REPORT_ERRORS)) |
|
| 266 | + if (($options&STREAM_REPORT_ERRORS)) |
|
| 267 | 267 | { |
| 268 | - trigger_error(__METHOD__."($url,$mode,$options) Is a directory!",E_USER_WARNING); |
|
| 268 | + trigger_error(__METHOD__."($url,$mode,$options) Is a directory!", E_USER_WARNING); |
|
| 269 | 269 | } |
| 270 | 270 | $this->opened_stream = $this->opened_path = $this->opened_mode = null; |
| 271 | 271 | return false; |
| 272 | 272 | } |
| 273 | 273 | else |
| 274 | 274 | { |
| 275 | - if ($mode == 'r' && !Vfs::check_access($url,Vfs::READABLE ,$stat) ||// we are not allowed to read |
|
| 276 | - $mode != 'r' && !Vfs::check_access($url,Vfs::WRITABLE,$stat)) // or edit it |
|
| 275 | + if ($mode == 'r' && !Vfs::check_access($url, Vfs::READABLE, $stat) || // we are not allowed to read |
|
| 276 | + $mode != 'r' && !Vfs::check_access($url, Vfs::WRITABLE, $stat)) // or edit it |
|
| 277 | 277 | { |
| 278 | 278 | self::_remove_password($url); |
| 279 | 279 | $op = $mode == 'r' ? 'read' : 'edited'; |
| 280 | 280 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) file can not be $op!"); |
| 281 | - if (($options & STREAM_REPORT_ERRORS)) |
|
| 281 | + if (($options&STREAM_REPORT_ERRORS)) |
|
| 282 | 282 | { |
| 283 | - trigger_error(__METHOD__."($url,$mode,$options) file can not be $op!",E_USER_WARNING); |
|
| 283 | + trigger_error(__METHOD__."($url,$mode,$options) file can not be $op!", E_USER_WARNING); |
|
| 284 | 284 | } |
| 285 | 285 | $this->opened_stream = $this->opened_path = $this->opened_mode = null; |
| 286 | 286 | return false; |
@@ -289,9 +289,9 @@ discard block |
||
| 289 | 289 | |
| 290 | 290 | if ($this->operation == self::STORE2DB) |
| 291 | 291 | { |
| 292 | - $stmt = self::$pdo->prepare($sql='SELECT fs_content FROM '.self::TABLE.' WHERE fs_id=?'); |
|
| 292 | + $stmt = self::$pdo->prepare($sql = 'SELECT fs_content FROM '.self::TABLE.' WHERE fs_id=?'); |
|
| 293 | 293 | $stmt->execute(array($stat['ino'])); |
| 294 | - $stmt->bindColumn(1,$this->opened_stream,\PDO::PARAM_LOB); |
|
| 294 | + $stmt->bindColumn(1, $this->opened_stream, \PDO::PARAM_LOB); |
|
| 295 | 295 | $stmt->fetch(\PDO::FETCH_BOUND); |
| 296 | 296 | // hack to work around a current php bug (http://bugs.php.net/bug.php?id=40913) |
| 297 | 297 | // PDOStatement::bindColumn(,,\PDO::PARAM_LOB) is not working for MySQL, content is returned as string :-( |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | if ($this->operation == self::STORE2FS) |
| 311 | 311 | { |
| 312 | 312 | if (self::LOG_LEVEL > 1) error_log(__METHOD__." fopen (may create a directory? mkdir) ($this->opened_fs_id,$mode,$options)"); |
| 313 | - if (!($this->opened_stream = fopen(self::_fs_path($this->opened_fs_id),$mode)) && $new_file) |
|
| 313 | + if (!($this->opened_stream = fopen(self::_fs_path($this->opened_fs_id), $mode)) && $new_file) |
|
| 314 | 314 | { |
| 315 | 315 | // delete db entry again, if we are not able to open a new(!) file |
| 316 | 316 | unset($stmt); |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | } |
| 321 | 321 | if ($mode[0] == 'a') // append modes: a, a+ |
| 322 | 322 | { |
| 323 | - $this->stream_seek(0,SEEK_END); |
|
| 323 | + $this->stream_seek(0, SEEK_END); |
|
| 324 | 324 | } |
| 325 | 325 | if (!is_resource($this->opened_stream)) error_log(__METHOD__."($url,$mode,$options) NO stream, returning false!"); |
| 326 | 326 | |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | * |
| 333 | 333 | * You must release any resources that were locked or allocated by the stream. |
| 334 | 334 | */ |
| 335 | - function stream_close ( ) |
|
| 335 | + function stream_close( ) |
|
| 336 | 336 | { |
| 337 | 337 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."()"); |
| 338 | 338 | |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | |
| 344 | 344 | if ($this->opened_mode != 'r') |
| 345 | 345 | { |
| 346 | - $this->stream_seek(0,SEEK_END); |
|
| 346 | + $this->stream_seek(0, SEEK_END); |
|
| 347 | 347 | |
| 348 | 348 | // we need to update the mime-type, size and content (if STORE2DB) |
| 349 | 349 | $values = array( |
@@ -366,10 +366,10 @@ discard block |
||
| 366 | 366 | else |
| 367 | 367 | { |
| 368 | 368 | $stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_size=:fs_size,fs_mime=:fs_mime,fs_modifier=:fs_modifier,fs_modified=:fs_modified,fs_content=:fs_content WHERE fs_id=:fs_id'); |
| 369 | - $this->stream_seek(0,SEEK_SET); // rewind to the start |
|
| 370 | - foreach($values as $name => &$value) |
|
| 369 | + $this->stream_seek(0, SEEK_SET); // rewind to the start |
|
| 370 | + foreach ($values as $name => &$value) |
|
| 371 | 371 | { |
| 372 | - $stmt->bindParam($name,$value); |
|
| 372 | + $stmt->bindParam($name, $value); |
|
| 373 | 373 | } |
| 374 | 374 | $stmt->bindParam('fs_content', $this->opened_stream, \PDO::PARAM_LOB); |
| 375 | 375 | if (!($ret = $stmt->execute())) |
@@ -402,13 +402,13 @@ discard block |
||
| 402 | 402 | * @param int $count |
| 403 | 403 | * @return string/false up to count bytes read or false on EOF |
| 404 | 404 | */ |
| 405 | - function stream_read ( $count ) |
|
| 405 | + function stream_read($count) |
|
| 406 | 406 | { |
| 407 | 407 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($count) pos=$this->opened_pos"); |
| 408 | 408 | |
| 409 | 409 | if (is_resource($this->opened_stream)) |
| 410 | 410 | { |
| 411 | - return fread($this->opened_stream,$count); |
|
| 411 | + return fread($this->opened_stream, $count); |
|
| 412 | 412 | } |
| 413 | 413 | return false; |
| 414 | 414 | } |
@@ -424,13 +424,13 @@ discard block |
||
| 424 | 424 | * @param string $data |
| 425 | 425 | * @return integer |
| 426 | 426 | */ |
| 427 | - function stream_write ( $data ) |
|
| 427 | + function stream_write($data) |
|
| 428 | 428 | { |
| 429 | 429 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($data)"); |
| 430 | 430 | |
| 431 | 431 | if (is_resource($this->opened_stream)) |
| 432 | 432 | { |
| 433 | - return fwrite($this->opened_stream,$data); |
|
| 433 | + return fwrite($this->opened_stream, $data); |
|
| 434 | 434 | } |
| 435 | 435 | return false; |
| 436 | 436 | } |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | * |
| 448 | 448 | * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise |
| 449 | 449 | */ |
| 450 | - function stream_eof ( ) |
|
| 450 | + function stream_eof( ) |
|
| 451 | 451 | { |
| 452 | 452 | if (is_resource($this->opened_stream)) |
| 453 | 453 | { |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | * |
| 462 | 462 | * @return integer current read/write position of the stream |
| 463 | 463 | */ |
| 464 | - function stream_tell ( ) |
|
| 464 | + function stream_tell( ) |
|
| 465 | 465 | { |
| 466 | 466 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."()"); |
| 467 | 467 | |
@@ -484,13 +484,13 @@ discard block |
||
| 484 | 484 | * SEEK_END - 2 - Set position to end-of-file plus offset. (To move to a position before the end-of-file, you need to pass a negative value in offset.) |
| 485 | 485 | * @return boolean TRUE if the position was updated, FALSE otherwise. |
| 486 | 486 | */ |
| 487 | - function stream_seek ( $offset, $whence ) |
|
| 487 | + function stream_seek($offset, $whence) |
|
| 488 | 488 | { |
| 489 | 489 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($offset,$whence)"); |
| 490 | 490 | |
| 491 | 491 | if (is_resource($this->opened_stream)) |
| 492 | 492 | { |
| 493 | - return !fseek($this->opened_stream,$offset,$whence); // fseek returns 0 on success and -1 on failure |
|
| 493 | + return !fseek($this->opened_stream, $offset, $whence); // fseek returns 0 on success and -1 on failure |
|
| 494 | 494 | } |
| 495 | 495 | return false; |
| 496 | 496 | } |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | * |
| 503 | 503 | * @return booelan TRUE if the cached data was successfully stored (or if there was no data to store), or FALSE if the data could not be stored. |
| 504 | 504 | */ |
| 505 | - function stream_flush ( ) |
|
| 505 | + function stream_flush( ) |
|
| 506 | 506 | { |
| 507 | 507 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."()"); |
| 508 | 508 | |
@@ -527,11 +527,11 @@ discard block |
||
| 527 | 527 | * |
| 528 | 528 | * @return array containing the same values as appropriate for the stream. |
| 529 | 529 | */ |
| 530 | - function stream_stat ( ) |
|
| 530 | + function stream_stat( ) |
|
| 531 | 531 | { |
| 532 | 532 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($this->opened_path)"); |
| 533 | 533 | |
| 534 | - return $this->url_stat($this->opened_path,0); |
|
| 534 | + return $this->url_stat($this->opened_path, 0); |
|
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | /** |
@@ -543,11 +543,11 @@ discard block |
||
| 543 | 543 | * @param string $url |
| 544 | 544 | * @return boolean TRUE on success or FALSE on failure |
| 545 | 545 | */ |
| 546 | - function unlink ( $url, $parent_stat=null ) |
|
| 546 | + function unlink($url, $parent_stat = null) |
|
| 547 | 547 | { |
| 548 | 548 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url)"); |
| 549 | 549 | |
| 550 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
| 550 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
| 551 | 551 | |
| 552 | 552 | // need to get parent stat from Sqlfs, not Vfs |
| 553 | 553 | if (!isset($parent_stat)) |
@@ -556,18 +556,18 @@ discard block |
||
| 556 | 556 | $this->url_stat($dir, STREAM_URL_STAT_LINK); |
| 557 | 557 | } |
| 558 | 558 | |
| 559 | - if (!$parent_stat || !($stat = $this->url_stat($path,STREAM_URL_STAT_LINK)) || |
|
| 559 | + if (!$parent_stat || !($stat = $this->url_stat($path, STREAM_URL_STAT_LINK)) || |
|
| 560 | 560 | !$dir || !Vfs::check_access($dir, Vfs::WRITABLE, $parent_stat)) |
| 561 | 561 | { |
| 562 | 562 | self::_remove_password($url); |
| 563 | 563 | if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!"); |
| 564 | - return false; // no permission or file does not exist |
|
| 564 | + return false; // no permission or file does not exist |
|
| 565 | 565 | } |
| 566 | 566 | if ($stat['mime'] == self::DIR_MIME_TYPE) |
| 567 | 567 | { |
| 568 | 568 | self::_remove_password($url); |
| 569 | 569 | if (self::LOG_LEVEL) error_log(__METHOD__."($url) is NO file!"); |
| 570 | - return false; // no permission or file does not exist |
|
| 570 | + return false; // no permission or file does not exist |
|
| 571 | 571 | } |
| 572 | 572 | $stmt = self::$pdo->prepare('DELETE FROM '.self::TABLE.' WHERE fs_id=:fs_id'); |
| 573 | 573 | unset(self::$stat_cache[$path]); |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | if (($ret = $stmt->execute(array('fs_id' => $stat['ino'])))) |
| 576 | 576 | { |
| 577 | 577 | if (self::url2operation($url) == self::STORE2FS && |
| 578 | - ($stat['mode'] & self::MODE_LINK) != self::MODE_LINK) |
|
| 578 | + ($stat['mode']&self::MODE_LINK) != self::MODE_LINK) |
|
| 579 | 579 | { |
| 580 | 580 | unlink(self::_fs_path($stat['ino'])); |
| 581 | 581 | } |
@@ -599,13 +599,13 @@ discard block |
||
| 599 | 599 | * @param string $url_to |
| 600 | 600 | * @return boolean TRUE on success or FALSE on failure |
| 601 | 601 | */ |
| 602 | - function rename ( $url_from, $url_to) |
|
| 602 | + function rename($url_from, $url_to) |
|
| 603 | 603 | { |
| 604 | 604 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url_from,$url_to)"); |
| 605 | 605 | |
| 606 | - $path_from = Vfs::parse_url($url_from,PHP_URL_PATH); |
|
| 606 | + $path_from = Vfs::parse_url($url_from, PHP_URL_PATH); |
|
| 607 | 607 | $from_dir = Vfs::dirname($path_from); |
| 608 | - $path_to = Vfs::parse_url($url_to,PHP_URL_PATH); |
|
| 608 | + $path_to = Vfs::parse_url($url_to, PHP_URL_PATH); |
|
| 609 | 609 | $to_dir = Vfs::dirname($path_to); |
| 610 | 610 | $operation = self::url2operation($url_from); |
| 611 | 611 | |
@@ -615,14 +615,14 @@ discard block |
||
| 615 | 615 | self::_remove_password($url_from); |
| 616 | 616 | self::_remove_password($url_to); |
| 617 | 617 | if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $path_from permission denied!"); |
| 618 | - return false; // no permission or file does not exist |
|
| 618 | + return false; // no permission or file does not exist |
|
| 619 | 619 | } |
| 620 | 620 | if (!$to_dir || !Vfs::check_access($to_dir, Vfs::WRITABLE, $to_dir_stat = $this->url_stat($to_dir, 0))) |
| 621 | 621 | { |
| 622 | 622 | self::_remove_password($url_from); |
| 623 | 623 | self::_remove_password($url_to); |
| 624 | 624 | if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $path_to permission denied!"); |
| 625 | - return false; // no permission or parent-dir does not exist |
|
| 625 | + return false; // no permission or parent-dir does not exist |
|
| 626 | 626 | } |
| 627 | 627 | // the filesystem stream-wrapper does NOT allow to rename files to directories, as this makes problems |
| 628 | 628 | // for our vfs too, we abort here with an error, like the filesystem one does |
@@ -633,10 +633,10 @@ discard block |
||
| 633 | 633 | self::_remove_password($url_to); |
| 634 | 634 | $is_dir = $to_stat['mime'] === self::DIR_MIME_TYPE ? 'a' : 'no'; |
| 635 | 635 | if (self::LOG_LEVEL) error_log(__METHOD__."($url_to,$url_from) $path_to is $is_dir directory!"); |
| 636 | - return false; // no permission or file does not exist |
|
| 636 | + return false; // no permission or file does not exist |
|
| 637 | 637 | } |
| 638 | 638 | // if destination file already exists, delete it |
| 639 | - if ($to_stat && !static::unlink($url_to,$operation)) |
|
| 639 | + if ($to_stat && !static::unlink($url_to, $operation)) |
|
| 640 | 640 | { |
| 641 | 641 | self::_remove_password($url_to); |
| 642 | 642 | if (self::LOG_LEVEL) error_log(__METHOD__."($url_to,$url_from) can't unlink existing $url_to!"); |
@@ -657,7 +657,7 @@ discard block |
||
| 657 | 657 | |
| 658 | 658 | // check if extension changed and update mime-type in that case (as we currently determine mime-type by it's extension!) |
| 659 | 659 | // fixes eg. problems with MsWord storing file with .tmp extension and then renaming to .doc |
| 660 | - if ($ok && ($new_mime = Vfs::mime_content_type($url_to,true)) != Vfs::mime_content_type($url_to)) |
|
| 660 | + if ($ok && ($new_mime = Vfs::mime_content_type($url_to, true)) != Vfs::mime_content_type($url_to)) |
|
| 661 | 661 | { |
| 662 | 662 | //echo "<p>Vfs::nime_content_type($url_to,true) = $new_mime</p>\n"; |
| 663 | 663 | $stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_mime=:fs_mime WHERE fs_id=:fs_id'); |
@@ -673,9 +673,9 @@ discard block |
||
| 673 | 673 | /** |
| 674 | 674 | * due to problems with recursive directory creation, we have our own here |
| 675 | 675 | */ |
| 676 | - protected static function mkdir_recursive($pathname, $mode, $depth=0) |
|
| 676 | + protected static function mkdir_recursive($pathname, $mode, $depth = 0) |
|
| 677 | 677 | { |
| 678 | - $maxdepth=10; |
|
| 678 | + $maxdepth = 10; |
|
| 679 | 679 | $depth2propagate = (int)$depth + 1; |
| 680 | 680 | if ($depth2propagate > $maxdepth) return is_dir($pathname); |
| 681 | 681 | is_dir(Vfs::dirname($pathname)) || self::mkdir_recursive(Vfs::dirname($pathname), $mode, $depth2propagate); |
@@ -693,19 +693,19 @@ discard block |
||
| 693 | 693 | * @param int $options Posible values include STREAM_REPORT_ERRORS and STREAM_MKDIR_RECURSIVE |
| 694 | 694 | * @return boolean TRUE on success or FALSE on failure |
| 695 | 695 | */ |
| 696 | - function mkdir ( $url, $mode, $options ) |
|
| 696 | + function mkdir($url, $mode, $options) |
|
| 697 | 697 | { |
| 698 | 698 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$mode,$options)"); |
| 699 | 699 | if (self::LOG_LEVEL > 1) error_log(__METHOD__." called from:".function_backtrace()); |
| 700 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
| 700 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
| 701 | 701 | |
| 702 | - if ($this->url_stat($path,STREAM_URL_STAT_QUIET)) |
|
| 702 | + if ($this->url_stat($path, STREAM_URL_STAT_QUIET)) |
|
| 703 | 703 | { |
| 704 | 704 | self::_remove_password($url); |
| 705 | 705 | if (self::LOG_LEVEL) error_log(__METHOD__."('$url',$mode,$options) already exist!"); |
| 706 | - if (!($options & STREAM_REPORT_ERRORS)) |
|
| 706 | + if (!($options&STREAM_REPORT_ERRORS)) |
|
| 707 | 707 | { |
| 708 | - trigger_error(__METHOD__."('$url',$mode,$options) already exist!",E_USER_WARNING); |
|
| 708 | + trigger_error(__METHOD__."('$url',$mode,$options) already exist!", E_USER_WARNING); |
|
| 709 | 709 | } |
| 710 | 710 | return false; |
| 711 | 711 | } |
@@ -713,35 +713,35 @@ discard block |
||
| 713 | 713 | { |
| 714 | 714 | self::_remove_password($url); |
| 715 | 715 | if (self::LOG_LEVEL) error_log(__METHOD__."('$url',$mode,$options) dirname('$path')===false!"); |
| 716 | - if (!($options & STREAM_REPORT_ERRORS)) |
|
| 716 | + if (!($options&STREAM_REPORT_ERRORS)) |
|
| 717 | 717 | { |
| 718 | 718 | trigger_error(__METHOD__."('$url',$mode,$options) dirname('$path')===false!", E_USER_WARNING); |
| 719 | 719 | } |
| 720 | 720 | return false; |
| 721 | 721 | } |
| 722 | - if (($query = Vfs::parse_url($url,PHP_URL_QUERY))) $parent_path .= '?'.$query; |
|
| 723 | - $parent = $this->url_stat($parent_path,STREAM_URL_STAT_QUIET); |
|
| 722 | + if (($query = Vfs::parse_url($url, PHP_URL_QUERY))) $parent_path .= '?'.$query; |
|
| 723 | + $parent = $this->url_stat($parent_path, STREAM_URL_STAT_QUIET); |
|
| 724 | 724 | |
| 725 | 725 | // check if we should also create all non-existing path components and our parent does not exist, |
| 726 | 726 | // if yes call ourself recursive with the parent directory |
| 727 | - if (($options & STREAM_MKDIR_RECURSIVE) && $parent_path != '/' && !$parent) |
|
| 727 | + if (($options&STREAM_MKDIR_RECURSIVE) && $parent_path != '/' && !$parent) |
|
| 728 | 728 | { |
| 729 | 729 | if (self::LOG_LEVEL > 1) error_log(__METHOD__." creating parents: $parent_path, $mode"); |
| 730 | - if (!$this->mkdir($parent_path,$mode,$options)) |
|
| 730 | + if (!$this->mkdir($parent_path, $mode, $options)) |
|
| 731 | 731 | { |
| 732 | 732 | return false; |
| 733 | 733 | } |
| 734 | - $parent = $this->url_stat($parent_path,0); |
|
| 734 | + $parent = $this->url_stat($parent_path, 0); |
|
| 735 | 735 | } |
| 736 | - if (!$parent || !Vfs::check_access($parent_path,Vfs::WRITABLE,$parent)) |
|
| 736 | + if (!$parent || !Vfs::check_access($parent_path, Vfs::WRITABLE, $parent)) |
|
| 737 | 737 | { |
| 738 | 738 | self::_remove_password($url); |
| 739 | 739 | if (self::LOG_LEVEL) error_log(__METHOD__."('$url',$mode,$options) permission denied!"); |
| 740 | - if (!($options & STREAM_REPORT_ERRORS)) |
|
| 740 | + if (!($options&STREAM_REPORT_ERRORS)) |
|
| 741 | 741 | { |
| 742 | - trigger_error(__METHOD__."('$url',$mode,$options) permission denied!",E_USER_WARNING); |
|
| 742 | + trigger_error(__METHOD__."('$url',$mode,$options) permission denied!", E_USER_WARNING); |
|
| 743 | 743 | } |
| 744 | - return false; // no permission or file does not exist |
|
| 744 | + return false; // no permission or file does not exist |
|
| 745 | 745 | } |
| 746 | 746 | unset(self::$stat_cache[$path]); |
| 747 | 747 | $stmt = self::$pdo->prepare('INSERT INTO '.self::TABLE.' (fs_name,fs_dir,fs_mode,fs_uid,fs_gid,fs_size,fs_mime,fs_created,fs_modified,fs_creator'. |
@@ -762,9 +762,9 @@ discard block |
||
| 762 | 762 | // check if some other process created the directory parallel to us (sqlfs would gives SQL errors later!) |
| 763 | 763 | $new_fs_id = self::$pdo->lastInsertId('egw_sqlfs_fs_id_seq'); |
| 764 | 764 | |
| 765 | - unset($stmt); // free statement object, on some installs a new prepare fails otherwise! |
|
| 765 | + unset($stmt); // free statement object, on some installs a new prepare fails otherwise! |
|
| 766 | 766 | |
| 767 | - $stmt = self::$pdo->prepare($q='SELECT COUNT(*) FROM '.self::TABLE. |
|
| 767 | + $stmt = self::$pdo->prepare($q = 'SELECT COUNT(*) FROM '.self::TABLE. |
|
| 768 | 768 | ' WHERE fs_dir=:fs_dir AND fs_active=:fs_active AND fs_name'.self::$case_sensitive_equal.':fs_name'); |
| 769 | 769 | if ($stmt->execute(array( |
| 770 | 770 | 'fs_dir' => $parent['ino'], |
@@ -788,25 +788,24 @@ discard block |
||
| 788 | 788 | * @param int $options Possible values include STREAM_REPORT_ERRORS. |
| 789 | 789 | * @return boolean TRUE on success or FALSE on failure. |
| 790 | 790 | */ |
| 791 | - function rmdir ( $url, $options ) |
|
| 791 | + function rmdir($url, $options) |
|
| 792 | 792 | { |
| 793 | 793 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url)"); |
| 794 | 794 | |
| 795 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
| 795 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
| 796 | 796 | |
| 797 | 797 | if (!($parent = Vfs::dirname($path)) || |
| 798 | 798 | !($stat = $this->url_stat($path, 0)) || $stat['mime'] != self::DIR_MIME_TYPE || |
| 799 | - !Vfs::check_access($parent, Vfs::WRITABLE, $this->url_stat($parent,0))) |
|
| 799 | + !Vfs::check_access($parent, Vfs::WRITABLE, $this->url_stat($parent, 0))) |
|
| 800 | 800 | { |
| 801 | 801 | self::_remove_password($url); |
| 802 | - $err_msg = __METHOD__."($url,$options) ".(!$stat ? 'not found!' : |
|
| 803 | - ($stat['mime'] != self::DIR_MIME_TYPE ? 'not a directory!' : 'permission denied!')); |
|
| 802 | + $err_msg = __METHOD__."($url,$options) ".(!$stat ? 'not found!' : ($stat['mime'] != self::DIR_MIME_TYPE ? 'not a directory!' : 'permission denied!')); |
|
| 804 | 803 | if (self::LOG_LEVEL) error_log($err_msg); |
| 805 | - if (!($options & STREAM_REPORT_ERRORS)) |
|
| 804 | + if (!($options&STREAM_REPORT_ERRORS)) |
|
| 806 | 805 | { |
| 807 | - trigger_error($err_msg,E_USER_WARNING); |
|
| 806 | + trigger_error($err_msg, E_USER_WARNING); |
|
| 808 | 807 | } |
| 809 | - return false; // no permission or file does not exist |
|
| 808 | + return false; // no permission or file does not exist |
|
| 810 | 809 | } |
| 811 | 810 | $stmt = self::$pdo->prepare('SELECT COUNT(*) FROM '.self::TABLE.' WHERE fs_dir=?'); |
| 812 | 811 | $stmt->execute(array($stat['ino'])); |
@@ -814,19 +813,19 @@ discard block |
||
| 814 | 813 | { |
| 815 | 814 | self::_remove_password($url); |
| 816 | 815 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$options) dir is not empty!"); |
| 817 | - if (!($options & STREAM_REPORT_ERRORS)) |
|
| 816 | + if (!($options&STREAM_REPORT_ERRORS)) |
|
| 818 | 817 | { |
| 819 | - trigger_error(__METHOD__."('$url',$options) dir is not empty!",E_USER_WARNING); |
|
| 818 | + trigger_error(__METHOD__."('$url',$options) dir is not empty!", E_USER_WARNING); |
|
| 820 | 819 | } |
| 821 | 820 | return false; |
| 822 | 821 | } |
| 823 | 822 | unset(self::$stat_cache[$path]); |
| 824 | - unset($stmt); // free statement object, on some installs a new prepare fails otherwise! |
|
| 823 | + unset($stmt); // free statement object, on some installs a new prepare fails otherwise! |
|
| 825 | 824 | |
| 826 | 825 | $del_stmt = self::$pdo->prepare('DELETE FROM '.self::TABLE.' WHERE fs_id=?'); |
| 827 | 826 | if (($ret = $del_stmt->execute(array($stat['ino'])))) |
| 828 | 827 | { |
| 829 | - self::eacl($path,null,false,$stat['ino']); // remove all (=false) evtl. existing extended acl for that dir |
|
| 828 | + self::eacl($path, null, false, $stat['ino']); // remove all (=false) evtl. existing extended acl for that dir |
|
| 830 | 829 | // delete props |
| 831 | 830 | unset($del_stmt); |
| 832 | 831 | $del_stmt = self::$pdo->prepare('DELETE FROM '.self::PROPS_TABLE.' WHERE fs_id=?'); |
@@ -853,10 +852,10 @@ discard block |
||
| 853 | 852 | { |
| 854 | 853 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path, $option, ".array2string($value).")"); |
| 855 | 854 | |
| 856 | - switch($option) |
|
| 855 | + switch ($option) |
|
| 857 | 856 | { |
| 858 | 857 | case STREAM_META_TOUCH: |
| 859 | - return $this->touch($path, $value[0]); // atime is not supported |
|
| 858 | + return $this->touch($path, $value[0]); // atime is not supported |
|
| 860 | 859 | |
| 861 | 860 | case STREAM_META_ACCESS: |
| 862 | 861 | return $this->chmod($path, $value); |
@@ -885,26 +884,26 @@ discard block |
||
| 885 | 884 | * @param int $time =null modification time (unix timestamp), default null = current time |
| 886 | 885 | * @param int $atime =null access time (unix timestamp), default null = current time, not implemented in the vfs! |
| 887 | 886 | */ |
| 888 | - protected function touch($url,$time=null,$atime=null) |
|
| 887 | + protected function touch($url, $time = null, $atime = null) |
|
| 889 | 888 | { |
| 890 | - unset($atime); // not used |
|
| 889 | + unset($atime); // not used |
|
| 891 | 890 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url, $time)"); |
| 892 | 891 | |
| 893 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
| 892 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
| 894 | 893 | |
| 895 | 894 | $vfs = new self(); |
| 896 | - if (!($stat = $vfs->url_stat($path,STREAM_URL_STAT_QUIET))) |
|
| 895 | + if (!($stat = $vfs->url_stat($path, STREAM_URL_STAT_QUIET))) |
|
| 897 | 896 | { |
| 898 | 897 | // file does not exist --> create an empty one |
| 899 | - if (!($f = fopen(self::SCHEME.'://default'.$path,'w')) || !fclose($f)) |
|
| 898 | + if (!($f = fopen(self::SCHEME.'://default'.$path, 'w')) || !fclose($f)) |
|
| 900 | 899 | { |
| 901 | 900 | return false; |
| 902 | 901 | } |
| 903 | 902 | if (!$time) |
| 904 | 903 | { |
| 905 | - return true; // new (empty) file created with current mod time |
|
| 904 | + return true; // new (empty) file created with current mod time |
|
| 906 | 905 | } |
| 907 | - $stat = $vfs->url_stat($path,0); |
|
| 906 | + $stat = $vfs->url_stat($path, 0); |
|
| 908 | 907 | } |
| 909 | 908 | unset(self::$stat_cache[$path]); |
| 910 | 909 | $stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_modified=:fs_modified,fs_modifier=:fs_modifier WHERE fs_id=:fs_id'); |
@@ -923,40 +922,40 @@ discard block |
||
| 923 | 922 | * @param int $owner |
| 924 | 923 | * @return boolean |
| 925 | 924 | */ |
| 926 | - protected function chown($url,$owner) |
|
| 925 | + protected function chown($url, $owner) |
|
| 927 | 926 | { |
| 928 | 927 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$owner)"); |
| 929 | 928 | |
| 930 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
| 929 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
| 931 | 930 | |
| 932 | 931 | $vfs = new self(); |
| 933 | - if (!($stat = $vfs->url_stat($path,0))) |
|
| 932 | + if (!($stat = $vfs->url_stat($path, 0))) |
|
| 934 | 933 | { |
| 935 | 934 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) no such file or directory!"); |
| 936 | - trigger_error("No such file or directory $url !",E_USER_WARNING); |
|
| 935 | + trigger_error("No such file or directory $url !", E_USER_WARNING); |
|
| 937 | 936 | return false; |
| 938 | 937 | } |
| 939 | 938 | if (!Vfs::$is_root) |
| 940 | 939 | { |
| 941 | 940 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) only root can do that!"); |
| 942 | - trigger_error("Only root can do that!",E_USER_WARNING); |
|
| 941 | + trigger_error("Only root can do that!", E_USER_WARNING); |
|
| 943 | 942 | return false; |
| 944 | 943 | } |
| 945 | 944 | if ($owner < 0 || $owner && !$GLOBALS['egw']->accounts->id2name($owner)) // not a user (0 == root) |
| 946 | 945 | { |
| 947 | 946 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) unknown (numeric) user id!"); |
| 948 | - trigger_error(__METHOD__."($url,$owner) Unknown (numeric) user id!",E_USER_WARNING); |
|
| 947 | + trigger_error(__METHOD__."($url,$owner) Unknown (numeric) user id!", E_USER_WARNING); |
|
| 949 | 948 | //throw new Exception(__METHOD__."($url,$owner) Unknown (numeric) user id!"); |
| 950 | 949 | return false; |
| 951 | 950 | } |
| 952 | 951 | $stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_uid=:fs_uid WHERE fs_id=:fs_id'); |
| 953 | 952 | |
| 954 | 953 | // update stat-cache |
| 955 | - if ($path != '/' && substr($path,-1) == '/') $path = substr($path, 0, -1); |
|
| 954 | + if ($path != '/' && substr($path, -1) == '/') $path = substr($path, 0, -1); |
|
| 956 | 955 | self::$stat_cache[$path]['fs_uid'] = $owner; |
| 957 | 956 | |
| 958 | 957 | return $stmt->execute(array( |
| 959 | - 'fs_uid' => (int) $owner, |
|
| 958 | + 'fs_uid' => (int)$owner, |
|
| 960 | 959 | 'fs_id' => $stat['ino'], |
| 961 | 960 | )); |
| 962 | 961 | } |
@@ -968,37 +967,37 @@ discard block |
||
| 968 | 967 | * @param int $owner |
| 969 | 968 | * @return boolean |
| 970 | 969 | */ |
| 971 | - protected function chgrp($url,$owner) |
|
| 970 | + protected function chgrp($url, $owner) |
|
| 972 | 971 | { |
| 973 | 972 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$owner)"); |
| 974 | 973 | |
| 975 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
| 974 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
| 976 | 975 | |
| 977 | 976 | $vfs = new self(); |
| 978 | - if (!($stat = $vfs->url_stat($path,0))) |
|
| 977 | + if (!($stat = $vfs->url_stat($path, 0))) |
|
| 979 | 978 | { |
| 980 | 979 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) no such file or directory!"); |
| 981 | - trigger_error("No such file or directory $url !",E_USER_WARNING); |
|
| 980 | + trigger_error("No such file or directory $url !", E_USER_WARNING); |
|
| 982 | 981 | return false; |
| 983 | 982 | } |
| 984 | - if (!Vfs::has_owner_rights($path,$stat)) |
|
| 983 | + if (!Vfs::has_owner_rights($path, $stat)) |
|
| 985 | 984 | { |
| 986 | 985 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) only owner or root can do that!"); |
| 987 | - trigger_error("Only owner or root can do that!",E_USER_WARNING); |
|
| 986 | + trigger_error("Only owner or root can do that!", E_USER_WARNING); |
|
| 988 | 987 | return false; |
| 989 | 988 | } |
| 990 | - if ($owner < 0) $owner = -$owner; // sqlfs uses a positiv group id's! |
|
| 989 | + if ($owner < 0) $owner = -$owner; // sqlfs uses a positiv group id's! |
|
| 991 | 990 | |
| 992 | 991 | if ($owner && !$GLOBALS['egw']->accounts->id2name(-$owner)) // not a group |
| 993 | 992 | { |
| 994 | 993 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) unknown (numeric) group id!"); |
| 995 | - trigger_error("Unknown (numeric) group id!",E_USER_WARNING); |
|
| 994 | + trigger_error("Unknown (numeric) group id!", E_USER_WARNING); |
|
| 996 | 995 | return false; |
| 997 | 996 | } |
| 998 | 997 | $stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_gid=:fs_gid WHERE fs_id=:fs_id'); |
| 999 | 998 | |
| 1000 | 999 | // update stat-cache |
| 1001 | - if ($path != '/' && substr($path,-1) == '/') $path = substr($path, 0, -1); |
|
| 1000 | + if ($path != '/' && substr($path, -1) == '/') $path = substr($path, 0, -1); |
|
| 1002 | 1001 | self::$stat_cache[$path]['fs_gid'] = $owner; |
| 1003 | 1002 | |
| 1004 | 1003 | return $stmt->execute(array( |
@@ -1014,39 +1013,39 @@ discard block |
||
| 1014 | 1013 | * @param int $mode |
| 1015 | 1014 | * @return boolean |
| 1016 | 1015 | */ |
| 1017 | - protected function chmod($url,$mode) |
|
| 1016 | + protected function chmod($url, $mode) |
|
| 1018 | 1017 | { |
| 1019 | 1018 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url, $mode)"); |
| 1020 | 1019 | |
| 1021 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
| 1020 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
| 1022 | 1021 | |
| 1023 | 1022 | $vfs = new self(); |
| 1024 | - if (!($stat = $vfs->url_stat($path,0))) |
|
| 1023 | + if (!($stat = $vfs->url_stat($path, 0))) |
|
| 1025 | 1024 | { |
| 1026 | 1025 | if (self::LOG_LEVEL) error_log(__METHOD__."($url, $mode) no such file or directory!"); |
| 1027 | - trigger_error("No such file or directory $url !",E_USER_WARNING); |
|
| 1026 | + trigger_error("No such file or directory $url !", E_USER_WARNING); |
|
| 1028 | 1027 | return false; |
| 1029 | 1028 | } |
| 1030 | - if (!Vfs::has_owner_rights($path,$stat)) |
|
| 1029 | + if (!Vfs::has_owner_rights($path, $stat)) |
|
| 1031 | 1030 | { |
| 1032 | 1031 | if (self::LOG_LEVEL) error_log(__METHOD__."($url, $mode) only owner or root can do that!"); |
| 1033 | - trigger_error("Only owner or root can do that!",E_USER_WARNING); |
|
| 1032 | + trigger_error("Only owner or root can do that!", E_USER_WARNING); |
|
| 1034 | 1033 | return false; |
| 1035 | 1034 | } |
| 1036 | 1035 | if (!is_numeric($mode)) // not a mode |
| 1037 | 1036 | { |
| 1038 | 1037 | if (self::LOG_LEVEL) error_log(__METHOD__."($url, $mode) no (numeric) mode!"); |
| 1039 | - trigger_error("No (numeric) mode!",E_USER_WARNING); |
|
| 1038 | + trigger_error("No (numeric) mode!", E_USER_WARNING); |
|
| 1040 | 1039 | return false; |
| 1041 | 1040 | } |
| 1042 | 1041 | $stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_mode=:fs_mode WHERE fs_id=:fs_id'); |
| 1043 | 1042 | |
| 1044 | 1043 | // update stat cache |
| 1045 | - if ($path != '/' && substr($path,-1) == '/') $path = substr($path, 0, -1); |
|
| 1046 | - self::$stat_cache[$path]['fs_mode'] = ((int) $mode) & 0777; |
|
| 1044 | + if ($path != '/' && substr($path, -1) == '/') $path = substr($path, 0, -1); |
|
| 1045 | + self::$stat_cache[$path]['fs_mode'] = ((int)$mode)&0777; |
|
| 1047 | 1046 | |
| 1048 | 1047 | return $stmt->execute(array( |
| 1049 | - 'fs_mode' => ((int) $mode) & 0777, // we dont store the file and dir bits, give int overflow! |
|
| 1048 | + 'fs_mode' => ((int)$mode)&0777, // we dont store the file and dir bits, give int overflow! |
|
| 1050 | 1049 | 'fs_id' => $stat['ino'], |
| 1051 | 1050 | )); |
| 1052 | 1051 | } |
@@ -1059,18 +1058,18 @@ discard block |
||
| 1059 | 1058 | * @param int $options |
| 1060 | 1059 | * @return booelan |
| 1061 | 1060 | */ |
| 1062 | - function dir_opendir ( $url, $options ) |
|
| 1061 | + function dir_opendir($url, $options) |
|
| 1063 | 1062 | { |
| 1064 | 1063 | $this->opened_dir = null; |
| 1065 | 1064 | |
| 1066 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
| 1065 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
| 1067 | 1066 | |
| 1068 | - if (!($stat = $this->url_stat($url,0)) || // dir not found |
|
| 1069 | - !($stat['mode'] & self::MODE_DIR) && $stat['mime'] != self::DIR_MIME_TYPE || // no dir |
|
| 1070 | - !Vfs::check_access($url,Vfs::EXECUTABLE|Vfs::READABLE,$stat)) // no access |
|
| 1067 | + if (!($stat = $this->url_stat($url, 0)) || // dir not found |
|
| 1068 | + !($stat['mode']&self::MODE_DIR) && $stat['mime'] != self::DIR_MIME_TYPE || // no dir |
|
| 1069 | + !Vfs::check_access($url, Vfs::EXECUTABLE|Vfs::READABLE, $stat)) // no access |
|
| 1071 | 1070 | { |
| 1072 | 1071 | self::_remove_password($url); |
| 1073 | - $msg = !($stat['mode'] & self::MODE_DIR) && $stat['mime'] != self::DIR_MIME_TYPE ? |
|
| 1072 | + $msg = !($stat['mode']&self::MODE_DIR) && $stat['mime'] != self::DIR_MIME_TYPE ? |
|
| 1074 | 1073 | "$url is no directory" : 'permission denied'; |
| 1075 | 1074 | if (self::LOG_LEVEL) error_log(__METHOD__."('$url',$options) $msg!"); |
| 1076 | 1075 | $this->opened_dir = null; |
@@ -1087,13 +1086,13 @@ discard block |
||
| 1087 | 1086 | $stmt->setFetchMode(\PDO::FETCH_ASSOC); |
| 1088 | 1087 | if ($stmt->execute(array($stat['ino']))) |
| 1089 | 1088 | { |
| 1090 | - foreach($stmt as $file) |
|
| 1089 | + foreach ($stmt as $file) |
|
| 1091 | 1090 | { |
| 1092 | 1091 | $this->opened_dir[] = $file['fs_name']; |
| 1093 | - self::$stat_cache[Vfs::concat($path,$file['fs_name'])] = $file; |
|
| 1092 | + self::$stat_cache[Vfs::concat($path, $file['fs_name'])] = $file; |
|
| 1094 | 1093 | } |
| 1095 | 1094 | } |
| 1096 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$options): ".implode(', ',$this->opened_dir)); |
|
| 1095 | + if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$options): ".implode(', ', $this->opened_dir)); |
|
| 1097 | 1096 | reset($this->opened_dir); |
| 1098 | 1097 | |
| 1099 | 1098 | return true; |
@@ -1126,26 +1125,26 @@ discard block |
||
| 1126 | 1125 | * @param boolean $eacl_access =null allows extending classes to pass the value of their check_extended_acl() method (no lsb!) |
| 1127 | 1126 | * @return array |
| 1128 | 1127 | */ |
| 1129 | - function url_stat ( $url, $flags, $eacl_access=null ) |
|
| 1128 | + function url_stat($url, $flags, $eacl_access = null) |
|
| 1130 | 1129 | { |
| 1131 | - static $max_subquery_depth=null; |
|
| 1130 | + static $max_subquery_depth = null; |
|
| 1132 | 1131 | if (is_null($max_subquery_depth)) |
| 1133 | 1132 | { |
| 1134 | 1133 | $max_subquery_depth = $GLOBALS['egw_info']['server']['max_subquery_depth']; |
| 1135 | - if (!$max_subquery_depth) $max_subquery_depth = 7; // setting current default of 7, if nothing set |
|
| 1134 | + if (!$max_subquery_depth) $max_subquery_depth = 7; // setting current default of 7, if nothing set |
|
| 1136 | 1135 | } |
| 1137 | 1136 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$url',$flags,$eacl_access)"); |
| 1138 | 1137 | |
| 1139 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
| 1138 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
| 1140 | 1139 | |
| 1141 | 1140 | // webdav adds a trailing slash to dirs, which causes url_stat to NOT find the file otherwise |
| 1142 | - if ($path != '/' && substr($path,-1) == '/') |
|
| 1141 | + if ($path != '/' && substr($path, -1) == '/') |
|
| 1143 | 1142 | { |
| 1144 | - $path = substr($path,0,-1); |
|
| 1143 | + $path = substr($path, 0, -1); |
|
| 1145 | 1144 | } |
| 1146 | 1145 | if (empty($path)) |
| 1147 | 1146 | { |
| 1148 | - return false; // is invalid and gives sql error |
|
| 1147 | + return false; // is invalid and gives sql error |
|
| 1149 | 1148 | } |
| 1150 | 1149 | // check if we already have the info from the last dir_open call, as the old vfs reads it anyway from the db |
| 1151 | 1150 | if (self::$stat_cache && isset(self::$stat_cache[$path]) && (is_null($eacl_access) || self::$stat_cache[$path] !== false)) |
@@ -1160,28 +1159,28 @@ discard block |
||
| 1160 | 1159 | $base_query = 'SELECT fs_id,fs_name,fs_mode,fs_uid,fs_gid,fs_size,fs_mime,fs_created,fs_modified'.self::$extra_columns. |
| 1161 | 1160 | ' FROM '.self::TABLE.' WHERE fs_active='.self::_pdo_boolean(true). |
| 1162 | 1161 | ' AND fs_name'.self::$case_sensitive_equal.'? AND fs_dir='; |
| 1163 | - $parts = explode('/',$path); |
|
| 1162 | + $parts = explode('/', $path); |
|
| 1164 | 1163 | |
| 1165 | 1164 | // if we have extendes acl access to the url, we dont need and can NOT include the sql for the readable check |
| 1166 | 1165 | if (is_null($eacl_access)) |
| 1167 | 1166 | { |
| 1168 | - $eacl_access = self::check_extended_acl($path,Vfs::READABLE); // should be static::check_extended_acl, but no lsb! |
|
| 1167 | + $eacl_access = self::check_extended_acl($path, Vfs::READABLE); // should be static::check_extended_acl, but no lsb! |
|
| 1169 | 1168 | } |
| 1170 | 1169 | |
| 1171 | 1170 | try { |
| 1172 | - foreach($parts as $n => $name) |
|
| 1171 | + foreach ($parts as $n => $name) |
|
| 1173 | 1172 | { |
| 1174 | 1173 | if ($n == 0) |
| 1175 | 1174 | { |
| 1176 | - $query = (int) ($path != '/'); // / always has fs_id == 1, no need to query it ($path=='/' needs fs_dir=0!) |
|
| 1175 | + $query = (int)($path != '/'); // / always has fs_id == 1, no need to query it ($path=='/' needs fs_dir=0!) |
|
| 1177 | 1176 | } |
| 1178 | - elseif ($n < count($parts)-1) |
|
| 1177 | + elseif ($n < count($parts) - 1) |
|
| 1179 | 1178 | { |
| 1180 | 1179 | // MySQL 5.0 has a nesting limit for subqueries |
| 1181 | 1180 | // --> we replace the so far cumulated subqueries with their result |
| 1182 | 1181 | // no idea about the other DBMS, but this does NOT hurt ... |
| 1183 | 1182 | // --> depth limit of subqueries is now dynamicly decremented in catch |
| 1184 | - if ($n > 1 && !(($n-1) % $max_subquery_depth) && !($query = self::$pdo->query($query)->fetchColumn())) |
|
| 1183 | + if ($n > 1 && !(($n - 1) % $max_subquery_depth) && !($query = self::$pdo->query($query)->fetchColumn())) |
|
| 1185 | 1184 | { |
| 1186 | 1185 | if (self::LOG_LEVEL > 1) |
| 1187 | 1186 | { |
@@ -1208,7 +1207,7 @@ discard block |
||
| 1208 | 1207 | } |
| 1209 | 1208 | else |
| 1210 | 1209 | { |
| 1211 | - $query = str_replace('fs_name'.self::$case_sensitive_equal.'?','fs_name'.self::$case_sensitive_equal.self::$pdo->quote($name),$base_query).'('.$query.')'; |
|
| 1210 | + $query = str_replace('fs_name'.self::$case_sensitive_equal.'?', 'fs_name'.self::$case_sensitive_equal.self::$pdo->quote($name), $base_query).'('.$query.')'; |
|
| 1212 | 1211 | } |
| 1213 | 1212 | } |
| 1214 | 1213 | if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__."($url,$flags,$eacl_access)".' */ '.$query; |
@@ -1234,7 +1233,7 @@ discard block |
||
| 1234 | 1233 | $GLOBALS['egw_info']['server']['max_subquery_depth'] = --$max_subquery_depth; |
| 1235 | 1234 | error_log(__METHOD__."() decremented max_subquery_depth to $max_subquery_depth"); |
| 1236 | 1235 | Api\Config::save_value('max_subquery_depth', $max_subquery_depth, 'phpgwapi'); |
| 1237 | - if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) $GLOBALS['egw']->invalidate_session_cache(); |
|
| 1236 | + if (method_exists($GLOBALS['egw'], 'invalidate_session_cache')) $GLOBALS['egw']->invalidate_session_cache(); |
|
| 1238 | 1237 | return $this->url_stat($url, $flags, $eacl_access); |
| 1239 | 1238 | } |
| 1240 | 1239 | self::$stat_cache[$path] = $info; |
@@ -1250,18 +1249,18 @@ discard block |
||
| 1250 | 1249 | */ |
| 1251 | 1250 | protected static function _sql_readable() |
| 1252 | 1251 | { |
| 1253 | - static $sql_read_acl=null; |
|
| 1252 | + static $sql_read_acl = null; |
|
| 1254 | 1253 | |
| 1255 | 1254 | if (is_null($sql_read_acl)) |
| 1256 | 1255 | { |
| 1257 | - foreach($GLOBALS['egw']->accounts->memberships(Vfs::$user,true) as $gid) |
|
| 1256 | + foreach ($GLOBALS['egw']->accounts->memberships(Vfs::$user, true) as $gid) |
|
| 1258 | 1257 | { |
| 1259 | - $memberships[] = abs($gid); // sqlfs stores the gid's positiv |
|
| 1258 | + $memberships[] = abs($gid); // sqlfs stores the gid's positiv |
|
| 1260 | 1259 | } |
| 1261 | 1260 | // using octal numbers with mysql leads to funny results (select 384 & 0400 --> 384 not 256=0400) |
| 1262 | 1261 | // 256 = 0400, 32 = 040 |
| 1263 | 1262 | $sql_read_acl = '((fs_mode & 4)=4 OR (fs_mode & 256)=256 AND fs_uid='.(int)Vfs::$user. |
| 1264 | - ($memberships ? ' OR (fs_mode & 32)=32 AND fs_gid IN('.implode(',',$memberships).')' : '').')'; |
|
| 1263 | + ($memberships ? ' OR (fs_mode & 32)=32 AND fs_gid IN('.implode(',', $memberships).')' : '').')'; |
|
| 1265 | 1264 | //error_log(__METHOD__."() Vfs::\$user=".array2string(Vfs::$user).' --> memberships='.array2string($memberships).' --> '.$sql_read_acl.($memberships?'':': '.function_backtrace())); |
| 1266 | 1265 | } |
| 1267 | 1266 | return $sql_read_acl; |
@@ -1274,7 +1273,7 @@ discard block |
||
| 1274 | 1273 | * |
| 1275 | 1274 | * @return string |
| 1276 | 1275 | */ |
| 1277 | - function dir_readdir ( ) |
|
| 1276 | + function dir_readdir( ) |
|
| 1278 | 1277 | { |
| 1279 | 1278 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."( )"); |
| 1280 | 1279 | |
@@ -1293,7 +1292,7 @@ discard block |
||
| 1293 | 1292 | * |
| 1294 | 1293 | * @return boolean |
| 1295 | 1294 | */ |
| 1296 | - function dir_rewinddir ( ) |
|
| 1295 | + function dir_rewinddir( ) |
|
| 1297 | 1296 | { |
| 1298 | 1297 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."( )"); |
| 1299 | 1298 | |
@@ -1311,7 +1310,7 @@ discard block |
||
| 1311 | 1310 | * |
| 1312 | 1311 | * @return boolean |
| 1313 | 1312 | */ |
| 1314 | - function dir_closedir ( ) |
|
| 1313 | + function dir_closedir( ) |
|
| 1315 | 1314 | { |
| 1316 | 1315 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."( )"); |
| 1317 | 1316 | |
@@ -1333,7 +1332,7 @@ discard block |
||
| 1333 | 1332 | static function readlink($path) |
| 1334 | 1333 | { |
| 1335 | 1334 | $vfs = new self(); |
| 1336 | - $link = !($lstat = $vfs->url_stat($path,STREAM_URL_STAT_LINK)) || is_null($lstat['readlink']) ? false : $lstat['readlink']; |
|
| 1335 | + $link = !($lstat = $vfs->url_stat($path, STREAM_URL_STAT_LINK)) || is_null($lstat['readlink']) ? false : $lstat['readlink']; |
|
| 1337 | 1336 | |
| 1338 | 1337 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = $link"); |
| 1339 | 1338 | |
@@ -1347,32 +1346,32 @@ discard block |
||
| 1347 | 1346 | * @param string $link |
| 1348 | 1347 | * @return boolean true on success false on error |
| 1349 | 1348 | */ |
| 1350 | - static function symlink($target,$link) |
|
| 1349 | + static function symlink($target, $link) |
|
| 1351 | 1350 | { |
| 1352 | 1351 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$target','$link')"); |
| 1353 | 1352 | |
| 1354 | 1353 | $inst = new static(); |
| 1355 | - if ($inst->url_stat($link,0)) |
|
| 1354 | + if ($inst->url_stat($link, 0)) |
|
| 1356 | 1355 | { |
| 1357 | 1356 | if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$target','$link') $link exists, returning false!"); |
| 1358 | - return false; // $link already exists |
|
| 1357 | + return false; // $link already exists |
|
| 1359 | 1358 | } |
| 1360 | 1359 | if (!($dir = Vfs::dirname($link)) || |
| 1361 | - !Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat=$inst->url_stat($dir,0))) |
|
| 1360 | + !Vfs::check_access($dir, Vfs::WRITABLE, $dir_stat = $inst->url_stat($dir, 0))) |
|
| 1362 | 1361 | { |
| 1363 | 1362 | if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$target','$link') returning false! (!is_writable('$dir'), dir_stat=".array2string($dir_stat).")"); |
| 1364 | - return false; // parent dir does not exist or is not writable |
|
| 1363 | + return false; // parent dir does not exist or is not writable |
|
| 1365 | 1364 | } |
| 1366 | 1365 | $query = 'INSERT INTO '.self::TABLE.' (fs_name,fs_dir,fs_mode,fs_uid,fs_gid,fs_created,fs_modified,fs_creator,fs_mime,fs_size,fs_link'. |
| 1367 | 1366 | ') VALUES (:fs_name,:fs_dir,:fs_mode,:fs_uid,:fs_gid,:fs_created,:fs_modified,:fs_creator,:fs_mime,:fs_size,:fs_link)'; |
| 1368 | 1367 | if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; |
| 1369 | 1368 | $stmt = self::$pdo->prepare($query); |
| 1370 | - unset(self::$stat_cache[Vfs::parse_url($link,PHP_URL_PATH)]); |
|
| 1369 | + unset(self::$stat_cache[Vfs::parse_url($link, PHP_URL_PATH)]); |
|
| 1371 | 1370 | |
| 1372 | 1371 | return !!$stmt->execute(array( |
| 1373 | 1372 | 'fs_name' => self::limit_filename(Vfs::basename($link)), |
| 1374 | 1373 | 'fs_dir' => $dir_stat['ino'], |
| 1375 | - 'fs_mode' => ($dir_stat['mode'] & 0666), |
|
| 1374 | + 'fs_mode' => ($dir_stat['mode']&0666), |
|
| 1376 | 1375 | 'fs_uid' => $dir_stat['uid'] ? $dir_stat['uid'] : Vfs::$user, |
| 1377 | 1376 | 'fs_gid' => $dir_stat['gid'], |
| 1378 | 1377 | 'fs_created' => self::_pdo_timestamp(time()), |
@@ -1396,24 +1395,24 @@ discard block |
||
| 1396 | 1395 | * @param int $check mode to check: one or more or'ed together of: 4 = read, 2 = write, 1 = executable |
| 1397 | 1396 | * @return boolean |
| 1398 | 1397 | */ |
| 1399 | - static function check_extended_acl($url,$check) |
|
| 1398 | + static function check_extended_acl($url, $check) |
|
| 1400 | 1399 | { |
| 1401 | - $url_path = Vfs::parse_url($url,PHP_URL_PATH); |
|
| 1400 | + $url_path = Vfs::parse_url($url, PHP_URL_PATH); |
|
| 1402 | 1401 | |
| 1403 | 1402 | if (is_null(self::$extended_acl)) |
| 1404 | 1403 | { |
| 1405 | 1404 | self::_read_extended_acl(); |
| 1406 | 1405 | } |
| 1407 | 1406 | $access = false; |
| 1408 | - foreach(self::$extended_acl as $path => $rights) |
|
| 1407 | + foreach (self::$extended_acl as $path => $rights) |
|
| 1409 | 1408 | { |
| 1410 | - if ($path == $url_path || substr($url_path,0,strlen($path)+1) == $path.'/') |
|
| 1409 | + if ($path == $url_path || substr($url_path, 0, strlen($path) + 1) == $path.'/') |
|
| 1411 | 1410 | { |
| 1412 | - $access = ($rights & $check) == $check; |
|
| 1411 | + $access = ($rights&$check) == $check; |
|
| 1413 | 1412 | break; |
| 1414 | 1413 | } |
| 1415 | 1414 | } |
| 1416 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$check) ".($access?"access granted by $path=$rights":'no access!!!')); |
|
| 1415 | + if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$check) ".($access ? "access granted by $path=$rights" : 'no access!!!')); |
|
| 1417 | 1416 | return $access; |
| 1418 | 1417 | } |
| 1419 | 1418 | |
@@ -1425,14 +1424,14 @@ discard block |
||
| 1425 | 1424 | { |
| 1426 | 1425 | if ((self::$extended_acl = Api\Cache::getSession(self::EACL_APPNAME, 'extended_acl'))) |
| 1427 | 1426 | { |
| 1428 | - return; // ext. ACL read from session. |
|
| 1427 | + return; // ext. ACL read from session. |
|
| 1429 | 1428 | } |
| 1430 | 1429 | self::$extended_acl = array(); |
| 1431 | - if (($rights = $GLOBALS['egw']->acl->get_all_location_rights(Vfs::$user,self::EACL_APPNAME))) |
|
| 1430 | + if (($rights = $GLOBALS['egw']->acl->get_all_location_rights(Vfs::$user, self::EACL_APPNAME))) |
|
| 1432 | 1431 | { |
| 1433 | 1432 | $pathes = self::id2path(array_keys($rights)); |
| 1434 | 1433 | } |
| 1435 | - foreach($rights as $fs_id => $right) |
|
| 1434 | + foreach ($rights as $fs_id => $right) |
|
| 1436 | 1435 | { |
| 1437 | 1436 | $path = $pathes[$fs_id]; |
| 1438 | 1437 | if (isset($path)) |
@@ -1441,8 +1440,8 @@ discard block |
||
| 1441 | 1440 | } |
| 1442 | 1441 | } |
| 1443 | 1442 | // sort by length descending, to allow more specific pathes to have precedence |
| 1444 | - uksort(self::$extended_acl, function($a,$b) { |
|
| 1445 | - return strlen($b)-strlen($a); |
|
| 1443 | + uksort(self::$extended_acl, function($a, $b) { |
|
| 1444 | + return strlen($b) - strlen($a); |
|
| 1446 | 1445 | }); |
| 1447 | 1446 | Api\Cache::setSession(self::EACL_APPNAME, 'extended_acl', self::$extended_acl); |
| 1448 | 1447 | if (self::LOG_LEVEL > 1) error_log(__METHOD__.'() '.array2string(self::$extended_acl)); |
@@ -1464,24 +1463,24 @@ discard block |
||
| 1464 | 1463 | * @param int $fs_id =null fs_id to use, to not query it again (eg. because it's already deleted) |
| 1465 | 1464 | * @return boolean true if acl is set/deleted, false on error |
| 1466 | 1465 | */ |
| 1467 | - static function eacl($path,$rights=null,$owner=null,$fs_id=null) |
|
| 1466 | + static function eacl($path, $rights = null, $owner = null, $fs_id = null) |
|
| 1468 | 1467 | { |
| 1469 | 1468 | if ($path[0] != '/') |
| 1470 | 1469 | { |
| 1471 | - $path = Vfs::parse_url($path,PHP_URL_PATH); |
|
| 1470 | + $path = Vfs::parse_url($path, PHP_URL_PATH); |
|
| 1472 | 1471 | } |
| 1473 | 1472 | if (is_null($fs_id)) |
| 1474 | 1473 | { |
| 1475 | 1474 | $vfs = new self(); |
| 1476 | - if (!($stat = $vfs->url_stat($path,0))) |
|
| 1475 | + if (!($stat = $vfs->url_stat($path, 0))) |
|
| 1477 | 1476 | { |
| 1478 | 1477 | if (self::LOG_LEVEL) error_log(__METHOD__."($path,$rights,$owner,$fs_id) no such file or directory!"); |
| 1479 | - return false; // $path not found |
|
| 1478 | + return false; // $path not found |
|
| 1480 | 1479 | } |
| 1481 | - if (!Vfs::has_owner_rights($path,$stat)) // not group dir and user is eGW admin |
|
| 1480 | + if (!Vfs::has_owner_rights($path, $stat)) // not group dir and user is eGW admin |
|
| 1482 | 1481 | { |
| 1483 | 1482 | if (self::LOG_LEVEL) error_log(__METHOD__."($path,$rights,$owner,$fs_id) permission denied!"); |
| 1484 | - return false; // permission denied |
|
| 1483 | + return false; // permission denied |
|
| 1485 | 1484 | } |
| 1486 | 1485 | $fs_id = $stat['ino']; |
| 1487 | 1486 | } |
@@ -1493,16 +1492,16 @@ discard block |
||
| 1493 | 1492 | { |
| 1494 | 1493 | // delete eacl |
| 1495 | 1494 | if (is_null($owner) || $owner == Vfs::$user || |
| 1496 | - $owner < 0 && Vfs::$user && in_array($owner,$GLOBALS['egw']->accounts->memberships(Vfs::$user,true))) |
|
| 1495 | + $owner < 0 && Vfs::$user && in_array($owner, $GLOBALS['egw']->accounts->memberships(Vfs::$user, true))) |
|
| 1497 | 1496 | { |
| 1498 | - self::$extended_acl = null; // force new read of eACL, as there could be multiple eACL for that path |
|
| 1497 | + self::$extended_acl = null; // force new read of eACL, as there could be multiple eACL for that path |
|
| 1499 | 1498 | } |
| 1500 | 1499 | $ret = $GLOBALS['egw']->acl->delete_repository(self::EACL_APPNAME, $fs_id, (int)$owner, false); |
| 1501 | 1500 | } |
| 1502 | 1501 | else |
| 1503 | 1502 | { |
| 1504 | 1503 | if (isset(self::$extended_acl) && ($owner == Vfs::$user || |
| 1505 | - $owner < 0 && Vfs::$user && in_array($owner,$GLOBALS['egw']->accounts->memberships(Vfs::$user,true)))) |
|
| 1504 | + $owner < 0 && Vfs::$user && in_array($owner, $GLOBALS['egw']->accounts->memberships(Vfs::$user, true)))) |
|
| 1506 | 1505 | { |
| 1507 | 1506 | // set rights for this class, if applicable |
| 1508 | 1507 | self::$extended_acl[$path] |= $rights; |
@@ -1531,10 +1530,10 @@ discard block |
||
| 1531 | 1530 | if (!($stat = $inst->url_stat($path, STREAM_URL_STAT_QUIET))) |
| 1532 | 1531 | { |
| 1533 | 1532 | error_log(__METHOD__.__LINE__.' '.array2string($path).' not found!'); |
| 1534 | - return false; // not found |
|
| 1533 | + return false; // not found |
|
| 1535 | 1534 | } |
| 1536 | 1535 | $eacls = array(); |
| 1537 | - foreach($GLOBALS['egw']->acl->get_all_rights($stat['ino'],self::EACL_APPNAME) as $owner => $rights) |
|
| 1536 | + foreach ($GLOBALS['egw']->acl->get_all_rights($stat['ino'], self::EACL_APPNAME) as $owner => $rights) |
|
| 1538 | 1537 | { |
| 1539 | 1538 | $eacls[] = array( |
| 1540 | 1539 | 'path' => $path, |
@@ -1545,7 +1544,7 @@ discard block |
||
| 1545 | 1544 | } |
| 1546 | 1545 | if (($path = Vfs::dirname($path))) |
| 1547 | 1546 | { |
| 1548 | - $eacls = array_merge((array)self::get_eacl($path),$eacls); |
|
| 1547 | + $eacls = array_merge((array)self::get_eacl($path), $eacls); |
|
| 1549 | 1548 | } |
| 1550 | 1549 | // sort by length descending, to show precedence |
| 1551 | 1550 | usort($eacls, function($a, $b) { |
@@ -1570,7 +1569,7 @@ discard block |
||
| 1570 | 1569 | * @param int $recursion_count =0 internally used to break infinit recursions |
| 1571 | 1570 | * @return false|string|array path or array or pathes indexed by fs_id, or false on error |
| 1572 | 1571 | */ |
| 1573 | - static function id2path($fs_ids, $recursion_count=0) |
|
| 1572 | + static function id2path($fs_ids, $recursion_count = 0) |
|
| 1574 | 1573 | { |
| 1575 | 1574 | if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($fs_ids).')'); |
| 1576 | 1575 | if ($recursion_count > self::MAX_ID2PATH_RECURSION) |
@@ -1581,9 +1580,9 @@ discard block |
||
| 1581 | 1580 | $ids = (array)$fs_ids; |
| 1582 | 1581 | $pathes = array(); |
| 1583 | 1582 | // first check our stat-cache for the ids |
| 1584 | - foreach(self::$stat_cache as $path => $stat) |
|
| 1583 | + foreach (self::$stat_cache as $path => $stat) |
|
| 1585 | 1584 | { |
| 1586 | - if (($key = array_search($stat['fs_id'],$ids)) !== false) |
|
| 1585 | + if (($key = array_search($stat['fs_id'], $ids)) !== false) |
|
| 1587 | 1586 | { |
| 1588 | 1587 | $pathes[$stat['fs_id']] = $path; |
| 1589 | 1588 | unset($ids[$key]); |
@@ -1597,7 +1596,7 @@ discard block |
||
| 1597 | 1596 | // now search via the database |
| 1598 | 1597 | if (count($ids) > 1) array_map(function(&$v) { $v = (int)$v; },$ids); |
| 1599 | 1598 | $query = 'SELECT fs_id,fs_dir,fs_name FROM '.self::TABLE.' WHERE fs_id'. |
| 1600 | - (count($ids) == 1 ? '='.(int)$ids[0] : ' IN ('.implode(',',$ids).')'); |
|
| 1599 | + (count($ids) == 1 ? '='.(int)$ids[0] : ' IN ('.implode(',', $ids).')'); |
|
| 1601 | 1600 | if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; |
| 1602 | 1601 | |
| 1603 | 1602 | if (!is_object(self::$pdo)) |
@@ -1608,12 +1607,12 @@ discard block |
||
| 1608 | 1607 | $stmt->setFetchMode(\PDO::FETCH_ASSOC); |
| 1609 | 1608 | if (!$stmt->execute()) |
| 1610 | 1609 | { |
| 1611 | - return false; // not found |
|
| 1610 | + return false; // not found |
|
| 1612 | 1611 | } |
| 1613 | 1612 | $parents = array(); |
| 1614 | - foreach($stmt as $row) |
|
| 1613 | + foreach ($stmt as $row) |
|
| 1615 | 1614 | { |
| 1616 | - if ($row['fs_dir'] > 1 && !in_array($row['fs_dir'],$parents)) |
|
| 1615 | + if ($row['fs_dir'] > 1 && !in_array($row['fs_dir'], $parents)) |
|
| 1617 | 1616 | { |
| 1618 | 1617 | $parents[] = $row['fs_dir']; |
| 1619 | 1618 | } |
@@ -1621,16 +1620,16 @@ discard block |
||
| 1621 | 1620 | } |
| 1622 | 1621 | unset($stmt); |
| 1623 | 1622 | |
| 1624 | - if ($parents && !($parents = self::id2path($parents, $recursion_count+1))) |
|
| 1623 | + if ($parents && !($parents = self::id2path($parents, $recursion_count + 1))) |
|
| 1625 | 1624 | { |
| 1626 | - return false; // parent not found, should never happen ... |
|
| 1625 | + return false; // parent not found, should never happen ... |
|
| 1627 | 1626 | } |
| 1628 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__." trying foreach with:".print_r($rows,true)."#"); |
|
| 1629 | - foreach((array)$rows as $fs_id => $row) |
|
| 1627 | + if (self::LOG_LEVEL > 1) error_log(__METHOD__." trying foreach with:".print_r($rows, true)."#"); |
|
| 1628 | + foreach ((array)$rows as $fs_id => $row) |
|
| 1630 | 1629 | { |
| 1631 | 1630 | $parent = $row['fs_dir'] > 1 ? $parents[$row['fs_dir']] : ''; |
| 1632 | 1631 | |
| 1633 | - $pathes[$fs_id] = $parent . '/' . $row['fs_name']; |
|
| 1632 | + $pathes[$fs_id] = $parent.'/'.$row['fs_name']; |
|
| 1634 | 1633 | } |
| 1635 | 1634 | if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($fs_ids).')='.array2string($pathes)); |
| 1636 | 1635 | return is_array($fs_ids) ? $pathes : array_shift($pathes); |
@@ -1654,7 +1653,7 @@ discard block |
||
| 1654 | 1653 | $parts = explode('.', $name); |
| 1655 | 1654 | if ($parts > 1 && mb_strlen($extension = '.'.array_pop($parts)) <= $fs_name_precision) |
| 1656 | 1655 | { |
| 1657 | - $name = mb_substr(implode('.', $parts), 0, $fs_name_precision-mb_strlen($extension)).$extension; |
|
| 1656 | + $name = mb_substr(implode('.', $parts), 0, $fs_name_precision - mb_strlen($extension)).$extension; |
|
| 1658 | 1657 | } |
| 1659 | 1658 | else |
| 1660 | 1659 | { |
@@ -1675,9 +1674,8 @@ discard block |
||
| 1675 | 1674 | $stat = array( |
| 1676 | 1675 | 'ino' => $info['fs_id'], |
| 1677 | 1676 | 'name' => $info['fs_name'], |
| 1678 | - 'mode' => $info['fs_mode'] | |
|
| 1679 | - ($info['fs_mime'] == self::DIR_MIME_TYPE ? self::MODE_DIR : |
|
| 1680 | - ($info['fs_mime'] == self::SYMLINK_MIME_TYPE ? self::MODE_LINK : self::MODE_FILE)), // required by the stream wrapper |
|
| 1677 | + 'mode' => $info['fs_mode']| |
|
| 1678 | + ($info['fs_mime'] == self::DIR_MIME_TYPE ? self::MODE_DIR : ($info['fs_mime'] == self::SYMLINK_MIME_TYPE ? self::MODE_LINK : self::MODE_FILE)), // required by the stream wrapper |
|
| 1681 | 1679 | 'size' => $info['fs_size'], |
| 1682 | 1680 | 'uid' => $info['fs_uid'], |
| 1683 | 1681 | 'gid' => $info['fs_gid'], |
@@ -1722,10 +1720,10 @@ discard block |
||
| 1722 | 1720 | { |
| 1723 | 1721 | if (is_object($GLOBALS['egw_setup']->db)) // if we run under setup, query the db for the files dir |
| 1724 | 1722 | { |
| 1725 | - $GLOBALS['egw_info']['server']['files_dir'] = $GLOBALS['egw_setup']->db->select('egw_config','config_value',array( |
|
| 1723 | + $GLOBALS['egw_info']['server']['files_dir'] = $GLOBALS['egw_setup']->db->select('egw_config', 'config_value', array( |
|
| 1726 | 1724 | 'config_name' => 'files_dir', |
| 1727 | 1725 | 'config_app' => 'phpgwapi', |
| 1728 | - ),__LINE__,__FILE__)->fetchColumn(); |
|
| 1726 | + ), __LINE__, __FILE__)->fetchColumn(); |
|
| 1729 | 1727 | } |
| 1730 | 1728 | } |
| 1731 | 1729 | if (!$GLOBALS['egw_info']['server']['files_dir']) |
@@ -1734,14 +1732,14 @@ discard block |
||
| 1734 | 1732 | } |
| 1735 | 1733 | $hash = array(); |
| 1736 | 1734 | $n = $id; |
| 1737 | - while(($n = (int) ($n / self::HASH_MAX))) |
|
| 1735 | + while (($n = (int)($n / self::HASH_MAX))) |
|
| 1738 | 1736 | { |
| 1739 | - $hash[] = sprintf('%02d',$n % self::HASH_MAX); |
|
| 1737 | + $hash[] = sprintf('%02d', $n % self::HASH_MAX); |
|
| 1740 | 1738 | } |
| 1741 | - if (!$hash) $hash[] = '00'; // we need at least one directory, to not conflict with the dir-names |
|
| 1742 | - array_unshift($hash,$id); |
|
| 1739 | + if (!$hash) $hash[] = '00'; // we need at least one directory, to not conflict with the dir-names |
|
| 1740 | + array_unshift($hash, $id); |
|
| 1743 | 1741 | |
| 1744 | - $path = '/sqlfs/'.implode('/',array_reverse($hash)); |
|
| 1742 | + $path = '/sqlfs/'.implode('/', array_reverse($hash)); |
|
| 1745 | 1743 | //error_log(__METHOD__."($id) = '$path'"); |
| 1746 | 1744 | return $GLOBALS['egw_info']['server']['files_dir'].$path; |
| 1747 | 1745 | } |
@@ -1757,7 +1755,7 @@ discard block |
||
| 1757 | 1755 | |
| 1758 | 1756 | if ($parts['pass'] || $parts['scheme']) |
| 1759 | 1757 | { |
| 1760 | - $url = $parts['scheme'].'://'.($parts['user'] ? $parts['user'].($parts['pass']?':...':'').'@' : ''). |
|
| 1758 | + $url = $parts['scheme'].'://'.($parts['user'] ? $parts['user'].($parts['pass'] ? ':...' : '').'@' : ''). |
|
| 1761 | 1759 | $parts['host'].$parts['path']; |
| 1762 | 1760 | } |
| 1763 | 1761 | } |
@@ -1772,10 +1770,10 @@ discard block |
||
| 1772 | 1770 | { |
| 1773 | 1771 | $operation = self::DEFAULT_OPERATION; |
| 1774 | 1772 | |
| 1775 | - if (strpos(is_array($url) ? $url['query'] : $url,'storage=') !== false) |
|
| 1773 | + if (strpos(is_array($url) ? $url['query'] : $url, 'storage=') !== false) |
|
| 1776 | 1774 | { |
| 1777 | 1775 | $query = null; |
| 1778 | - parse_str(is_array($url) ? $url['query'] : Vfs::parse_url($url,PHP_URL_QUERY), $query); |
|
| 1776 | + parse_str(is_array($url) ? $url['query'] : Vfs::parse_url($url, PHP_URL_QUERY), $query); |
|
| 1779 | 1777 | switch ($query['storage']) |
| 1780 | 1778 | { |
| 1781 | 1779 | case 'db': |
@@ -1798,29 +1796,29 @@ discard block |
||
| 1798 | 1796 | * @param array $props array of array with values for keys 'name', 'ns', 'val' (null to delete the prop) |
| 1799 | 1797 | * @return boolean true if props are updated, false otherwise (eg. ressource not found) |
| 1800 | 1798 | */ |
| 1801 | - static function proppatch($path,array $props) |
|
| 1799 | + static function proppatch($path, array $props) |
|
| 1802 | 1800 | { |
| 1803 | 1801 | static $inst = null; |
| 1804 | 1802 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."(".array2string($path).','.array2string($props)); |
| 1805 | 1803 | if (!is_numeric($path)) |
| 1806 | 1804 | { |
| 1807 | 1805 | if (!isset($inst)) $inst = new self(); |
| 1808 | - if (!($stat = $inst->url_stat($path,0))) |
|
| 1806 | + if (!($stat = $inst->url_stat($path, 0))) |
|
| 1809 | 1807 | { |
| 1810 | 1808 | return false; |
| 1811 | 1809 | } |
| 1812 | 1810 | $id = $stat['ino']; |
| 1813 | 1811 | } |
| 1814 | - elseif(!($path = self::id2path($id=$path))) |
|
| 1812 | + elseif (!($path = self::id2path($id = $path))) |
|
| 1815 | 1813 | { |
| 1816 | 1814 | return false; |
| 1817 | 1815 | } |
| 1818 | - if (!Vfs::check_access($path,Api\Acl::EDIT,$stat)) |
|
| 1816 | + if (!Vfs::check_access($path, Api\Acl::EDIT, $stat)) |
|
| 1819 | 1817 | { |
| 1820 | - return false; // permission denied |
|
| 1818 | + return false; // permission denied |
|
| 1821 | 1819 | } |
| 1822 | 1820 | $ins_stmt = $del_stmt = null; |
| 1823 | - foreach($props as &$prop) |
|
| 1821 | + foreach ($props as &$prop) |
|
| 1824 | 1822 | { |
| 1825 | 1823 | if (!isset($prop['ns'])) $prop['ns'] = Vfs::DEFAULT_PROP_NAMESPACE; |
| 1826 | 1824 | |
@@ -1865,17 +1863,17 @@ discard block |
||
| 1865 | 1863 | * @return array|boolean false on error ($path_ids does not exist), array with props (values for keys 'name', 'ns', 'value'), or |
| 1866 | 1864 | * fs_id/path => array of props for $depth==1 or is_array($path_ids) |
| 1867 | 1865 | */ |
| 1868 | - static function propfind($path_ids,$ns=Vfs::DEFAULT_PROP_NAMESPACE) |
|
| 1866 | + static function propfind($path_ids, $ns = Vfs::DEFAULT_PROP_NAMESPACE) |
|
| 1869 | 1867 | { |
| 1870 | 1868 | static $inst = null; |
| 1871 | 1869 | |
| 1872 | 1870 | $ids = is_array($path_ids) ? $path_ids : array($path_ids); |
| 1873 | - foreach($ids as &$id) |
|
| 1871 | + foreach ($ids as &$id) |
|
| 1874 | 1872 | { |
| 1875 | 1873 | if (!is_numeric($id)) |
| 1876 | 1874 | { |
| 1877 | 1875 | if (!isset($inst)) $inst = new self(); |
| 1878 | - if (!($stat = $inst->url_stat($id,0))) |
|
| 1876 | + if (!($stat = $inst->url_stat($id, 0))) |
|
| 1879 | 1877 | { |
| 1880 | 1878 | if (self::LOG_LEVEL) error_log(__METHOD__."(".array2string($path_ids).",$ns) path '$id' not found!"); |
| 1881 | 1879 | return false; |
@@ -1885,7 +1883,7 @@ discard block |
||
| 1885 | 1883 | } |
| 1886 | 1884 | if (count($ids) >= 1) array_map(function(&$v) { $v = (int)$v; },$ids); |
| 1887 | 1885 | $query = 'SELECT * FROM '.self::PROPS_TABLE.' WHERE (fs_id'. |
| 1888 | - (count($ids) == 1 ? '='.(int)implode('',$ids) : ' IN ('.implode(',',$ids).')').')'. |
|
| 1886 | + (count($ids) == 1 ? '='.(int)implode('', $ids) : ' IN ('.implode(',', $ids).')').')'. |
|
| 1889 | 1887 | (!is_null($ns) ? ' AND prop_namespace=?' : ''); |
| 1890 | 1888 | if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; |
| 1891 | 1889 | |
@@ -1894,7 +1892,7 @@ discard block |
||
| 1894 | 1892 | $stmt->execute(!is_null($ns) ? array($ns) : array()); |
| 1895 | 1893 | |
| 1896 | 1894 | $props = array(); |
| 1897 | - foreach($stmt as $row) |
|
| 1895 | + foreach ($stmt as $row) |
|
| 1898 | 1896 | { |
| 1899 | 1897 | $props[$row['fs_id']][] = array( |
| 1900 | 1898 | 'val' => $row['prop_value'], |
@@ -1904,19 +1902,19 @@ discard block |
||
| 1904 | 1902 | } |
| 1905 | 1903 | if (!is_array($path_ids)) |
| 1906 | 1904 | { |
| 1907 | - $props = $props[$row['fs_id']] ? $props[$row['fs_id']] : array(); // return empty array for no props |
|
| 1905 | + $props = $props[$row['fs_id']] ? $props[$row['fs_id']] : array(); // return empty array for no props |
|
| 1908 | 1906 | } |
| 1909 | 1907 | elseif ($props && isset($stat) && is_array($id2path = self::id2path(array_keys($props)))) // need to map fs_id's to pathes |
| 1910 | 1908 | { |
| 1911 | - foreach($id2path as $id => $path) |
|
| 1909 | + foreach ($id2path as $id => $path) |
|
| 1912 | 1910 | { |
| 1913 | - $props[$path] =& $props[$id]; |
|
| 1911 | + $props[$path] = & $props[$id]; |
|
| 1914 | 1912 | unset($props[$id]); |
| 1915 | 1913 | } |
| 1916 | 1914 | } |
| 1917 | 1915 | if (self::LOG_LEVEL > 1) |
| 1918 | 1916 | { |
| 1919 | - foreach((array)$props as $k => $v) |
|
| 1917 | + foreach ((array)$props as $k => $v) |
|
| 1920 | 1918 | { |
| 1921 | 1919 | error_log(__METHOD__."($path_ids,$ns) $k => ".array2string($v)); |
| 1922 | 1920 | } |