@@ -58,21 +58,21 @@ discard block |
||
58 | 58 | */ |
59 | 59 | function read_repository() |
60 | 60 | { |
61 | - if (!isset($GLOBALS['egw_info']['apps']) || !is_array($GLOBALS['egw_info']['apps'])) |
|
61 | + if (!isset($GLOBALS['egw_info']['apps']) || !is_array($GLOBALS['egw_info']['apps'])) |
|
62 | 62 | { |
63 | 63 | $this->read_installed_apps(); |
64 | 64 | } |
65 | 65 | $this->data = Array(); |
66 | - if(!$this->account_id) |
|
66 | + if (!$this->account_id) |
|
67 | 67 | { |
68 | 68 | return False; |
69 | 69 | } |
70 | 70 | $apps = $GLOBALS['egw']->acl->get_user_applications($this->account_id); |
71 | - foreach(array_keys($GLOBALS['egw_info']['apps']) as $app) |
|
71 | + foreach (array_keys($GLOBALS['egw_info']['apps']) as $app) |
|
72 | 72 | { |
73 | 73 | if (isset($apps[$app]) && $apps[$app]) |
74 | 74 | { |
75 | - $this->data[$app] =& $GLOBALS['egw_info']['apps'][$app]; |
|
75 | + $this->data[$app] = & $GLOBALS['egw_info']['apps'][$app]; |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 | return $this->data; |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | function read_installed_apps() |
86 | 86 | { |
87 | - foreach($this->db->select($this->table_name,'*',false,__LINE__,__FILE__,false,'ORDER BY app_order ASC') as $row) |
|
87 | + foreach ($this->db->select($this->table_name, '*', false, __LINE__, __FILE__, false, 'ORDER BY app_order ASC') as $row) |
|
88 | 88 | { |
89 | 89 | $title = $app_name = $row['app_name']; |
90 | 90 |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | class Applications |
20 | 20 | { |
21 | 21 | var $account_id; |
22 | - var $data = Array(); |
|
22 | + var $data = array(); |
|
23 | 23 | /** |
24 | 24 | * Reference to the global db class |
25 | 25 | * |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | { |
63 | 63 | $this->read_installed_apps(); |
64 | 64 | } |
65 | - $this->data = Array(); |
|
65 | + $this->data = array(); |
|
66 | 66 | if(!$this->account_id) |
67 | 67 | { |
68 | 68 | return False; |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | { |
93 | 93 | $title = $t; |
94 | 94 | } |
95 | - $GLOBALS['egw_info']['apps'][$app_name] = Array( |
|
95 | + $GLOBALS['egw_info']['apps'][$app_name] = array( |
|
96 | 96 | 'title' => $title, |
97 | 97 | 'name' => $app_name, |
98 | 98 | 'enabled' => True, |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | } |
481 | 481 | $ids = Link\Storage::get_links($app, $id, $only_app, $order, $deleted, $limit); |
482 | 482 | if (empty($only_app) || $only_app == self::VFS_APPNAME || |
483 | - ($only_app[0] == '!' && $only_app != '!'.self::VFS_APPNAME)) |
|
483 | + ($only_app[0] == '!' && $only_app != '!'.self::VFS_APPNAME)) |
|
484 | 484 | { |
485 | 485 | if (($vfs_ids = self::list_attached($app,$id))) |
486 | 486 | { |
@@ -536,7 +536,7 @@ discard block |
||
536 | 536 | $links = Link\Storage::get_links($app,$ids,$only_app,$order,$deleted); |
537 | 537 | |
538 | 538 | if (empty($only_app) || $only_app == self::VFS_APPNAME || |
539 | - ($only_app[0] == '!' && $only_app != '!'.self::VFS_APPNAME)) |
|
539 | + ($only_app[0] == '!' && $only_app != '!'.self::VFS_APPNAME)) |
|
540 | 540 | { |
541 | 541 | // todo do that in a single query, eg. directory listing, too |
542 | 542 | foreach($ids as $id) |
@@ -793,7 +793,7 @@ discard block |
||
793 | 793 | |
794 | 794 | if (!isset($options['total'])) |
795 | 795 | { |
796 | - $options['total'] = count($result); |
|
796 | + $options['total'] = count($result); |
|
797 | 797 | } |
798 | 798 | if (is_array($result) && (isset($options['start']) || (isset($options['num_rows']) && count($result) > $options['num_rows']))) |
799 | 799 | { |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | * generate temporary link_id used as array-key |
434 | 434 | * |
435 | 435 | * @param string $app app-name |
436 | - * @param mixed $id |
|
436 | + * @param string $id |
|
437 | 437 | * @return string |
438 | 438 | */ |
439 | 439 | static function temp_link_id($app,$id) |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | * @param string|array $id ='' id if $app_link_id is an appname or array with links, if 1. entry not yet created |
580 | 580 | * @param string $app2 ='' second app |
581 | 581 | * @param string $id2 ='' id in $app2 |
582 | - * @return array with link-data or False |
|
582 | + * @return string with link-data or False |
|
583 | 583 | */ |
584 | 584 | static function get_link($app_link_id,$id='',$app2='',$id2='') |
585 | 585 | { |
@@ -1197,7 +1197,6 @@ discard block |
||
1197 | 1197 | * @param string $app appname to link the file to |
1198 | 1198 | * @param string $id id in $app |
1199 | 1199 | * @param string $file VFS path to link to |
1200 | - * @param string $comment ='' comment to add to the link |
|
1201 | 1200 | */ |
1202 | 1201 | static function link_file($app,$id,$file)//,$comment='') |
1203 | 1202 | { |
@@ -1224,7 +1223,7 @@ discard block |
||
1224 | 1223 | * @param int|string $app > 0: file_id of an attchemnt or $app/$id entry which linked to |
1225 | 1224 | * @param string $id ='' id in app |
1226 | 1225 | * @param string $fname ='' filename |
1227 | - * @return boolean|array false on error ($app or $id not found), array with path as key and boolean result of delete |
|
1226 | + * @return boolean false on error ($app or $id not found), array with path as key and boolean result of delete |
|
1228 | 1227 | */ |
1229 | 1228 | static function delete_attached($app,$id='',$fname='') |
1230 | 1229 | { |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | /** |
114 | 114 | * appname used for returned attached files (!= 'filemanager'!) |
115 | 115 | */ |
116 | - const VFS_APPNAME = 'file'; // pseudo-appname for own file-attachments in vfs, this is NOT the vfs-app |
|
116 | + const VFS_APPNAME = 'file'; // pseudo-appname for own file-attachments in vfs, this is NOT the vfs-app |
|
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Appname used of files stored via Link::set_data() |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | 'icon' => 'addressbook/accounts', |
147 | 147 | 'query' => 'EGroupware\\Api\\Accounts::link_query', |
148 | 148 | 'title' => 'EGroupware\\Api\\Accounts::username', |
149 | - 'view' => array('menuaction'=>'addressbook.addressbook_ui.view','ajax'=>'true'), |
|
149 | + 'view' => array('menuaction'=>'addressbook.addressbook_ui.view', 'ajax'=>'true'), |
|
150 | 150 | 'view_id' => 'account_id' |
151 | 151 | ), |
152 | 152 | 'api' => array( |
@@ -207,19 +207,19 @@ discard block |
||
207 | 207 | // for performance reasons, we do it only once / cache it in the session |
208 | 208 | if (!($search_link_hooks = Cache::getSession(__CLASS__, 'search_link_hooks'))) |
209 | 209 | { |
210 | - $search_link_hooks = Hooks::process('search_link',array(), (bool)$GLOBALS['egw_info']['flags']['async-service']); |
|
210 | + $search_link_hooks = Hooks::process('search_link', array(), (bool)$GLOBALS['egw_info']['flags']['async-service']); |
|
211 | 211 | Cache::setSession(__CLASS__, 'search_link_hooks', $search_link_hooks); |
212 | 212 | } |
213 | 213 | if (is_array($search_link_hooks)) |
214 | 214 | { |
215 | - foreach($search_link_hooks as $app => $data) |
|
215 | + foreach ($search_link_hooks as $app => $data) |
|
216 | 216 | { |
217 | 217 | // allow apps to register additional types |
218 | 218 | if (isset($data['additional'])) |
219 | 219 | { |
220 | - foreach($data['additional'] as $name => $values) |
|
220 | + foreach ($data['additional'] as $name => $values) |
|
221 | 221 | { |
222 | - $values['app'] = $app; // store name of registring app, to be able to check access |
|
222 | + $values['app'] = $app; // store name of registring app, to be able to check access |
|
223 | 223 | self::$app_register[$name] = $values; |
224 | 224 | } |
225 | 225 | unset($data['additional']); |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | { |
230 | 230 | $data['list'] = array('menuaction' => $data['view_list']); |
231 | 231 | } |
232 | - elseif(isset($data['list']) && !isset($data['view_list'])) |
|
232 | + elseif (isset($data['list']) && !isset($data['view_list'])) |
|
233 | 233 | { |
234 | 234 | $data['view_list'] = $data['list']['menuaction']; |
235 | 235 | } |
@@ -273,18 +273,18 @@ discard block |
||
273 | 273 | public static function json_registry() |
274 | 274 | { |
275 | 275 | $to_json = array(); |
276 | - foreach(self::$app_register as $app => $data) |
|
276 | + foreach (self::$app_register as $app => $data) |
|
277 | 277 | { |
278 | 278 | if (isset($GLOBALS['egw_info']['user']['apps'][$app]) || |
279 | 279 | isset($data['app']) && isset($GLOBALS['egw_info']['user']['apps'][$data['app']])) |
280 | 280 | { |
281 | 281 | $to_json[$app] = array_intersect_key($data, array_flip(array( |
282 | - 'view','view_id','view_popup', |
|
283 | - 'add','add_app','add_id','add_popup', |
|
284 | - 'edit','edit_id','edit_popup', |
|
285 | - 'list','list_popup', |
|
286 | - 'name','icon','query', |
|
287 | - 'mime','entry','entries', |
|
282 | + 'view', 'view_id', 'view_popup', |
|
283 | + 'add', 'add_app', 'add_id', 'add_popup', |
|
284 | + 'edit', 'edit_id', 'edit_popup', |
|
285 | + 'list', 'list_popup', |
|
286 | + 'name', 'icon', 'query', |
|
287 | + 'mime', 'entry', 'entries', |
|
288 | 288 | ))); |
289 | 289 | } |
290 | 290 | } |
@@ -329,11 +329,11 @@ discard block |
||
329 | 329 | * @param int $no_notify =0 &1 dont notify $app1, &2 dont notify $app2 |
330 | 330 | * @return int/boolean False (for db or param-error) or on success link_id (Please not the return-value of $id1) |
331 | 331 | */ |
332 | - static function link( $app1,&$id1,$app2,$id2='',$remark='',$owner=0,$lastmod=0,$no_notify=0 ) |
|
332 | + static function link($app1, &$id1, $app2, $id2 = '', $remark = '', $owner = 0, $lastmod = 0, $no_notify = 0) |
|
333 | 333 | { |
334 | 334 | if (self::DEBUG) |
335 | 335 | { |
336 | - echo "<p>Link::link('$app1',$id1,'".print_r($app2,true)."',".print_r($id2,true).",'$remark',$owner,$lastmod)</p>\n"; |
|
336 | + echo "<p>Link::link('$app1',$id1,'".print_r($app2, true)."',".print_r($id2, true).",'$remark',$owner,$lastmod)</p>\n"; |
|
337 | 337 | } |
338 | 338 | if (!$app1 || !$app2 || $app1 == $app2 && $id1 == $id2) |
339 | 339 | { |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | } |
353 | 353 | if (is_array($id1) || !$id1) // create link only in $id1 array |
354 | 354 | { |
355 | - self::link($app1, $id1, $link['app'], $link['id'], $link['remark'],$link['owner'],$link['lastmod']); |
|
355 | + self::link($app1, $id1, $link['app'], $link['id'], $link['remark'], $link['owner'], $link['lastmod']); |
|
356 | 356 | continue; |
357 | 357 | } |
358 | 358 | switch ($link['app']) |
@@ -365,19 +365,19 @@ discard block |
||
365 | 365 | } |
366 | 366 | // fall through |
367 | 367 | case self::VFS_APPNAME: |
368 | - $link_id = self::attach_file($app1,$id1,$link['id'],$link['remark']); |
|
368 | + $link_id = self::attach_file($app1, $id1, $link['id'], $link['remark']); |
|
369 | 369 | break; |
370 | 370 | |
371 | 371 | case self::VFS_LINK: |
372 | - $link_id = self::link_file($app1,$id1, $link['id'],$link['remark']); |
|
372 | + $link_id = self::link_file($app1, $id1, $link['id'], $link['remark']); |
|
373 | 373 | break; |
374 | 374 | |
375 | 375 | default: |
376 | - $link_id = Link\Storage::link($app1,$id1,$link['app'],$link['id'], |
|
377 | - $link['remark'],$link['owner'],$link['lastmod']); |
|
376 | + $link_id = Link\Storage::link($app1, $id1, $link['app'], $link['id'], |
|
377 | + $link['remark'], $link['owner'], $link['lastmod']); |
|
378 | 378 | // notify both sides |
379 | - if (!($no_notify&2)) self::notify('link',$link['app'],$link['id'],$app1,$id1,$link_id); |
|
380 | - if (!($no_notify&1)) self::notify('link',$app1,$id1,$link['app'],$link['id'],$link_id); |
|
379 | + if (!($no_notify&2)) self::notify('link', $link['app'], $link['id'], $app1, $id1, $link_id); |
|
380 | + if (!($no_notify&1)) self::notify('link', $app1, $id1, $link['app'], $link['id'], $link_id); |
|
381 | 381 | break; |
382 | 382 | } |
383 | 383 | } |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | { |
390 | 390 | $id1 = array( ); |
391 | 391 | } |
392 | - $link_id = self::temp_link_id($app2,$id2); |
|
392 | + $link_id = self::temp_link_id($app2, $id2); |
|
393 | 393 | |
394 | 394 | $id1[$link_id] = array( |
395 | 395 | 'app' => $app2, |
@@ -407,24 +407,24 @@ discard block |
||
407 | 407 | } |
408 | 408 | if ($app1 == self::VFS_LINK) |
409 | 409 | { |
410 | - return self::link_file($app2,$id2,$id1,$remark); |
|
410 | + return self::link_file($app2, $id2, $id1, $remark); |
|
411 | 411 | } |
412 | 412 | elseif ($app2 == self::VFS_LINK) |
413 | 413 | { |
414 | - return self::link_file($app1,$id1,$id2,$remark); |
|
414 | + return self::link_file($app1, $id1, $id2, $remark); |
|
415 | 415 | } |
416 | 416 | if ($app1 == self::VFS_APPNAME) |
417 | 417 | { |
418 | - return self::attach_file($app2,$id2,$id1,$remark); |
|
418 | + return self::attach_file($app2, $id2, $id1, $remark); |
|
419 | 419 | } |
420 | 420 | elseif ($app2 == self::VFS_APPNAME) |
421 | 421 | { |
422 | - return self::attach_file($app1,$id1,$id2,$remark); |
|
422 | + return self::attach_file($app1, $id1, $id2, $remark); |
|
423 | 423 | } |
424 | - $link_id = Link\Storage::link($app1,$id1,$app2,$id2,$remark,$owner); |
|
424 | + $link_id = Link\Storage::link($app1, $id1, $app2, $id2, $remark, $owner); |
|
425 | 425 | |
426 | - if (!($no_notify&2)) self::notify('link',$app2,$id2,$app1,$id1,$link_id); |
|
427 | - if (!($no_notify&1)) self::notify('link',$app1,$id1,$app2,$id2,$link_id); |
|
426 | + if (!($no_notify&2)) self::notify('link', $app2, $id2, $app1, $id1, $link_id); |
|
427 | + if (!($no_notify&1)) self::notify('link', $app1, $id1, $app2, $id2, $link_id); |
|
428 | 428 | |
429 | 429 | return $link_id; |
430 | 430 | } |
@@ -436,9 +436,9 @@ discard block |
||
436 | 436 | * @param mixed $id |
437 | 437 | * @return string |
438 | 438 | */ |
439 | - static function temp_link_id($app,$id) |
|
439 | + static function temp_link_id($app, $id) |
|
440 | 440 | { |
441 | - return $app.':'.(!in_array($app, array(self::VFS_APPNAME,self::VFS_LINK, self::DATA_APPNAME)) ? $id : $id['name']); |
|
441 | + return $app.':'.(!in_array($app, array(self::VFS_APPNAME, self::VFS_LINK, self::DATA_APPNAME)) ? $id : $id['name']); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | /** |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | * @param int $limit =null number of entries to return, only affects links, attachments are allways reported! |
455 | 455 | * @return array id => links pairs if $id is an array or just the links (only_app: ids) or empty array if no matching links found |
456 | 456 | */ |
457 | - static function get_links($app, $id, $only_app='', $order='link_lastmod DESC',$cache_titles=false, $deleted=false, $limit=null) |
|
457 | + static function get_links($app, $id, $only_app = '', $order = 'link_lastmod DESC', $cache_titles = false, $deleted = false, $limit = null) |
|
458 | 458 | { |
459 | 459 | if (self::DEBUG) echo "<p>Link::get_links(app='$app',id='$id',only_app='$only_app',order='$order',deleted='$deleted')</p>\n"; |
460 | 460 | |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | { |
466 | 466 | if (($not_only = $only_app[0] == '!')) |
467 | 467 | { |
468 | - $only_app = substr(1,$only_app); |
|
468 | + $only_app = substr(1, $only_app); |
|
469 | 469 | } |
470 | 470 | foreach (array_reverse($id) as $link) |
471 | 471 | { |
@@ -482,7 +482,7 @@ discard block |
||
482 | 482 | if (empty($only_app) || $only_app == self::VFS_APPNAME || |
483 | 483 | ($only_app[0] == '!' && $only_app != '!'.self::VFS_APPNAME)) |
484 | 484 | { |
485 | - if (($vfs_ids = self::list_attached($app,$id))) |
|
485 | + if (($vfs_ids = self::list_attached($app, $id))) |
|
486 | 486 | { |
487 | 487 | $ids += $vfs_ids; |
488 | 488 | } |
@@ -492,18 +492,18 @@ discard block |
||
492 | 492 | { |
493 | 493 | // agregate links by app |
494 | 494 | $app_ids = array(); |
495 | - foreach($ids as $link) |
|
495 | + foreach ($ids as $link) |
|
496 | 496 | { |
497 | 497 | $app_ids[$link['app']][] = $link['id']; |
498 | 498 | } |
499 | - foreach($app_ids as $appname => $a_ids) |
|
499 | + foreach ($app_ids as $appname => $a_ids) |
|
500 | 500 | { |
501 | - self::titles($appname,array_unique($a_ids)); |
|
501 | + self::titles($appname, array_unique($a_ids)); |
|
502 | 502 | } |
503 | 503 | // remove links, current user has no access, from result |
504 | - foreach($ids as $key => $link) |
|
504 | + foreach ($ids as $key => $link) |
|
505 | 505 | { |
506 | - if (!self::title($link['app'],$link['id'])) |
|
506 | + if (!self::title($link['app'], $link['id'])) |
|
507 | 507 | { |
508 | 508 | unset($ids[$key]); |
509 | 509 | } |
@@ -525,27 +525,27 @@ discard block |
||
525 | 525 | * @param boolean $deleted =false Include links that have been flagged as deleted, waiting for purge of linked record. |
526 | 526 | * @return array of $id => array($links) pairs |
527 | 527 | */ |
528 | - static function get_links_multiple($app,array $ids,$cache_titles=true,$only_app='',$order='link_lastmod DESC', $deleted=false ) |
|
528 | + static function get_links_multiple($app, array $ids, $cache_titles = true, $only_app = '', $order = 'link_lastmod DESC', $deleted = false) |
|
529 | 529 | { |
530 | - if (self::DEBUG) echo "<p>".__METHOD__."('$app',".print_r($ids,true).",$cache_titles,'$only_app','$order')</p>\n"; |
|
530 | + if (self::DEBUG) echo "<p>".__METHOD__."('$app',".print_r($ids, true).",$cache_titles,'$only_app','$order')</p>\n"; |
|
531 | 531 | |
532 | 532 | if (!$ids) |
533 | 533 | { |
534 | - return array(); // no ids are linked to nothing |
|
534 | + return array(); // no ids are linked to nothing |
|
535 | 535 | } |
536 | - $links = Link\Storage::get_links($app,$ids,$only_app,$order,$deleted); |
|
536 | + $links = Link\Storage::get_links($app, $ids, $only_app, $order, $deleted); |
|
537 | 537 | |
538 | 538 | if (empty($only_app) || $only_app == self::VFS_APPNAME || |
539 | 539 | ($only_app[0] == '!' && $only_app != '!'.self::VFS_APPNAME)) |
540 | 540 | { |
541 | 541 | // todo do that in a single query, eg. directory listing, too |
542 | - foreach($ids as $id) |
|
542 | + foreach ($ids as $id) |
|
543 | 543 | { |
544 | 544 | if (!isset($links[$id])) |
545 | 545 | { |
546 | 546 | $links[$id] = array(); |
547 | 547 | } |
548 | - if (($vfs_ids = self::list_attached($app,$id))) |
|
548 | + if (($vfs_ids = self::list_attached($app, $id))) |
|
549 | 549 | { |
550 | 550 | $links[$id] += $vfs_ids; |
551 | 551 | } |
@@ -555,16 +555,16 @@ discard block |
||
555 | 555 | { |
556 | 556 | // agregate links by app |
557 | 557 | $app_ids = array(); |
558 | - foreach($links as &$targets) |
|
558 | + foreach ($links as &$targets) |
|
559 | 559 | { |
560 | - foreach($targets as $link) |
|
560 | + foreach ($targets as $link) |
|
561 | 561 | { |
562 | 562 | if (is_array($link)) $app_ids[$link['app']][] = $link['id']; |
563 | 563 | } |
564 | 564 | } |
565 | - foreach($app_ids as $app => $a_ids) |
|
565 | + foreach ($app_ids as $app => $a_ids) |
|
566 | 566 | { |
567 | - self::titles($app,array_unique($a_ids)); |
|
567 | + self::titles($app, array_unique($a_ids)); |
|
568 | 568 | } |
569 | 569 | } |
570 | 570 | return $links; |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | * @param string $id2 ='' id in $app2 |
582 | 582 | * @return array with link-data or False |
583 | 583 | */ |
584 | - static function get_link($app_link_id,$id='',$app2='',$id2='') |
|
584 | + static function get_link($app_link_id, $id = '', $app2 = '', $id2 = '') |
|
585 | 585 | { |
586 | 586 | if (self::DEBUG) |
587 | 587 | { |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | } |
590 | 590 | if (is_array($id)) |
591 | 591 | { |
592 | - if (strpos($app_link_id,':') === false) $app_link_id = self::temp_link_id($app2,$id2); // create link_id of temporary link, if not given |
|
592 | + if (strpos($app_link_id, ':') === false) $app_link_id = self::temp_link_id($app2, $id2); // create link_id of temporary link, if not given |
|
593 | 593 | |
594 | 594 | if (isset($id[$app_link_id]) && is_array($id[$app_link_id])) // check for unlinked-marker |
595 | 595 | { |
@@ -605,11 +605,11 @@ discard block |
||
605 | 605 | } |
606 | 606 | if ($app_link_id == self::VFS_APPNAME) |
607 | 607 | { |
608 | - return self::info_attached($app2,$id2,$id); |
|
608 | + return self::info_attached($app2, $id2, $id); |
|
609 | 609 | } |
610 | - return self::info_attached($app_link_id,$id,$id2); |
|
610 | + return self::info_attached($app_link_id, $id, $id2); |
|
611 | 611 | } |
612 | - return Link\Storage::get_link($app_link_id,$id,$app2,$id2); |
|
612 | + return Link\Storage::get_link($app_link_id, $id, $app2, $id2); |
|
613 | 613 | } |
614 | 614 | |
615 | 615 | /** |
@@ -627,9 +627,9 @@ discard block |
||
627 | 627 | * @param boolean $hold_for_purge Don't really delete the link, just mark it as deleted and wait for final delete |
628 | 628 | * @return the number of links deleted |
629 | 629 | */ |
630 | - static function unlink($link_id,$app='',$id='',$owner=0,$app2='',$id2='',$hold_for_purge=false) |
|
630 | + static function unlink($link_id, $app = '', $id = '', $owner = 0, $app2 = '', $id2 = '', $hold_for_purge = false) |
|
631 | 631 | { |
632 | - return self::unlink2($link_id,$app,$id,$owner,$app2,$id2,$hold_for_purge); |
|
632 | + return self::unlink2($link_id, $app, $id, $owner, $app2, $id2, $hold_for_purge); |
|
633 | 633 | } |
634 | 634 | |
635 | 635 | /** |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | * @param boolean $hold_for_purge Don't really delete the link, just mark it as deleted and wait for final delete |
645 | 645 | * @return the number of links deleted |
646 | 646 | */ |
647 | - static function unlink2($link_id,$app,&$id,$owner=0,$app2='',$id2='',$hold_for_purge=false) |
|
647 | + static function unlink2($link_id, $app, &$id, $owner = 0, $app2 = '', $id2 = '', $hold_for_purge = false) |
|
648 | 648 | { |
649 | 649 | if (self::DEBUG) |
650 | 650 | { |
@@ -656,22 +656,22 @@ discard block |
||
656 | 656 | } |
657 | 657 | elseif ($app == self::VFS_APPNAME) |
658 | 658 | { |
659 | - return self::delete_attached($app2,$id2,$id); |
|
659 | + return self::delete_attached($app2, $id2, $id); |
|
660 | 660 | } |
661 | 661 | elseif ($app2 == self::VFS_APPNAME) |
662 | 662 | { |
663 | - return self::delete_attached($app,$id,$id2); |
|
663 | + return self::delete_attached($app, $id, $id2); |
|
664 | 664 | } |
665 | 665 | if (!is_array($id)) |
666 | 666 | { |
667 | 667 | if (!$link_id && !$app2 && !$id2 && $app2 != '!'.self::VFS_APPNAME) |
668 | 668 | { |
669 | - self::delete_attached($app,$id); // deleting all attachments |
|
670 | - self::delete_cache($app,$id); |
|
669 | + self::delete_attached($app, $id); // deleting all attachments |
|
670 | + self::delete_cache($app, $id); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | // Log in history |
674 | - if($link_id && (!$app || !$app2)) |
|
674 | + if ($link_id && (!$app || !$app2)) |
|
675 | 675 | { |
676 | 676 | // Need to load it first |
677 | 677 | $link = self::get_link($link_id); |
@@ -682,21 +682,21 @@ discard block |
||
682 | 682 | } |
683 | 683 | if ($app && $app2) |
684 | 684 | { |
685 | - Storage\History::static_add($app,$id,$GLOBALS['egw_info']['user']['account_id'],'~link~','',$app2.':'.$id2); |
|
686 | - Storage\History::static_add($app2,$id2,$GLOBALS['egw_info']['user']['account_id'],'~link~','',$app.':'.$id); |
|
685 | + Storage\History::static_add($app, $id, $GLOBALS['egw_info']['user']['account_id'], '~link~', '', $app2.':'.$id2); |
|
686 | + Storage\History::static_add($app2, $id2, $GLOBALS['egw_info']['user']['account_id'], '~link~', '', $app.':'.$id); |
|
687 | 687 | } |
688 | - $deleted =& Link\Storage::unlink($link_id,$app,$id,$owner,$app2 != '!'.self::VFS_APPNAME ? $app2 : '',$id2,$hold_for_purge); |
|
688 | + $deleted = & Link\Storage::unlink($link_id, $app, $id, $owner, $app2 != '!'.self::VFS_APPNAME ? $app2 : '', $id2, $hold_for_purge); |
|
689 | 689 | |
690 | 690 | // only notify on real links, not the one cached for writing or fileattachments |
691 | 691 | self::notify_unlink($deleted); |
692 | 692 | |
693 | 693 | return count($deleted); |
694 | 694 | } |
695 | - if (!$link_id) $link_id = self::temp_link_id($app2,$id2); // create link_id of temporary link, if not given |
|
695 | + if (!$link_id) $link_id = self::temp_link_id($app2, $id2); // create link_id of temporary link, if not given |
|
696 | 696 | |
697 | 697 | if (isset($id[$link_id])) |
698 | 698 | { |
699 | - $id[$link_id] = False; // set the unlink marker |
|
699 | + $id[$link_id] = False; // set the unlink marker |
|
700 | 700 | |
701 | 701 | if (self::DEBUG) |
702 | 702 | { |
@@ -713,10 +713,10 @@ discard block |
||
713 | 713 | * @param string $must_support capability the apps need to support, eg. 'add', default ''=list all apps |
714 | 714 | * @return array with app => title pairs |
715 | 715 | */ |
716 | - static function app_list($must_support='') |
|
716 | + static function app_list($must_support = '') |
|
717 | 717 | { |
718 | 718 | $apps = array(); |
719 | - foreach(self::$app_register as $type => $reg) |
|
719 | + foreach (self::$app_register as $type => $reg) |
|
720 | 720 | { |
721 | 721 | if ($must_support && !isset($reg[$must_support])) continue; |
722 | 722 | |
@@ -773,11 +773,11 @@ discard block |
||
773 | 773 | * @param array $link =null link-data for file-attachments |
774 | 774 | * @return string/boolean string with title, null if $id does not exist in $app or false if no perms to view it |
775 | 775 | */ |
776 | - static function title($app,$id,$link=null) |
|
776 | + static function title($app, $id, $link = null) |
|
777 | 777 | { |
778 | 778 | if (!$id) return ''; |
779 | 779 | |
780 | - $title =& self::get_cache($app,$id); |
|
780 | + $title = & self::get_cache($app, $id); |
|
781 | 781 | if (isset($title) && !empty($title) && !is_array($id)) |
782 | 782 | { |
783 | 783 | if (self::DEBUG) echo '<p>'.__METHOD__."('$app','$id')='$title' (from cache)</p>\n"; |
@@ -819,7 +819,7 @@ discard block |
||
819 | 819 | if (!isset($unlinking[$app]) || !isset($unlinking[$app][$id])) |
820 | 820 | { |
821 | 821 | $unlinking[$app][$id] = true; |
822 | - self::unlink(0,$app,$id); |
|
822 | + self::unlink(0, $app, $id); |
|
823 | 823 | unset($unlinking[$app][$id]); |
824 | 824 | } |
825 | 825 | if (self::DEBUG) echo '<p>'.__METHOD__."('$app','$id') unlinked, as $method returned null</p>\n"; |
@@ -844,36 +844,36 @@ discard block |
||
844 | 844 | * @param string $app |
845 | 845 | * @param array $ids |
846 | 846 | */ |
847 | - static function titles($app,array $ids) |
|
847 | + static function titles($app, array $ids) |
|
848 | 848 | { |
849 | 849 | if (self::DEBUG) |
850 | 850 | { |
851 | - echo "<p>".__METHOD__."($app,".implode(',',$ids).")</p>\n"; |
|
851 | + echo "<p>".__METHOD__."($app,".implode(',', $ids).")</p>\n"; |
|
852 | 852 | } |
853 | 853 | $titles = $ids_to_query = array(); |
854 | - foreach($ids as $id) |
|
854 | + foreach ($ids as $id) |
|
855 | 855 | { |
856 | - $title =& self::get_cache($app,$id); |
|
856 | + $title = & self::get_cache($app, $id); |
|
857 | 857 | if (!isset($title)) |
858 | 858 | { |
859 | 859 | if (isset(self::$app_register[$app]['titles'])) |
860 | 860 | { |
861 | - $ids_to_query[] = $id; // titles method --> collect links to query at once |
|
861 | + $ids_to_query[] = $id; // titles method --> collect links to query at once |
|
862 | 862 | } |
863 | 863 | else |
864 | 864 | { |
865 | - $title = self::title($app,$id); // no titles method --> fallback to query each link separate |
|
865 | + $title = self::title($app, $id); // no titles method --> fallback to query each link separate |
|
866 | 866 | } |
867 | 867 | } |
868 | 868 | $titles[$id] = $title; |
869 | 869 | } |
870 | 870 | if ($ids_to_query) |
871 | 871 | { |
872 | - for ($n = 0; ($ids = array_slice($ids_to_query,$n*self::MAX_TITLES_QUERY,self::MAX_TITLES_QUERY)); ++$n) |
|
872 | + for ($n = 0; ($ids = array_slice($ids_to_query, $n * self::MAX_TITLES_QUERY, self::MAX_TITLES_QUERY)); ++$n) |
|
873 | 873 | { |
874 | - foreach(self::exec(self::$app_register[$app]['titles'], array($ids)) as $id => $t) |
|
874 | + foreach (self::exec(self::$app_register[$app]['titles'], array($ids)) as $id => $t) |
|
875 | 875 | { |
876 | - $title =& self::get_cache($app,$id); |
|
876 | + $title = & self::get_cache($app, $id); |
|
877 | 877 | $titles[$id] = $title = $t; |
878 | 878 | } |
879 | 879 | } |
@@ -889,7 +889,7 @@ discard block |
||
889 | 889 | * @param string $to_id =''id in $to_app |
890 | 890 | * @return array/boolean with name-value pairs for link to add-methode of $app or false if add not supported |
891 | 891 | */ |
892 | - static function add($app,$to_app='',$to_id='') |
|
892 | + static function add($app, $to_app = '', $to_id = '') |
|
893 | 893 | { |
894 | 894 | //echo "<p>Link::add('$app','$to_app','$to_id') app_register[$app] ="; _debug_array($app_register[$app]); |
895 | 895 | if ($app == '' || !is_array($reg = self::$app_register[$app]) || !isset($reg['add'])) |
@@ -914,7 +914,7 @@ discard block |
||
914 | 914 | * @param string &$popup=null on return popup size eg. '600x400' or null |
915 | 915 | * @return array|boolean with name-value pairs for link to edit-methode of $app or false if edit not supported |
916 | 916 | */ |
917 | - static function edit($app,$id,&$popup=null) |
|
917 | + static function edit($app, $id, &$popup = null) |
|
918 | 918 | { |
919 | 919 | //echo "<p>Link::add('$app','$to_app','$to_id') app_register[$app] ="; _debug_array($app_register[$app]); |
920 | 920 | if (empty($app) || empty($id) || !is_array($reg = self::$app_register[$app]) || !isset($reg['edit'])) |
@@ -922,7 +922,7 @@ discard block |
||
922 | 922 | if ($reg && isset($reg['view'])) |
923 | 923 | { |
924 | 924 | $popup = $reg['view_popup']; |
925 | - return self::view($app,$id); // fallback to view |
|
925 | + return self::view($app, $id); // fallback to view |
|
926 | 926 | } |
927 | 927 | return false; |
928 | 928 | } |
@@ -942,12 +942,12 @@ discard block |
||
942 | 942 | * @param array $link =null link-data for file-attachments |
943 | 943 | * @return array with name-value pairs for link to view-methode of $app to view $id |
944 | 944 | */ |
945 | - static function view($app,$id,$link=null) |
|
945 | + static function view($app, $id, $link = null) |
|
946 | 946 | { |
947 | 947 | if ($app == self::VFS_APPNAME && !empty($id) && is_array($link)) |
948 | 948 | { |
949 | 949 | //return Vfs::download_url(self::vfs_path($link['app2'],$link['id2'],$link['id'],true)); |
950 | - return self::mime_open(self::vfs_path($link['app2'],$link['id2'],$link['id'],true), $link['type']); |
|
950 | + return self::mime_open(self::vfs_path($link['app2'], $link['id2'], $link['id'], true), $link['type']); |
|
951 | 951 | } |
952 | 952 | if ($app == '' || !is_array($reg = self::$app_register[$app]) || !isset($reg['view']) || !isset($reg['view_id'])) |
953 | 953 | { |
@@ -955,11 +955,11 @@ discard block |
||
955 | 955 | } |
956 | 956 | $view = $reg['view']; |
957 | 957 | |
958 | - $names = explode(':',$reg['view_id']); |
|
958 | + $names = explode(':', $reg['view_id']); |
|
959 | 959 | if (count($names) > 1) |
960 | 960 | { |
961 | - $id = explode(':',$id); |
|
962 | - while (list($n,$name) = each($names)) |
|
961 | + $id = explode(':', $id); |
|
962 | + while (list($n, $name) = each($names)) |
|
963 | 963 | { |
964 | 964 | $view[$name] = $id[$n]; |
965 | 965 | } |
@@ -983,13 +983,13 @@ discard block |
||
983 | 983 | */ |
984 | 984 | static function get_mime_info($type) |
985 | 985 | { |
986 | - foreach(self::$app_register as $app => $registry) |
|
986 | + foreach (self::$app_register as $app => $registry) |
|
987 | 987 | { |
988 | 988 | if (isset($registry['mime']) && |
989 | 989 | (isset($GLOBALS['egw_info']['user']['apps'][$app]) || |
990 | 990 | isset($registry['app']) && isset($GLOBALS['egw_info']['user']['apps'][$registry['app']]))) |
991 | 991 | { |
992 | - foreach($registry['mime'] as $mime => $data) |
|
992 | + foreach ($registry['mime'] as $mime => $data) |
|
993 | 993 | { |
994 | 994 | if ($mime == $type) return $data; |
995 | 995 | if ($mime[0] == '/' && preg_match($mime.'i', $type)) |
@@ -1010,7 +1010,7 @@ discard block |
||
1010 | 1010 | * @param string &$popup=null on return popup size or null |
1011 | 1011 | * @return string|array string with EGw relative link, array with get-parameters for '/index.php' or null (directory and not filemanager access) |
1012 | 1012 | */ |
1013 | - static function mime_open($path, $type=null, &$popup=null) |
|
1013 | + static function mime_open($path, $type = null, &$popup = null) |
|
1014 | 1014 | { |
1015 | 1015 | if (is_null($type)) $type = Vfs::mime_content_type($path); |
1016 | 1016 | |
@@ -1026,7 +1026,7 @@ discard block |
||
1026 | 1026 | $data[$data['mime_id']] = $path; |
1027 | 1027 | unset($data['mime_id']); |
1028 | 1028 | } |
1029 | - elseif(isset($data['mime_popup'])) |
|
1029 | + elseif (isset($data['mime_popup'])) |
|
1030 | 1030 | { |
1031 | 1031 | $popup = $data['mime_popup']; |
1032 | 1032 | } |
@@ -1051,9 +1051,9 @@ discard block |
||
1051 | 1051 | * @param array $link =null link-data for file-attachments |
1052 | 1052 | * @return boolean|string false if no popup is used or $app is not registered, otherwise string with the prefered popup size (eg. '640x400) |
1053 | 1053 | */ |
1054 | - static function is_popup($app, $action='view', $link=null) |
|
1054 | + static function is_popup($app, $action = 'view', $link = null) |
|
1055 | 1055 | { |
1056 | - $popup = self::get_registry($app,$action.'_popup'); |
|
1056 | + $popup = self::get_registry($app, $action.'_popup'); |
|
1057 | 1057 | |
1058 | 1058 | // for files/attachments check mime-registry |
1059 | 1059 | if ($app == self::VFS_APPNAME && is_array($link) && !empty($link['type'])) |
@@ -1076,7 +1076,7 @@ discard block |
||
1076 | 1076 | * @param string $name name / key in the registry, eg. 'view' |
1077 | 1077 | * @return boolean|string false if $app is not registered, otherwise string with the value for $name |
1078 | 1078 | */ |
1079 | - static function get_registry($app,$name) |
|
1079 | + static function get_registry($app, $name) |
|
1080 | 1080 | { |
1081 | 1081 | $reg = self::$app_register[$app]; |
1082 | 1082 | |
@@ -1084,7 +1084,7 @@ discard block |
||
1084 | 1084 | |
1085 | 1085 | if (!isset($reg[$name])) // some defaults |
1086 | 1086 | { |
1087 | - switch($name) |
|
1087 | + switch ($name) |
|
1088 | 1088 | { |
1089 | 1089 | case 'name': |
1090 | 1090 | $reg[$name] = $app; |
@@ -1120,16 +1120,16 @@ discard block |
||
1120 | 1120 | * @param boolean $just_the_path =false return url or just the vfs path |
1121 | 1121 | * @return string/array path or array with path and relatives, depending on $relatives |
1122 | 1122 | */ |
1123 | - static function vfs_path($app,$id='',$file='',$just_the_path=false) |
|
1123 | + static function vfs_path($app, $id = '', $file = '', $just_the_path = false) |
|
1124 | 1124 | { |
1125 | 1125 | $path = self::VFS_BASEURL; |
1126 | 1126 | |
1127 | 1127 | if ($app) |
1128 | 1128 | { |
1129 | - if( isset(self::$app_register[$app]) ) { |
|
1129 | + if (isset(self::$app_register[$app])) { |
|
1130 | 1130 | $reg = self::$app_register[$app]; |
1131 | 1131 | |
1132 | - if( isset($reg['file_dir']) ) { |
|
1132 | + if (isset($reg['file_dir'])) { |
|
1133 | 1133 | $app = $reg['file_dir']; |
1134 | 1134 | } |
1135 | 1135 | } |
@@ -1148,7 +1148,7 @@ discard block |
||
1148 | 1148 | } |
1149 | 1149 | if ($just_the_path) |
1150 | 1150 | { |
1151 | - $path = parse_url($path,PHP_URL_PATH); |
|
1151 | + $path = parse_url($path, PHP_URL_PATH); |
|
1152 | 1152 | } |
1153 | 1153 | else |
1154 | 1154 | { |
@@ -1172,16 +1172,16 @@ discard block |
||
1172 | 1172 | * @param string $comment ='' comment to add to the link |
1173 | 1173 | * @return int negative id of egw_sqlfs table as negative link-id's are for vfs attachments |
1174 | 1174 | */ |
1175 | - static function attach_file($app,$id,$file,$comment='') |
|
1175 | + static function attach_file($app, $id, $file, $comment = '') |
|
1176 | 1176 | { |
1177 | - $entry_dir = self::vfs_path($app,$id); |
|
1177 | + $entry_dir = self::vfs_path($app, $id); |
|
1178 | 1178 | if (self::DEBUG) |
1179 | 1179 | { |
1180 | 1180 | echo "<p>attach_file: app='$app', id='$id', tmp_name='$file[tmp_name]', name='$file[name]', size='$file[size]', type='$file[type]', path='$file[path]', ip='$file[ip]', comment='$comment', entry_dir='$entry_dir'</p>\n"; |
1181 | 1181 | } |
1182 | - if (file_exists($entry_dir) || ($Ok = mkdir($entry_dir,0,true))) |
|
1182 | + if (file_exists($entry_dir) || ($Ok = mkdir($entry_dir, 0, true))) |
|
1183 | 1183 | { |
1184 | - $Ok = Vfs::copy_uploaded($file, $p=self::vfs_path($app,$id,'',true), $comment, false); // no is_uploaded_file() check! |
|
1184 | + $Ok = Vfs::copy_uploaded($file, $p = self::vfs_path($app, $id, '', true), $comment, false); // no is_uploaded_file() check! |
|
1185 | 1185 | if (!$Ok) error_log(__METHOD__."('$app', '$id', ".array2string($file).", '$comment') called Vfs::copy_uploaded('$file[tmp_name]', '$p', '$comment', false)=".array2string($Ok)); |
1186 | 1186 | } |
1187 | 1187 | else |
@@ -1199,24 +1199,24 @@ discard block |
||
1199 | 1199 | * @param string $file VFS path to link to |
1200 | 1200 | * @param string $comment ='' comment to add to the link |
1201 | 1201 | */ |
1202 | - static function link_file($app,$id,$file)//,$comment='') |
|
1202 | + static function link_file($app, $id, $file)//,$comment='') |
|
1203 | 1203 | { |
1204 | 1204 | // Don't try to link into app dir if there is no id |
1205 | - if(!$id) return; |
|
1205 | + if (!$id) return; |
|
1206 | 1206 | |
1207 | - $app_path = self::vfs_path($app,$id); |
|
1207 | + $app_path = self::vfs_path($app, $id); |
|
1208 | 1208 | $ok = true; |
1209 | - if (Vfs::file_exists($app_path) || ($ok = Vfs::mkdir($app_path,0,true))) |
|
1209 | + if (Vfs::file_exists($app_path) || ($ok = Vfs::mkdir($app_path, 0, true))) |
|
1210 | 1210 | { |
1211 | 1211 | if (!Vfs::stat($file)) |
1212 | 1212 | { |
1213 | - error_log(__METHOD__. ' (Link target ' . Vfs::decodePath($file) . ' not found!'); |
|
1213 | + error_log(__METHOD__.' (Link target '.Vfs::decodePath($file).' not found!'); |
|
1214 | 1214 | return false; |
1215 | 1215 | } |
1216 | 1216 | } |
1217 | 1217 | |
1218 | - $link = Vfs::concat($app_path,Vfs::basename($file)); |
|
1219 | - return Vfs::symlink($file,$link); |
|
1218 | + $link = Vfs::concat($app_path, Vfs::basename($file)); |
|
1219 | + return Vfs::symlink($file, $link); |
|
1220 | 1220 | } |
1221 | 1221 | /** |
1222 | 1222 | * deletes a single or all attached files of an entry (for all there's no acl check, as the entry probably not exists any more!) |
@@ -1226,7 +1226,7 @@ discard block |
||
1226 | 1226 | * @param string $fname ='' filename |
1227 | 1227 | * @return boolean|array false on error ($app or $id not found), array with path as key and boolean result of delete |
1228 | 1228 | */ |
1229 | - static function delete_attached($app,$id='',$fname='') |
|
1229 | + static function delete_attached($app, $id = '', $fname = '') |
|
1230 | 1230 | { |
1231 | 1231 | if ((int)$app > 0) // is file_id |
1232 | 1232 | { |
@@ -1236,9 +1236,9 @@ discard block |
||
1236 | 1236 | { |
1237 | 1237 | if (empty($app) || empty($id)) |
1238 | 1238 | { |
1239 | - return False; // dont delete more than all attachments of an entry |
|
1239 | + return False; // dont delete more than all attachments of an entry |
|
1240 | 1240 | } |
1241 | - $url = self::vfs_path($app,$id,$fname); |
|
1241 | + $url = self::vfs_path($app, $id, $fname); |
|
1242 | 1242 | |
1243 | 1243 | if (!$fname || !$id) // we delete the whole entry (or all entries), which probably not exist anymore |
1244 | 1244 | { |
@@ -1251,15 +1251,15 @@ discard block |
||
1251 | 1251 | echo '<p>'.__METHOD__."('$app','$id','$fname') url=$url</p>\n"; |
1252 | 1252 | } |
1253 | 1253 | // Log in history - Need to load it first |
1254 | - if((int)$app > 0) |
|
1254 | + if ((int)$app > 0) |
|
1255 | 1255 | { |
1256 | 1256 | $link = self::get_link(-$app); |
1257 | - if($link['app2'] && $link['id2']) |
|
1257 | + if ($link['app2'] && $link['id2']) |
|
1258 | 1258 | { |
1259 | - Storage\History::static_add($link['app2'],$link['id2'],$GLOBALS['egw_info']['user']['account_id'],'~file~','', basename($url)); |
|
1259 | + Storage\History::static_add($link['app2'], $link['id2'], $GLOBALS['egw_info']['user']['account_id'], '~file~', '', basename($url)); |
|
1260 | 1260 | } |
1261 | 1261 | } |
1262 | - if (($Ok = !file_exists($url) || Vfs::remove($url,true)) && ((int)$app > 0 || $fname)) |
|
1262 | + if (($Ok = !file_exists($url) || Vfs::remove($url, true)) && ((int)$app > 0 || $fname)) |
|
1263 | 1263 | { |
1264 | 1264 | // try removing the dir, in case it's empty |
1265 | 1265 | if (($dir = Vfs::dirname($url))) @Vfs::rmdir($dir); |
@@ -1279,14 +1279,14 @@ discard block |
||
1279 | 1279 | * @param string $filename filename |
1280 | 1280 | * @return array 'kind' of link-array |
1281 | 1281 | */ |
1282 | - static function info_attached($app,$id,$filename) |
|
1282 | + static function info_attached($app, $id, $filename) |
|
1283 | 1283 | { |
1284 | - $path = self::vfs_path($app,$id,$filename,true); |
|
1285 | - if (!($stat = Vfs::stat($path,STREAM_URL_STAT_QUIET))) |
|
1284 | + $path = self::vfs_path($app, $id, $filename, true); |
|
1285 | + if (!($stat = Vfs::stat($path, STREAM_URL_STAT_QUIET))) |
|
1286 | 1286 | { |
1287 | 1287 | return false; |
1288 | 1288 | } |
1289 | - return self::fileinfo2link($stat,$path); |
|
1289 | + return self::fileinfo2link($stat, $path); |
|
1290 | 1290 | } |
1291 | 1291 | |
1292 | 1292 | /** |
@@ -1295,36 +1295,36 @@ discard block |
||
1295 | 1295 | * @param array|int $fileinfo a row from the vfs-db-table (eg. returned by the vfs ls static function) or a file_id of that table |
1296 | 1296 | * @return array a 'kind' of link-array |
1297 | 1297 | */ |
1298 | - static function fileinfo2link($fileinfo,$url=null) |
|
1298 | + static function fileinfo2link($fileinfo, $url = null) |
|
1299 | 1299 | { |
1300 | 1300 | if (!is_array($fileinfo)) |
1301 | 1301 | { |
1302 | 1302 | $url = Vfs\Sqlfs\StreamWrapper::id2path($fileinfo); |
1303 | - if (!($fileinfo = Vfs::url_stat($url,STREAM_URL_STAT_QUIET))) |
|
1303 | + if (!($fileinfo = Vfs::url_stat($url, STREAM_URL_STAT_QUIET))) |
|
1304 | 1304 | { |
1305 | 1305 | return false; |
1306 | 1306 | } |
1307 | 1307 | } |
1308 | 1308 | |
1309 | - $up = explode('/',$url[0] == '/' ? $url : parse_url($url,PHP_URL_PATH)); // /apps/$app/$id |
|
1309 | + $up = explode('/', $url[0] == '/' ? $url : parse_url($url, PHP_URL_PATH)); // /apps/$app/$id |
|
1310 | 1310 | $app = null; |
1311 | 1311 | |
1312 | - foreach( self::$app_register as $tapp => $reg ) { |
|
1313 | - if( isset($reg['file_dir']) ) { |
|
1312 | + foreach (self::$app_register as $tapp => $reg) { |
|
1313 | + if (isset($reg['file_dir'])) { |
|
1314 | 1314 | $lup = $up; |
1315 | 1315 | |
1316 | 1316 | unset($lup[0]); |
1317 | 1317 | unset($lup[1]); |
1318 | 1318 | reset($lup); |
1319 | 1319 | |
1320 | - $fdp = explode('/',$reg['file_dir'][0] == '/' ? |
|
1321 | - $reg['file_dir'] : parse_url($reg['file_dir'],PHP_URL_PATH)); |
|
1320 | + $fdp = explode('/', $reg['file_dir'][0] == '/' ? |
|
1321 | + $reg['file_dir'] : parse_url($reg['file_dir'], PHP_URL_PATH)); |
|
1322 | 1322 | |
1323 | 1323 | $found = true; |
1324 | 1324 | |
1325 | - foreach( $fdp as $part ) { |
|
1326 | - if( current($lup) == $part ) { |
|
1327 | - if( next($lup) === false ) { |
|
1325 | + foreach ($fdp as $part) { |
|
1326 | + if (current($lup) == $part) { |
|
1327 | + if (next($lup) === false) { |
|
1328 | 1328 | $found = false; |
1329 | 1329 | break; |
1330 | 1330 | } |
@@ -1335,16 +1335,16 @@ discard block |
||
1335 | 1335 | } |
1336 | 1336 | } |
1337 | 1337 | |
1338 | - if( $found ) { |
|
1339 | - $id = current($lup); |
|
1338 | + if ($found) { |
|
1339 | + $id = current($lup); |
|
1340 | 1340 | $app = $tapp; |
1341 | 1341 | break; |
1342 | 1342 | } |
1343 | 1343 | } |
1344 | 1344 | } |
1345 | 1345 | |
1346 | - if( $app === null ) { |
|
1347 | - list(,,$app,$id) = $up; |
|
1346 | + if ($app === null) { |
|
1347 | + list(,, $app, $id) = $up; |
|
1348 | 1348 | } |
1349 | 1349 | |
1350 | 1350 | return array( |
@@ -1352,7 +1352,7 @@ discard block |
||
1352 | 1352 | 'id' => $fileinfo['name'], |
1353 | 1353 | 'app2' => $app, |
1354 | 1354 | 'id2' => $id, |
1355 | - 'remark' => '', // only list_attached currently sets the remark |
|
1355 | + 'remark' => '', // only list_attached currently sets the remark |
|
1356 | 1356 | 'owner' => $fileinfo['uid'], |
1357 | 1357 | 'link_id' => -$fileinfo['ino'], |
1358 | 1358 | 'lastmod' => $fileinfo['mtime'], |
@@ -1368,26 +1368,26 @@ discard block |
||
1368 | 1368 | * @param string $id id in app |
1369 | 1369 | * @return array with link_id => 'kind' of link-array pairs |
1370 | 1370 | */ |
1371 | - static function list_attached($app,$id) |
|
1371 | + static function list_attached($app, $id) |
|
1372 | 1372 | { |
1373 | - $path = self::vfs_path($app,$id); |
|
1373 | + $path = self::vfs_path($app, $id); |
|
1374 | 1374 | //error_log(__METHOD__."($app,$id) url=$url"); |
1375 | 1375 | |
1376 | - if (!($extra = self::get_registry($app,'find_extra'))) $extra = array(); |
|
1376 | + if (!($extra = self::get_registry($app, 'find_extra'))) $extra = array(); |
|
1377 | 1377 | |
1378 | 1378 | // always use regular links stream wrapper here: extended one is unnecessary (slow) for just listing attachments |
1379 | - if (substr($path,0,13) == 'stylite.links') $path = substr($path,8); |
|
1379 | + if (substr($path, 0, 13) == 'stylite.links') $path = substr($path, 8); |
|
1380 | 1380 | |
1381 | 1381 | $attached = array(); |
1382 | - if (($url2stats = Vfs::find($path,array('need_mime'=>true,'type'=>'F','url'=>true)+$extra,true))) |
|
1382 | + if (($url2stats = Vfs::find($path, array('need_mime'=>true, 'type'=>'F', 'url'=>true) + $extra, true))) |
|
1383 | 1383 | { |
1384 | - $props = Vfs::propfind(array_keys($url2stats)); // get the comments |
|
1385 | - foreach($url2stats as $url => &$fileinfo) |
|
1384 | + $props = Vfs::propfind(array_keys($url2stats)); // get the comments |
|
1385 | + foreach ($url2stats as $url => &$fileinfo) |
|
1386 | 1386 | { |
1387 | - $link = self::fileinfo2link($fileinfo,$url); |
|
1387 | + $link = self::fileinfo2link($fileinfo, $url); |
|
1388 | 1388 | if ($props && isset($props[$url])) |
1389 | 1389 | { |
1390 | - foreach($props[$url] as $prop) |
|
1390 | + foreach ($props[$url] as $prop) |
|
1391 | 1391 | { |
1392 | 1392 | if ($prop['ns'] == Vfs::DEFAULT_PROP_NAMESPACE && $prop['name'] == 'comment') |
1393 | 1393 | { |
@@ -1409,7 +1409,7 @@ discard block |
||
1409 | 1409 | */ |
1410 | 1410 | static private function decode_htmlspecialchars($str) |
1411 | 1411 | { |
1412 | - return str_replace(array('&','"','<','>'),array('&','"','<','>'),$str); |
|
1412 | + return str_replace(array('&', '"', '<', '>'), array('&', '"', '<', '>'), $str); |
|
1413 | 1413 | } |
1414 | 1414 | |
1415 | 1415 | /** |
@@ -1427,18 +1427,18 @@ discard block |
||
1427 | 1427 | * @param string $id id in $app of the updated entry |
1428 | 1428 | * @param array $data =null updated data of changed entry, as the read-method of the BO-layer would supply it |
1429 | 1429 | */ |
1430 | - static function notify_update($app,$id,$data=null) |
|
1430 | + static function notify_update($app, $id, $data = null) |
|
1431 | 1431 | { |
1432 | - self::delete_cache($app,$id); |
|
1432 | + self::delete_cache($app, $id); |
|
1433 | 1433 | //error_log(__METHOD__."('$app', $id, $data)"); |
1434 | - foreach(self::get_links($app,$id,'!'.self::VFS_APPNAME) as $link_id => $link) |
|
1434 | + foreach (self::get_links($app, $id, '!'.self::VFS_APPNAME) as $link_id => $link) |
|
1435 | 1435 | { |
1436 | - self::notify('update',$link['app'],$link['id'],$app,$id,$link_id,$data); |
|
1436 | + self::notify('update', $link['app'], $link['id'], $app, $id, $link_id, $data); |
|
1437 | 1437 | } |
1438 | - if($data[Link::OLD_LINK_TITLE] && Json\Response::isJSONResponse()) |
|
1438 | + if ($data[Link::OLD_LINK_TITLE] && Json\Response::isJSONResponse()) |
|
1439 | 1439 | { |
1440 | 1440 | // Update client side with new title |
1441 | - Json\Response::get()->apply('egw.link_title_callback',array(array($app => array($id => self::title($app, $id))))); |
|
1441 | + Json\Response::get()->apply('egw.link_title_callback', array(array($app => array($id => self::title($app, $id))))); |
|
1442 | 1442 | } |
1443 | 1443 | } |
1444 | 1444 | |
@@ -1462,7 +1462,7 @@ discard block |
||
1462 | 1462 | * @param string $target_id id in $target_app |
1463 | 1463 | * @param array $data =null data of entry in app2 (optional) |
1464 | 1464 | */ |
1465 | - static private function notify($type,$notify_app,$notify_id,$target_app,$target_id,$link_id,$data=null) |
|
1465 | + static private function notify($type, $notify_app, $notify_id, $target_app, $target_id, $link_id, $data = null) |
|
1466 | 1466 | { |
1467 | 1467 | //error_log(__METHOD__."('$type', '$notify_app', $notify_id, '$target_app', $target_id, $link_id, $data)"); |
1468 | 1468 | if ($link_id && isset(self::$app_register[$notify_app]) && isset(self::$app_register[$notify_app]['notify'])) |
@@ -1489,7 +1489,7 @@ discard block |
||
1489 | 1489 | static public function run_notifies() |
1490 | 1490 | { |
1491 | 1491 | //error_log(__METHOD__."() count(self::\$notifies)=".count(self::$notifies)); |
1492 | - while(self::$notifies) |
|
1492 | + while (self::$notifies) |
|
1493 | 1493 | { |
1494 | 1494 | $args = array_shift(self::$notifies); |
1495 | 1495 | $method = $args['method']; |
@@ -1507,11 +1507,11 @@ discard block |
||
1507 | 1507 | */ |
1508 | 1508 | static private function notify_unlink(&$links) |
1509 | 1509 | { |
1510 | - foreach($links as $link) |
|
1510 | + foreach ($links as $link) |
|
1511 | 1511 | { |
1512 | 1512 | // we notify both sides of the link, as the unlink command NOT clearly knows which side initiated the unlink |
1513 | - self::notify('unlink',$link['link_app1'],$link['link_id1'],$link['link_app2'],$link['link_id2'],$link['link_id']); |
|
1514 | - self::notify('unlink',$link['link_app2'],$link['link_id2'],$link['link_app1'],$link['link_id1'],$link['link_id']); |
|
1513 | + self::notify('unlink', $link['link_app1'], $link['link_id1'], $link['link_app2'], $link['link_id2'], $link['link_id']); |
|
1514 | + self::notify('unlink', $link['link_app2'], $link['link_id2'], $link['link_app1'], $link['link_id1'], $link['link_id']); |
|
1515 | 1515 | } |
1516 | 1516 | } |
1517 | 1517 | |
@@ -1523,9 +1523,9 @@ discard block |
||
1523 | 1523 | * @param string $type ='title' 'title' or 'file_access' |
1524 | 1524 | * @return int|string can be null, if cache not yet set |
1525 | 1525 | */ |
1526 | - private static function &get_cache($app,$id,$type = 'title') |
|
1526 | + private static function &get_cache($app, $id, $type = 'title') |
|
1527 | 1527 | { |
1528 | - switch($type) |
|
1528 | + switch ($type) |
|
1529 | 1529 | { |
1530 | 1530 | case 'title': |
1531 | 1531 | return self::$title_cache[$app.':'.$id]; |
@@ -1548,7 +1548,7 @@ discard block |
||
1548 | 1548 | * @param string $title title string or null |
1549 | 1549 | * @param int $file_access =null Acl::READ, Acl::EDIT or both or'ed together |
1550 | 1550 | */ |
1551 | - public static function set_cache($app,$id,$title,$file_access=null) |
|
1551 | + public static function set_cache($app, $id, $title, $file_access = null) |
|
1552 | 1552 | { |
1553 | 1553 | //error_log(__METHOD__."($app,$id,$title,$file_access)"); |
1554 | 1554 | if (!is_null($title)) |
@@ -1567,7 +1567,7 @@ discard block |
||
1567 | 1567 | * @param string $app app-name or null to delete the whole cache |
1568 | 1568 | * @param int|string $id id or null to delete only file_access cache of given app (keeps title cache, if app implements file_access!) |
1569 | 1569 | */ |
1570 | - private static function delete_cache($app,$id) |
|
1570 | + private static function delete_cache($app, $id) |
|
1571 | 1571 | { |
1572 | 1572 | unset(self::$title_cache[$app.':'.$id]); |
1573 | 1573 | unset(self::$file_access_cache[$app.':'.$id]); |
@@ -1582,7 +1582,7 @@ discard block |
||
1582 | 1582 | * @param boolean $ignore_mime =false true: return id, even if nothing registered for given mime-type |
1583 | 1583 | * @return string|null md5 hash of stored data of server-side supported mime-type or null otherwise |
1584 | 1584 | */ |
1585 | - public static function set_data($mime_type, $method, array $params, $ignore_mime=false) |
|
1585 | + public static function set_data($mime_type, $method, array $params, $ignore_mime = false) |
|
1586 | 1586 | { |
1587 | 1587 | if (!$ignore_mime && (!($info = self::get_mime_info($mime_type)) || empty($info['mime_data']))) |
1588 | 1588 | { |
@@ -1603,7 +1603,7 @@ discard block |
||
1603 | 1603 | * @return mixed null if id is not found or invalid |
1604 | 1604 | * @throws Exception\WrongParameter |
1605 | 1605 | */ |
1606 | - public static function get_data($id, $return_resource=false) |
|
1606 | + public static function get_data($id, $return_resource = false) |
|
1607 | 1607 | { |
1608 | 1608 | $data = Cache::getSession(__CLASS__, $id); |
1609 | 1609 | |
@@ -1627,7 +1627,7 @@ discard block |
||
1627 | 1627 | { |
1628 | 1628 | $fp = $ret; |
1629 | 1629 | $ret = ''; |
1630 | - while(!feof($fp)) |
|
1630 | + while (!feof($fp)) |
|
1631 | 1631 | { |
1632 | 1632 | $ret .= fread($fp, 8192); |
1633 | 1633 | } |
@@ -1652,13 +1652,13 @@ discard block |
||
1652 | 1652 | * @param int $user =null default null = current user |
1653 | 1653 | * @return boolean true if access granted, false otherwise |
1654 | 1654 | */ |
1655 | - static function file_access($app,$id,$required=Acl::READ,$rel_path=null,$user=null) |
|
1655 | + static function file_access($app, $id, $required = Acl::READ, $rel_path = null, $user = null) |
|
1656 | 1656 | { |
1657 | 1657 | // are we called for an other user |
1658 | 1658 | if ($user && $user != $GLOBALS['egw_info']['user']['account_id']) |
1659 | 1659 | { |
1660 | 1660 | // check if app supports file_access WITH 4th $user parameter --> return false if not |
1661 | - if (!self::get_registry($app,'file_access_user') || !($method = self::get_registry($app,'file_access'))) |
|
1661 | + if (!self::get_registry($app, 'file_access_user') || !($method = self::get_registry($app, 'file_access'))) |
|
1662 | 1662 | { |
1663 | 1663 | $ret = false; |
1664 | 1664 | $err = "(no file_access_user)"; |
@@ -1672,22 +1672,22 @@ discard block |
||
1672 | 1672 | return $ret; |
1673 | 1673 | } |
1674 | 1674 | |
1675 | - $cache =& self::get_cache($app,$id,'file_access'); |
|
1675 | + $cache = & self::get_cache($app, $id, 'file_access'); |
|
1676 | 1676 | |
1677 | - if (!isset($cache) || $required == Acl::EDIT && !($cache & $required)) |
|
1677 | + if (!isset($cache) || $required == Acl::EDIT && !($cache&$required)) |
|
1678 | 1678 | { |
1679 | - if(($method = self::get_registry($app,'file_access'))) |
|
1679 | + if (($method = self::get_registry($app, 'file_access'))) |
|
1680 | 1680 | { |
1681 | 1681 | $cache |= self::exec($method, array($id, $required, $rel_path)) ? $required|Acl::READ : 0; |
1682 | 1682 | } |
1683 | 1683 | else |
1684 | 1684 | { |
1685 | - $cache |= self::title($app,$id) ? Acl::READ|Acl::EDIT : 0; |
|
1685 | + $cache |= self::title($app, $id) ? Acl::READ|Acl::EDIT : 0; |
|
1686 | 1686 | } |
1687 | 1687 | //error_log(__METHOD__."($app,$id,$required,$rel_path) got $cache --> ".($cache & $required ? 'true' : 'false')); |
1688 | 1688 | } |
1689 | 1689 | //else error_log(__METHOD__."($app,$id,$required,$rel_path) using cached value $cache --> ".($cache & $required ? 'true' : 'false')); |
1690 | - return !!($cache & $required); |
|
1690 | + return !!($cache&$required); |
|
1691 | 1691 | } |
1692 | 1692 | |
1693 | 1693 | /** |
@@ -1700,7 +1700,7 @@ discard block |
||
1700 | 1700 | * @param array $params array with arguments incl. references |
1701 | 1701 | * @return mixed |
1702 | 1702 | */ |
1703 | - protected static function exec($method, array $params=array()) |
|
1703 | + protected static function exec($method, array $params = array()) |
|
1704 | 1704 | { |
1705 | 1705 | static $objs = array(); |
1706 | 1706 |
@@ -298,10 +298,13 @@ discard block |
||
298 | 298 | */ |
299 | 299 | static function save_session_cache() |
300 | 300 | { |
301 | - if (isset($GLOBALS['egw']->session)) // eg. cron-jobs use it too, without any session |
|
301 | + if (isset($GLOBALS['egw']->session)) |
|
302 | + { |
|
303 | + // eg. cron-jobs use it too, without any session |
|
302 | 304 | { |
303 | 305 | //error_log(__METHOD__.'() items in title-cache: '.count(self::$title_cache).' file-access-cache: '.count(self::$file_access_cache)); |
304 | 306 | Cache::setSession(__CLASS__, 'link_title_cache', self::$title_cache); |
307 | + } |
|
305 | 308 | Cache::setSession(__CLASS__, 'link_file_access_cache', self::$file_access_cache); |
306 | 309 | } |
307 | 310 | } |
@@ -345,14 +348,20 @@ discard block |
||
345 | 348 | $link_id = True; |
346 | 349 | while ($link_id && list(,$link) = each($app2)) |
347 | 350 | { |
348 | - if (!is_array($link)) // check for unlink-marker |
|
351 | + if (!is_array($link)) |
|
352 | + { |
|
353 | + // check for unlink-marker |
|
349 | 354 | { |
350 | 355 | //echo "<b>link='$link' is no array</b><br>\n"; |
351 | 356 | continue; |
352 | 357 | } |
353 | - if (is_array($id1) || !$id1) // create link only in $id1 array |
|
358 | + } |
|
359 | + if (is_array($id1) || !$id1) |
|
360 | + { |
|
361 | + // create link only in $id1 array |
|
354 | 362 | { |
355 | 363 | self::link($app1, $id1, $link['app'], $link['id'], $link['remark'],$link['owner'],$link['lastmod']); |
364 | + } |
|
356 | 365 | continue; |
357 | 366 | } |
358 | 367 | switch ($link['app']) |
@@ -376,18 +385,27 @@ discard block |
||
376 | 385 | $link_id = Link\Storage::link($app1,$id1,$link['app'],$link['id'], |
377 | 386 | $link['remark'],$link['owner'],$link['lastmod']); |
378 | 387 | // notify both sides |
379 | - if (!($no_notify&2)) self::notify('link',$link['app'],$link['id'],$app1,$id1,$link_id); |
|
380 | - if (!($no_notify&1)) self::notify('link',$app1,$id1,$link['app'],$link['id'],$link_id); |
|
388 | + if (!($no_notify&2)) |
|
389 | + { |
|
390 | + self::notify('link',$link['app'],$link['id'],$app1,$id1,$link_id); |
|
391 | + } |
|
392 | + if (!($no_notify&1)) |
|
393 | + { |
|
394 | + self::notify('link',$app1,$id1,$link['app'],$link['id'],$link_id); |
|
395 | + } |
|
381 | 396 | break; |
382 | 397 | } |
383 | 398 | } |
384 | 399 | return $link_id; |
385 | 400 | } |
386 | - if (is_array($id1) || !$id1) // create link only in $id1 array |
|
401 | + if (is_array($id1) || !$id1) |
|
402 | + { |
|
403 | + // create link only in $id1 array |
|
387 | 404 | { |
388 | 405 | if (!is_array($id1)) |
389 | 406 | { |
390 | 407 | $id1 = array( ); |
408 | + } |
|
391 | 409 | } |
392 | 410 | $link_id = self::temp_link_id($app2,$id2); |
393 | 411 | |
@@ -423,8 +441,14 @@ discard block |
||
423 | 441 | } |
424 | 442 | $link_id = Link\Storage::link($app1,$id1,$app2,$id2,$remark,$owner); |
425 | 443 | |
426 | - if (!($no_notify&2)) self::notify('link',$app2,$id2,$app1,$id1,$link_id); |
|
427 | - if (!($no_notify&1)) self::notify('link',$app1,$id1,$app2,$id2,$link_id); |
|
444 | + if (!($no_notify&2)) |
|
445 | + { |
|
446 | + self::notify('link',$app2,$id2,$app1,$id1,$link_id); |
|
447 | + } |
|
448 | + if (!($no_notify&1)) |
|
449 | + { |
|
450 | + self::notify('link',$app1,$id1,$app2,$id2,$link_id); |
|
451 | + } |
|
428 | 452 | |
429 | 453 | return $link_id; |
430 | 454 | } |
@@ -456,7 +480,10 @@ discard block |
||
456 | 480 | */ |
457 | 481 | static function get_links($app, $id, $only_app='', $order='link_lastmod DESC',$cache_titles=false, $deleted=false, $limit=null) |
458 | 482 | { |
459 | - if (self::DEBUG) echo "<p>Link::get_links(app='$app',id='$id',only_app='$only_app',order='$order',deleted='$deleted')</p>\n"; |
|
483 | + if (self::DEBUG) |
|
484 | + { |
|
485 | + echo "<p>Link::get_links(app='$app',id='$id',only_app='$only_app',order='$order',deleted='$deleted')</p>\n"; |
|
486 | + } |
|
460 | 487 | |
461 | 488 | if (is_array($id) || !$id) |
462 | 489 | { |
@@ -527,7 +554,10 @@ discard block |
||
527 | 554 | */ |
528 | 555 | static function get_links_multiple($app,array $ids,$cache_titles=true,$only_app='',$order='link_lastmod DESC', $deleted=false ) |
529 | 556 | { |
530 | - if (self::DEBUG) echo "<p>".__METHOD__."('$app',".print_r($ids,true).",$cache_titles,'$only_app','$order')</p>\n"; |
|
557 | + if (self::DEBUG) |
|
558 | + { |
|
559 | + echo "<p>".__METHOD__."('$app',".print_r($ids,true).",$cache_titles,'$only_app','$order')</p>\n"; |
|
560 | + } |
|
531 | 561 | |
532 | 562 | if (!$ids) |
533 | 563 | { |
@@ -559,7 +589,10 @@ discard block |
||
559 | 589 | { |
560 | 590 | foreach($targets as $link) |
561 | 591 | { |
562 | - if (is_array($link)) $app_ids[$link['app']][] = $link['id']; |
|
592 | + if (is_array($link)) |
|
593 | + { |
|
594 | + $app_ids[$link['app']][] = $link['id']; |
|
595 | + } |
|
563 | 596 | } |
564 | 597 | } |
565 | 598 | foreach($app_ids as $app => $a_ids) |
@@ -589,20 +622,30 @@ discard block |
||
589 | 622 | } |
590 | 623 | if (is_array($id)) |
591 | 624 | { |
592 | - if (strpos($app_link_id,':') === false) $app_link_id = self::temp_link_id($app2,$id2); // create link_id of temporary link, if not given |
|
625 | + if (strpos($app_link_id,':') === false) |
|
626 | + { |
|
627 | + $app_link_id = self::temp_link_id($app2,$id2); |
|
628 | + } |
|
629 | + // create link_id of temporary link, if not given |
|
593 | 630 | |
594 | - if (isset($id[$app_link_id]) && is_array($id[$app_link_id])) // check for unlinked-marker |
|
631 | + if (isset($id[$app_link_id]) && is_array($id[$app_link_id])) |
|
632 | + { |
|
633 | + // check for unlinked-marker |
|
595 | 634 | { |
596 | 635 | return $id[$app_link_id]; |
597 | 636 | } |
637 | + } |
|
598 | 638 | return False; |
599 | 639 | } |
600 | 640 | if ((int)$app_link_id < 0 || $app_link_id == self::VFS_APPNAME || $app2 == self::VFS_APPNAME) |
601 | 641 | { |
602 | - if ((int)$app_link_id < 0) // vfs link_id ? |
|
642 | + if ((int)$app_link_id < 0) |
|
643 | + { |
|
644 | + // vfs link_id ? |
|
603 | 645 | { |
604 | 646 | return self::fileinfo2link(-$app_link_id); |
605 | 647 | } |
648 | + } |
|
606 | 649 | if ($app_link_id == self::VFS_APPNAME) |
607 | 650 | { |
608 | 651 | return self::info_attached($app2,$id2,$id); |
@@ -650,10 +693,13 @@ discard block |
||
650 | 693 | { |
651 | 694 | echo "<p>Link::unlink('$link_id','$app',".array2string($id).",'$owner','$app2','$id2', $hold_for_purge)</p>\n"; |
652 | 695 | } |
653 | - if ($link_id < 0) // vfs-link? |
|
696 | + if ($link_id < 0) |
|
697 | + { |
|
698 | + // vfs-link? |
|
654 | 699 | { |
655 | 700 | return self::delete_attached(-$link_id); |
656 | 701 | } |
702 | + } |
|
657 | 703 | elseif ($app == self::VFS_APPNAME) |
658 | 704 | { |
659 | 705 | return self::delete_attached($app2,$id2,$id); |
@@ -692,7 +738,11 @@ discard block |
||
692 | 738 | |
693 | 739 | return count($deleted); |
694 | 740 | } |
695 | - if (!$link_id) $link_id = self::temp_link_id($app2,$id2); // create link_id of temporary link, if not given |
|
741 | + if (!$link_id) |
|
742 | + { |
|
743 | + $link_id = self::temp_link_id($app2,$id2); |
|
744 | + } |
|
745 | + // create link_id of temporary link, if not given |
|
696 | 746 | |
697 | 747 | if (isset($id[$link_id])) |
698 | 748 | { |
@@ -718,7 +768,10 @@ discard block |
||
718 | 768 | $apps = array(); |
719 | 769 | foreach(self::$app_register as $type => $reg) |
720 | 770 | { |
721 | - if ($must_support && !isset($reg[$must_support])) continue; |
|
771 | + if ($must_support && !isset($reg[$must_support])) |
|
772 | + { |
|
773 | + continue; |
|
774 | + } |
|
722 | 775 | |
723 | 776 | list($app) = explode('-', $type); |
724 | 777 | if ($GLOBALS['egw_info']['user']['apps'][$app]) |
@@ -775,12 +828,18 @@ discard block |
||
775 | 828 | */ |
776 | 829 | static function title($app,$id,$link=null) |
777 | 830 | { |
778 | - if (!$id) return ''; |
|
831 | + if (!$id) |
|
832 | + { |
|
833 | + return ''; |
|
834 | + } |
|
779 | 835 | |
780 | 836 | $title =& self::get_cache($app,$id); |
781 | 837 | if (isset($title) && !empty($title) && !is_array($id)) |
782 | 838 | { |
783 | - if (self::DEBUG) echo '<p>'.__METHOD__."('$app','$id')='$title' (from cache)</p>\n"; |
|
839 | + if (self::DEBUG) |
|
840 | + { |
|
841 | + echo '<p>'.__METHOD__."('$app','$id')='$title' (from cache)</p>\n"; |
|
842 | + } |
|
784 | 843 | return $title; |
785 | 844 | } |
786 | 845 | if ($app == self::VFS_APPNAME) |
@@ -800,21 +859,33 @@ discard block |
||
800 | 859 | { |
801 | 860 | $title .= ': '.$link['type'] . ' '.Vfs::hsize($link['size']); |
802 | 861 | }*/ |
803 | - if (self::DEBUG) echo '<p>'.__METHOD__."('$app','$id')='$title' (file)</p>\n"; |
|
862 | + if (self::DEBUG) |
|
863 | + { |
|
864 | + echo '<p>'.__METHOD__."('$app','$id')='$title' (file)</p>\n"; |
|
865 | + } |
|
804 | 866 | return $title; |
805 | 867 | } |
806 | 868 | if ($app == '' || !is_array($reg = self::$app_register[$app]) || !isset($reg['title'])) |
807 | 869 | { |
808 | - if (self::DEBUG) echo "<p>".__METHOD__."('$app','$id') something is wrong!!!</p>\n"; |
|
870 | + if (self::DEBUG) |
|
871 | + { |
|
872 | + echo "<p>".__METHOD__."('$app','$id') something is wrong!!!</p>\n"; |
|
873 | + } |
|
809 | 874 | return false; //array(); // not sure why it should return an array on failure, as the description states boolean/string |
810 | 875 | } |
811 | 876 | $method = $reg['title']; |
812 | 877 | |
813 | - if (true) $title = self::exec($method, array($id)); |
|
878 | + if (true) |
|
879 | + { |
|
880 | + $title = self::exec($method, array($id)); |
|
881 | + } |
|
814 | 882 | |
815 | - if ($id && is_null($title)) // $app,$id has been deleted ==> unlink all links to it |
|
883 | + if ($id && is_null($title)) |
|
884 | + { |
|
885 | + // $app,$id has been deleted ==> unlink all links to it |
|
816 | 886 | { |
817 | 887 | static $unlinking = array(); |
888 | + } |
|
818 | 889 | // check if we are already trying to unlink the entry, to avoid an infinit recursion |
819 | 890 | if (!isset($unlinking[$app]) || !isset($unlinking[$app][$id])) |
820 | 891 | { |
@@ -822,10 +893,16 @@ discard block |
||
822 | 893 | self::unlink(0,$app,$id); |
823 | 894 | unset($unlinking[$app][$id]); |
824 | 895 | } |
825 | - if (self::DEBUG) echo '<p>'.__METHOD__."('$app','$id') unlinked, as $method returned null</p>\n"; |
|
896 | + if (self::DEBUG) |
|
897 | + { |
|
898 | + echo '<p>'.__METHOD__."('$app','$id') unlinked, as $method returned null</p>\n"; |
|
899 | + } |
|
826 | 900 | return False; |
827 | 901 | } |
828 | - if (self::DEBUG) echo '<p>'.__METHOD__."('$app','$id')='$title' (from $method)</p>\n"; |
|
902 | + if (self::DEBUG) |
|
903 | + { |
|
904 | + echo '<p>'.__METHOD__."('$app','$id')='$title' (from $method)</p>\n"; |
|
905 | + } |
|
829 | 906 | |
830 | 907 | return $title; |
831 | 908 | } |
@@ -991,7 +1068,10 @@ discard block |
||
991 | 1068 | { |
992 | 1069 | foreach($registry['mime'] as $mime => $data) |
993 | 1070 | { |
994 | - if ($mime == $type) return $data; |
|
1071 | + if ($mime == $type) |
|
1072 | + { |
|
1073 | + return $data; |
|
1074 | + } |
|
995 | 1075 | if ($mime[0] == '/' && preg_match($mime.'i', $type)) |
996 | 1076 | { |
997 | 1077 | $wildcard_mime = $data; |
@@ -1012,7 +1092,10 @@ discard block |
||
1012 | 1092 | */ |
1013 | 1093 | static function mime_open($path, $type=null, &$popup=null) |
1014 | 1094 | { |
1015 | - if (is_null($type)) $type = Vfs::mime_content_type($path); |
|
1095 | + if (is_null($type)) |
|
1096 | + { |
|
1097 | + $type = Vfs::mime_content_type($path); |
|
1098 | + } |
|
1016 | 1099 | |
1017 | 1100 | if (($data = self::get_mime_info($type))) |
1018 | 1101 | { |
@@ -1080,14 +1163,20 @@ discard block |
||
1080 | 1163 | { |
1081 | 1164 | $reg = self::$app_register[$app]; |
1082 | 1165 | |
1083 | - if (!isset($reg)) return false; |
|
1166 | + if (!isset($reg)) |
|
1167 | + { |
|
1168 | + return false; |
|
1169 | + } |
|
1084 | 1170 | |
1085 | - if (!isset($reg[$name])) // some defaults |
|
1171 | + if (!isset($reg[$name])) |
|
1172 | + { |
|
1173 | + // some defaults |
|
1086 | 1174 | { |
1087 | 1175 | switch($name) |
1088 | 1176 | { |
1089 | 1177 | case 'name': |
1090 | 1178 | $reg[$name] = $app; |
1179 | + } |
|
1091 | 1180 | break; |
1092 | 1181 | case 'entry': |
1093 | 1182 | $reg[$name] = $app; |
@@ -1126,10 +1215,12 @@ discard block |
||
1126 | 1215 | |
1127 | 1216 | if ($app) |
1128 | 1217 | { |
1129 | - if( isset(self::$app_register[$app]) ) { |
|
1218 | + if( isset(self::$app_register[$app]) ) |
|
1219 | + { |
|
1130 | 1220 | $reg = self::$app_register[$app]; |
1131 | 1221 | |
1132 | - if( isset($reg['file_dir']) ) { |
|
1222 | + if( isset($reg['file_dir']) ) |
|
1223 | + { |
|
1133 | 1224 | $app = $reg['file_dir']; |
1134 | 1225 | } |
1135 | 1226 | } |
@@ -1182,7 +1273,10 @@ discard block |
||
1182 | 1273 | if (file_exists($entry_dir) || ($Ok = mkdir($entry_dir,0,true))) |
1183 | 1274 | { |
1184 | 1275 | $Ok = Vfs::copy_uploaded($file, $p=self::vfs_path($app,$id,'',true), $comment, false); // no is_uploaded_file() check! |
1185 | - if (!$Ok) error_log(__METHOD__."('$app', '$id', ".array2string($file).", '$comment') called Vfs::copy_uploaded('$file[tmp_name]', '$p', '$comment', false)=".array2string($Ok)); |
|
1276 | + if (!$Ok) |
|
1277 | + { |
|
1278 | + error_log(__METHOD__."('$app', '$id', ".array2string($file).", '$comment') called Vfs::copy_uploaded('$file[tmp_name]', '$p', '$comment', false)=".array2string($Ok)); |
|
1279 | + } |
|
1186 | 1280 | } |
1187 | 1281 | else |
1188 | 1282 | { |
@@ -1202,7 +1296,10 @@ discard block |
||
1202 | 1296 | static function link_file($app,$id,$file)//,$comment='') |
1203 | 1297 | { |
1204 | 1298 | // Don't try to link into app dir if there is no id |
1205 | - if(!$id) return; |
|
1299 | + if(!$id) |
|
1300 | + { |
|
1301 | + return; |
|
1302 | + } |
|
1206 | 1303 | |
1207 | 1304 | $app_path = self::vfs_path($app,$id); |
1208 | 1305 | $ok = true; |
@@ -1228,10 +1325,13 @@ discard block |
||
1228 | 1325 | */ |
1229 | 1326 | static function delete_attached($app,$id='',$fname='') |
1230 | 1327 | { |
1231 | - if ((int)$app > 0) // is file_id |
|
1328 | + if ((int)$app > 0) |
|
1329 | + { |
|
1330 | + // is file_id |
|
1232 | 1331 | { |
1233 | 1332 | $url = Vfs::resolve_url(Vfs\Sqlfs\StreamWrapper::id2path($app)); |
1234 | 1333 | } |
1334 | + } |
|
1235 | 1335 | else |
1236 | 1336 | { |
1237 | 1337 | if (empty($app) || empty($id)) |
@@ -1240,9 +1340,12 @@ discard block |
||
1240 | 1340 | } |
1241 | 1341 | $url = self::vfs_path($app,$id,$fname); |
1242 | 1342 | |
1243 | - if (!$fname || !$id) // we delete the whole entry (or all entries), which probably not exist anymore |
|
1343 | + if (!$fname || !$id) |
|
1344 | + { |
|
1345 | + // we delete the whole entry (or all entries), which probably not exist anymore |
|
1244 | 1346 | { |
1245 | 1347 | $current_is_root = Vfs::$is_root; |
1348 | + } |
|
1246 | 1349 | Vfs::$is_root = true; |
1247 | 1350 | } |
1248 | 1351 | } |
@@ -1262,7 +1365,10 @@ discard block |
||
1262 | 1365 | if (($Ok = !file_exists($url) || Vfs::remove($url,true)) && ((int)$app > 0 || $fname)) |
1263 | 1366 | { |
1264 | 1367 | // try removing the dir, in case it's empty |
1265 | - if (($dir = Vfs::dirname($url))) @Vfs::rmdir($dir); |
|
1368 | + if (($dir = Vfs::dirname($url))) |
|
1369 | + { |
|
1370 | + @Vfs::rmdir($dir); |
|
1371 | + } |
|
1266 | 1372 | } |
1267 | 1373 | if (!is_null($current_is_root)) |
1268 | 1374 | { |
@@ -1309,8 +1415,10 @@ discard block |
||
1309 | 1415 | $up = explode('/',$url[0] == '/' ? $url : parse_url($url,PHP_URL_PATH)); // /apps/$app/$id |
1310 | 1416 | $app = null; |
1311 | 1417 | |
1312 | - foreach( self::$app_register as $tapp => $reg ) { |
|
1313 | - if( isset($reg['file_dir']) ) { |
|
1418 | + foreach( self::$app_register as $tapp => $reg ) |
|
1419 | + { |
|
1420 | + if( isset($reg['file_dir']) ) |
|
1421 | + { |
|
1314 | 1422 | $lup = $up; |
1315 | 1423 | |
1316 | 1424 | unset($lup[0]); |
@@ -1322,20 +1430,25 @@ discard block |
||
1322 | 1430 | |
1323 | 1431 | $found = true; |
1324 | 1432 | |
1325 | - foreach( $fdp as $part ) { |
|
1326 | - if( current($lup) == $part ) { |
|
1327 | - if( next($lup) === false ) { |
|
1433 | + foreach( $fdp as $part ) |
|
1434 | + { |
|
1435 | + if( current($lup) == $part ) |
|
1436 | + { |
|
1437 | + if( next($lup) === false ) |
|
1438 | + { |
|
1328 | 1439 | $found = false; |
1329 | 1440 | break; |
1330 | 1441 | } |
1331 | 1442 | } |
1332 | - else { |
|
1443 | + else |
|
1444 | + { |
|
1333 | 1445 | $found = false; |
1334 | 1446 | break; |
1335 | 1447 | } |
1336 | 1448 | } |
1337 | 1449 | |
1338 | - if( $found ) { |
|
1450 | + if( $found ) |
|
1451 | + { |
|
1339 | 1452 | $id = current($lup); |
1340 | 1453 | $app = $tapp; |
1341 | 1454 | break; |
@@ -1343,7 +1456,8 @@ discard block |
||
1343 | 1456 | } |
1344 | 1457 | } |
1345 | 1458 | |
1346 | - if( $app === null ) { |
|
1459 | + if( $app === null ) |
|
1460 | + { |
|
1347 | 1461 | list(,,$app,$id) = $up; |
1348 | 1462 | } |
1349 | 1463 | |
@@ -1373,10 +1487,16 @@ discard block |
||
1373 | 1487 | $path = self::vfs_path($app,$id); |
1374 | 1488 | //error_log(__METHOD__."($app,$id) url=$url"); |
1375 | 1489 | |
1376 | - if (!($extra = self::get_registry($app,'find_extra'))) $extra = array(); |
|
1490 | + if (!($extra = self::get_registry($app,'find_extra'))) |
|
1491 | + { |
|
1492 | + $extra = array(); |
|
1493 | + } |
|
1377 | 1494 | |
1378 | 1495 | // always use regular links stream wrapper here: extended one is unnecessary (slow) for just listing attachments |
1379 | - if (substr($path,0,13) == 'stylite.links') $path = substr($path,8); |
|
1496 | + if (substr($path,0,13) == 'stylite.links') |
|
1497 | + { |
|
1498 | + $path = substr($path,8); |
|
1499 | + } |
|
1380 | 1500 | |
1381 | 1501 | $attached = array(); |
1382 | 1502 | if (($url2stats = Vfs::find($path,array('need_mime'=>true,'type'=>'F','url'=>true)+$extra,true))) |
@@ -1613,7 +1733,10 @@ discard block |
||
1613 | 1733 | } |
1614 | 1734 | $ret = call_user_func_array('self::exec', $data); |
1615 | 1735 | |
1616 | - if (is_resource($ret)) fseek($ret, 0); |
|
1736 | + if (is_resource($ret)) |
|
1737 | + { |
|
1738 | + fseek($ret, 0); |
|
1739 | + } |
|
1617 | 1740 | |
1618 | 1741 | if ($return_resource != is_resource($ret)) |
1619 | 1742 | { |
@@ -1711,7 +1834,10 @@ discard block |
||
1711 | 1834 | } |
1712 | 1835 | |
1713 | 1836 | list($app, $class, $m) = $parts = explode('.', $method); |
1714 | - if (count($parts) != 3) throw Api\Exception\WrongParameter("Wrong dot-delimited method string '$method'!"); |
|
1837 | + if (count($parts) != 3) |
|
1838 | + { |
|
1839 | + throw Api\Exception\WrongParameter("Wrong dot-delimited method string '$method'!"); |
|
1840 | + } |
|
1715 | 1841 | |
1716 | 1842 | if (!isset($objs[$class])) |
1717 | 1843 | { |
@@ -106,17 +106,17 @@ discard block |
||
106 | 106 | * @param array $old =null old/last state of the entry or null for a new entry |
107 | 107 | * @return mixed |
108 | 108 | */ |
109 | - function get_config($name,$data,$old=null) |
|
109 | + function get_config($name, $data, $old = null) |
|
110 | 110 | { |
111 | - unset($old); // not used, but required by function signature |
|
111 | + unset($old); // not used, but required by function signature |
|
112 | 112 | |
113 | - switch($name) |
|
113 | + switch ($name) |
|
114 | 114 | { |
115 | 115 | case 'copy': |
116 | 116 | if ($data['is_contactform']) |
117 | 117 | { |
118 | - $copy = preg_split('/, ?/',$data['email_contactform']); |
|
119 | - if ($data['email_copytoreceiver']) $copy[] = $data['email']; |
|
118 | + $copy = preg_split('/, ?/', $data['email_contactform']); |
|
119 | + if ($data['email_copytoreceiver']) $copy[] = $data['email']; |
|
120 | 120 | return $copy; |
121 | 121 | } |
122 | 122 | break; |
@@ -144,27 +144,27 @@ discard block |
||
144 | 144 | * @param array $changed_fields =null changed fields from ealier call to $this->changed_fields($data,$old), to not compute it again |
145 | 145 | * @return int number of log-entries made |
146 | 146 | */ |
147 | - protected function save_history(array $data,array $old=null,$deleted=null,array $changed_fields=null) |
|
147 | + protected function save_history(array $data, array $old = null, $deleted = null, array $changed_fields = null) |
|
148 | 148 | { |
149 | 149 | if (is_null($changed_fields)) |
150 | 150 | { |
151 | - $changed_fields = self::changed_fields($data,$old); |
|
151 | + $changed_fields = self::changed_fields($data, $old); |
|
152 | 152 | } |
153 | 153 | if (!$changed_fields) return 0; |
154 | 154 | |
155 | - foreach(array('adr_one_countryname' => 'adr_one_countrycode', 'adr_two_countryname' => 'adr_two_countrycode') as $name => $code) |
|
155 | + foreach (array('adr_one_countryname' => 'adr_one_countrycode', 'adr_two_countryname' => 'adr_two_countrycode') as $name => $code) |
|
156 | 156 | { |
157 | 157 | // Only codes involved, but old text name is automatically added when loaded |
158 | - if($old[$code] && $data[$code] && ($key = array_search($name, $changed_fields)) !== false) |
|
158 | + if ($old[$code] && $data[$code] && ($key = array_search($name, $changed_fields)) !== false) |
|
159 | 159 | { |
160 | 160 | unset($changed_fields[$key]); |
161 | 161 | continue; |
162 | 162 | } |
163 | 163 | |
164 | 164 | // Code and a text name |
165 | - if(in_array($name, $changed_fields) && in_array($code, $changed_fields)) |
|
165 | + if (in_array($name, $changed_fields) && in_array($code, $changed_fields)) |
|
166 | 166 | { |
167 | - if($data[$code]) |
|
167 | + if ($data[$code]) |
|
168 | 168 | { |
169 | 169 | $data[$name] = Api\Country::get_full_name($data[$code], true); |
170 | 170 | } |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | } |
173 | 173 | } |
174 | 174 | //error_log(__METHOD__.__LINE__.' ChangedFields:'.array2string($changed_fields)); |
175 | - return parent::save_history($data,$old,$deleted,$changed_fields); |
|
175 | + return parent::save_history($data, $old, $deleted, $changed_fields); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -183,9 +183,9 @@ discard block |
||
183 | 183 | * @param int|string $receiver nummeric account_id or email address |
184 | 184 | * @return string |
185 | 185 | */ |
186 | - protected function get_message($data,$old,$receiver=null) |
|
186 | + protected function get_message($data, $old, $receiver = null) |
|
187 | 187 | { |
188 | - unset($receiver); // not used, but required by function signature |
|
188 | + unset($receiver); // not used, but required by function signature |
|
189 | 189 | |
190 | 190 | if (!$data['modified'] || !$old) |
191 | 191 | { |
@@ -207,9 +207,9 @@ discard block |
||
207 | 207 | * @param int|string $receiver nummeric account_id or email address |
208 | 208 | * @return string |
209 | 209 | */ |
210 | - protected function get_subject($data,$old,$deleted=null,$receiver=null) |
|
210 | + protected function get_subject($data, $old, $deleted = null, $receiver = null) |
|
211 | 211 | { |
212 | - unset($old, $deleted, $receiver); // not used, but required by function signature |
|
212 | + unset($old, $deleted, $receiver); // not used, but required by function signature |
|
213 | 213 | |
214 | 214 | if ($data['is_contactform']) |
215 | 215 | { |
@@ -225,15 +225,15 @@ discard block |
||
225 | 225 | * @param int|string $receiver nummeric account_id or email address |
226 | 226 | * @return array of details as array with values for keys 'label','value','type' |
227 | 227 | */ |
228 | - function get_details($data,$receiver=null) |
|
228 | + function get_details($data, $receiver = null) |
|
229 | 229 | { |
230 | - unset($receiver); // not used, but required by function signature |
|
230 | + unset($receiver); // not used, but required by function signature |
|
231 | 231 | |
232 | - foreach($this->contacts->contact_fields as $name => $label) |
|
232 | + foreach ($this->contacts->contact_fields as $name => $label) |
|
233 | 233 | { |
234 | 234 | if (!$data[$name] && $name != 'owner') continue; |
235 | 235 | |
236 | - switch($name) |
|
236 | + switch ($name) |
|
237 | 237 | { |
238 | 238 | case 'n_prefix': case 'n_given': case 'n_middle': case 'n_family': case 'n_suffix': // already in n_fn |
239 | 239 | case 'n_fileas': case 'id': case 'tid': |
@@ -263,13 +263,13 @@ discard block |
||
263 | 263 | if ($data[$name]) |
264 | 264 | { |
265 | 265 | $cats = array(); |
266 | - foreach(is_array($data[$name]) ? $data[$name] : explode(',',$data[$name]) as $cat_id) |
|
266 | + foreach (is_array($data[$name]) ? $data[$name] : explode(',', $data[$name]) as $cat_id) |
|
267 | 267 | { |
268 | 268 | $cats[] = $GLOBALS['egw']->cats->id2name($cat_id); |
269 | 269 | } |
270 | 270 | $details[$name] = array( |
271 | 271 | 'label' => $label, |
272 | - 'value' => explode(', ',$cats), |
|
272 | + 'value' => explode(', ', $cats), |
|
273 | 273 | ); |
274 | 274 | } |
275 | 275 | case 'note': |
@@ -116,7 +116,10 @@ discard block |
||
116 | 116 | if ($data['is_contactform']) |
117 | 117 | { |
118 | 118 | $copy = preg_split('/, ?/',$data['email_contactform']); |
119 | - if ($data['email_copytoreceiver']) $copy[] = $data['email']; |
|
119 | + if ($data['email_copytoreceiver']) |
|
120 | + { |
|
121 | + $copy[] = $data['email']; |
|
122 | + } |
|
120 | 123 | return $copy; |
121 | 124 | } |
122 | 125 | break; |
@@ -150,7 +153,10 @@ discard block |
||
150 | 153 | { |
151 | 154 | $changed_fields = self::changed_fields($data,$old); |
152 | 155 | } |
153 | - if (!$changed_fields) return 0; |
|
156 | + if (!$changed_fields) |
|
157 | + { |
|
158 | + return 0; |
|
159 | + } |
|
154 | 160 | |
155 | 161 | foreach(array('adr_one_countryname' => 'adr_one_countrycode', 'adr_two_countryname' => 'adr_two_countrycode') as $name => $code) |
156 | 162 | { |
@@ -231,7 +237,10 @@ discard block |
||
231 | 237 | |
232 | 238 | foreach($this->contacts->contact_fields as $name => $label) |
233 | 239 | { |
234 | - if (!$data[$name] && $name != 'owner') continue; |
|
240 | + if (!$data[$name] && $name != 'owner') |
|
241 | + { |
|
242 | + continue; |
|
243 | + } |
|
235 | 244 | |
236 | 245 | switch($name) |
237 | 246 | { |
@@ -35,7 +35,7 @@ |
||
35 | 35 | * @param array $keys if given $keys are copied to data before saveing => allows a save as |
36 | 36 | * @return int 0 on success and errno != 0 else |
37 | 37 | */ |
38 | - function save($keys=null) |
|
38 | + function save($keys = null) |
|
39 | 39 | { |
40 | 40 | // UCS lowercases email when storing |
41 | 41 | $keys['email'] = strtolower(!empty($keys['email']) ? $keys['email'] : $this->data['email']); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | use EGroupware\Api; |
17 | 17 | |
18 | 18 | // explicit import not namespaced classes |
19 | -use calendar_boupdate; // we detect if it is not available |
|
19 | +use calendar_boupdate; // we detect if it is not available |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Contacts document merge |
@@ -55,22 +55,22 @@ discard block |
||
55 | 55 | * @param boolean $ignore_acl =false true: no acl check |
56 | 56 | * @return array|boolean |
57 | 57 | */ |
58 | - protected function get_replacements($id,&$content=null,$ignore_acl=false) |
|
58 | + protected function get_replacements($id, &$content = null, $ignore_acl = false) |
|
59 | 59 | { |
60 | - if (!($replacements = $this->contact_replacements($id,'',$ignore_acl))) |
|
60 | + if (!($replacements = $this->contact_replacements($id, '', $ignore_acl))) |
|
61 | 61 | { |
62 | 62 | return false; |
63 | 63 | } |
64 | - if($content && strpos($content, '$$#') !== 0) |
|
64 | + if ($content && strpos($content, '$$#') !== 0) |
|
65 | 65 | { |
66 | - $this->cf_link_to_expand($this->contacts->read($id, $ignore_acl), $content, $replacements,'addressbook'); |
|
66 | + $this->cf_link_to_expand($this->contacts->read($id, $ignore_acl), $content, $replacements, 'addressbook'); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | // Links |
70 | 70 | $replacements += $this->get_all_links('addressbook', $id, '', $content); |
71 | - if (!(strpos($content,'$$calendar/') === false)) |
|
71 | + if (!(strpos($content, '$$calendar/') === false)) |
|
72 | 72 | { |
73 | - $replacements += $this->calendar_replacements($id,!(strpos($content,'$$calendar/-1/') === false)); |
|
73 | + $replacements += $this->calendar_replacements($id, !(strpos($content, '$$calendar/-1/') === false)); |
|
74 | 74 | } |
75 | 75 | return $replacements; |
76 | 76 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @param boolean $last_event_too =false also include information about the last event |
83 | 83 | * @return array |
84 | 84 | */ |
85 | - protected function calendar_replacements($id,$last_event_too=false) |
|
85 | + protected function calendar_replacements($id, $last_event_too = false) |
|
86 | 86 | { |
87 | 87 | if (!class_exists('calendar_boupdate')) return array(); |
88 | 88 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | { |
102 | 102 | $events = array(); |
103 | 103 | } |
104 | - if ($last_event_too==true) |
|
104 | + if ($last_event_too == true) |
|
105 | 105 | { |
106 | 106 | $last = $calendar->search(array( |
107 | 107 | 'end' => $calendar->now_su, |
@@ -111,41 +111,41 @@ discard block |
||
111 | 111 | 'order' => 'cal_start DESC', |
112 | 112 | 'enum_recurring' => true |
113 | 113 | )); |
114 | - $events['-1'] = $last ? array_shift($last) : array(); // returned events are indexed by cal_id! |
|
114 | + $events['-1'] = $last ? array_shift($last) : array(); // returned events are indexed by cal_id! |
|
115 | 115 | } |
116 | 116 | $replacements = array(); |
117 | - $n = 1; // Returned events are indexed by cal_id, need to index sequentially |
|
118 | - foreach($events as $key => $event) |
|
117 | + $n = 1; // Returned events are indexed by cal_id, need to index sequentially |
|
118 | + foreach ($events as $key => $event) |
|
119 | 119 | { |
120 | 120 | // Use -1 for previous key |
121 | - if($key < 0) $n = $key; |
|
121 | + if ($key < 0) $n = $key; |
|
122 | 122 | |
123 | - foreach($calendar->event2array($event) as $name => $data) |
|
123 | + foreach ($calendar->event2array($event) as $name => $data) |
|
124 | 124 | { |
125 | - if (substr($name,-4) == 'date') $name = substr($name,0,-4); |
|
126 | - $replacements['$$calendar/'.$n.'/'.$name.'$$'] = is_array($data['data']) ? implode(', ',$data['data']) : $data['data']; |
|
125 | + if (substr($name, -4) == 'date') $name = substr($name, 0, -4); |
|
126 | + $replacements['$$calendar/'.$n.'/'.$name.'$$'] = is_array($data['data']) ? implode(', ', $data['data']) : $data['data']; |
|
127 | 127 | } |
128 | - foreach(array('start','end') as $what) |
|
128 | + foreach (array('start', 'end') as $what) |
|
129 | 129 | { |
130 | - foreach(array( |
|
130 | + foreach (array( |
|
131 | 131 | 'date' => $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], |
132 | 132 | 'day' => 'l', |
133 | 133 | 'time' => $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i', |
134 | 134 | ) as $name => $format) |
135 | 135 | { |
136 | - $value = $event[$what] ? date($format,$event[$what]) : ''; |
|
136 | + $value = $event[$what] ? date($format, $event[$what]) : ''; |
|
137 | 137 | if ($format == 'l') $value = lang($value); |
138 | 138 | $replacements['$$calendar/'.$n.'/'.$what.$name.'$$'] = $value; |
139 | 139 | } |
140 | 140 | } |
141 | - $duration = ($event['end'] - $event['start'])/60; |
|
142 | - $replacements['$$calendar/'.$n.'/duration$$'] = floor($duration/60).lang('h').($duration%60 ? $duration%60 : ''); |
|
141 | + $duration = ($event['end'] - $event['start']) / 60; |
|
142 | + $replacements['$$calendar/'.$n.'/duration$$'] = floor($duration / 60).lang('h').($duration % 60 ? $duration % 60 : ''); |
|
143 | 143 | |
144 | 144 | ++$n; |
145 | 145 | } |
146 | 146 | |
147 | 147 | // Need to set some keys if there is no previous event |
148 | - if($last_event_too && count($events['-1']) == 0) { |
|
148 | + if ($last_event_too && count($events['-1']) == 0) { |
|
149 | 149 | $replacements['$$calendar/-1/start$$'] = ''; |
150 | 150 | $replacements['$$calendar/-1/end$$'] = ''; |
151 | 151 | $replacements['$$calendar/-1/owner$$'] = ''; |
@@ -168,18 +168,18 @@ discard block |
||
168 | 168 | echo '<tr><td colspan="4"><h3>'.lang('Contact fields:')."</h3></td></tr>"; |
169 | 169 | |
170 | 170 | $n = 0; |
171 | - foreach($this->contacts->contact_fields as $name => $label) |
|
171 | + foreach ($this->contacts->contact_fields as $name => $label) |
|
172 | 172 | { |
173 | - if (in_array($name,array('tid','label','geo'))) continue; // dont show them, as they are not used in the UI atm. |
|
173 | + if (in_array($name, array('tid', 'label', 'geo'))) continue; // dont show them, as they are not used in the UI atm. |
|
174 | 174 | |
175 | - if (in_array($name,array('email','org_name','tel_work','url')) && $n&1) // main values, which should be in the first column |
|
175 | + if (in_array($name, array('email', 'org_name', 'tel_work', 'url')) && $n&1) // main values, which should be in the first column |
|
176 | 176 | { |
177 | 177 | echo "</tr>\n"; |
178 | 178 | $n++; |
179 | 179 | } |
180 | 180 | if (!($n&1)) echo '<tr>'; |
181 | 181 | echo '<td>{{'.$name.'}}</td><td>'.$label.'</td>'; |
182 | - if($name == 'cat_id') |
|
182 | + if ($name == 'cat_id') |
|
183 | 183 | { |
184 | 184 | if ($n&1) echo "</tr>\n"; |
185 | 185 | echo '<td>{{categories}}</td><td>'.lang('Category path').'</td>'; |
@@ -190,13 +190,13 @@ discard block |
||
190 | 190 | } |
191 | 191 | |
192 | 192 | echo '<tr><td colspan="4"><h3>'.lang('Custom fields').":</h3></td></tr>"; |
193 | - foreach($this->contacts->customfields as $name => $field) |
|
193 | + foreach ($this->contacts->customfields as $name => $field) |
|
194 | 194 | { |
195 | 195 | echo '<tr><td>{{#'.$name.'}}</td><td colspan="3">'.$field['label']."</td></tr>\n"; |
196 | 196 | } |
197 | 197 | |
198 | 198 | echo '<tr><td colspan="4"><h3>'.lang('General fields:')."</h3></td></tr>"; |
199 | - foreach(array( |
|
199 | + foreach (array( |
|
200 | 200 | 'link' => lang('HTML link to the current record'), |
201 | 201 | 'links' => lang('Titles of any entries linked to the current record, excluding attached files'), |
202 | 202 | 'attachments' => lang('List of files linked to the current record'), |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | |
221 | 221 | Api\Translation::add_app('calendar'); |
222 | 222 | echo '<tr><td colspan="4"><h3>'.lang('Calendar fields:')." # = 1, 2, ..., 20, -1</h3></td></tr>"; |
223 | - foreach(array( |
|
223 | + foreach (array( |
|
224 | 224 | 'title' => lang('Title'), |
225 | 225 | 'description' => lang('Description'), |
226 | 226 | 'participants' => lang('Participants'), |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | 'owner' => lang('Owner'), |
243 | 243 | ) as $name => $label) |
244 | 244 | { |
245 | - if (in_array($name,array('start','end')) && $n&1) // main values, which should be in the first column |
|
245 | + if (in_array($name, array('start', 'end')) && $n&1) // main values, which should be in the first column |
|
246 | 246 | { |
247 | 247 | echo "</tr>\n"; |
248 | 248 | $n++; |
@@ -84,7 +84,10 @@ discard block |
||
84 | 84 | */ |
85 | 85 | protected function calendar_replacements($id,$last_event_too=false) |
86 | 86 | { |
87 | - if (!class_exists('calendar_boupdate')) return array(); |
|
87 | + if (!class_exists('calendar_boupdate')) |
|
88 | + { |
|
89 | + return array(); |
|
90 | + } |
|
88 | 91 | |
89 | 92 | $calendar = new calendar_boupdate(); |
90 | 93 | |
@@ -118,11 +121,17 @@ discard block |
||
118 | 121 | foreach($events as $key => $event) |
119 | 122 | { |
120 | 123 | // Use -1 for previous key |
121 | - if($key < 0) $n = $key; |
|
124 | + if($key < 0) |
|
125 | + { |
|
126 | + $n = $key; |
|
127 | + } |
|
122 | 128 | |
123 | 129 | foreach($calendar->event2array($event) as $name => $data) |
124 | 130 | { |
125 | - if (substr($name,-4) == 'date') $name = substr($name,0,-4); |
|
131 | + if (substr($name,-4) == 'date') |
|
132 | + { |
|
133 | + $name = substr($name,0,-4); |
|
134 | + } |
|
126 | 135 | $replacements['$$calendar/'.$n.'/'.$name.'$$'] = is_array($data['data']) ? implode(', ',$data['data']) : $data['data']; |
127 | 136 | } |
128 | 137 | foreach(array('start','end') as $what) |
@@ -134,7 +143,10 @@ discard block |
||
134 | 143 | ) as $name => $format) |
135 | 144 | { |
136 | 145 | $value = $event[$what] ? date($format,$event[$what]) : ''; |
137 | - if ($format == 'l') $value = lang($value); |
|
146 | + if ($format == 'l') |
|
147 | + { |
|
148 | + $value = lang($value); |
|
149 | + } |
|
138 | 150 | $replacements['$$calendar/'.$n.'/'.$what.$name.'$$'] = $value; |
139 | 151 | } |
140 | 152 | } |
@@ -145,7 +157,8 @@ discard block |
||
145 | 157 | } |
146 | 158 | |
147 | 159 | // Need to set some keys if there is no previous event |
148 | - if($last_event_too && count($events['-1']) == 0) { |
|
160 | + if($last_event_too && count($events['-1']) == 0) |
|
161 | + { |
|
149 | 162 | $replacements['$$calendar/-1/start$$'] = ''; |
150 | 163 | $replacements['$$calendar/-1/end$$'] = ''; |
151 | 164 | $replacements['$$calendar/-1/owner$$'] = ''; |
@@ -170,22 +183,38 @@ discard block |
||
170 | 183 | $n = 0; |
171 | 184 | foreach($this->contacts->contact_fields as $name => $label) |
172 | 185 | { |
173 | - if (in_array($name,array('tid','label','geo'))) continue; // dont show them, as they are not used in the UI atm. |
|
186 | + if (in_array($name,array('tid','label','geo'))) |
|
187 | + { |
|
188 | + continue; |
|
189 | + } |
|
190 | + // dont show them, as they are not used in the UI atm. |
|
174 | 191 | |
175 | - if (in_array($name,array('email','org_name','tel_work','url')) && $n&1) // main values, which should be in the first column |
|
192 | + if (in_array($name,array('email','org_name','tel_work','url')) && $n&1) |
|
193 | + { |
|
194 | + // main values, which should be in the first column |
|
176 | 195 | { |
177 | 196 | echo "</tr>\n"; |
197 | + } |
|
178 | 198 | $n++; |
179 | 199 | } |
180 | - if (!($n&1)) echo '<tr>'; |
|
200 | + if (!($n&1)) |
|
201 | + { |
|
202 | + echo '<tr>'; |
|
203 | + } |
|
181 | 204 | echo '<td>{{'.$name.'}}</td><td>'.$label.'</td>'; |
182 | 205 | if($name == 'cat_id') |
183 | 206 | { |
184 | - if ($n&1) echo "</tr>\n"; |
|
207 | + if ($n&1) |
|
208 | + { |
|
209 | + echo "</tr>\n"; |
|
210 | + } |
|
185 | 211 | echo '<td>{{categories}}</td><td>'.lang('Category path').'</td>'; |
186 | 212 | $n++; |
187 | 213 | } |
188 | - if ($n&1) echo "</tr>\n"; |
|
214 | + if ($n&1) |
|
215 | + { |
|
216 | + echo "</tr>\n"; |
|
217 | + } |
|
189 | 218 | $n++; |
190 | 219 | } |
191 | 220 | |
@@ -242,14 +271,23 @@ discard block |
||
242 | 271 | 'owner' => lang('Owner'), |
243 | 272 | ) as $name => $label) |
244 | 273 | { |
245 | - if (in_array($name,array('start','end')) && $n&1) // main values, which should be in the first column |
|
274 | + if (in_array($name,array('start','end')) && $n&1) |
|
275 | + { |
|
276 | + // main values, which should be in the first column |
|
246 | 277 | { |
247 | 278 | echo "</tr>\n"; |
279 | + } |
|
248 | 280 | $n++; |
249 | 281 | } |
250 | - if (!($n&1)) echo '<tr>'; |
|
282 | + if (!($n&1)) |
|
283 | + { |
|
284 | + echo '<tr>'; |
|
285 | + } |
|
251 | 286 | echo '<td>{{calendar/#/'.$name.'}}</td><td>'.$label.'</td>'; |
252 | - if ($n&1) echo "</tr>\n"; |
|
287 | + if ($n&1) |
|
288 | + { |
|
289 | + echo "</tr>\n"; |
|
290 | + } |
|
253 | 291 | $n++; |
254 | 292 | } |
255 | 293 | echo "</table>\n"; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @var string |
44 | 44 | * @access public |
45 | 45 | */ |
46 | - var $debug = 0; // This will turn on debugging information. |
|
46 | + var $debug = 0; // This will turn on debugging information. |
|
47 | 47 | /** |
48 | 48 | * Instance of the account object |
49 | 49 | * |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | * @author [email protected] |
58 | 58 | * @param array $domain_names array with valid egw-domain names |
59 | 59 | */ |
60 | - function __construct($domain_names=null) |
|
60 | + function __construct($domain_names = null) |
|
61 | 61 | { |
62 | - $GLOBALS['egw'] =& $this; // we need to be immediately available there for the other classes we instantiate |
|
63 | - $this->setup($domain_names,True); |
|
62 | + $GLOBALS['egw'] = & $this; // we need to be immediately available there for the other classes we instantiate |
|
63 | + $this->setup($domain_names, True); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @param array $domain_names array with valid egw-domain names |
71 | 71 | * @param boolean $createsessionobject True to create the session object (default=True) |
72 | 72 | */ |
73 | - function setup($domain_names,$createsessionobject=True) |
|
73 | + function setup($domain_names, $createsessionobject = True) |
|
74 | 74 | { |
75 | 75 | // create the DB-object |
76 | 76 | // as SiteMgr, Wiki, KnowledgeBase and probably more still use eg next_record(), we stick with Db\Deprecated for now |
@@ -84,18 +84,18 @@ discard block |
||
84 | 84 | // check if eGW is already setup, if not redirect to setup/ |
85 | 85 | try { |
86 | 86 | $this->db->connect(); |
87 | - $num_config = $this->db->select(Config::TABLE,'COUNT(config_name)',false,__LINE__,__FILE__)->fetchColumn(); |
|
87 | + $num_config = $this->db->select(Config::TABLE, 'COUNT(config_name)', false, __LINE__, __FILE__)->fetchColumn(); |
|
88 | 88 | } |
89 | - catch(Db\Exception\Connection $e) { |
|
89 | + catch (Db\Exception\Connection $e) { |
|
90 | 90 | // ignore exception, get handled below |
91 | 91 | } |
92 | - catch(Db\Exception\InvalidSql $e1) { |
|
93 | - unset($e1); // not used |
|
92 | + catch (Db\Exception\InvalidSql $e1) { |
|
93 | + unset($e1); // not used |
|
94 | 94 | try { |
95 | - $phpgw_config = $this->db->select('phpgw_config','COUNT(config_name)',false,__LINE__,__FILE__)->fetchColumn(); |
|
95 | + $phpgw_config = $this->db->select('phpgw_config', 'COUNT(config_name)', false, __LINE__, __FILE__)->fetchColumn(); |
|
96 | 96 | } |
97 | 97 | catch (Db\Exception\InvalidSql $e2) { |
98 | - unset($e2); // not used |
|
98 | + unset($e2); // not used |
|
99 | 99 | // ignor error, get handled below |
100 | 100 | } |
101 | 101 | } |
@@ -104,20 +104,20 @@ discard block |
||
104 | 104 | // we check for the old table too, to not scare updating users ;-) |
105 | 105 | if ($phpgw_config) |
106 | 106 | { |
107 | - throw new Exception('You need to update EGroupware before you can continue using it.',999); |
|
107 | + throw new Exception('You need to update EGroupware before you can continue using it.', 999); |
|
108 | 108 | } |
109 | 109 | if ($e) |
110 | 110 | { |
111 | 111 | throw new Db\Exception\Setup('Connection with '.$e->getMessage()."\n\n". |
112 | - 'Maybe you not created a database for EGroupware yet.',999); |
|
112 | + 'Maybe you not created a database for EGroupware yet.', 999); |
|
113 | 113 | } |
114 | - throw new Db\Exception\Setup('It appears that you have not created the database tables for EGroupware.',999); |
|
114 | + throw new Db\Exception\Setup('It appears that you have not created the database tables for EGroupware.', 999); |
|
115 | 115 | } |
116 | 116 | // Set the DB's client charset if a system-charset is set and some other values needed by egw_cache (used in Config::read) |
117 | - foreach($this->db->select(Config::TABLE,'config_name,config_value',array( |
|
117 | + foreach ($this->db->select(Config::TABLE, 'config_name,config_value', array( |
|
118 | 118 | 'config_app' => 'phpgwapi', |
119 | - 'config_name' => array('system_charset','install_id','temp_dir'), |
|
120 | - ),__LINE__,__FILE__) as $row) |
|
119 | + 'config_name' => array('system_charset', 'install_id', 'temp_dir'), |
|
120 | + ), __LINE__, __FILE__) as $row) |
|
121 | 121 | { |
122 | 122 | $GLOBALS['egw_info']['server'][$row['config_name']] = $row['config_value']; |
123 | 123 | } |
@@ -136,10 +136,10 @@ discard block |
||
136 | 136 | try |
137 | 137 | { |
138 | 138 | $tz = new \DateTimeZone(date_default_timezone_get()); |
139 | - Config::save_value('server_timezone',$GLOBALS['egw_info']['server']['server_timezone'] = $tz->getName(),'phpgwapi'); |
|
139 | + Config::save_value('server_timezone', $GLOBALS['egw_info']['server']['server_timezone'] = $tz->getName(), 'phpgwapi'); |
|
140 | 140 | error_log(__METHOD__."() stored server_timezone=".$GLOBALS['egw_info']['server']['server_timezone']); |
141 | 141 | } |
142 | - catch(Exception $e) |
|
142 | + catch (Exception $e) |
|
143 | 143 | { |
144 | 144 | // do nothing if new DateTimeZone fails (eg. 'System/Localtime' returned), specially do NOT store it! |
145 | 145 | error_log(__METHOD__."() NO valid 'date.timezone' set in your php.ini!"); |
@@ -150,24 +150,24 @@ discard block |
||
150 | 150 | // if phpgwapi exists we prefer accounts and egw_session, as they have some deprecated methods |
151 | 151 | if (file_exists(EGW_SERVER_ROOT.'/phpgwapi')) |
152 | 152 | { |
153 | - $this->accounts = new egw_accounts(); |
|
153 | + $this->accounts = new egw_accounts(); |
|
154 | 154 | /* Do not create the session object if called by the sessions class. This way |
155 | 155 | * we ensure the correct db based on the user domain. |
156 | 156 | */ |
157 | - if($createsessionobject) |
|
157 | + if ($createsessionobject) |
|
158 | 158 | { |
159 | - $this->session = new egw_session($domain_names); |
|
159 | + $this->session = new egw_session($domain_names); |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | else |
163 | 163 | { |
164 | - $this->accounts = new Accounts(); |
|
164 | + $this->accounts = new Accounts(); |
|
165 | 165 | /* Do not create the session object if called by the sessions class. This way |
166 | 166 | * we ensure the correct db based on the user domain. |
167 | 167 | */ |
168 | - if($createsessionobject) |
|
168 | + if ($createsessionobject) |
|
169 | 169 | { |
170 | - $this->session = new Session($domain_names); |
|
170 | + $this->session = new Session($domain_names); |
|
171 | 171 | } |
172 | 172 | } |
173 | 173 | // setup the other subclasses |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | if ($GLOBALS['egw_info']['flags']['currentapp'] != 'login' && $GLOBALS['egw_info']['flags']['currentapp'] != 'logout') |
179 | 179 | { |
180 | 180 | $this->verify_session(); |
181 | - $this->applications->read_installed_apps(); // to get translated app-titles, has to be after verify_session |
|
181 | + $this->applications->read_installed_apps(); // to get translated app-titles, has to be after verify_session |
|
182 | 182 | |
183 | 183 | $this->define_egw_constants(); |
184 | 184 | |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | */ |
200 | 200 | function __wakeup() |
201 | 201 | { |
202 | - $GLOBALS['egw'] =& $this; // we need to be immediately available there for the other classes we instantiate |
|
202 | + $GLOBALS['egw'] = & $this; // we need to be immediately available there for the other classes we instantiate |
|
203 | 203 | // for the migration: reference us to the old phpgw object |
204 | - $GLOBALS['phpgw'] =& $this; |
|
204 | + $GLOBALS['phpgw'] = & $this; |
|
205 | 205 | |
206 | 206 | if ($GLOBALS['egw_info']['server']['system_charset']) |
207 | 207 | { |
@@ -271,15 +271,15 @@ discard block |
||
271 | 271 | } |
272 | 272 | |
273 | 273 | // Load the (depricated) app include files if they exists |
274 | - if (EGW_APP_INC != "" && ! preg_match ('/phpgwapi/i', EGW_APP_INC) && |
|
275 | - file_exists(EGW_APP_INC . '/functions.inc.php') && !isset($_GET['menuaction'])) |
|
274 | + if (EGW_APP_INC != "" && !preg_match('/phpgwapi/i', EGW_APP_INC) && |
|
275 | + file_exists(EGW_APP_INC.'/functions.inc.php') && !isset($_GET['menuaction'])) |
|
276 | 276 | { |
277 | - include(EGW_APP_INC . '/functions.inc.php'); |
|
277 | + include(EGW_APP_INC.'/functions.inc.php'); |
|
278 | 278 | } |
279 | 279 | if (!@$GLOBALS['egw_info']['flags']['noheader'] && !@$GLOBALS['egw_info']['flags']['noappheader'] && |
280 | - file_exists(EGW_APP_INC . '/header.inc.php') && !isset($_GET['menuaction'])) |
|
280 | + file_exists(EGW_APP_INC.'/header.inc.php') && !isset($_GET['menuaction'])) |
|
281 | 281 | { |
282 | - include(EGW_APP_INC . '/header.inc.php'); |
|
282 | + include(EGW_APP_INC.'/header.inc.php'); |
|
283 | 283 | } |
284 | 284 | } |
285 | 285 | |
@@ -295,9 +295,9 @@ discard block |
||
295 | 295 | */ |
296 | 296 | function verify_session() |
297 | 297 | { |
298 | - if($GLOBALS['egw_info']['server']['enforce_ssl'] === 'redirect' && !$_SERVER['HTTPS']) |
|
298 | + if ($GLOBALS['egw_info']['server']['enforce_ssl'] === 'redirect' && !$_SERVER['HTTPS']) |
|
299 | 299 | { |
300 | - Header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); |
|
300 | + Header('Location: https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); |
|
301 | 301 | exit; |
302 | 302 | } |
303 | 303 | // check if we have a session, if not try to automatic create one |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | |
306 | 306 | $account = null; |
307 | 307 | if (($account_callback = $GLOBALS['egw_info']['flags']['autocreate_session_callback']) && is_callable($account_callback) && |
308 | - ($sessionid = call_user_func_array($account_callback,array(&$account))) === true) // $account_call_back returns true, false or a session-id |
|
308 | + ($sessionid = call_user_func_array($account_callback, array(&$account))) === true) // $account_call_back returns true, false or a session-id |
|
309 | 309 | { |
310 | 310 | $sessionid = $this->session->create($account); |
311 | 311 | } |
@@ -314,21 +314,21 @@ discard block |
||
314 | 314 | //echo "<p>account_callback='$account_callback', account=".print_r($account,true).", sessionid=$sessionid</p>\n"; exit; |
315 | 315 | // we forward to the same place after the re-login |
316 | 316 | if ($GLOBALS['egw_info']['server']['webserver_url'] && $GLOBALS['egw_info']['server']['webserver_url'] != '/' && |
317 | - ($webserver_path = parse_url($GLOBALS['egw_info']['server']['webserver_url'],PHP_URL_PATH)) && $webserver_path != '/') |
|
317 | + ($webserver_path = parse_url($GLOBALS['egw_info']['server']['webserver_url'], PHP_URL_PATH)) && $webserver_path != '/') |
|
318 | 318 | { |
319 | 319 | // we have to use only path component, to cope with domains like http://egroupware.domain.com and /egroupware |
320 | - list(,$relpath) = explode($webserver_path,parse_url($_SERVER['PHP_SELF'],PHP_URL_PATH),2); |
|
320 | + list(,$relpath) = explode($webserver_path, parse_url($_SERVER['PHP_SELF'], PHP_URL_PATH), 2); |
|
321 | 321 | } |
322 | 322 | else // the webserver-url is empty or just a slash '/' (eGW is installed in the docroot and no domain given) |
323 | 323 | { |
324 | 324 | $matches = null; |
325 | - if (preg_match('/^https?:\/\/[^\/]*\/(.*)$/',$relpath=$_SERVER['PHP_SELF'],$matches)) |
|
325 | + if (preg_match('/^https?:\/\/[^\/]*\/(.*)$/', $relpath = $_SERVER['PHP_SELF'], $matches)) |
|
326 | 326 | { |
327 | 327 | $relpath = $matches[1]; |
328 | 328 | } |
329 | 329 | } |
330 | 330 | // this removes the sessiondata if its saved in the URL |
331 | - $query = preg_replace('/[&]?sessionid(=|%3D)[^&]+&kp3(=|%3D)[^&]+&domain=.*$/','',$_SERVER['QUERY_STRING']); |
|
331 | + $query = preg_replace('/[&]?sessionid(=|%3D)[^&]+&kp3(=|%3D)[^&]+&domain=.*$/', '', $_SERVER['QUERY_STRING']); |
|
332 | 332 | if ($GLOBALS['egw_info']['server']['http_auth_types']) |
333 | 333 | { |
334 | 334 | $redirect = '/phpgwapi/ntlm/index.php?'; |
@@ -355,9 +355,9 @@ discard block |
||
355 | 355 | */ |
356 | 356 | function check_app_rights() |
357 | 357 | { |
358 | - $this->currentapp = $GLOBALS['egw_info']['flags']['currentapp']; // some apps change it later |
|
358 | + $this->currentapp = $GLOBALS['egw_info']['flags']['currentapp']; // some apps change it later |
|
359 | 359 | |
360 | - if (!in_array($GLOBALS['egw_info']['flags']['currentapp'], array('api','about'))) // give everyone implicit api rights |
|
360 | + if (!in_array($GLOBALS['egw_info']['flags']['currentapp'], array('api', 'about'))) // give everyone implicit api rights |
|
361 | 361 | { |
362 | 362 | // This will need to use ACL in the future |
363 | 363 | if (!$GLOBALS['egw_info']['user']['apps'][$currentapp = $GLOBALS['egw_info']['flags']['currentapp']] || |
@@ -387,25 +387,25 @@ discard block |
||
387 | 387 | */ |
388 | 388 | function define_egw_constants() |
389 | 389 | { |
390 | - define('EGW_ACL_READ',1); |
|
391 | - define('EGW_ACL_ADD',2); |
|
392 | - define('EGW_ACL_EDIT',4); |
|
393 | - define('EGW_ACL_DELETE',8); |
|
394 | - define('EGW_ACL_PRIVATE',16); |
|
395 | - define('EGW_ACL_GROUP_MANAGERS',32); |
|
396 | - define('EGW_ACL_CUSTOM_1',64); |
|
397 | - define('EGW_ACL_CUSTOM_2',128); |
|
398 | - define('EGW_ACL_CUSTOM_3',256); |
|
390 | + define('EGW_ACL_READ', 1); |
|
391 | + define('EGW_ACL_ADD', 2); |
|
392 | + define('EGW_ACL_EDIT', 4); |
|
393 | + define('EGW_ACL_DELETE', 8); |
|
394 | + define('EGW_ACL_PRIVATE', 16); |
|
395 | + define('EGW_ACL_GROUP_MANAGERS', 32); |
|
396 | + define('EGW_ACL_CUSTOM_1', 64); |
|
397 | + define('EGW_ACL_CUSTOM_2', 128); |
|
398 | + define('EGW_ACL_CUSTOM_3', 256); |
|
399 | 399 | // and the old ones |
400 | - define('PHPGW_ACL_READ',1); |
|
401 | - define('PHPGW_ACL_ADD',2); |
|
402 | - define('PHPGW_ACL_EDIT',4); |
|
403 | - define('PHPGW_ACL_DELETE',8); |
|
404 | - define('PHPGW_ACL_PRIVATE',16); |
|
405 | - define('PHPGW_ACL_GROUP_MANAGERS',32); |
|
406 | - define('PHPGW_ACL_CUSTOM_1',64); |
|
407 | - define('PHPGW_ACL_CUSTOM_2',128); |
|
408 | - define('PHPGW_ACL_CUSTOM_3',256); |
|
400 | + define('PHPGW_ACL_READ', 1); |
|
401 | + define('PHPGW_ACL_ADD', 2); |
|
402 | + define('PHPGW_ACL_EDIT', 4); |
|
403 | + define('PHPGW_ACL_DELETE', 8); |
|
404 | + define('PHPGW_ACL_PRIVATE', 16); |
|
405 | + define('PHPGW_ACL_GROUP_MANAGERS', 32); |
|
406 | + define('PHPGW_ACL_CUSTOM_1', 64); |
|
407 | + define('PHPGW_ACL_CUSTOM_2', 128); |
|
408 | + define('PHPGW_ACL_CUSTOM_3', 256); |
|
409 | 409 | // A few hacker resistant constants that will be used throught the program |
410 | 410 | if (file_exists(EGW_SERVER_ROOT.'/phpgwapi')) |
411 | 411 | { |
@@ -418,14 +418,14 @@ discard block |
||
418 | 418 | define('EGW_IMAGES', $this->common->get_image_path()); |
419 | 419 | define('EGW_APP_IMAGES_DIR', $this->common->get_image_dir()); |
420 | 420 | // and the old ones |
421 | - define('PHPGW_TEMPLATE_DIR',EGW_TEMPLATE_DIR); |
|
422 | - define('PHPGW_IMAGES_DIR',EGW_IMAGES_DIR); |
|
423 | - define('PHPGW_IMAGES_FILEDIR',EGW_IMAGES_FILEDIR); |
|
424 | - define('PHPGW_APP_ROOT',EGW_APP_ROOT); |
|
425 | - define('PHPGW_APP_INC',EGW_APP_INC); |
|
426 | - define('PHPGW_APP_TPL',EGW_APP_TPL); |
|
427 | - define('PHPGW_IMAGES',EGW_IMAGES); |
|
428 | - define('PHPGW_APP_IMAGES_DIR',EGW_APP_IMAGES_DIR); |
|
421 | + define('PHPGW_TEMPLATE_DIR', EGW_TEMPLATE_DIR); |
|
422 | + define('PHPGW_IMAGES_DIR', EGW_IMAGES_DIR); |
|
423 | + define('PHPGW_IMAGES_FILEDIR', EGW_IMAGES_FILEDIR); |
|
424 | + define('PHPGW_APP_ROOT', EGW_APP_ROOT); |
|
425 | + define('PHPGW_APP_INC', EGW_APP_INC); |
|
426 | + define('PHPGW_APP_TPL', EGW_APP_TPL); |
|
427 | + define('PHPGW_IMAGES', EGW_IMAGES); |
|
428 | + define('PHPGW_APP_IMAGES_DIR', EGW_APP_IMAGES_DIR); |
|
429 | 429 | } |
430 | 430 | } |
431 | 431 | |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | * @param string $link_app =null if appname or true, some templates generate a special link-handler url |
461 | 461 | * @return string The full url after processing |
462 | 462 | */ |
463 | - static function link($url, $extravars = '', $link_app=null) |
|
463 | + static function link($url, $extravars = '', $link_app = null) |
|
464 | 464 | { |
465 | 465 | return $GLOBALS['egw']->framework->link($url, $extravars, $link_app); |
466 | 466 | } |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | * @param string $link_app =null if appname or true, some templates generate a special link-handler url |
474 | 474 | * @return string The full url after processing |
475 | 475 | */ |
476 | - static function redirect_link($url, $extravars='', $link_app=null) |
|
476 | + static function redirect_link($url, $extravars = '', $link_app = null) |
|
477 | 477 | { |
478 | 478 | return $GLOBALS['egw']->framework->redirect_link($url, $extravars, $link_app); |
479 | 479 | } |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | * @param string $url url to redirect to |
487 | 487 | * @param string $link_app =null appname to redirect for, default currentapp |
488 | 488 | */ |
489 | - static function redirect($url, $link_app=null) |
|
489 | + static function redirect($url, $link_app = null) |
|
490 | 490 | { |
491 | 491 | Framework::redirect($url, $link_app); |
492 | 492 | } |
@@ -500,14 +500,14 @@ discard block |
||
500 | 500 | * @param string The key for the phrase |
501 | 501 | * @see Translation::translate() |
502 | 502 | */ |
503 | - static function lang($key,$args=null) |
|
503 | + static function lang($key, $args = null) |
|
504 | 504 | { |
505 | 505 | if (!is_array($args)) |
506 | 506 | { |
507 | 507 | $args = func_get_args(); |
508 | 508 | array_shift($args); |
509 | 509 | } |
510 | - return Translation::translate($key,$args); |
|
510 | + return Translation::translate($key, $args); |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | /** |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | * @param callable $callback use array($classname, $method) for static methods |
527 | 527 | * @param array $args =array() |
528 | 528 | */ |
529 | - public static function on_shutdown($callback, array $args=array()) |
|
529 | + public static function on_shutdown($callback, array $args = array()) |
|
530 | 530 | { |
531 | 531 | array_unshift($args, $callback); |
532 | 532 | |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | { |
542 | 542 | if (!defined('EGW_SHUTDOWN')) |
543 | 543 | { |
544 | - define('EGW_SHUTDOWN',True); |
|
544 | + define('EGW_SHUTDOWN', True); |
|
545 | 545 | |
546 | 546 | // send json response BEFORE flushing output |
547 | 547 | if (Json\Request::isJSONRequest()) |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | } |
551 | 551 | |
552 | 552 | // run all on_shutdown callbacks with session in their name (eg. egw_link::save_session_cache), do NOT stop on exceptions |
553 | - foreach(self::$shutdown_callbacks as $n => $data) |
|
553 | + foreach (self::$shutdown_callbacks as $n => $data) |
|
554 | 554 | { |
555 | 555 | try { |
556 | 556 | //error_log(__METHOD__."() running ".array2string($data)); |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | } |
582 | 582 | |
583 | 583 | // run all on_shutdown, do NOT stop on exceptions |
584 | - foreach(self::$shutdown_callbacks as $data) |
|
584 | + foreach (self::$shutdown_callbacks as $data) |
|
585 | 585 | { |
586 | 586 | try { |
587 | 587 | //error_log(__METHOD__."() running ".array2string($data)); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | 'config_app' => 'phpgwapi', |
119 | 119 | 'config_name' => array('system_charset','install_id','temp_dir'), |
120 | 120 | ),__LINE__,__FILE__) as $row) |
121 | - { |
|
121 | + { |
|
122 | 122 | $GLOBALS['egw_info']['server'][$row['config_name']] = $row['config_value']; |
123 | 123 | } |
124 | 124 | if ($GLOBALS['egw_info']['server']['system_charset'] && $GLOBALS['egw_info']['server']['system_charset'] != 'utf-8') |
@@ -131,11 +131,14 @@ discard block |
||
131 | 131 | // if no server timezone set, use date_default_timezone_get() to determine it once |
132 | 132 | // it fills to log with deprecated warnings under 5.3 otherwise |
133 | 133 | if (empty($GLOBALS['egw_info']['server']['server_timezone']) || |
134 | - $GLOBALS['egw_info']['server']['server_timezone'] == 'System/Localtime') // treat invalid tz like empty! |
|
134 | + $GLOBALS['egw_info']['server']['server_timezone'] == 'System/Localtime') |
|
135 | + { |
|
136 | + // treat invalid tz like empty! |
|
135 | 137 | { |
136 | 138 | try |
137 | 139 | { |
138 | 140 | $tz = new \DateTimeZone(date_default_timezone_get()); |
141 | + } |
|
139 | 142 | Config::save_value('server_timezone',$GLOBALS['egw_info']['server']['server_timezone'] = $tz->getName(),'phpgwapi'); |
140 | 143 | error_log(__METHOD__."() stored server_timezone=".$GLOBALS['egw_info']['server']['server_timezone']); |
141 | 144 | } |
@@ -301,14 +304,20 @@ discard block |
||
301 | 304 | exit; |
302 | 305 | } |
303 | 306 | // check if we have a session, if not try to automatic create one |
304 | - if ($this->session->verify()) return true; |
|
307 | + if ($this->session->verify()) |
|
308 | + { |
|
309 | + return true; |
|
310 | + } |
|
305 | 311 | |
306 | 312 | $account = null; |
307 | 313 | if (($account_callback = $GLOBALS['egw_info']['flags']['autocreate_session_callback']) && is_callable($account_callback) && |
308 | - ($sessionid = call_user_func_array($account_callback,array(&$account))) === true) // $account_call_back returns true, false or a session-id |
|
314 | + ($sessionid = call_user_func_array($account_callback,array(&$account))) === true) |
|
315 | + { |
|
316 | + // $account_call_back returns true, false or a session-id |
|
309 | 317 | { |
310 | 318 | $sessionid = $this->session->create($account); |
311 | 319 | } |
320 | + } |
|
312 | 321 | if (!$sessionid) |
313 | 322 | { |
314 | 323 | //echo "<p>account_callback='$account_callback', account=".print_r($account,true).", sessionid=$sessionid</p>\n"; exit; |
@@ -337,9 +346,15 @@ discard block |
||
337 | 346 | { |
338 | 347 | $redirect = '/login.php?'; |
339 | 348 | // only add "your session could not be verified", if a sessionid is given (cookie or on url) |
340 | - if (Session::get_sessionid()) $redirect .= 'cd=10&'; |
|
349 | + if (Session::get_sessionid()) |
|
350 | + { |
|
351 | + $redirect .= 'cd=10&'; |
|
352 | + } |
|
353 | + } |
|
354 | + if ($relpath) |
|
355 | + { |
|
356 | + $redirect .= 'phpgw_forward='.urlencode($relpath.(!empty($query) ? '?'.$query : '')); |
|
341 | 357 | } |
342 | - if ($relpath) $redirect .= 'phpgw_forward='.urlencode($relpath.(!empty($query) ? '?'.$query : '')); |
|
343 | 358 | self::redirect_link($redirect); |
344 | 359 | } |
345 | 360 | } |
@@ -357,7 +372,9 @@ discard block |
||
357 | 372 | { |
358 | 373 | $this->currentapp = $GLOBALS['egw_info']['flags']['currentapp']; // some apps change it later |
359 | 374 | |
360 | - if (!in_array($GLOBALS['egw_info']['flags']['currentapp'], array('api','about'))) // give everyone implicit api rights |
|
375 | + if (!in_array($GLOBALS['egw_info']['flags']['currentapp'], array('api','about'))) |
|
376 | + { |
|
377 | + // give everyone implicit api rights |
|
361 | 378 | { |
362 | 379 | // This will need to use ACL in the future |
363 | 380 | if (!$GLOBALS['egw_info']['user']['apps'][$currentapp = $GLOBALS['egw_info']['flags']['currentapp']] || |
@@ -370,6 +387,7 @@ discard block |
||
370 | 387 | if (($sessionid = Session::get_sessionid(true))) |
371 | 388 | { |
372 | 389 | $GLOBALS['egw']->session->destroy($sessionid); |
390 | + } |
|
373 | 391 | } |
374 | 392 | throw new Exception\Redirect(self::link('/logout.php')); |
375 | 393 | } |
@@ -555,7 +573,10 @@ discard block |
||
555 | 573 | try { |
556 | 574 | //error_log(__METHOD__."() running ".array2string($data)); |
557 | 575 | $callback = array_shift($data); |
558 | - if (!is_array($callback) || strpos($callback[1], 'session') === false) continue; |
|
576 | + if (!is_array($callback) || strpos($callback[1], 'session') === false) |
|
577 | + { |
|
578 | + continue; |
|
579 | + } |
|
559 | 580 | call_user_func_array($callback, $data); |
560 | 581 | } |
561 | 582 | catch (\Exception $ex) { |
@@ -565,7 +586,10 @@ discard block |
||
565 | 586 | } |
566 | 587 | // now we can close the session |
567 | 588 | // without closing the session fastcgi_finish_request() will NOT send output to user |
568 | - if (isset($GLOBALS['egw']->session) && is_object($GLOBALS['egw']->session)) $GLOBALS['egw']->session->commit_session(); |
|
589 | + if (isset($GLOBALS['egw']->session) && is_object($GLOBALS['egw']->session)) |
|
590 | + { |
|
591 | + $GLOBALS['egw']->session->commit_session(); |
|
592 | + } |
|
569 | 593 | |
570 | 594 | // flush all output to user |
571 | 595 | /* does NOT work on Apache :-( |
@@ -593,9 +617,12 @@ discard block |
||
593 | 617 | } |
594 | 618 | } |
595 | 619 | // call the asyncservice check_run function if it is not explicitly set to cron-only |
596 | - if (!$GLOBALS['egw_info']['server']['asyncservice']) // is default |
|
620 | + if (!$GLOBALS['egw_info']['server']['asyncservice']) |
|
621 | + { |
|
622 | + // is default |
|
597 | 623 | { |
598 | 624 | $async = new Asyncservice(); |
625 | + } |
|
599 | 626 | $async->check_run('fallback'); |
600 | 627 | } |
601 | 628 | $this->db->disconnect(); |
@@ -447,10 +447,10 @@ discard block |
||
447 | 447 | * Important: PHP 5.0 introduced a bug that wasn't fixed until 5.1: the return value has to be the oposite! |
448 | 448 | * |
449 | 449 | * if(version_compare(PHP_VERSION,'5.0','>=') && version_compare(PHP_VERSION,'5.1','<')) |
450 | - * { |
|
450 | + * { |
|
451 | 451 | * $eof = !$eof; |
452 | 452 | * } |
453 | - * |
|
453 | + * |
|
454 | 454 | * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise |
455 | 455 | */ |
456 | 456 | function stream_eof ( ) |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | * See fseek() for more information about these parameters. |
486 | 486 | * |
487 | 487 | * @param integer $offset |
488 | - * @param integer $whence SEEK_SET - 0 - Set position equal to offset bytes |
|
488 | + * @param integer $whence SEEK_SET - 0 - Set position equal to offset bytes |
|
489 | 489 | * SEEK_CUR - 1 - Set position to current location plus offset. |
490 | 490 | * 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.) |
491 | 491 | * @return boolean TRUE if the position was updated, FALSE otherwise. |
@@ -681,8 +681,8 @@ discard block |
||
681 | 681 | $maxdepth=10; |
682 | 682 | $depth2propagate = (int)$depth + 1; |
683 | 683 | if ($depth2propagate > $maxdepth) return is_dir($pathname); |
684 | - is_dir(Vfs::dirname($pathname)) || self::mkdir_recursive(Vfs::dirname($pathname), $mode, $depth2propagate); |
|
685 | - return is_dir($pathname) || @mkdir($pathname, $mode); |
|
684 | + is_dir(Vfs::dirname($pathname)) || self::mkdir_recursive(Vfs::dirname($pathname), $mode, $depth2propagate); |
|
685 | + return is_dir($pathname) || @mkdir($pathname, $mode); |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | /** |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | * |
501 | 501 | * If you have cached data in your stream but not yet stored it into the underlying storage, you should do so now. |
502 | 502 | * |
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. |
|
503 | + * @return boolean 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 | 505 | function stream_flush ( ) |
506 | 506 | { |
@@ -541,6 +541,7 @@ discard block |
||
541 | 541 | * In order for the appropriate error message to be returned, do not define this method if your wrapper does not support unlinking! |
542 | 542 | * |
543 | 543 | * @param string $url |
544 | + * @param integer $parent_stat |
|
544 | 545 | * @return boolean TRUE on success or FALSE on failure |
545 | 546 | */ |
546 | 547 | static function unlink ( $url, $parent_stat=null ) |
@@ -669,6 +670,8 @@ discard block |
||
669 | 670 | |
670 | 671 | /** |
671 | 672 | * due to problems with recursive directory creation, we have our own here |
673 | + * @param false|string $pathname |
|
674 | + * @param integer $mode |
|
672 | 675 | */ |
673 | 676 | protected static function mkdir_recursive($pathname, $mode, $depth=0) |
674 | 677 | { |
@@ -999,7 +1002,7 @@ discard block |
||
999 | 1002 | * |
1000 | 1003 | * @param string $url URL that was passed to opendir() and that this object is expected to explore. |
1001 | 1004 | * @param int $options |
1002 | - * @return booelan |
|
1005 | + * @return boolean |
|
1003 | 1006 | */ |
1004 | 1007 | function dir_opendir ( $url, $options ) |
1005 | 1008 | { |
@@ -1399,7 +1402,7 @@ discard block |
||
1399 | 1402 | * |
1400 | 1403 | * @param string $path string with path |
1401 | 1404 | * @param int $rights =null rights to set, or null to delete the entry |
1402 | - * @param int|boolean $owner =null owner for whom to set the rights, null for the current user, or false to delete all rights for $path |
|
1405 | + * @param boolean $owner =null owner for whom to set the rights, null for the current user, or false to delete all rights for $path |
|
1403 | 1406 | * @param int $fs_id =null fs_id to use, to not query it again (eg. because it's already deleted) |
1404 | 1407 | * @return boolean true if acl is set/deleted, false on error |
1405 | 1408 | */ |
@@ -1676,6 +1679,7 @@ discard block |
||
1676 | 1679 | * Replace the password of an url with '...' for error messages |
1677 | 1680 | * |
1678 | 1681 | * @param string &$url |
1682 | + * @param string $url |
|
1679 | 1683 | */ |
1680 | 1684 | static protected function _remove_password(&$url) |
1681 | 1685 | { |
@@ -1691,7 +1695,7 @@ discard block |
||
1691 | 1695 | /** |
1692 | 1696 | * Get storage mode from url (get parameter 'storage', eg. ?storage=db) |
1693 | 1697 | * |
1694 | - * @param string|array $url complete url or array of url-parts from parse_url |
|
1698 | + * @param string $url complete url or array of url-parts from parse_url |
|
1695 | 1699 | * @return int self::STORE2FS or self::STORE2DB |
1696 | 1700 | */ |
1697 | 1701 | static function url2operation($url) |
@@ -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 = static::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 = static::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=static::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 = static::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,31 +543,30 @@ discard block |
||
543 | 543 | * @param string $url |
544 | 544 | * @return boolean TRUE on success or FALSE on failure |
545 | 545 | */ |
546 | - static function unlink ( $url, $parent_stat=null ) |
|
546 | + static 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)) |
554 | 554 | { |
555 | - $parent_stat = !($dir = Vfs::dirname($path)) ? false : |
|
556 | - static::url_stat($dir, STREAM_URL_STAT_LINK); |
|
555 | + $parent_stat = !($dir = Vfs::dirname($path)) ? false : static::url_stat($dir, STREAM_URL_STAT_LINK); |
|
557 | 556 | } |
558 | 557 | |
559 | - if (!$parent_stat || !($stat = self::url_stat($path,STREAM_URL_STAT_LINK)) || |
|
558 | + if (!$parent_stat || !($stat = self::url_stat($path, STREAM_URL_STAT_LINK)) || |
|
560 | 559 | !Vfs::check_access($dir, Vfs::WRITABLE, $parent_stat)) |
561 | 560 | { |
562 | 561 | self::_remove_password($url); |
563 | 562 | if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!"); |
564 | - return false; // no permission or file does not exist |
|
563 | + return false; // no permission or file does not exist |
|
565 | 564 | } |
566 | 565 | if ($stat['mime'] == self::DIR_MIME_TYPE) |
567 | 566 | { |
568 | 567 | self::_remove_password($url); |
569 | 568 | if (self::LOG_LEVEL) error_log(__METHOD__."($url) is NO file!"); |
570 | - return false; // no permission or file does not exist |
|
569 | + return false; // no permission or file does not exist |
|
571 | 570 | } |
572 | 571 | $stmt = self::$pdo->prepare('DELETE FROM '.self::TABLE.' WHERE fs_id=:fs_id'); |
573 | 572 | unset(self::$stat_cache[$path]); |
@@ -575,7 +574,7 @@ discard block |
||
575 | 574 | if (($ret = $stmt->execute(array('fs_id' => $stat['ino'])))) |
576 | 575 | { |
577 | 576 | if (self::url2operation($url) == self::STORE2FS && |
578 | - ($stat['mode'] & self::MODE_LINK) != self::MODE_LINK) |
|
577 | + ($stat['mode']&self::MODE_LINK) != self::MODE_LINK) |
|
579 | 578 | { |
580 | 579 | unlink(self::_fs_path($stat['ino'])); |
581 | 580 | } |
@@ -599,13 +598,13 @@ discard block |
||
599 | 598 | * @param string $url_to |
600 | 599 | * @return boolean TRUE on success or FALSE on failure |
601 | 600 | */ |
602 | - static function rename ( $url_from, $url_to) |
|
601 | + static function rename($url_from, $url_to) |
|
603 | 602 | { |
604 | 603 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url_from,$url_to)"); |
605 | 604 | |
606 | - $path_from = Vfs::parse_url($url_from,PHP_URL_PATH); |
|
605 | + $path_from = Vfs::parse_url($url_from, PHP_URL_PATH); |
|
607 | 606 | $from_dir = Vfs::dirname($path_from); |
608 | - $path_to = Vfs::parse_url($url_to,PHP_URL_PATH); |
|
607 | + $path_to = Vfs::parse_url($url_to, PHP_URL_PATH); |
|
609 | 608 | $to_dir = Vfs::dirname($path_to); |
610 | 609 | $operation = self::url2operation($url_from); |
611 | 610 | |
@@ -615,14 +614,14 @@ discard block |
||
615 | 614 | self::_remove_password($url_from); |
616 | 615 | self::_remove_password($url_to); |
617 | 616 | 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 |
|
617 | + return false; // no permission or file does not exist |
|
619 | 618 | } |
620 | 619 | if (!$to_dir || !Vfs::check_access($to_dir, Vfs::WRITABLE, $to_dir_stat = static::url_stat($to_dir, 0))) |
621 | 620 | { |
622 | 621 | self::_remove_password($url_from); |
623 | 622 | self::_remove_password($url_to); |
624 | 623 | 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 |
|
624 | + return false; // no permission or parent-dir does not exist |
|
626 | 625 | } |
627 | 626 | // the filesystem stream-wrapper does NOT allow to rename files to directories, as this makes problems |
628 | 627 | // for our vfs too, we abort here with an error, like the filesystem one does |
@@ -633,10 +632,10 @@ discard block |
||
633 | 632 | self::_remove_password($url_to); |
634 | 633 | $is_dir = $to_stat['mime'] === self::DIR_MIME_TYPE ? 'a' : 'no'; |
635 | 634 | 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 |
|
635 | + return false; // no permission or file does not exist |
|
637 | 636 | } |
638 | 637 | // if destination file already exists, delete it |
639 | - if ($to_stat && !static::unlink($url_to,$operation)) |
|
638 | + if ($to_stat && !static::unlink($url_to, $operation)) |
|
640 | 639 | { |
641 | 640 | self::_remove_password($url_to); |
642 | 641 | if (self::LOG_LEVEL) error_log(__METHOD__."($url_to,$url_from) can't unlink existing $url_to!"); |
@@ -657,7 +656,7 @@ discard block |
||
657 | 656 | |
658 | 657 | // check if extension changed and update mime-type in that case (as we currently determine mime-type by it's extension!) |
659 | 658 | // 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)) |
|
659 | + if ($ok && ($new_mime = Vfs::mime_content_type($url_to, true)) != Vfs::mime_content_type($url_to)) |
|
661 | 660 | { |
662 | 661 | //echo "<p>Vfs::nime_content_type($url_to,true) = $new_mime</p>\n"; |
663 | 662 | $stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_mime=:fs_mime WHERE fs_id=:fs_id'); |
@@ -673,9 +672,9 @@ discard block |
||
673 | 672 | /** |
674 | 673 | * due to problems with recursive directory creation, we have our own here |
675 | 674 | */ |
676 | - protected static function mkdir_recursive($pathname, $mode, $depth=0) |
|
675 | + protected static function mkdir_recursive($pathname, $mode, $depth = 0) |
|
677 | 676 | { |
678 | - $maxdepth=10; |
|
677 | + $maxdepth = 10; |
|
679 | 678 | $depth2propagate = (int)$depth + 1; |
680 | 679 | if ($depth2propagate > $maxdepth) return is_dir($pathname); |
681 | 680 | is_dir(Vfs::dirname($pathname)) || self::mkdir_recursive(Vfs::dirname($pathname), $mode, $depth2propagate); |
@@ -693,19 +692,19 @@ discard block |
||
693 | 692 | * @param int $options Posible values include STREAM_REPORT_ERRORS and STREAM_MKDIR_RECURSIVE |
694 | 693 | * @return boolean TRUE on success or FALSE on failure |
695 | 694 | */ |
696 | - static function mkdir ( $url, $mode, $options ) |
|
695 | + static function mkdir($url, $mode, $options) |
|
697 | 696 | { |
698 | 697 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$mode,$options)"); |
699 | 698 | if (self::LOG_LEVEL > 1) error_log(__METHOD__." called from:".function_backtrace()); |
700 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
699 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
701 | 700 | |
702 | - if (self::url_stat($path,STREAM_URL_STAT_QUIET)) |
|
701 | + if (self::url_stat($path, STREAM_URL_STAT_QUIET)) |
|
703 | 702 | { |
704 | 703 | self::_remove_password($url); |
705 | 704 | if (self::LOG_LEVEL) error_log(__METHOD__."('$url',$mode,$options) already exist!"); |
706 | - if (!($options & STREAM_REPORT_ERRORS)) |
|
705 | + if (!($options&STREAM_REPORT_ERRORS)) |
|
707 | 706 | { |
708 | - trigger_error(__METHOD__."('$url',$mode,$options) already exist!",E_USER_WARNING); |
|
707 | + trigger_error(__METHOD__."('$url',$mode,$options) already exist!", E_USER_WARNING); |
|
709 | 708 | } |
710 | 709 | return false; |
711 | 710 | } |
@@ -713,35 +712,35 @@ discard block |
||
713 | 712 | { |
714 | 713 | self::_remove_password($url); |
715 | 714 | if (self::LOG_LEVEL) error_log(__METHOD__."('$url',$mode,$options) dirname('$path')===false!"); |
716 | - if (!($options & STREAM_REPORT_ERRORS)) |
|
715 | + if (!($options&STREAM_REPORT_ERRORS)) |
|
717 | 716 | { |
718 | 717 | trigger_error(__METHOD__."('$url',$mode,$options) dirname('$path')===false!", E_USER_WARNING); |
719 | 718 | } |
720 | 719 | return false; |
721 | 720 | } |
722 | - if (($query = Vfs::parse_url($url,PHP_URL_QUERY))) $parent_path .= '?'.$query; |
|
723 | - $parent = self::url_stat($parent_path,STREAM_URL_STAT_QUIET); |
|
721 | + if (($query = Vfs::parse_url($url, PHP_URL_QUERY))) $parent_path .= '?'.$query; |
|
722 | + $parent = self::url_stat($parent_path, STREAM_URL_STAT_QUIET); |
|
724 | 723 | |
725 | 724 | // check if we should also create all non-existing path components and our parent does not exist, |
726 | 725 | // if yes call ourself recursive with the parent directory |
727 | - if (($options & STREAM_MKDIR_RECURSIVE) && $parent_path != '/' && !$parent) |
|
726 | + if (($options&STREAM_MKDIR_RECURSIVE) && $parent_path != '/' && !$parent) |
|
728 | 727 | { |
729 | 728 | if (self::LOG_LEVEL > 1) error_log(__METHOD__." creating parents: $parent_path, $mode"); |
730 | - if (!self::mkdir($parent_path,$mode,$options)) |
|
729 | + if (!self::mkdir($parent_path, $mode, $options)) |
|
731 | 730 | { |
732 | 731 | return false; |
733 | 732 | } |
734 | - $parent = self::url_stat($parent_path,0); |
|
733 | + $parent = self::url_stat($parent_path, 0); |
|
735 | 734 | } |
736 | - if (!$parent || !Vfs::check_access($parent_path,Vfs::WRITABLE,$parent)) |
|
735 | + if (!$parent || !Vfs::check_access($parent_path, Vfs::WRITABLE, $parent)) |
|
737 | 736 | { |
738 | 737 | self::_remove_password($url); |
739 | 738 | if (self::LOG_LEVEL) error_log(__METHOD__."('$url',$mode,$options) permission denied!"); |
740 | - if (!($options & STREAM_REPORT_ERRORS)) |
|
739 | + if (!($options&STREAM_REPORT_ERRORS)) |
|
741 | 740 | { |
742 | - trigger_error(__METHOD__."('$url',$mode,$options) permission denied!",E_USER_WARNING); |
|
741 | + trigger_error(__METHOD__."('$url',$mode,$options) permission denied!", E_USER_WARNING); |
|
743 | 742 | } |
744 | - return false; // no permission or file does not exist |
|
743 | + return false; // no permission or file does not exist |
|
745 | 744 | } |
746 | 745 | unset(self::$stat_cache[$path]); |
747 | 746 | $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 +761,9 @@ discard block |
||
762 | 761 | // check if some other process created the directory parallel to us (sqlfs would gives SQL errors later!) |
763 | 762 | $new_fs_id = self::$pdo->lastInsertId('egw_sqlfs_fs_id_seq'); |
764 | 763 | |
765 | - unset($stmt); // free statement object, on some installs a new prepare fails otherwise! |
|
764 | + unset($stmt); // free statement object, on some installs a new prepare fails otherwise! |
|
766 | 765 | |
767 | - $stmt = self::$pdo->prepare($q='SELECT COUNT(*) FROM '.self::TABLE. |
|
766 | + $stmt = self::$pdo->prepare($q = 'SELECT COUNT(*) FROM '.self::TABLE. |
|
768 | 767 | ' WHERE fs_dir=:fs_dir AND fs_active=:fs_active AND fs_name'.self::$case_sensitive_equal.':fs_name'); |
769 | 768 | if ($stmt->execute(array( |
770 | 769 | 'fs_dir' => $parent['ino'], |
@@ -788,25 +787,24 @@ discard block |
||
788 | 787 | * @param int $options Possible values include STREAM_REPORT_ERRORS. |
789 | 788 | * @return boolean TRUE on success or FALSE on failure. |
790 | 789 | */ |
791 | - static function rmdir ( $url, $options ) |
|
790 | + static function rmdir($url, $options) |
|
792 | 791 | { |
793 | 792 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url)"); |
794 | 793 | |
795 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
794 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
796 | 795 | |
797 | 796 | if (!($parent = Vfs::dirname($path)) || |
798 | 797 | !($stat = self::url_stat($path, 0)) || $stat['mime'] != self::DIR_MIME_TYPE || |
799 | - !Vfs::check_access($parent, Vfs::WRITABLE, static::url_stat($parent,0))) |
|
798 | + !Vfs::check_access($parent, Vfs::WRITABLE, static::url_stat($parent, 0))) |
|
800 | 799 | { |
801 | 800 | 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!')); |
|
801 | + $err_msg = __METHOD__."($url,$options) ".(!$stat ? 'not found!' : ($stat['mime'] != self::DIR_MIME_TYPE ? 'not a directory!' : 'permission denied!')); |
|
804 | 802 | if (self::LOG_LEVEL) error_log($err_msg); |
805 | - if (!($options & STREAM_REPORT_ERRORS)) |
|
803 | + if (!($options&STREAM_REPORT_ERRORS)) |
|
806 | 804 | { |
807 | - trigger_error($err_msg,E_USER_WARNING); |
|
805 | + trigger_error($err_msg, E_USER_WARNING); |
|
808 | 806 | } |
809 | - return false; // no permission or file does not exist |
|
807 | + return false; // no permission or file does not exist |
|
810 | 808 | } |
811 | 809 | $stmt = self::$pdo->prepare('SELECT COUNT(*) FROM '.self::TABLE.' WHERE fs_dir=?'); |
812 | 810 | $stmt->execute(array($stat['ino'])); |
@@ -814,19 +812,19 @@ discard block |
||
814 | 812 | { |
815 | 813 | self::_remove_password($url); |
816 | 814 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$options) dir is not empty!"); |
817 | - if (!($options & STREAM_REPORT_ERRORS)) |
|
815 | + if (!($options&STREAM_REPORT_ERRORS)) |
|
818 | 816 | { |
819 | - trigger_error(__METHOD__."('$url',$options) dir is not empty!",E_USER_WARNING); |
|
817 | + trigger_error(__METHOD__."('$url',$options) dir is not empty!", E_USER_WARNING); |
|
820 | 818 | } |
821 | 819 | return false; |
822 | 820 | } |
823 | 821 | unset(self::$stat_cache[$path]); |
824 | - unset($stmt); // free statement object, on some installs a new prepare fails otherwise! |
|
822 | + unset($stmt); // free statement object, on some installs a new prepare fails otherwise! |
|
825 | 823 | |
826 | 824 | $del_stmt = self::$pdo->prepare('DELETE FROM '.self::TABLE.' WHERE fs_id=?'); |
827 | 825 | if (($ret = $del_stmt->execute(array($stat['ino'])))) |
828 | 826 | { |
829 | - self::eacl($path,null,false,$stat['ino']); // remove all (=false) evtl. existing extended acl for that dir |
|
827 | + self::eacl($path, null, false, $stat['ino']); // remove all (=false) evtl. existing extended acl for that dir |
|
830 | 828 | // delete props |
831 | 829 | unset($del_stmt); |
832 | 830 | $del_stmt = self::$pdo->prepare('DELETE FROM '.self::PROPS_TABLE.' WHERE fs_id=?'); |
@@ -842,25 +840,25 @@ discard block |
||
842 | 840 | * @param int $time =null modification time (unix timestamp), default null = current time |
843 | 841 | * @param int $atime =null access time (unix timestamp), default null = current time, not implemented in the vfs! |
844 | 842 | */ |
845 | - static function touch($url,$time=null,$atime=null) |
|
843 | + static function touch($url, $time = null, $atime = null) |
|
846 | 844 | { |
847 | - unset($atime); // not used |
|
845 | + unset($atime); // not used |
|
848 | 846 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url, $time)"); |
849 | 847 | |
850 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
848 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
851 | 849 | |
852 | - if (!($stat = self::url_stat($path,STREAM_URL_STAT_QUIET))) |
|
850 | + if (!($stat = self::url_stat($path, STREAM_URL_STAT_QUIET))) |
|
853 | 851 | { |
854 | 852 | // file does not exist --> create an empty one |
855 | - if (!($f = fopen(self::SCHEME.'://default'.$path,'w')) || !fclose($f)) |
|
853 | + if (!($f = fopen(self::SCHEME.'://default'.$path, 'w')) || !fclose($f)) |
|
856 | 854 | { |
857 | 855 | return false; |
858 | 856 | } |
859 | 857 | if (is_null($time)) |
860 | 858 | { |
861 | - return true; // new (empty) file created with current mod time |
|
859 | + return true; // new (empty) file created with current mod time |
|
862 | 860 | } |
863 | - $stat = self::url_stat($path,0); |
|
861 | + $stat = self::url_stat($path, 0); |
|
864 | 862 | } |
865 | 863 | unset(self::$stat_cache[$path]); |
866 | 864 | $stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_modified=:fs_modified,fs_modifier=:fs_modifier WHERE fs_id=:fs_id'); |
@@ -879,39 +877,39 @@ discard block |
||
879 | 877 | * @param int $owner |
880 | 878 | * @return boolean |
881 | 879 | */ |
882 | - static function chown($url,$owner) |
|
880 | + static function chown($url, $owner) |
|
883 | 881 | { |
884 | 882 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$owner)"); |
885 | 883 | |
886 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
884 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
887 | 885 | |
888 | - if (!($stat = self::url_stat($path,0))) |
|
886 | + if (!($stat = self::url_stat($path, 0))) |
|
889 | 887 | { |
890 | 888 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) no such file or directory!"); |
891 | - trigger_error("No such file or directory $url !",E_USER_WARNING); |
|
889 | + trigger_error("No such file or directory $url !", E_USER_WARNING); |
|
892 | 890 | return false; |
893 | 891 | } |
894 | 892 | if (!Vfs::$is_root) |
895 | 893 | { |
896 | 894 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) only root can do that!"); |
897 | - trigger_error("Only root can do that!",E_USER_WARNING); |
|
895 | + trigger_error("Only root can do that!", E_USER_WARNING); |
|
898 | 896 | return false; |
899 | 897 | } |
900 | 898 | if ($owner < 0 || $owner && !$GLOBALS['egw']->accounts->id2name($owner)) // not a user (0 == root) |
901 | 899 | { |
902 | 900 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) unknown (numeric) user id!"); |
903 | - trigger_error(__METHOD__."($url,$owner) Unknown (numeric) user id!",E_USER_WARNING); |
|
901 | + trigger_error(__METHOD__."($url,$owner) Unknown (numeric) user id!", E_USER_WARNING); |
|
904 | 902 | //throw new Exception(__METHOD__."($url,$owner) Unknown (numeric) user id!"); |
905 | 903 | return false; |
906 | 904 | } |
907 | 905 | $stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_uid=:fs_uid WHERE fs_id=:fs_id'); |
908 | 906 | |
909 | 907 | // update stat-cache |
910 | - if ($path != '/' && substr($path,-1) == '/') $path = substr($path, 0, -1); |
|
908 | + if ($path != '/' && substr($path, -1) == '/') $path = substr($path, 0, -1); |
|
911 | 909 | self::$stat_cache[$path]['fs_uid'] = $owner; |
912 | 910 | |
913 | 911 | return $stmt->execute(array( |
914 | - 'fs_uid' => (int) $owner, |
|
912 | + 'fs_uid' => (int)$owner, |
|
915 | 913 | 'fs_id' => $stat['ino'], |
916 | 914 | )); |
917 | 915 | } |
@@ -923,36 +921,36 @@ discard block |
||
923 | 921 | * @param int $owner |
924 | 922 | * @return boolean |
925 | 923 | */ |
926 | - static function chgrp($url,$owner) |
|
924 | + static function chgrp($url, $owner) |
|
927 | 925 | { |
928 | 926 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$owner)"); |
929 | 927 | |
930 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
928 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
931 | 929 | |
932 | - if (!($stat = self::url_stat($path,0))) |
|
930 | + if (!($stat = self::url_stat($path, 0))) |
|
933 | 931 | { |
934 | 932 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) no such file or directory!"); |
935 | - trigger_error("No such file or directory $url !",E_USER_WARNING); |
|
933 | + trigger_error("No such file or directory $url !", E_USER_WARNING); |
|
936 | 934 | return false; |
937 | 935 | } |
938 | - if (!Vfs::has_owner_rights($path,$stat)) |
|
936 | + if (!Vfs::has_owner_rights($path, $stat)) |
|
939 | 937 | { |
940 | 938 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) only owner or root can do that!"); |
941 | - trigger_error("Only owner or root can do that!",E_USER_WARNING); |
|
939 | + trigger_error("Only owner or root can do that!", E_USER_WARNING); |
|
942 | 940 | return false; |
943 | 941 | } |
944 | - if ($owner < 0) $owner = -$owner; // sqlfs uses a positiv group id's! |
|
942 | + if ($owner < 0) $owner = -$owner; // sqlfs uses a positiv group id's! |
|
945 | 943 | |
946 | 944 | if ($owner && !$GLOBALS['egw']->accounts->id2name(-$owner)) // not a group |
947 | 945 | { |
948 | 946 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) unknown (numeric) group id!"); |
949 | - trigger_error("Unknown (numeric) group id!",E_USER_WARNING); |
|
947 | + trigger_error("Unknown (numeric) group id!", E_USER_WARNING); |
|
950 | 948 | return false; |
951 | 949 | } |
952 | 950 | $stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_gid=:fs_gid WHERE fs_id=:fs_id'); |
953 | 951 | |
954 | 952 | // update stat-cache |
955 | - if ($path != '/' && substr($path,-1) == '/') $path = substr($path, 0, -1); |
|
953 | + if ($path != '/' && substr($path, -1) == '/') $path = substr($path, 0, -1); |
|
956 | 954 | self::$stat_cache[$path]['fs_gid'] = $owner; |
957 | 955 | |
958 | 956 | return $stmt->execute(array( |
@@ -968,38 +966,38 @@ discard block |
||
968 | 966 | * @param int $mode |
969 | 967 | * @return boolean |
970 | 968 | */ |
971 | - static function chmod($url,$mode) |
|
969 | + static function chmod($url, $mode) |
|
972 | 970 | { |
973 | 971 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url, $mode)"); |
974 | 972 | |
975 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
973 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
976 | 974 | |
977 | - if (!($stat = self::url_stat($path,0))) |
|
975 | + if (!($stat = self::url_stat($path, 0))) |
|
978 | 976 | { |
979 | 977 | if (self::LOG_LEVEL) error_log(__METHOD__."($url, $mode) no such file or directory!"); |
980 | - trigger_error("No such file or directory $url !",E_USER_WARNING); |
|
978 | + trigger_error("No such file or directory $url !", E_USER_WARNING); |
|
981 | 979 | return false; |
982 | 980 | } |
983 | - if (!Vfs::has_owner_rights($path,$stat)) |
|
981 | + if (!Vfs::has_owner_rights($path, $stat)) |
|
984 | 982 | { |
985 | 983 | if (self::LOG_LEVEL) error_log(__METHOD__."($url, $mode) only owner or root can do that!"); |
986 | - trigger_error("Only owner or root can do that!",E_USER_WARNING); |
|
984 | + trigger_error("Only owner or root can do that!", E_USER_WARNING); |
|
987 | 985 | return false; |
988 | 986 | } |
989 | 987 | if (!is_numeric($mode)) // not a mode |
990 | 988 | { |
991 | 989 | if (self::LOG_LEVEL) error_log(__METHOD__."($url, $mode) no (numeric) mode!"); |
992 | - trigger_error("No (numeric) mode!",E_USER_WARNING); |
|
990 | + trigger_error("No (numeric) mode!", E_USER_WARNING); |
|
993 | 991 | return false; |
994 | 992 | } |
995 | 993 | $stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_mode=:fs_mode WHERE fs_id=:fs_id'); |
996 | 994 | |
997 | 995 | // update stat cache |
998 | - if ($path != '/' && substr($path,-1) == '/') $path = substr($path, 0, -1); |
|
999 | - self::$stat_cache[$path]['fs_mode'] = ((int) $mode) & 0777; |
|
996 | + if ($path != '/' && substr($path, -1) == '/') $path = substr($path, 0, -1); |
|
997 | + self::$stat_cache[$path]['fs_mode'] = ((int)$mode)&0777; |
|
1000 | 998 | |
1001 | 999 | return $stmt->execute(array( |
1002 | - 'fs_mode' => ((int) $mode) & 0777, // we dont store the file and dir bits, give int overflow! |
|
1000 | + 'fs_mode' => ((int)$mode)&0777, // we dont store the file and dir bits, give int overflow! |
|
1003 | 1001 | 'fs_id' => $stat['ino'], |
1004 | 1002 | )); |
1005 | 1003 | } |
@@ -1012,15 +1010,15 @@ discard block |
||
1012 | 1010 | * @param int $options |
1013 | 1011 | * @return booelan |
1014 | 1012 | */ |
1015 | - function dir_opendir ( $url, $options ) |
|
1013 | + function dir_opendir($url, $options) |
|
1016 | 1014 | { |
1017 | 1015 | $this->opened_dir = null; |
1018 | 1016 | |
1019 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
1017 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
1020 | 1018 | |
1021 | - if (!($stat = self::url_stat($url,0)) || // dir not found |
|
1022 | - $stat['mime'] != self::DIR_MIME_TYPE || // no dir |
|
1023 | - !Vfs::check_access($url,Vfs::EXECUTABLE|Vfs::READABLE,$stat)) // no access |
|
1019 | + if (!($stat = self::url_stat($url, 0)) || // dir not found |
|
1020 | + $stat['mime'] != self::DIR_MIME_TYPE || // no dir |
|
1021 | + !Vfs::check_access($url, Vfs::EXECUTABLE|Vfs::READABLE, $stat)) // no access |
|
1024 | 1022 | { |
1025 | 1023 | self::_remove_password($url); |
1026 | 1024 | $msg = $stat['mime'] != self::DIR_MIME_TYPE ? "$url is no directory" : 'permission denied'; |
@@ -1039,13 +1037,13 @@ discard block |
||
1039 | 1037 | $stmt->setFetchMode(\PDO::FETCH_ASSOC); |
1040 | 1038 | if ($stmt->execute(array($stat['ino']))) |
1041 | 1039 | { |
1042 | - foreach($stmt as $file) |
|
1040 | + foreach ($stmt as $file) |
|
1043 | 1041 | { |
1044 | 1042 | $this->opened_dir[] = $file['fs_name']; |
1045 | - self::$stat_cache[Vfs::concat($path,$file['fs_name'])] = $file; |
|
1043 | + self::$stat_cache[Vfs::concat($path, $file['fs_name'])] = $file; |
|
1046 | 1044 | } |
1047 | 1045 | } |
1048 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$options): ".implode(', ',$this->opened_dir)); |
|
1046 | + if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$options): ".implode(', ', $this->opened_dir)); |
|
1049 | 1047 | reset($this->opened_dir); |
1050 | 1048 | |
1051 | 1049 | return true; |
@@ -1078,26 +1076,26 @@ discard block |
||
1078 | 1076 | * @param boolean $eacl_access =null allows extending classes to pass the value of their check_extended_acl() method (no lsb!) |
1079 | 1077 | * @return array |
1080 | 1078 | */ |
1081 | - static function url_stat ( $url, $flags, $eacl_access=null ) |
|
1079 | + static function url_stat($url, $flags, $eacl_access = null) |
|
1082 | 1080 | { |
1083 | - static $max_subquery_depth=null; |
|
1081 | + static $max_subquery_depth = null; |
|
1084 | 1082 | if (is_null($max_subquery_depth)) |
1085 | 1083 | { |
1086 | 1084 | $max_subquery_depth = $GLOBALS['egw_info']['server']['max_subquery_depth']; |
1087 | - if (!$max_subquery_depth) $max_subquery_depth = 7; // setting current default of 7, if nothing set |
|
1085 | + if (!$max_subquery_depth) $max_subquery_depth = 7; // setting current default of 7, if nothing set |
|
1088 | 1086 | } |
1089 | 1087 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$url',$flags,$eacl_access)"); |
1090 | 1088 | |
1091 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
1089 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
1092 | 1090 | |
1093 | 1091 | // webdav adds a trailing slash to dirs, which causes url_stat to NOT find the file otherwise |
1094 | - if ($path != '/' && substr($path,-1) == '/') |
|
1092 | + if ($path != '/' && substr($path, -1) == '/') |
|
1095 | 1093 | { |
1096 | - $path = substr($path,0,-1); |
|
1094 | + $path = substr($path, 0, -1); |
|
1097 | 1095 | } |
1098 | 1096 | if (empty($path)) |
1099 | 1097 | { |
1100 | - return false; // is invalid and gives sql error |
|
1098 | + return false; // is invalid and gives sql error |
|
1101 | 1099 | } |
1102 | 1100 | // check if we already have the info from the last dir_open call, as the old vfs reads it anyway from the db |
1103 | 1101 | if (self::$stat_cache && isset(self::$stat_cache[$path]) && (is_null($eacl_access) || self::$stat_cache[$path] !== false)) |
@@ -1112,28 +1110,28 @@ discard block |
||
1112 | 1110 | $base_query = 'SELECT fs_id,fs_name,fs_mode,fs_uid,fs_gid,fs_size,fs_mime,fs_created,fs_modified'.self::$extra_columns. |
1113 | 1111 | ' FROM '.self::TABLE.' WHERE fs_active='.self::_pdo_boolean(true). |
1114 | 1112 | ' AND fs_name'.self::$case_sensitive_equal.'? AND fs_dir='; |
1115 | - $parts = explode('/',$path); |
|
1113 | + $parts = explode('/', $path); |
|
1116 | 1114 | |
1117 | 1115 | // if we have extendes acl access to the url, we dont need and can NOT include the sql for the readable check |
1118 | 1116 | if (is_null($eacl_access)) |
1119 | 1117 | { |
1120 | - $eacl_access = self::check_extended_acl($path,Vfs::READABLE); // should be static::check_extended_acl, but no lsb! |
|
1118 | + $eacl_access = self::check_extended_acl($path, Vfs::READABLE); // should be static::check_extended_acl, but no lsb! |
|
1121 | 1119 | } |
1122 | 1120 | |
1123 | 1121 | try { |
1124 | - foreach($parts as $n => $name) |
|
1122 | + foreach ($parts as $n => $name) |
|
1125 | 1123 | { |
1126 | 1124 | if ($n == 0) |
1127 | 1125 | { |
1128 | - $query = (int) ($path != '/'); // / always has fs_id == 1, no need to query it ($path=='/' needs fs_dir=0!) |
|
1126 | + $query = (int)($path != '/'); // / always has fs_id == 1, no need to query it ($path=='/' needs fs_dir=0!) |
|
1129 | 1127 | } |
1130 | - elseif ($n < count($parts)-1) |
|
1128 | + elseif ($n < count($parts) - 1) |
|
1131 | 1129 | { |
1132 | 1130 | // MySQL 5.0 has a nesting limit for subqueries |
1133 | 1131 | // --> we replace the so far cumulated subqueries with their result |
1134 | 1132 | // no idea about the other DBMS, but this does NOT hurt ... |
1135 | 1133 | // --> depth limit of subqueries is now dynamicly decremented in catch |
1136 | - if ($n > 1 && !(($n-1) % $max_subquery_depth) && !($query = self::$pdo->query($query)->fetchColumn())) |
|
1134 | + if ($n > 1 && !(($n - 1) % $max_subquery_depth) && !($query = self::$pdo->query($query)->fetchColumn())) |
|
1137 | 1135 | { |
1138 | 1136 | if (self::LOG_LEVEL > 1) |
1139 | 1137 | { |
@@ -1160,7 +1158,7 @@ discard block |
||
1160 | 1158 | } |
1161 | 1159 | else |
1162 | 1160 | { |
1163 | - $query = str_replace('fs_name'.self::$case_sensitive_equal.'?','fs_name'.self::$case_sensitive_equal.self::$pdo->quote($name),$base_query).'('.$query.')'; |
|
1161 | + $query = str_replace('fs_name'.self::$case_sensitive_equal.'?', 'fs_name'.self::$case_sensitive_equal.self::$pdo->quote($name), $base_query).'('.$query.')'; |
|
1164 | 1162 | } |
1165 | 1163 | } |
1166 | 1164 | if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__."($url,$flags,$eacl_access)".' */ '.$query; |
@@ -1186,7 +1184,7 @@ discard block |
||
1186 | 1184 | $GLOBALS['egw_info']['server']['max_subquery_depth'] = --$max_subquery_depth; |
1187 | 1185 | error_log(__METHOD__."() decremented max_subquery_depth to $max_subquery_depth"); |
1188 | 1186 | Api\Config::save_value('max_subquery_depth', $max_subquery_depth, 'phpgwapi'); |
1189 | - if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) $GLOBALS['egw']->invalidate_session_cache(); |
|
1187 | + if (method_exists($GLOBALS['egw'], 'invalidate_session_cache')) $GLOBALS['egw']->invalidate_session_cache(); |
|
1190 | 1188 | return self::url_stat($url, $flags, $eacl_access); |
1191 | 1189 | } |
1192 | 1190 | self::$stat_cache[$path] = $info; |
@@ -1202,18 +1200,18 @@ discard block |
||
1202 | 1200 | */ |
1203 | 1201 | protected static function _sql_readable() |
1204 | 1202 | { |
1205 | - static $sql_read_acl=null; |
|
1203 | + static $sql_read_acl = null; |
|
1206 | 1204 | |
1207 | 1205 | if (is_null($sql_read_acl)) |
1208 | 1206 | { |
1209 | - foreach($GLOBALS['egw']->accounts->memberships(Vfs::$user,true) as $gid) |
|
1207 | + foreach ($GLOBALS['egw']->accounts->memberships(Vfs::$user, true) as $gid) |
|
1210 | 1208 | { |
1211 | - $memberships[] = abs($gid); // sqlfs stores the gid's positiv |
|
1209 | + $memberships[] = abs($gid); // sqlfs stores the gid's positiv |
|
1212 | 1210 | } |
1213 | 1211 | // using octal numbers with mysql leads to funny results (select 384 & 0400 --> 384 not 256=0400) |
1214 | 1212 | // 256 = 0400, 32 = 040 |
1215 | 1213 | $sql_read_acl = '((fs_mode & 4)=4 OR (fs_mode & 256)=256 AND fs_uid='.(int)Vfs::$user. |
1216 | - ($memberships ? ' OR (fs_mode & 32)=32 AND fs_gid IN('.implode(',',$memberships).')' : '').')'; |
|
1214 | + ($memberships ? ' OR (fs_mode & 32)=32 AND fs_gid IN('.implode(',', $memberships).')' : '').')'; |
|
1217 | 1215 | //error_log(__METHOD__."() Vfs::\$user=".array2string(Vfs::$user).' --> memberships='.array2string($memberships).' --> '.$sql_read_acl.($memberships?'':': '.function_backtrace())); |
1218 | 1216 | } |
1219 | 1217 | return $sql_read_acl; |
@@ -1226,7 +1224,7 @@ discard block |
||
1226 | 1224 | * |
1227 | 1225 | * @return string |
1228 | 1226 | */ |
1229 | - function dir_readdir ( ) |
|
1227 | + function dir_readdir( ) |
|
1230 | 1228 | { |
1231 | 1229 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."( )"); |
1232 | 1230 | |
@@ -1245,7 +1243,7 @@ discard block |
||
1245 | 1243 | * |
1246 | 1244 | * @return boolean |
1247 | 1245 | */ |
1248 | - function dir_rewinddir ( ) |
|
1246 | + function dir_rewinddir( ) |
|
1249 | 1247 | { |
1250 | 1248 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."( )"); |
1251 | 1249 | |
@@ -1263,7 +1261,7 @@ discard block |
||
1263 | 1261 | * |
1264 | 1262 | * @return boolean |
1265 | 1263 | */ |
1266 | - function dir_closedir ( ) |
|
1264 | + function dir_closedir( ) |
|
1267 | 1265 | { |
1268 | 1266 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."( )"); |
1269 | 1267 | |
@@ -1284,7 +1282,7 @@ discard block |
||
1284 | 1282 | */ |
1285 | 1283 | static function readlink($path) |
1286 | 1284 | { |
1287 | - $link = !($lstat = self::url_stat($path,STREAM_URL_STAT_LINK)) || is_null($lstat['readlink']) ? false : $lstat['readlink']; |
|
1285 | + $link = !($lstat = self::url_stat($path, STREAM_URL_STAT_LINK)) || is_null($lstat['readlink']) ? false : $lstat['readlink']; |
|
1288 | 1286 | |
1289 | 1287 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = $link"); |
1290 | 1288 | |
@@ -1298,31 +1296,31 @@ discard block |
||
1298 | 1296 | * @param string $link |
1299 | 1297 | * @return boolean true on success false on error |
1300 | 1298 | */ |
1301 | - static function symlink($target,$link) |
|
1299 | + static function symlink($target, $link) |
|
1302 | 1300 | { |
1303 | 1301 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$target','$link')"); |
1304 | 1302 | |
1305 | - if (self::url_stat($link,0)) |
|
1303 | + if (self::url_stat($link, 0)) |
|
1306 | 1304 | { |
1307 | 1305 | if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$target','$link') $link exists, returning false!"); |
1308 | - return false; // $link already exists |
|
1306 | + return false; // $link already exists |
|
1309 | 1307 | } |
1310 | 1308 | if (!($dir = Vfs::dirname($link)) || |
1311 | - !Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat=static::url_stat($dir,0))) |
|
1309 | + !Vfs::check_access($dir, Vfs::WRITABLE, $dir_stat = static::url_stat($dir, 0))) |
|
1312 | 1310 | { |
1313 | 1311 | if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$target','$link') returning false! (!is_writable('$dir'), dir_stat=".array2string($dir_stat).")"); |
1314 | - return false; // parent dir does not exist or is not writable |
|
1312 | + return false; // parent dir does not exist or is not writable |
|
1315 | 1313 | } |
1316 | 1314 | $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'. |
1317 | 1315 | ') VALUES (:fs_name,:fs_dir,:fs_mode,:fs_uid,:fs_gid,:fs_created,:fs_modified,:fs_creator,:fs_mime,:fs_size,:fs_link)'; |
1318 | 1316 | if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; |
1319 | 1317 | $stmt = self::$pdo->prepare($query); |
1320 | - unset(self::$stat_cache[Vfs::parse_url($link,PHP_URL_PATH)]); |
|
1318 | + unset(self::$stat_cache[Vfs::parse_url($link, PHP_URL_PATH)]); |
|
1321 | 1319 | |
1322 | 1320 | return !!$stmt->execute(array( |
1323 | 1321 | 'fs_name' => self::limit_filename(Vfs::basename($link)), |
1324 | 1322 | 'fs_dir' => $dir_stat['ino'], |
1325 | - 'fs_mode' => ($dir_stat['mode'] & 0666), |
|
1323 | + 'fs_mode' => ($dir_stat['mode']&0666), |
|
1326 | 1324 | 'fs_uid' => $dir_stat['uid'] ? $dir_stat['uid'] : Vfs::$user, |
1327 | 1325 | 'fs_gid' => $dir_stat['gid'], |
1328 | 1326 | 'fs_created' => self::_pdo_timestamp(time()), |
@@ -1346,24 +1344,24 @@ discard block |
||
1346 | 1344 | * @param int $check mode to check: one or more or'ed together of: 4 = read, 2 = write, 1 = executable |
1347 | 1345 | * @return boolean |
1348 | 1346 | */ |
1349 | - static function check_extended_acl($url,$check) |
|
1347 | + static function check_extended_acl($url, $check) |
|
1350 | 1348 | { |
1351 | - $url_path = Vfs::parse_url($url,PHP_URL_PATH); |
|
1349 | + $url_path = Vfs::parse_url($url, PHP_URL_PATH); |
|
1352 | 1350 | |
1353 | 1351 | if (is_null(self::$extended_acl)) |
1354 | 1352 | { |
1355 | 1353 | self::_read_extended_acl(); |
1356 | 1354 | } |
1357 | 1355 | $access = false; |
1358 | - foreach(self::$extended_acl as $path => $rights) |
|
1356 | + foreach (self::$extended_acl as $path => $rights) |
|
1359 | 1357 | { |
1360 | - if ($path == $url_path || substr($url_path,0,strlen($path)+1) == $path.'/') |
|
1358 | + if ($path == $url_path || substr($url_path, 0, strlen($path) + 1) == $path.'/') |
|
1361 | 1359 | { |
1362 | - $access = ($rights & $check) == $check; |
|
1360 | + $access = ($rights&$check) == $check; |
|
1363 | 1361 | break; |
1364 | 1362 | } |
1365 | 1363 | } |
1366 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$check) ".($access?"access granted by $path=$rights":'no access!!!')); |
|
1364 | + if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$check) ".($access ? "access granted by $path=$rights" : 'no access!!!')); |
|
1367 | 1365 | return $access; |
1368 | 1366 | } |
1369 | 1367 | |
@@ -1375,14 +1373,14 @@ discard block |
||
1375 | 1373 | { |
1376 | 1374 | if ((self::$extended_acl = Api\Cache::getSession(self::EACL_APPNAME, 'extended_acl'))) |
1377 | 1375 | { |
1378 | - return; // ext. ACL read from session. |
|
1376 | + return; // ext. ACL read from session. |
|
1379 | 1377 | } |
1380 | 1378 | self::$extended_acl = array(); |
1381 | - if (($rights = $GLOBALS['egw']->acl->get_all_location_rights(Vfs::$user,self::EACL_APPNAME))) |
|
1379 | + if (($rights = $GLOBALS['egw']->acl->get_all_location_rights(Vfs::$user, self::EACL_APPNAME))) |
|
1382 | 1380 | { |
1383 | 1381 | $pathes = self::id2path(array_keys($rights)); |
1384 | 1382 | } |
1385 | - foreach($rights as $fs_id => $right) |
|
1383 | + foreach ($rights as $fs_id => $right) |
|
1386 | 1384 | { |
1387 | 1385 | $path = $pathes[$fs_id]; |
1388 | 1386 | if (isset($path)) |
@@ -1391,8 +1389,8 @@ discard block |
||
1391 | 1389 | } |
1392 | 1390 | } |
1393 | 1391 | // sort by length descending, to allow more specific pathes to have precedence |
1394 | - uksort(self::$extended_acl, function($a,$b) { |
|
1395 | - return strlen($b)-strlen($a); |
|
1392 | + uksort(self::$extended_acl, function($a, $b) { |
|
1393 | + return strlen($b) - strlen($a); |
|
1396 | 1394 | }); |
1397 | 1395 | Api\Cache::setSession(self::EACL_APPNAME, 'extended_acl', self::$extended_acl); |
1398 | 1396 | if (self::LOG_LEVEL > 1) error_log(__METHOD__.'() '.array2string(self::$extended_acl)); |
@@ -1414,23 +1412,23 @@ discard block |
||
1414 | 1412 | * @param int $fs_id =null fs_id to use, to not query it again (eg. because it's already deleted) |
1415 | 1413 | * @return boolean true if acl is set/deleted, false on error |
1416 | 1414 | */ |
1417 | - static function eacl($path,$rights=null,$owner=null,$fs_id=null) |
|
1415 | + static function eacl($path, $rights = null, $owner = null, $fs_id = null) |
|
1418 | 1416 | { |
1419 | 1417 | if ($path[0] != '/') |
1420 | 1418 | { |
1421 | - $path = Vfs::parse_url($path,PHP_URL_PATH); |
|
1419 | + $path = Vfs::parse_url($path, PHP_URL_PATH); |
|
1422 | 1420 | } |
1423 | 1421 | if (is_null($fs_id)) |
1424 | 1422 | { |
1425 | - if (!($stat = self::url_stat($path,0))) |
|
1423 | + if (!($stat = self::url_stat($path, 0))) |
|
1426 | 1424 | { |
1427 | 1425 | if (self::LOG_LEVEL) error_log(__METHOD__."($path,$rights,$owner,$fs_id) no such file or directory!"); |
1428 | - return false; // $path not found |
|
1426 | + return false; // $path not found |
|
1429 | 1427 | } |
1430 | - if (!Vfs::has_owner_rights($path,$stat)) // not group dir and user is eGW admin |
|
1428 | + if (!Vfs::has_owner_rights($path, $stat)) // not group dir and user is eGW admin |
|
1431 | 1429 | { |
1432 | 1430 | if (self::LOG_LEVEL) error_log(__METHOD__."($path,$rights,$owner,$fs_id) permission denied!"); |
1433 | - return false; // permission denied |
|
1431 | + return false; // permission denied |
|
1434 | 1432 | } |
1435 | 1433 | $fs_id = $stat['ino']; |
1436 | 1434 | } |
@@ -1442,21 +1440,21 @@ discard block |
||
1442 | 1440 | { |
1443 | 1441 | // delete eacl |
1444 | 1442 | if (is_null($owner) || $owner == Vfs::$user || |
1445 | - $owner < 0 && Vfs::$user && in_array($owner,$GLOBALS['egw']->accounts->memberships(Vfs::$user,true))) |
|
1443 | + $owner < 0 && Vfs::$user && in_array($owner, $GLOBALS['egw']->accounts->memberships(Vfs::$user, true))) |
|
1446 | 1444 | { |
1447 | - self::$extended_acl = null; // force new read of eACL, as there could be multiple eACL for that path |
|
1445 | + self::$extended_acl = null; // force new read of eACL, as there could be multiple eACL for that path |
|
1448 | 1446 | } |
1449 | - $ret = $GLOBALS['egw']->acl->delete_repository(self::EACL_APPNAME,$fs_id,(int)$owner); |
|
1447 | + $ret = $GLOBALS['egw']->acl->delete_repository(self::EACL_APPNAME, $fs_id, (int)$owner); |
|
1450 | 1448 | } |
1451 | 1449 | else |
1452 | 1450 | { |
1453 | 1451 | if (isset(self::$extended_acl) && ($owner == Vfs::$user || |
1454 | - $owner < 0 && Vfs::$user && in_array($owner,$GLOBALS['egw']->accounts->memberships(Vfs::$user,true)))) |
|
1452 | + $owner < 0 && Vfs::$user && in_array($owner, $GLOBALS['egw']->accounts->memberships(Vfs::$user, true)))) |
|
1455 | 1453 | { |
1456 | 1454 | // set rights for this class, if applicable |
1457 | 1455 | self::$extended_acl[$path] |= $rights; |
1458 | 1456 | } |
1459 | - $ret = $GLOBALS['egw']->acl->add_repository(self::EACL_APPNAME,$fs_id,$owner,$rights); |
|
1457 | + $ret = $GLOBALS['egw']->acl->add_repository(self::EACL_APPNAME, $fs_id, $owner, $rights); |
|
1460 | 1458 | } |
1461 | 1459 | if ($ret) |
1462 | 1460 | { |
@@ -1479,10 +1477,10 @@ discard block |
||
1479 | 1477 | if (!($stat = static::url_stat($path, STREAM_URL_STAT_QUIET))) |
1480 | 1478 | { |
1481 | 1479 | error_log(__METHOD__.__LINE__.' '.array2string($path).' not found!'); |
1482 | - return false; // not found |
|
1480 | + return false; // not found |
|
1483 | 1481 | } |
1484 | 1482 | $eacls = array(); |
1485 | - foreach($GLOBALS['egw']->acl->get_all_rights($stat['ino'],self::EACL_APPNAME) as $owner => $rights) |
|
1483 | + foreach ($GLOBALS['egw']->acl->get_all_rights($stat['ino'], self::EACL_APPNAME) as $owner => $rights) |
|
1486 | 1484 | { |
1487 | 1485 | $eacls[] = array( |
1488 | 1486 | 'path' => $path, |
@@ -1493,7 +1491,7 @@ discard block |
||
1493 | 1491 | } |
1494 | 1492 | if (($path = Vfs::dirname($path))) |
1495 | 1493 | { |
1496 | - $eacls = array_merge((array)self::get_eacl($path),$eacls); |
|
1494 | + $eacls = array_merge((array)self::get_eacl($path), $eacls); |
|
1497 | 1495 | } |
1498 | 1496 | // sort by length descending, to show precedence |
1499 | 1497 | usort($eacls, function($a, $b) { |
@@ -1518,9 +1516,9 @@ discard block |
||
1518 | 1516 | $ids = (array)$fs_ids; |
1519 | 1517 | $pathes = array(); |
1520 | 1518 | // first check our stat-cache for the ids |
1521 | - foreach(self::$stat_cache as $path => $stat) |
|
1519 | + foreach (self::$stat_cache as $path => $stat) |
|
1522 | 1520 | { |
1523 | - if (($key = array_search($stat['fs_id'],$ids)) !== false) |
|
1521 | + if (($key = array_search($stat['fs_id'], $ids)) !== false) |
|
1524 | 1522 | { |
1525 | 1523 | $pathes[$stat['fs_id']] = $path; |
1526 | 1524 | unset($ids[$key]); |
@@ -1534,7 +1532,7 @@ discard block |
||
1534 | 1532 | // now search via the database |
1535 | 1533 | if (count($ids) > 1) array_map(function(&$v) { $v = (int)$v; },$ids); |
1536 | 1534 | $query = 'SELECT fs_id,fs_dir,fs_name FROM '.self::TABLE.' WHERE fs_id'. |
1537 | - (count($ids) == 1 ? '='.(int)$ids[0] : ' IN ('.implode(',',$ids).')'); |
|
1535 | + (count($ids) == 1 ? '='.(int)$ids[0] : ' IN ('.implode(',', $ids).')'); |
|
1538 | 1536 | if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; |
1539 | 1537 | |
1540 | 1538 | if (!is_object(self::$pdo)) |
@@ -1545,12 +1543,12 @@ discard block |
||
1545 | 1543 | $stmt->setFetchMode(\PDO::FETCH_ASSOC); |
1546 | 1544 | if (!$stmt->execute()) |
1547 | 1545 | { |
1548 | - return false; // not found |
|
1546 | + return false; // not found |
|
1549 | 1547 | } |
1550 | 1548 | $parents = array(); |
1551 | - foreach($stmt as $row) |
|
1549 | + foreach ($stmt as $row) |
|
1552 | 1550 | { |
1553 | - if ($row['fs_dir'] > 1 && !in_array($row['fs_dir'],$parents)) |
|
1551 | + if ($row['fs_dir'] > 1 && !in_array($row['fs_dir'], $parents)) |
|
1554 | 1552 | { |
1555 | 1553 | $parents[] = $row['fs_dir']; |
1556 | 1554 | } |
@@ -1560,14 +1558,14 @@ discard block |
||
1560 | 1558 | |
1561 | 1559 | if ($parents && !($parents = self::id2path($parents))) |
1562 | 1560 | { |
1563 | - return false; // parent not found, should never happen ... |
|
1561 | + return false; // parent not found, should never happen ... |
|
1564 | 1562 | } |
1565 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__." trying foreach with:".print_r($rows,true)."#"); |
|
1566 | - foreach((array)$rows as $fs_id => $row) |
|
1563 | + if (self::LOG_LEVEL > 1) error_log(__METHOD__." trying foreach with:".print_r($rows, true)."#"); |
|
1564 | + foreach ((array)$rows as $fs_id => $row) |
|
1567 | 1565 | { |
1568 | 1566 | $parent = $row['fs_dir'] > 1 ? $parents[$row['fs_dir']] : ''; |
1569 | 1567 | |
1570 | - $pathes[$fs_id] = $parent . '/' . $row['fs_name']; |
|
1568 | + $pathes[$fs_id] = $parent.'/'.$row['fs_name']; |
|
1571 | 1569 | } |
1572 | 1570 | if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($fs_ids).')='.array2string($pathes)); |
1573 | 1571 | return is_array($fs_ids) ? $pathes : array_shift($pathes); |
@@ -1591,7 +1589,7 @@ discard block |
||
1591 | 1589 | $parts = explode('.', $name); |
1592 | 1590 | if ($parts > 1 && mb_strlen($extension = '.'.array_pop($parts)) <= $fs_name_precision) |
1593 | 1591 | { |
1594 | - $name = mb_substr(implode('.', $parts), 0, $fs_name_precision-mb_strlen($extension)).$extension; |
|
1592 | + $name = mb_substr(implode('.', $parts), 0, $fs_name_precision - mb_strlen($extension)).$extension; |
|
1595 | 1593 | } |
1596 | 1594 | else |
1597 | 1595 | { |
@@ -1612,9 +1610,8 @@ discard block |
||
1612 | 1610 | $stat = array( |
1613 | 1611 | 'ino' => $info['fs_id'], |
1614 | 1612 | 'name' => $info['fs_name'], |
1615 | - 'mode' => $info['fs_mode'] | |
|
1616 | - ($info['fs_mime'] == self::DIR_MIME_TYPE ? self::MODE_DIR : |
|
1617 | - ($info['fs_mime'] == self::SYMLINK_MIME_TYPE ? self::MODE_LINK : self::MODE_FILE)), // required by the stream wrapper |
|
1613 | + 'mode' => $info['fs_mode']| |
|
1614 | + ($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 |
|
1618 | 1615 | 'size' => $info['fs_size'], |
1619 | 1616 | 'uid' => $info['fs_uid'], |
1620 | 1617 | 'gid' => $info['fs_gid'], |
@@ -1659,10 +1656,10 @@ discard block |
||
1659 | 1656 | { |
1660 | 1657 | if (is_object($GLOBALS['egw_setup']->db)) // if we run under setup, query the db for the files dir |
1661 | 1658 | { |
1662 | - $GLOBALS['egw_info']['server']['files_dir'] = $GLOBALS['egw_setup']->db->select('egw_config','config_value',array( |
|
1659 | + $GLOBALS['egw_info']['server']['files_dir'] = $GLOBALS['egw_setup']->db->select('egw_config', 'config_value', array( |
|
1663 | 1660 | 'config_name' => 'files_dir', |
1664 | 1661 | 'config_app' => 'phpgwapi', |
1665 | - ),__LINE__,__FILE__)->fetchColumn(); |
|
1662 | + ), __LINE__, __FILE__)->fetchColumn(); |
|
1666 | 1663 | } |
1667 | 1664 | } |
1668 | 1665 | if (!$GLOBALS['egw_info']['server']['files_dir']) |
@@ -1671,14 +1668,14 @@ discard block |
||
1671 | 1668 | } |
1672 | 1669 | $hash = array(); |
1673 | 1670 | $n = $id; |
1674 | - while(($n = (int) ($n / self::HASH_MAX))) |
|
1671 | + while (($n = (int)($n / self::HASH_MAX))) |
|
1675 | 1672 | { |
1676 | - $hash[] = sprintf('%02d',$n % self::HASH_MAX); |
|
1673 | + $hash[] = sprintf('%02d', $n % self::HASH_MAX); |
|
1677 | 1674 | } |
1678 | - if (!$hash) $hash[] = '00'; // we need at least one directory, to not conflict with the dir-names |
|
1679 | - array_unshift($hash,$id); |
|
1675 | + if (!$hash) $hash[] = '00'; // we need at least one directory, to not conflict with the dir-names |
|
1676 | + array_unshift($hash, $id); |
|
1680 | 1677 | |
1681 | - $path = '/sqlfs/'.implode('/',array_reverse($hash)); |
|
1678 | + $path = '/sqlfs/'.implode('/', array_reverse($hash)); |
|
1682 | 1679 | //error_log(__METHOD__."($id) = '$path'"); |
1683 | 1680 | return $GLOBALS['egw_info']['server']['files_dir'].$path; |
1684 | 1681 | } |
@@ -1694,7 +1691,7 @@ discard block |
||
1694 | 1691 | |
1695 | 1692 | if ($parts['pass'] || $parts['scheme']) |
1696 | 1693 | { |
1697 | - $url = $parts['scheme'].'://'.($parts['user'] ? $parts['user'].($parts['pass']?':...':'').'@' : ''). |
|
1694 | + $url = $parts['scheme'].'://'.($parts['user'] ? $parts['user'].($parts['pass'] ? ':...' : '').'@' : ''). |
|
1698 | 1695 | $parts['host'].$parts['path']; |
1699 | 1696 | } |
1700 | 1697 | } |
@@ -1709,10 +1706,10 @@ discard block |
||
1709 | 1706 | { |
1710 | 1707 | $operation = self::DEFAULT_OPERATION; |
1711 | 1708 | |
1712 | - if (strpos(is_array($url) ? $url['query'] : $url,'storage=') !== false) |
|
1709 | + if (strpos(is_array($url) ? $url['query'] : $url, 'storage=') !== false) |
|
1713 | 1710 | { |
1714 | 1711 | $query = null; |
1715 | - parse_str(is_array($url) ? $url['query'] : Vfs::parse_url($url,PHP_URL_QUERY), $query); |
|
1712 | + parse_str(is_array($url) ? $url['query'] : Vfs::parse_url($url, PHP_URL_QUERY), $query); |
|
1716 | 1713 | switch ($query['storage']) |
1717 | 1714 | { |
1718 | 1715 | case 'db': |
@@ -1735,27 +1732,27 @@ discard block |
||
1735 | 1732 | * @param array $props array of array with values for keys 'name', 'ns', 'val' (null to delete the prop) |
1736 | 1733 | * @return boolean true if props are updated, false otherwise (eg. ressource not found) |
1737 | 1734 | */ |
1738 | - static function proppatch($path,array $props) |
|
1735 | + static function proppatch($path, array $props) |
|
1739 | 1736 | { |
1740 | 1737 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."(".array2string($path).','.array2string($props)); |
1741 | 1738 | if (!is_numeric($path)) |
1742 | 1739 | { |
1743 | - if (!($stat = self::url_stat($path,0))) |
|
1740 | + if (!($stat = self::url_stat($path, 0))) |
|
1744 | 1741 | { |
1745 | 1742 | return false; |
1746 | 1743 | } |
1747 | 1744 | $id = $stat['ino']; |
1748 | 1745 | } |
1749 | - elseif(!($path = self::id2path($id=$path))) |
|
1746 | + elseif (!($path = self::id2path($id = $path))) |
|
1750 | 1747 | { |
1751 | 1748 | return false; |
1752 | 1749 | } |
1753 | - if (!Vfs::check_access($path,Api\Acl::EDIT,$stat)) |
|
1750 | + if (!Vfs::check_access($path, Api\Acl::EDIT, $stat)) |
|
1754 | 1751 | { |
1755 | - return false; // permission denied |
|
1752 | + return false; // permission denied |
|
1756 | 1753 | } |
1757 | 1754 | $ins_stmt = $del_stmt = null; |
1758 | - foreach($props as &$prop) |
|
1755 | + foreach ($props as &$prop) |
|
1759 | 1756 | { |
1760 | 1757 | if (!isset($prop['ns'])) $prop['ns'] = Vfs::DEFAULT_PROP_NAMESPACE; |
1761 | 1758 | |
@@ -1800,14 +1797,14 @@ discard block |
||
1800 | 1797 | * @return array|boolean false on error ($path_ids does not exist), array with props (values for keys 'name', 'ns', 'value'), or |
1801 | 1798 | * fs_id/path => array of props for $depth==1 or is_array($path_ids) |
1802 | 1799 | */ |
1803 | - static function propfind($path_ids,$ns=Vfs::DEFAULT_PROP_NAMESPACE) |
|
1800 | + static function propfind($path_ids, $ns = Vfs::DEFAULT_PROP_NAMESPACE) |
|
1804 | 1801 | { |
1805 | 1802 | $ids = is_array($path_ids) ? $path_ids : array($path_ids); |
1806 | - foreach($ids as &$id) |
|
1803 | + foreach ($ids as &$id) |
|
1807 | 1804 | { |
1808 | 1805 | if (!is_numeric($id)) |
1809 | 1806 | { |
1810 | - if (!($stat = self::url_stat($id,0))) |
|
1807 | + if (!($stat = self::url_stat($id, 0))) |
|
1811 | 1808 | { |
1812 | 1809 | if (self::LOG_LEVEL) error_log(__METHOD__."(".array2string($path_ids).",$ns) path '$id' not found!"); |
1813 | 1810 | return false; |
@@ -1817,7 +1814,7 @@ discard block |
||
1817 | 1814 | } |
1818 | 1815 | if (count($ids) >= 1) array_map(function(&$v) { $v = (int)$v; },$ids); |
1819 | 1816 | $query = 'SELECT * FROM '.self::PROPS_TABLE.' WHERE (fs_id'. |
1820 | - (count($ids) == 1 ? '='.(int)implode('',$ids) : ' IN ('.implode(',',$ids).')').')'. |
|
1817 | + (count($ids) == 1 ? '='.(int)implode('', $ids) : ' IN ('.implode(',', $ids).')').')'. |
|
1821 | 1818 | (!is_null($ns) ? ' AND prop_namespace=?' : ''); |
1822 | 1819 | if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; |
1823 | 1820 | |
@@ -1826,7 +1823,7 @@ discard block |
||
1826 | 1823 | $stmt->execute(!is_null($ns) ? array($ns) : array()); |
1827 | 1824 | |
1828 | 1825 | $props = array(); |
1829 | - foreach($stmt as $row) |
|
1826 | + foreach ($stmt as $row) |
|
1830 | 1827 | { |
1831 | 1828 | $props[$row['fs_id']][] = array( |
1832 | 1829 | 'val' => $row['prop_value'], |
@@ -1836,19 +1833,19 @@ discard block |
||
1836 | 1833 | } |
1837 | 1834 | if (!is_array($path_ids)) |
1838 | 1835 | { |
1839 | - $props = $props[$row['fs_id']] ? $props[$row['fs_id']] : array(); // return empty array for no props |
|
1836 | + $props = $props[$row['fs_id']] ? $props[$row['fs_id']] : array(); // return empty array for no props |
|
1840 | 1837 | } |
1841 | 1838 | elseif ($props && isset($stat)) // need to map fs_id's to pathes |
1842 | 1839 | { |
1843 | - foreach(self::id2path(array_keys($props)) as $id => $path) |
|
1840 | + foreach (self::id2path(array_keys($props)) as $id => $path) |
|
1844 | 1841 | { |
1845 | - $props[$path] =& $props[$id]; |
|
1842 | + $props[$path] = & $props[$id]; |
|
1846 | 1843 | unset($props[$id]); |
1847 | 1844 | } |
1848 | 1845 | } |
1849 | 1846 | if (self::LOG_LEVEL > 1) |
1850 | 1847 | { |
1851 | - foreach((array)$props as $k => $v) |
|
1848 | + foreach ((array)$props as $k => $v) |
|
1852 | 1849 | { |
1853 | 1850 | error_log(__METHOD__."($path_ids,$ns) $k => ".array2string($v)); |
1854 | 1851 | } |
@@ -189,7 +189,10 @@ discard block |
||
189 | 189 | */ |
190 | 190 | function stream_open ( $url, $mode, $options, &$opened_path, array $overwrite_new=null ) |
191 | 191 | { |
192 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$mode,$options)"); |
|
192 | + if (self::LOG_LEVEL > 1) |
|
193 | + { |
|
194 | + error_log(__METHOD__."($url,$mode,$options)"); |
|
195 | + } |
|
193 | 196 | |
194 | 197 | $path = Vfs::parse_url($url,PHP_URL_PATH); |
195 | 198 | $this->operation = self::url2operation($url); |
@@ -201,7 +204,9 @@ discard block |
||
201 | 204 | |
202 | 205 | parse_str(parse_url($url, PHP_URL_QUERY), $this->dir_url_params); |
203 | 206 | |
204 | - if (!is_null($overwrite_new) || !($stat = static::url_stat($path,STREAM_URL_STAT_QUIET)) || $mode[0] == 'x') // file not found or file should NOT exist |
|
207 | + if (!is_null($overwrite_new) || !($stat = static::url_stat($path,STREAM_URL_STAT_QUIET)) || $mode[0] == 'x') |
|
208 | + { |
|
209 | + // file not found or file should NOT exist |
|
205 | 210 | { |
206 | 211 | if (!$dir || $mode[0] == 'r' || // does $mode require the file to exist (r,r+) |
207 | 212 | $mode[0] == 'x' && $stat || // or file should not exist, but does |
@@ -209,7 +214,11 @@ discard block |
||
209 | 214 | !Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat)) // or we are not allowed to create it |
210 | 215 | { |
211 | 216 | self::_remove_password($url); |
212 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) file does not exist or can not be created!"); |
|
217 | + } |
|
218 | + if (self::LOG_LEVEL) |
|
219 | + { |
|
220 | + error_log(__METHOD__."($url,$mode,$options) file does not exist or can not be created!"); |
|
221 | + } |
|
213 | 222 | if (($options & STREAM_REPORT_ERRORS)) |
214 | 223 | { |
215 | 224 | trigger_error(__METHOD__."($url,$mode,$options) file does not exist or can not be created!",E_USER_WARNING); |
@@ -221,7 +230,10 @@ discard block |
||
221 | 230 | $new_file = true; |
222 | 231 | $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_active'. |
223 | 232 | ') VALUES (:fs_name,:fs_dir,:fs_mode,:fs_uid,:fs_gid,:fs_created,:fs_modified,:fs_creator,:fs_mime,:fs_size,:fs_active)'; |
224 | - if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; |
|
233 | + if (self::LOG_LEVEL > 2) |
|
234 | + { |
|
235 | + $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; |
|
236 | + } |
|
225 | 237 | $stmt = self::$pdo->prepare($query); |
226 | 238 | $values = array( |
227 | 239 | 'fs_name' => self::limit_filename(Vfs::basename($path)), |
@@ -239,11 +251,17 @@ discard block |
||
239 | 251 | 'fs_size' => 0, |
240 | 252 | 'fs_active' => self::_pdo_boolean(true), |
241 | 253 | ); |
242 | - if ($overwrite_new) $values = array_merge($values,$overwrite_new); |
|
254 | + if ($overwrite_new) |
|
255 | + { |
|
256 | + $values = array_merge($values,$overwrite_new); |
|
257 | + } |
|
243 | 258 | if (!$stmt->execute($values) || !($this->opened_fs_id = self::$pdo->lastInsertId('egw_sqlfs_fs_id_seq'))) |
244 | 259 | { |
245 | 260 | $this->opened_stream = $this->opened_path = $this->opened_mode = null; |
246 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) execute() failed: ".self::$pdo->errorInfo()); |
|
261 | + if (self::LOG_LEVEL) |
|
262 | + { |
|
263 | + error_log(__METHOD__."($url,$mode,$options) execute() failed: ".self::$pdo->errorInfo()); |
|
264 | + } |
|
247 | 265 | return false; |
248 | 266 | } |
249 | 267 | if ($this->operation == self::STORE2DB) |
@@ -255,14 +273,20 @@ discard block |
||
255 | 273 | elseif(!file_exists($fs_dir=Vfs::dirname(self::_fs_path($this->opened_fs_id)))) |
256 | 274 | { |
257 | 275 | $umaskbefore = umask(); |
258 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__." about to call mkdir for $fs_dir # Present UMASK:".decoct($umaskbefore)." called from:".function_backtrace()); |
|
276 | + if (self::LOG_LEVEL > 1) |
|
277 | + { |
|
278 | + error_log(__METHOD__." about to call mkdir for $fs_dir # Present UMASK:".decoct($umaskbefore)." called from:".function_backtrace()); |
|
279 | + } |
|
259 | 280 | self::mkdir_recursive($fs_dir,0700,true); |
260 | 281 | } |
261 | 282 | } |
262 | 283 | // check if opend file is a directory |
263 | 284 | elseif($stat && ($stat['mode'] & self::MODE_DIR) == self::MODE_DIR) |
264 | 285 | { |
265 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) Is a directory!"); |
|
286 | + if (self::LOG_LEVEL) |
|
287 | + { |
|
288 | + error_log(__METHOD__."($url,$mode,$options) Is a directory!"); |
|
289 | + } |
|
266 | 290 | if (($options & STREAM_REPORT_ERRORS)) |
267 | 291 | { |
268 | 292 | trigger_error(__METHOD__."($url,$mode,$options) Is a directory!",E_USER_WARNING); |
@@ -273,11 +297,17 @@ discard block |
||
273 | 297 | else |
274 | 298 | { |
275 | 299 | 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 |
|
300 | + $mode != 'r' && !Vfs::check_access($url,Vfs::WRITABLE,$stat)) |
|
301 | + { |
|
302 | + // or edit it |
|
277 | 303 | { |
278 | 304 | self::_remove_password($url); |
305 | + } |
|
279 | 306 | $op = $mode == 'r' ? 'read' : 'edited'; |
280 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) file can not be $op!"); |
|
307 | + if (self::LOG_LEVEL) |
|
308 | + { |
|
309 | + error_log(__METHOD__."($url,$mode,$options) file can not be $op!"); |
|
310 | + } |
|
281 | 311 | if (($options & STREAM_REPORT_ERRORS)) |
282 | 312 | { |
283 | 313 | trigger_error(__METHOD__."($url,$mode,$options) file can not be $op!",E_USER_WARNING); |
@@ -309,7 +339,10 @@ discard block |
||
309 | 339 | // do we operate directly on the filesystem --> open file from there |
310 | 340 | if ($this->operation == self::STORE2FS) |
311 | 341 | { |
312 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__." fopen (may create a directory? mkdir) ($this->opened_fs_id,$mode,$options)"); |
|
342 | + if (self::LOG_LEVEL > 1) |
|
343 | + { |
|
344 | + error_log(__METHOD__." fopen (may create a directory? mkdir) ($this->opened_fs_id,$mode,$options)"); |
|
345 | + } |
|
313 | 346 | if (!($this->opened_stream = fopen(self::_fs_path($this->opened_fs_id),$mode)) && $new_file) |
314 | 347 | { |
315 | 348 | // delete db entry again, if we are not able to open a new(!) file |
@@ -318,11 +351,17 @@ discard block |
||
318 | 351 | $stmt->execute(array('fs_id' => $this->opened_fs_id)); |
319 | 352 | } |
320 | 353 | } |
321 | - if ($mode[0] == 'a') // append modes: a, a+ |
|
354 | + if ($mode[0] == 'a') |
|
355 | + { |
|
356 | + // append modes: a, a+ |
|
322 | 357 | { |
323 | 358 | $this->stream_seek(0,SEEK_END); |
324 | 359 | } |
325 | - if (!is_resource($this->opened_stream)) error_log(__METHOD__."($url,$mode,$options) NO stream, returning false!"); |
|
360 | + } |
|
361 | + if (!is_resource($this->opened_stream)) |
|
362 | + { |
|
363 | + error_log(__METHOD__."($url,$mode,$options) NO stream, returning false!"); |
|
364 | + } |
|
326 | 365 | |
327 | 366 | return is_resource($this->opened_stream); |
328 | 367 | } |
@@ -334,7 +373,10 @@ discard block |
||
334 | 373 | */ |
335 | 374 | function stream_close ( ) |
336 | 375 | { |
337 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."()"); |
|
376 | + if (self::LOG_LEVEL > 1) |
|
377 | + { |
|
378 | + error_log(__METHOD__."()"); |
|
379 | + } |
|
338 | 380 | |
339 | 381 | if (is_null($this->opened_path) || !is_resource($this->opened_stream) || !$this->opened_fs_id) |
340 | 382 | { |
@@ -404,7 +446,10 @@ discard block |
||
404 | 446 | */ |
405 | 447 | function stream_read ( $count ) |
406 | 448 | { |
407 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($count) pos=$this->opened_pos"); |
|
449 | + if (self::LOG_LEVEL > 1) |
|
450 | + { |
|
451 | + error_log(__METHOD__."($count) pos=$this->opened_pos"); |
|
452 | + } |
|
408 | 453 | |
409 | 454 | if (is_resource($this->opened_stream)) |
410 | 455 | { |
@@ -426,7 +471,10 @@ discard block |
||
426 | 471 | */ |
427 | 472 | function stream_write ( $data ) |
428 | 473 | { |
429 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($data)"); |
|
474 | + if (self::LOG_LEVEL > 1) |
|
475 | + { |
|
476 | + error_log(__METHOD__."($data)"); |
|
477 | + } |
|
430 | 478 | |
431 | 479 | if (is_resource($this->opened_stream)) |
432 | 480 | { |
@@ -463,7 +511,10 @@ discard block |
||
463 | 511 | */ |
464 | 512 | function stream_tell ( ) |
465 | 513 | { |
466 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."()"); |
|
514 | + if (self::LOG_LEVEL > 1) |
|
515 | + { |
|
516 | + error_log(__METHOD__."()"); |
|
517 | + } |
|
467 | 518 | |
468 | 519 | if (is_resource($this->opened_stream)) |
469 | 520 | { |
@@ -486,7 +537,10 @@ discard block |
||
486 | 537 | */ |
487 | 538 | function stream_seek ( $offset, $whence ) |
488 | 539 | { |
489 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($offset,$whence)"); |
|
540 | + if (self::LOG_LEVEL > 1) |
|
541 | + { |
|
542 | + error_log(__METHOD__."($offset,$whence)"); |
|
543 | + } |
|
490 | 544 | |
491 | 545 | if (is_resource($this->opened_stream)) |
492 | 546 | { |
@@ -504,7 +558,10 @@ discard block |
||
504 | 558 | */ |
505 | 559 | function stream_flush ( ) |
506 | 560 | { |
507 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."()"); |
|
561 | + if (self::LOG_LEVEL > 1) |
|
562 | + { |
|
563 | + error_log(__METHOD__."()"); |
|
564 | + } |
|
508 | 565 | |
509 | 566 | if (is_resource($this->opened_stream)) |
510 | 567 | { |
@@ -529,7 +586,10 @@ discard block |
||
529 | 586 | */ |
530 | 587 | function stream_stat ( ) |
531 | 588 | { |
532 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($this->opened_path)"); |
|
589 | + if (self::LOG_LEVEL > 1) |
|
590 | + { |
|
591 | + error_log(__METHOD__."($this->opened_path)"); |
|
592 | + } |
|
533 | 593 | |
534 | 594 | return $this->url_stat($this->opened_path,0); |
535 | 595 | } |
@@ -545,7 +605,10 @@ discard block |
||
545 | 605 | */ |
546 | 606 | static function unlink ( $url, $parent_stat=null ) |
547 | 607 | { |
548 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url)"); |
|
608 | + if (self::LOG_LEVEL > 1) |
|
609 | + { |
|
610 | + error_log(__METHOD__."($url)"); |
|
611 | + } |
|
549 | 612 | |
550 | 613 | $path = Vfs::parse_url($url,PHP_URL_PATH); |
551 | 614 | |
@@ -560,13 +623,19 @@ discard block |
||
560 | 623 | !Vfs::check_access($dir, Vfs::WRITABLE, $parent_stat)) |
561 | 624 | { |
562 | 625 | self::_remove_password($url); |
563 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!"); |
|
626 | + if (self::LOG_LEVEL) |
|
627 | + { |
|
628 | + error_log(__METHOD__."($url) permission denied!"); |
|
629 | + } |
|
564 | 630 | return false; // no permission or file does not exist |
565 | 631 | } |
566 | 632 | if ($stat['mime'] == self::DIR_MIME_TYPE) |
567 | 633 | { |
568 | 634 | self::_remove_password($url); |
569 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url) is NO file!"); |
|
635 | + if (self::LOG_LEVEL) |
|
636 | + { |
|
637 | + error_log(__METHOD__."($url) is NO file!"); |
|
638 | + } |
|
570 | 639 | return false; // no permission or file does not exist |
571 | 640 | } |
572 | 641 | $stmt = self::$pdo->prepare('DELETE FROM '.self::TABLE.' WHERE fs_id=:fs_id'); |
@@ -601,7 +670,10 @@ discard block |
||
601 | 670 | */ |
602 | 671 | static function rename ( $url_from, $url_to) |
603 | 672 | { |
604 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url_from,$url_to)"); |
|
673 | + if (self::LOG_LEVEL > 1) |
|
674 | + { |
|
675 | + error_log(__METHOD__."($url_from,$url_to)"); |
|
676 | + } |
|
605 | 677 | |
606 | 678 | $path_from = Vfs::parse_url($url_from,PHP_URL_PATH); |
607 | 679 | $from_dir = Vfs::dirname($path_from); |
@@ -614,14 +686,20 @@ discard block |
||
614 | 686 | { |
615 | 687 | self::_remove_password($url_from); |
616 | 688 | self::_remove_password($url_to); |
617 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $path_from permission denied!"); |
|
689 | + if (self::LOG_LEVEL) |
|
690 | + { |
|
691 | + error_log(__METHOD__."($url_from,$url_to): $path_from permission denied!"); |
|
692 | + } |
|
618 | 693 | return false; // no permission or file does not exist |
619 | 694 | } |
620 | 695 | if (!$to_dir || !Vfs::check_access($to_dir, Vfs::WRITABLE, $to_dir_stat = static::url_stat($to_dir, 0))) |
621 | 696 | { |
622 | 697 | self::_remove_password($url_from); |
623 | 698 | self::_remove_password($url_to); |
624 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $path_to permission denied!"); |
|
699 | + if (self::LOG_LEVEL) |
|
700 | + { |
|
701 | + error_log(__METHOD__."($url_from,$url_to): $path_to permission denied!"); |
|
702 | + } |
|
625 | 703 | return false; // no permission or parent-dir does not exist |
626 | 704 | } |
627 | 705 | // the filesystem stream-wrapper does NOT allow to rename files to directories, as this makes problems |
@@ -632,14 +710,20 @@ discard block |
||
632 | 710 | self::_remove_password($url_from); |
633 | 711 | self::_remove_password($url_to); |
634 | 712 | $is_dir = $to_stat['mime'] === self::DIR_MIME_TYPE ? 'a' : 'no'; |
635 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url_to,$url_from) $path_to is $is_dir directory!"); |
|
713 | + if (self::LOG_LEVEL) |
|
714 | + { |
|
715 | + error_log(__METHOD__."($url_to,$url_from) $path_to is $is_dir directory!"); |
|
716 | + } |
|
636 | 717 | return false; // no permission or file does not exist |
637 | 718 | } |
638 | 719 | // if destination file already exists, delete it |
639 | 720 | if ($to_stat && !static::unlink($url_to,$operation)) |
640 | 721 | { |
641 | 722 | self::_remove_password($url_to); |
642 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url_to,$url_from) can't unlink existing $url_to!"); |
|
723 | + if (self::LOG_LEVEL) |
|
724 | + { |
|
725 | + error_log(__METHOD__."($url_to,$url_from) can't unlink existing $url_to!"); |
|
726 | + } |
|
643 | 727 | return false; |
644 | 728 | } |
645 | 729 | unset(self::$stat_cache[$path_from]); |
@@ -677,7 +761,10 @@ discard block |
||
677 | 761 | { |
678 | 762 | $maxdepth=10; |
679 | 763 | $depth2propagate = (int)$depth + 1; |
680 | - if ($depth2propagate > $maxdepth) return is_dir($pathname); |
|
764 | + if ($depth2propagate > $maxdepth) |
|
765 | + { |
|
766 | + return is_dir($pathname); |
|
767 | + } |
|
681 | 768 | is_dir(Vfs::dirname($pathname)) || self::mkdir_recursive(Vfs::dirname($pathname), $mode, $depth2propagate); |
682 | 769 | return is_dir($pathname) || @mkdir($pathname, $mode); |
683 | 770 | } |
@@ -695,14 +782,23 @@ discard block |
||
695 | 782 | */ |
696 | 783 | static function mkdir ( $url, $mode, $options ) |
697 | 784 | { |
698 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$mode,$options)"); |
|
699 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__." called from:".function_backtrace()); |
|
785 | + if (self::LOG_LEVEL > 1) |
|
786 | + { |
|
787 | + error_log(__METHOD__."($url,$mode,$options)"); |
|
788 | + } |
|
789 | + if (self::LOG_LEVEL > 1) |
|
790 | + { |
|
791 | + error_log(__METHOD__." called from:".function_backtrace()); |
|
792 | + } |
|
700 | 793 | $path = Vfs::parse_url($url,PHP_URL_PATH); |
701 | 794 | |
702 | 795 | if (self::url_stat($path,STREAM_URL_STAT_QUIET)) |
703 | 796 | { |
704 | 797 | self::_remove_password($url); |
705 | - if (self::LOG_LEVEL) error_log(__METHOD__."('$url',$mode,$options) already exist!"); |
|
798 | + if (self::LOG_LEVEL) |
|
799 | + { |
|
800 | + error_log(__METHOD__."('$url',$mode,$options) already exist!"); |
|
801 | + } |
|
706 | 802 | if (!($options & STREAM_REPORT_ERRORS)) |
707 | 803 | { |
708 | 804 | trigger_error(__METHOD__."('$url',$mode,$options) already exist!",E_USER_WARNING); |
@@ -712,21 +808,30 @@ discard block |
||
712 | 808 | if (!($parent_path = Vfs::dirname($path))) |
713 | 809 | { |
714 | 810 | self::_remove_password($url); |
715 | - if (self::LOG_LEVEL) error_log(__METHOD__."('$url',$mode,$options) dirname('$path')===false!"); |
|
811 | + if (self::LOG_LEVEL) |
|
812 | + { |
|
813 | + error_log(__METHOD__."('$url',$mode,$options) dirname('$path')===false!"); |
|
814 | + } |
|
716 | 815 | if (!($options & STREAM_REPORT_ERRORS)) |
717 | 816 | { |
718 | 817 | trigger_error(__METHOD__."('$url',$mode,$options) dirname('$path')===false!", E_USER_WARNING); |
719 | 818 | } |
720 | 819 | return false; |
721 | 820 | } |
722 | - if (($query = Vfs::parse_url($url,PHP_URL_QUERY))) $parent_path .= '?'.$query; |
|
821 | + if (($query = Vfs::parse_url($url,PHP_URL_QUERY))) |
|
822 | + { |
|
823 | + $parent_path .= '?'.$query; |
|
824 | + } |
|
723 | 825 | $parent = self::url_stat($parent_path,STREAM_URL_STAT_QUIET); |
724 | 826 | |
725 | 827 | // check if we should also create all non-existing path components and our parent does not exist, |
726 | 828 | // if yes call ourself recursive with the parent directory |
727 | 829 | if (($options & STREAM_MKDIR_RECURSIVE) && $parent_path != '/' && !$parent) |
728 | 830 | { |
729 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__." creating parents: $parent_path, $mode"); |
|
831 | + if (self::LOG_LEVEL > 1) |
|
832 | + { |
|
833 | + error_log(__METHOD__." creating parents: $parent_path, $mode"); |
|
834 | + } |
|
730 | 835 | if (!self::mkdir($parent_path,$mode,$options)) |
731 | 836 | { |
732 | 837 | return false; |
@@ -736,7 +841,10 @@ discard block |
||
736 | 841 | if (!$parent || !Vfs::check_access($parent_path,Vfs::WRITABLE,$parent)) |
737 | 842 | { |
738 | 843 | self::_remove_password($url); |
739 | - if (self::LOG_LEVEL) error_log(__METHOD__."('$url',$mode,$options) permission denied!"); |
|
844 | + if (self::LOG_LEVEL) |
|
845 | + { |
|
846 | + error_log(__METHOD__."('$url',$mode,$options) permission denied!"); |
|
847 | + } |
|
740 | 848 | if (!($options & STREAM_REPORT_ERRORS)) |
741 | 849 | { |
742 | 850 | trigger_error(__METHOD__."('$url',$mode,$options) permission denied!",E_USER_WARNING); |
@@ -770,10 +878,13 @@ discard block |
||
770 | 878 | 'fs_dir' => $parent['ino'], |
771 | 879 | 'fs_active' => self::_pdo_boolean(true), |
772 | 880 | 'fs_name' => self::limit_filename(Vfs::basename($path)), |
773 | - )) && $stmt->fetchColumn() > 1) // if there's more then one --> remove our new dir |
|
881 | + )) && $stmt->fetchColumn() > 1) |
|
882 | + { |
|
883 | + // if there's more then one --> remove our new dir |
|
774 | 884 | { |
775 | 885 | self::$pdo->query('DELETE FROM '.self::TABLE.' WHERE fs_id='.$new_fs_id); |
776 | 886 | } |
887 | + } |
|
777 | 888 | } |
778 | 889 | return $ok; |
779 | 890 | } |
@@ -790,7 +901,10 @@ discard block |
||
790 | 901 | */ |
791 | 902 | static function rmdir ( $url, $options ) |
792 | 903 | { |
793 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url)"); |
|
904 | + if (self::LOG_LEVEL > 1) |
|
905 | + { |
|
906 | + error_log(__METHOD__."($url)"); |
|
907 | + } |
|
794 | 908 | |
795 | 909 | $path = Vfs::parse_url($url,PHP_URL_PATH); |
796 | 910 | |
@@ -801,7 +915,10 @@ discard block |
||
801 | 915 | self::_remove_password($url); |
802 | 916 | $err_msg = __METHOD__."($url,$options) ".(!$stat ? 'not found!' : |
803 | 917 | ($stat['mime'] != self::DIR_MIME_TYPE ? 'not a directory!' : 'permission denied!')); |
804 | - if (self::LOG_LEVEL) error_log($err_msg); |
|
918 | + if (self::LOG_LEVEL) |
|
919 | + { |
|
920 | + error_log($err_msg); |
|
921 | + } |
|
805 | 922 | if (!($options & STREAM_REPORT_ERRORS)) |
806 | 923 | { |
807 | 924 | trigger_error($err_msg,E_USER_WARNING); |
@@ -813,7 +930,10 @@ discard block |
||
813 | 930 | if ($stmt->fetchColumn()) |
814 | 931 | { |
815 | 932 | self::_remove_password($url); |
816 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url,$options) dir is not empty!"); |
|
933 | + if (self::LOG_LEVEL) |
|
934 | + { |
|
935 | + error_log(__METHOD__."($url,$options) dir is not empty!"); |
|
936 | + } |
|
817 | 937 | if (!($options & STREAM_REPORT_ERRORS)) |
818 | 938 | { |
819 | 939 | trigger_error(__METHOD__."('$url',$options) dir is not empty!",E_USER_WARNING); |
@@ -845,7 +965,10 @@ discard block |
||
845 | 965 | static function touch($url,$time=null,$atime=null) |
846 | 966 | { |
847 | 967 | unset($atime); // not used |
848 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url, $time)"); |
|
968 | + if (self::LOG_LEVEL > 1) |
|
969 | + { |
|
970 | + error_log(__METHOD__."($url, $time)"); |
|
971 | + } |
|
849 | 972 | |
850 | 973 | $path = Vfs::parse_url($url,PHP_URL_PATH); |
851 | 974 | |
@@ -881,25 +1004,37 @@ discard block |
||
881 | 1004 | */ |
882 | 1005 | static function chown($url,$owner) |
883 | 1006 | { |
884 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$owner)"); |
|
1007 | + if (self::LOG_LEVEL > 1) |
|
1008 | + { |
|
1009 | + error_log(__METHOD__."($url,$owner)"); |
|
1010 | + } |
|
885 | 1011 | |
886 | 1012 | $path = Vfs::parse_url($url,PHP_URL_PATH); |
887 | 1013 | |
888 | 1014 | if (!($stat = self::url_stat($path,0))) |
889 | 1015 | { |
890 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) no such file or directory!"); |
|
1016 | + if (self::LOG_LEVEL) |
|
1017 | + { |
|
1018 | + error_log(__METHOD__."($url,$owner) no such file or directory!"); |
|
1019 | + } |
|
891 | 1020 | trigger_error("No such file or directory $url !",E_USER_WARNING); |
892 | 1021 | return false; |
893 | 1022 | } |
894 | 1023 | if (!Vfs::$is_root) |
895 | 1024 | { |
896 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) only root can do that!"); |
|
1025 | + if (self::LOG_LEVEL) |
|
1026 | + { |
|
1027 | + error_log(__METHOD__."($url,$owner) only root can do that!"); |
|
1028 | + } |
|
897 | 1029 | trigger_error("Only root can do that!",E_USER_WARNING); |
898 | 1030 | return false; |
899 | 1031 | } |
900 | - if ($owner < 0 || $owner && !$GLOBALS['egw']->accounts->id2name($owner)) // not a user (0 == root) |
|
1032 | + if ($owner < 0 || $owner && !$GLOBALS['egw']->accounts->id2name($owner)) |
|
1033 | + { |
|
1034 | + // not a user (0 == root) |
|
901 | 1035 | { |
902 | 1036 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) unknown (numeric) user id!"); |
1037 | + } |
|
903 | 1038 | trigger_error(__METHOD__."($url,$owner) Unknown (numeric) user id!",E_USER_WARNING); |
904 | 1039 | //throw new Exception(__METHOD__."($url,$owner) Unknown (numeric) user id!"); |
905 | 1040 | return false; |
@@ -907,7 +1042,10 @@ discard block |
||
907 | 1042 | $stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_uid=:fs_uid WHERE fs_id=:fs_id'); |
908 | 1043 | |
909 | 1044 | // update stat-cache |
910 | - if ($path != '/' && substr($path,-1) == '/') $path = substr($path, 0, -1); |
|
1045 | + if ($path != '/' && substr($path,-1) == '/') |
|
1046 | + { |
|
1047 | + $path = substr($path, 0, -1); |
|
1048 | + } |
|
911 | 1049 | self::$stat_cache[$path]['fs_uid'] = $owner; |
912 | 1050 | |
913 | 1051 | return $stmt->execute(array( |
@@ -925,34 +1063,53 @@ discard block |
||
925 | 1063 | */ |
926 | 1064 | static function chgrp($url,$owner) |
927 | 1065 | { |
928 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$owner)"); |
|
1066 | + if (self::LOG_LEVEL > 1) |
|
1067 | + { |
|
1068 | + error_log(__METHOD__."($url,$owner)"); |
|
1069 | + } |
|
929 | 1070 | |
930 | 1071 | $path = Vfs::parse_url($url,PHP_URL_PATH); |
931 | 1072 | |
932 | 1073 | if (!($stat = self::url_stat($path,0))) |
933 | 1074 | { |
934 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) no such file or directory!"); |
|
1075 | + if (self::LOG_LEVEL) |
|
1076 | + { |
|
1077 | + error_log(__METHOD__."($url,$owner) no such file or directory!"); |
|
1078 | + } |
|
935 | 1079 | trigger_error("No such file or directory $url !",E_USER_WARNING); |
936 | 1080 | return false; |
937 | 1081 | } |
938 | 1082 | if (!Vfs::has_owner_rights($path,$stat)) |
939 | 1083 | { |
940 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) only owner or root can do that!"); |
|
1084 | + if (self::LOG_LEVEL) |
|
1085 | + { |
|
1086 | + error_log(__METHOD__."($url,$owner) only owner or root can do that!"); |
|
1087 | + } |
|
941 | 1088 | trigger_error("Only owner or root can do that!",E_USER_WARNING); |
942 | 1089 | return false; |
943 | 1090 | } |
944 | - if ($owner < 0) $owner = -$owner; // sqlfs uses a positiv group id's! |
|
1091 | + if ($owner < 0) |
|
1092 | + { |
|
1093 | + $owner = -$owner; |
|
1094 | + } |
|
1095 | + // sqlfs uses a positiv group id's! |
|
945 | 1096 | |
946 | - if ($owner && !$GLOBALS['egw']->accounts->id2name(-$owner)) // not a group |
|
1097 | + if ($owner && !$GLOBALS['egw']->accounts->id2name(-$owner)) |
|
1098 | + { |
|
1099 | + // not a group |
|
947 | 1100 | { |
948 | 1101 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) unknown (numeric) group id!"); |
1102 | + } |
|
949 | 1103 | trigger_error("Unknown (numeric) group id!",E_USER_WARNING); |
950 | 1104 | return false; |
951 | 1105 | } |
952 | 1106 | $stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_gid=:fs_gid WHERE fs_id=:fs_id'); |
953 | 1107 | |
954 | 1108 | // update stat-cache |
955 | - if ($path != '/' && substr($path,-1) == '/') $path = substr($path, 0, -1); |
|
1109 | + if ($path != '/' && substr($path,-1) == '/') |
|
1110 | + { |
|
1111 | + $path = substr($path, 0, -1); |
|
1112 | + } |
|
956 | 1113 | self::$stat_cache[$path]['fs_gid'] = $owner; |
957 | 1114 | |
958 | 1115 | return $stmt->execute(array( |
@@ -970,32 +1127,47 @@ discard block |
||
970 | 1127 | */ |
971 | 1128 | static function chmod($url,$mode) |
972 | 1129 | { |
973 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url, $mode)"); |
|
1130 | + if (self::LOG_LEVEL > 1) |
|
1131 | + { |
|
1132 | + error_log(__METHOD__."($url, $mode)"); |
|
1133 | + } |
|
974 | 1134 | |
975 | 1135 | $path = Vfs::parse_url($url,PHP_URL_PATH); |
976 | 1136 | |
977 | 1137 | if (!($stat = self::url_stat($path,0))) |
978 | 1138 | { |
979 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url, $mode) no such file or directory!"); |
|
1139 | + if (self::LOG_LEVEL) |
|
1140 | + { |
|
1141 | + error_log(__METHOD__."($url, $mode) no such file or directory!"); |
|
1142 | + } |
|
980 | 1143 | trigger_error("No such file or directory $url !",E_USER_WARNING); |
981 | 1144 | return false; |
982 | 1145 | } |
983 | 1146 | if (!Vfs::has_owner_rights($path,$stat)) |
984 | 1147 | { |
985 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url, $mode) only owner or root can do that!"); |
|
1148 | + if (self::LOG_LEVEL) |
|
1149 | + { |
|
1150 | + error_log(__METHOD__."($url, $mode) only owner or root can do that!"); |
|
1151 | + } |
|
986 | 1152 | trigger_error("Only owner or root can do that!",E_USER_WARNING); |
987 | 1153 | return false; |
988 | 1154 | } |
989 | - if (!is_numeric($mode)) // not a mode |
|
1155 | + if (!is_numeric($mode)) |
|
1156 | + { |
|
1157 | + // not a mode |
|
990 | 1158 | { |
991 | 1159 | if (self::LOG_LEVEL) error_log(__METHOD__."($url, $mode) no (numeric) mode!"); |
1160 | + } |
|
992 | 1161 | trigger_error("No (numeric) mode!",E_USER_WARNING); |
993 | 1162 | return false; |
994 | 1163 | } |
995 | 1164 | $stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_mode=:fs_mode WHERE fs_id=:fs_id'); |
996 | 1165 | |
997 | 1166 | // update stat cache |
998 | - if ($path != '/' && substr($path,-1) == '/') $path = substr($path, 0, -1); |
|
1167 | + if ($path != '/' && substr($path,-1) == '/') |
|
1168 | + { |
|
1169 | + $path = substr($path, 0, -1); |
|
1170 | + } |
|
999 | 1171 | self::$stat_cache[$path]['fs_mode'] = ((int) $mode) & 0777; |
1000 | 1172 | |
1001 | 1173 | return $stmt->execute(array( |
@@ -1020,11 +1192,17 @@ discard block |
||
1020 | 1192 | |
1021 | 1193 | if (!($stat = self::url_stat($url,0)) || // dir not found |
1022 | 1194 | $stat['mime'] != self::DIR_MIME_TYPE || // no dir |
1023 | - !Vfs::check_access($url,Vfs::EXECUTABLE|Vfs::READABLE,$stat)) // no access |
|
1195 | + !Vfs::check_access($url,Vfs::EXECUTABLE|Vfs::READABLE,$stat)) |
|
1196 | + { |
|
1197 | + // no access |
|
1024 | 1198 | { |
1025 | 1199 | self::_remove_password($url); |
1200 | + } |
|
1026 | 1201 | $msg = $stat['mime'] != self::DIR_MIME_TYPE ? "$url is no directory" : 'permission denied'; |
1027 | - if (self::LOG_LEVEL) error_log(__METHOD__."('$url',$options) $msg!"); |
|
1202 | + if (self::LOG_LEVEL) |
|
1203 | + { |
|
1204 | + error_log(__METHOD__."('$url',$options) $msg!"); |
|
1205 | + } |
|
1028 | 1206 | $this->opened_dir = null; |
1029 | 1207 | return false; |
1030 | 1208 | } |
@@ -1033,7 +1211,10 @@ discard block |
||
1033 | 1211 | ' FROM '.self::TABLE.' WHERE fs_dir=? AND fs_active='.self::_pdo_boolean(true). |
1034 | 1212 | " ORDER BY fs_mime='httpd/unix-directory' DESC, fs_name ASC"; |
1035 | 1213 | //if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; |
1036 | - if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__."($url,$options)".' */ '.$query; |
|
1214 | + if (self::LOG_LEVEL > 2) |
|
1215 | + { |
|
1216 | + $query = '/* '.__METHOD__."($url,$options)".' */ '.$query; |
|
1217 | + } |
|
1037 | 1218 | |
1038 | 1219 | $stmt = self::$pdo->prepare($query); |
1039 | 1220 | $stmt->setFetchMode(\PDO::FETCH_ASSOC); |
@@ -1045,7 +1226,10 @@ discard block |
||
1045 | 1226 | self::$stat_cache[Vfs::concat($path,$file['fs_name'])] = $file; |
1046 | 1227 | } |
1047 | 1228 | } |
1048 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$options): ".implode(', ',$this->opened_dir)); |
|
1229 | + if (self::LOG_LEVEL > 1) |
|
1230 | + { |
|
1231 | + error_log(__METHOD__."($url,$options): ".implode(', ',$this->opened_dir)); |
|
1232 | + } |
|
1049 | 1233 | reset($this->opened_dir); |
1050 | 1234 | |
1051 | 1235 | return true; |
@@ -1084,9 +1268,16 @@ discard block |
||
1084 | 1268 | if (is_null($max_subquery_depth)) |
1085 | 1269 | { |
1086 | 1270 | $max_subquery_depth = $GLOBALS['egw_info']['server']['max_subquery_depth']; |
1087 | - if (!$max_subquery_depth) $max_subquery_depth = 7; // setting current default of 7, if nothing set |
|
1271 | + if (!$max_subquery_depth) |
|
1272 | + { |
|
1273 | + $max_subquery_depth = 7; |
|
1274 | + } |
|
1275 | + // setting current default of 7, if nothing set |
|
1276 | + } |
|
1277 | + if (self::LOG_LEVEL > 1) |
|
1278 | + { |
|
1279 | + error_log(__METHOD__."('$url',$flags,$eacl_access)"); |
|
1088 | 1280 | } |
1089 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$url',$flags,$eacl_access)"); |
|
1090 | 1281 | |
1091 | 1282 | $path = Vfs::parse_url($url,PHP_URL_PATH); |
1092 | 1283 | |
@@ -1152,7 +1343,10 @@ discard block |
||
1152 | 1343 | if (!Vfs::$user) |
1153 | 1344 | { |
1154 | 1345 | self::_remove_password($url); |
1155 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$url',$flags) permission denied, no user-id and not root!"); |
|
1346 | + if (self::LOG_LEVEL > 1) |
|
1347 | + { |
|
1348 | + error_log(__METHOD__."('$url',$flags) permission denied, no user-id and not root!"); |
|
1349 | + } |
|
1156 | 1350 | return false; |
1157 | 1351 | } |
1158 | 1352 | $query .= ' AND '.self::_sql_readable(); |
@@ -1163,7 +1357,10 @@ discard block |
||
1163 | 1357 | $query = str_replace('fs_name'.self::$case_sensitive_equal.'?','fs_name'.self::$case_sensitive_equal.self::$pdo->quote($name),$base_query).'('.$query.')'; |
1164 | 1358 | } |
1165 | 1359 | } |
1166 | - if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__."($url,$flags,$eacl_access)".' */ '.$query; |
|
1360 | + if (self::LOG_LEVEL > 2) |
|
1361 | + { |
|
1362 | + $query = '/* '.__METHOD__."($url,$flags,$eacl_access)".' */ '.$query; |
|
1363 | + } |
|
1167 | 1364 | //if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; |
1168 | 1365 | |
1169 | 1366 | if (!($result = self::$pdo->query($query)) || !($info = $result->fetch(\PDO::FETCH_ASSOC))) |
@@ -1186,12 +1383,18 @@ discard block |
||
1186 | 1383 | $GLOBALS['egw_info']['server']['max_subquery_depth'] = --$max_subquery_depth; |
1187 | 1384 | error_log(__METHOD__."() decremented max_subquery_depth to $max_subquery_depth"); |
1188 | 1385 | Api\Config::save_value('max_subquery_depth', $max_subquery_depth, 'phpgwapi'); |
1189 | - if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) $GLOBALS['egw']->invalidate_session_cache(); |
|
1386 | + if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) |
|
1387 | + { |
|
1388 | + $GLOBALS['egw']->invalidate_session_cache(); |
|
1389 | + } |
|
1190 | 1390 | return self::url_stat($url, $flags, $eacl_access); |
1191 | 1391 | } |
1192 | 1392 | self::$stat_cache[$path] = $info; |
1193 | 1393 | |
1194 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$flags)=".array2string($info)); |
|
1394 | + if (self::LOG_LEVEL > 1) |
|
1395 | + { |
|
1396 | + error_log(__METHOD__."($url,$flags)=".array2string($info)); |
|
1397 | + } |
|
1195 | 1398 | return self::_vfsinfo2stat($info); |
1196 | 1399 | } |
1197 | 1400 | |
@@ -1228,9 +1431,15 @@ discard block |
||
1228 | 1431 | */ |
1229 | 1432 | function dir_readdir ( ) |
1230 | 1433 | { |
1231 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."( )"); |
|
1434 | + if (self::LOG_LEVEL > 1) |
|
1435 | + { |
|
1436 | + error_log(__METHOD__."( )"); |
|
1437 | + } |
|
1232 | 1438 | |
1233 | - if (!is_array($this->opened_dir)) return false; |
|
1439 | + if (!is_array($this->opened_dir)) |
|
1440 | + { |
|
1441 | + return false; |
|
1442 | + } |
|
1234 | 1443 | |
1235 | 1444 | $file = current($this->opened_dir); next($this->opened_dir); |
1236 | 1445 | |
@@ -1247,9 +1456,15 @@ discard block |
||
1247 | 1456 | */ |
1248 | 1457 | function dir_rewinddir ( ) |
1249 | 1458 | { |
1250 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."( )"); |
|
1459 | + if (self::LOG_LEVEL > 1) |
|
1460 | + { |
|
1461 | + error_log(__METHOD__."( )"); |
|
1462 | + } |
|
1251 | 1463 | |
1252 | - if (!is_array($this->opened_dir)) return false; |
|
1464 | + if (!is_array($this->opened_dir)) |
|
1465 | + { |
|
1466 | + return false; |
|
1467 | + } |
|
1253 | 1468 | |
1254 | 1469 | reset($this->opened_dir); |
1255 | 1470 | |
@@ -1265,9 +1480,15 @@ discard block |
||
1265 | 1480 | */ |
1266 | 1481 | function dir_closedir ( ) |
1267 | 1482 | { |
1268 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."( )"); |
|
1483 | + if (self::LOG_LEVEL > 1) |
|
1484 | + { |
|
1485 | + error_log(__METHOD__."( )"); |
|
1486 | + } |
|
1269 | 1487 | |
1270 | - if (!is_array($this->opened_dir)) return false; |
|
1488 | + if (!is_array($this->opened_dir)) |
|
1489 | + { |
|
1490 | + return false; |
|
1491 | + } |
|
1271 | 1492 | |
1272 | 1493 | $this->opened_dir = null; |
1273 | 1494 | |
@@ -1286,7 +1507,10 @@ discard block |
||
1286 | 1507 | { |
1287 | 1508 | $link = !($lstat = self::url_stat($path,STREAM_URL_STAT_LINK)) || is_null($lstat['readlink']) ? false : $lstat['readlink']; |
1288 | 1509 | |
1289 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = $link"); |
|
1510 | + if (self::LOG_LEVEL > 1) |
|
1511 | + { |
|
1512 | + error_log(__METHOD__."('$path') = $link"); |
|
1513 | + } |
|
1290 | 1514 | |
1291 | 1515 | return $link; |
1292 | 1516 | } |
@@ -1300,22 +1524,34 @@ discard block |
||
1300 | 1524 | */ |
1301 | 1525 | static function symlink($target,$link) |
1302 | 1526 | { |
1303 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$target','$link')"); |
|
1527 | + if (self::LOG_LEVEL > 1) |
|
1528 | + { |
|
1529 | + error_log(__METHOD__."('$target','$link')"); |
|
1530 | + } |
|
1304 | 1531 | |
1305 | 1532 | if (self::url_stat($link,0)) |
1306 | 1533 | { |
1307 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$target','$link') $link exists, returning false!"); |
|
1534 | + if (self::LOG_LEVEL > 0) |
|
1535 | + { |
|
1536 | + error_log(__METHOD__."('$target','$link') $link exists, returning false!"); |
|
1537 | + } |
|
1308 | 1538 | return false; // $link already exists |
1309 | 1539 | } |
1310 | 1540 | if (!($dir = Vfs::dirname($link)) || |
1311 | 1541 | !Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat=static::url_stat($dir,0))) |
1312 | 1542 | { |
1313 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$target','$link') returning false! (!is_writable('$dir'), dir_stat=".array2string($dir_stat).")"); |
|
1543 | + if (self::LOG_LEVEL > 0) |
|
1544 | + { |
|
1545 | + error_log(__METHOD__."('$target','$link') returning false! (!is_writable('$dir'), dir_stat=".array2string($dir_stat).")"); |
|
1546 | + } |
|
1314 | 1547 | return false; // parent dir does not exist or is not writable |
1315 | 1548 | } |
1316 | 1549 | $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'. |
1317 | 1550 | ') VALUES (:fs_name,:fs_dir,:fs_mode,:fs_uid,:fs_gid,:fs_created,:fs_modified,:fs_creator,:fs_mime,:fs_size,:fs_link)'; |
1318 | - if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; |
|
1551 | + if (self::LOG_LEVEL > 2) |
|
1552 | + { |
|
1553 | + $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; |
|
1554 | + } |
|
1319 | 1555 | $stmt = self::$pdo->prepare($query); |
1320 | 1556 | unset(self::$stat_cache[Vfs::parse_url($link,PHP_URL_PATH)]); |
1321 | 1557 | |
@@ -1363,7 +1599,10 @@ discard block |
||
1363 | 1599 | break; |
1364 | 1600 | } |
1365 | 1601 | } |
1366 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$check) ".($access?"access granted by $path=$rights":'no access!!!')); |
|
1602 | + if (self::LOG_LEVEL > 1) |
|
1603 | + { |
|
1604 | + error_log(__METHOD__."($url,$check) ".($access?"access granted by $path=$rights":'no access!!!')); |
|
1605 | + } |
|
1367 | 1606 | return $access; |
1368 | 1607 | } |
1369 | 1608 | |
@@ -1391,11 +1630,15 @@ discard block |
||
1391 | 1630 | } |
1392 | 1631 | } |
1393 | 1632 | // sort by length descending, to allow more specific pathes to have precedence |
1394 | - uksort(self::$extended_acl, function($a,$b) { |
|
1633 | + uksort(self::$extended_acl, function($a,$b) |
|
1634 | + { |
|
1395 | 1635 | return strlen($b)-strlen($a); |
1396 | 1636 | }); |
1397 | 1637 | Api\Cache::setSession(self::EACL_APPNAME, 'extended_acl', self::$extended_acl); |
1398 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__.'() '.array2string(self::$extended_acl)); |
|
1638 | + if (self::LOG_LEVEL > 1) |
|
1639 | + { |
|
1640 | + error_log(__METHOD__.'() '.array2string(self::$extended_acl)); |
|
1641 | + } |
|
1399 | 1642 | } |
1400 | 1643 | |
1401 | 1644 | /** |
@@ -1424,12 +1667,18 @@ discard block |
||
1424 | 1667 | { |
1425 | 1668 | if (!($stat = self::url_stat($path,0))) |
1426 | 1669 | { |
1427 | - if (self::LOG_LEVEL) error_log(__METHOD__."($path,$rights,$owner,$fs_id) no such file or directory!"); |
|
1670 | + if (self::LOG_LEVEL) |
|
1671 | + { |
|
1672 | + error_log(__METHOD__."($path,$rights,$owner,$fs_id) no such file or directory!"); |
|
1673 | + } |
|
1428 | 1674 | return false; // $path not found |
1429 | 1675 | } |
1430 | - if (!Vfs::has_owner_rights($path,$stat)) // not group dir and user is eGW admin |
|
1676 | + if (!Vfs::has_owner_rights($path,$stat)) |
|
1677 | + { |
|
1678 | + // not group dir and user is eGW admin |
|
1431 | 1679 | { |
1432 | 1680 | if (self::LOG_LEVEL) error_log(__METHOD__."($path,$rights,$owner,$fs_id) permission denied!"); |
1681 | + } |
|
1433 | 1682 | return false; // permission denied |
1434 | 1683 | } |
1435 | 1684 | $fs_id = $stat['ino']; |
@@ -1462,7 +1711,10 @@ discard block |
||
1462 | 1711 | { |
1463 | 1712 | Api\Cache::setSession(self::EACL_APPNAME, 'extended_acl', self::$extended_acl); |
1464 | 1713 | } |
1465 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path,$rights,$owner,$fs_id)=".(int)$ret); |
|
1714 | + if (self::LOG_LEVEL > 1) |
|
1715 | + { |
|
1716 | + error_log(__METHOD__."($path,$rights,$owner,$fs_id)=".(int)$ret); |
|
1717 | + } |
|
1466 | 1718 | return $ret; |
1467 | 1719 | } |
1468 | 1720 | |
@@ -1496,7 +1748,8 @@ discard block |
||
1496 | 1748 | $eacls = array_merge((array)self::get_eacl($path),$eacls); |
1497 | 1749 | } |
1498 | 1750 | // sort by length descending, to show precedence |
1499 | - usort($eacls, function($a, $b) { |
|
1751 | + usort($eacls, function($a, $b) |
|
1752 | + { |
|
1500 | 1753 | return strlen($b['path']) - strlen($a['path']); |
1501 | 1754 | }); |
1502 | 1755 | //error_log(__METHOD__."('$_path') returning ".array2string($eacls)); |
@@ -1514,7 +1767,10 @@ discard block |
||
1514 | 1767 | */ |
1515 | 1768 | static function id2path($fs_ids) |
1516 | 1769 | { |
1517 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($fs_ids).')'); |
|
1770 | + if (self::LOG_LEVEL > 1) |
|
1771 | + { |
|
1772 | + error_log(__METHOD__.'('.array2string($fs_ids).')'); |
|
1773 | + } |
|
1518 | 1774 | $ids = (array)$fs_ids; |
1519 | 1775 | $pathes = array(); |
1520 | 1776 | // first check our stat-cache for the ids |
@@ -1526,16 +1782,26 @@ discard block |
||
1526 | 1782 | unset($ids[$key]); |
1527 | 1783 | if (!$ids) |
1528 | 1784 | { |
1529 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($fs_ids).')='.array2string($pathes).' *from stat_cache*'); |
|
1785 | + if (self::LOG_LEVEL > 1) |
|
1786 | + { |
|
1787 | + error_log(__METHOD__.'('.array2string($fs_ids).')='.array2string($pathes).' *from stat_cache*'); |
|
1788 | + } |
|
1530 | 1789 | return is_array($fs_ids) ? $pathes : array_shift($pathes); |
1531 | 1790 | } |
1532 | 1791 | } |
1533 | 1792 | } |
1534 | 1793 | // now search via the database |
1535 | - if (count($ids) > 1) array_map(function(&$v) { $v = (int)$v; },$ids); |
|
1794 | + if (count($ids) > 1) |
|
1795 | + { |
|
1796 | + array_map(function(&$v) { $v = (int)$v; |
|
1797 | + } |
|
1798 | + },$ids); |
|
1536 | 1799 | $query = 'SELECT fs_id,fs_dir,fs_name FROM '.self::TABLE.' WHERE fs_id'. |
1537 | 1800 | (count($ids) == 1 ? '='.(int)$ids[0] : ' IN ('.implode(',',$ids).')'); |
1538 | - if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; |
|
1801 | + if (self::LOG_LEVEL > 2) |
|
1802 | + { |
|
1803 | + $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; |
|
1804 | + } |
|
1539 | 1805 | |
1540 | 1806 | if (!is_object(self::$pdo)) |
1541 | 1807 | { |
@@ -1562,14 +1828,20 @@ discard block |
||
1562 | 1828 | { |
1563 | 1829 | return false; // parent not found, should never happen ... |
1564 | 1830 | } |
1565 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__." trying foreach with:".print_r($rows,true)."#"); |
|
1831 | + if (self::LOG_LEVEL > 1) |
|
1832 | + { |
|
1833 | + error_log(__METHOD__." trying foreach with:".print_r($rows,true)."#"); |
|
1834 | + } |
|
1566 | 1835 | foreach((array)$rows as $fs_id => $row) |
1567 | 1836 | { |
1568 | 1837 | $parent = $row['fs_dir'] > 1 ? $parents[$row['fs_dir']] : ''; |
1569 | 1838 | |
1570 | 1839 | $pathes[$fs_id] = $parent . '/' . $row['fs_name']; |
1571 | 1840 | } |
1572 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($fs_ids).')='.array2string($pathes)); |
|
1841 | + if (self::LOG_LEVEL > 1) |
|
1842 | + { |
|
1843 | + error_log(__METHOD__.'('.array2string($fs_ids).')='.array2string($pathes)); |
|
1844 | + } |
|
1573 | 1845 | return is_array($fs_ids) ? $pathes : array_shift($pathes); |
1574 | 1846 | } |
1575 | 1847 | |
@@ -1625,7 +1897,10 @@ discard block |
||
1625 | 1897 | 'mime' => $info['fs_mime'], |
1626 | 1898 | 'readlink' => $info['fs_link'], |
1627 | 1899 | ); |
1628 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($info[name]) = ".array2string($stat)); |
|
1900 | + if (self::LOG_LEVEL > 1) |
|
1901 | + { |
|
1902 | + error_log(__METHOD__."($info[name]) = ".array2string($stat)); |
|
1903 | + } |
|
1629 | 1904 | return $stat; |
1630 | 1905 | } |
1631 | 1906 | |
@@ -1657,13 +1932,16 @@ discard block |
||
1657 | 1932 | } |
1658 | 1933 | if (!isset($GLOBALS['egw_info']['server']['files_dir'])) |
1659 | 1934 | { |
1660 | - if (is_object($GLOBALS['egw_setup']->db)) // if we run under setup, query the db for the files dir |
|
1935 | + if (is_object($GLOBALS['egw_setup']->db)) |
|
1936 | + { |
|
1937 | + // if we run under setup, query the db for the files dir |
|
1661 | 1938 | { |
1662 | 1939 | $GLOBALS['egw_info']['server']['files_dir'] = $GLOBALS['egw_setup']->db->select('egw_config','config_value',array( |
1663 | 1940 | 'config_name' => 'files_dir', |
1664 | 1941 | 'config_app' => 'phpgwapi', |
1665 | 1942 | ),__LINE__,__FILE__)->fetchColumn(); |
1666 | 1943 | } |
1944 | + } |
|
1667 | 1945 | } |
1668 | 1946 | if (!$GLOBALS['egw_info']['server']['files_dir']) |
1669 | 1947 | { |
@@ -1675,7 +1953,11 @@ discard block |
||
1675 | 1953 | { |
1676 | 1954 | $hash[] = sprintf('%02d',$n % self::HASH_MAX); |
1677 | 1955 | } |
1678 | - if (!$hash) $hash[] = '00'; // we need at least one directory, to not conflict with the dir-names |
|
1956 | + if (!$hash) |
|
1957 | + { |
|
1958 | + $hash[] = '00'; |
|
1959 | + } |
|
1960 | + // we need at least one directory, to not conflict with the dir-names |
|
1679 | 1961 | array_unshift($hash,$id); |
1680 | 1962 | |
1681 | 1963 | $path = '/sqlfs/'.implode('/',array_reverse($hash)); |
@@ -1737,7 +2019,10 @@ discard block |
||
1737 | 2019 | */ |
1738 | 2020 | static function proppatch($path,array $props) |
1739 | 2021 | { |
1740 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."(".array2string($path).','.array2string($props)); |
|
2022 | + if (self::LOG_LEVEL > 1) |
|
2023 | + { |
|
2024 | + error_log(__METHOD__."(".array2string($path).','.array2string($props)); |
|
2025 | + } |
|
1741 | 2026 | if (!is_numeric($path)) |
1742 | 2027 | { |
1743 | 2028 | if (!($stat = self::url_stat($path,0))) |
@@ -1757,13 +2042,19 @@ discard block |
||
1757 | 2042 | $ins_stmt = $del_stmt = null; |
1758 | 2043 | foreach($props as &$prop) |
1759 | 2044 | { |
1760 | - if (!isset($prop['ns'])) $prop['ns'] = Vfs::DEFAULT_PROP_NAMESPACE; |
|
2045 | + if (!isset($prop['ns'])) |
|
2046 | + { |
|
2047 | + $prop['ns'] = Vfs::DEFAULT_PROP_NAMESPACE; |
|
2048 | + } |
|
1761 | 2049 | |
1762 | - if (!isset($prop['val']) || self::$pdo_type != 'mysql') // for non mysql, we have to delete the prop anyway, as there's no REPLACE! |
|
2050 | + if (!isset($prop['val']) || self::$pdo_type != 'mysql') |
|
2051 | + { |
|
2052 | + // for non mysql, we have to delete the prop anyway, as there's no REPLACE! |
|
1763 | 2053 | { |
1764 | 2054 | if (!isset($del_stmt)) |
1765 | 2055 | { |
1766 | 2056 | $del_stmt = self::$pdo->prepare('DELETE FROM '.self::PROPS_TABLE.' WHERE fs_id=:fs_id AND prop_namespace=:prop_namespace AND prop_name=:prop_name'); |
2057 | + } |
|
1767 | 2058 | } |
1768 | 2059 | $del_stmt->execute(array( |
1769 | 2060 | 'fs_id' => $id, |
@@ -1809,17 +2100,27 @@ discard block |
||
1809 | 2100 | { |
1810 | 2101 | if (!($stat = self::url_stat($id,0))) |
1811 | 2102 | { |
1812 | - if (self::LOG_LEVEL) error_log(__METHOD__."(".array2string($path_ids).",$ns) path '$id' not found!"); |
|
2103 | + if (self::LOG_LEVEL) |
|
2104 | + { |
|
2105 | + error_log(__METHOD__."(".array2string($path_ids).",$ns) path '$id' not found!"); |
|
2106 | + } |
|
1813 | 2107 | return false; |
1814 | 2108 | } |
1815 | 2109 | $id = $stat['ino']; |
1816 | 2110 | } |
1817 | 2111 | } |
1818 | - if (count($ids) >= 1) array_map(function(&$v) { $v = (int)$v; },$ids); |
|
2112 | + if (count($ids) >= 1) |
|
2113 | + { |
|
2114 | + array_map(function(&$v) { $v = (int)$v; |
|
2115 | + } |
|
2116 | + },$ids); |
|
1819 | 2117 | $query = 'SELECT * FROM '.self::PROPS_TABLE.' WHERE (fs_id'. |
1820 | 2118 | (count($ids) == 1 ? '='.(int)implode('',$ids) : ' IN ('.implode(',',$ids).')').')'. |
1821 | 2119 | (!is_null($ns) ? ' AND prop_namespace=?' : ''); |
1822 | - if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; |
|
2120 | + if (self::LOG_LEVEL > 2) |
|
2121 | + { |
|
2122 | + $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; |
|
2123 | + } |
|
1823 | 2124 | |
1824 | 2125 | $stmt = self::$pdo->prepare($query); |
1825 | 2126 | $stmt->setFetchMode(\PDO::FETCH_ASSOC); |
@@ -1838,11 +2139,14 @@ discard block |
||
1838 | 2139 | { |
1839 | 2140 | $props = $props[$row['fs_id']] ? $props[$row['fs_id']] : array(); // return empty array for no props |
1840 | 2141 | } |
1841 | - elseif ($props && isset($stat)) // need to map fs_id's to pathes |
|
2142 | + elseif ($props && isset($stat)) |
|
2143 | + { |
|
2144 | + // need to map fs_id's to pathes |
|
1842 | 2145 | { |
1843 | 2146 | foreach(self::id2path(array_keys($props)) as $id => $path) |
1844 | 2147 | { |
1845 | 2148 | $props[$path] =& $props[$id]; |
2149 | + } |
|
1846 | 2150 | unset($props[$id]); |
1847 | 2151 | } |
1848 | 2152 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @param boolean $debug true to echo a message for each copied file |
28 | 28 | */ |
29 | - static function migrate_db2fs($debug=true) |
|
29 | + static function migrate_db2fs($debug = true) |
|
30 | 30 | { |
31 | 31 | if (!is_object(self::$pdo)) |
32 | 32 | { |
@@ -40,15 +40,15 @@ discard block |
||
40 | 40 | $fs_id = $fs_name = $fs_size = $fs_content = null; |
41 | 41 | $n = 0; |
42 | 42 | $stmt = self::$pdo->prepare($query); |
43 | - $stmt->bindColumn(1,$fs_id); |
|
44 | - $stmt->bindColumn(2,$fs_name); |
|
45 | - $stmt->bindColumn(3,$fs_size); |
|
46 | - $stmt->bindColumn(4,$fs_content,\PDO::PARAM_LOB); |
|
43 | + $stmt->bindColumn(1, $fs_id); |
|
44 | + $stmt->bindColumn(2, $fs_name); |
|
45 | + $stmt->bindColumn(3, $fs_size); |
|
46 | + $stmt->bindColumn(4, $fs_content, \PDO::PARAM_LOB); |
|
47 | 47 | $stmt->bindValue(':offset', $n, \PDO::PARAM_INT); |
48 | 48 | |
49 | 49 | while ($stmt->execute()) |
50 | 50 | { |
51 | - foreach($stmt as $row) |
|
51 | + foreach ($stmt as $row) |
|
52 | 52 | { |
53 | 53 | // hack to work around a current php bug (http://bugs.php.net/bug.php?id=40913) |
54 | 54 | // PDOStatement::bindColumn(,,\PDO::PARAM_LOB) is not working for MySQL, content is returned as string :-( |
@@ -68,15 +68,15 @@ discard block |
||
68 | 68 | throw new Api\Exception\AssertionFailed(__METHOD__."(): fs_id=$fs_id ($fs_name, $fs_size bytes) content is NO resource! ".array2string($content)); |
69 | 69 | } |
70 | 70 | $filename = self::_fs_path($fs_id); |
71 | - if (!file_exists($fs_dir=Vfs::dirname($filename))) |
|
71 | + if (!file_exists($fs_dir = Vfs::dirname($filename))) |
|
72 | 72 | { |
73 | - self::mkdir_recursive($fs_dir,0700,true); |
|
73 | + self::mkdir_recursive($fs_dir, 0700, true); |
|
74 | 74 | } |
75 | - if (!($dest = fopen($filename,'w'))) |
|
75 | + if (!($dest = fopen($filename, 'w'))) |
|
76 | 76 | { |
77 | 77 | throw new Api\Exception\AssertionFailed(__METHOD__."(): fopen($filename,'w') failed!"); |
78 | 78 | } |
79 | - if (($bytes = stream_copy_to_stream($content,$dest)) != $fs_size) |
|
79 | + if (($bytes = stream_copy_to_stream($content, $dest)) != $fs_size) |
|
80 | 80 | { |
81 | 81 | throw new Api\Exception\AssertionFailed(__METHOD__."(): fs_id=$fs_id ($fs_name) $bytes bytes copied != size of $fs_size bytes!"); |
82 | 82 | } |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | |
87 | 87 | ++$n; |
88 | 88 | } |
89 | - if (!$n) break; // just in case nothing is found, statement will execute just fine |
|
89 | + if (!$n) break; // just in case nothing is found, statement will execute just fine |
|
90 | 90 | |
91 | 91 | $stmt->bindValue(':offset', $n, \PDO::PARAM_INT); |
92 | 92 | } |
93 | - unset($row); // not used, as we access bound variables |
|
93 | + unset($row); // not used, as we access bound variables |
|
94 | 94 | unset($stmt); |
95 | 95 | |
96 | 96 | if ($n) // delete all content in DB, if there was some AND no error (exception thrown!) |
@@ -108,14 +108,14 @@ discard block |
||
108 | 108 | * @param boolean $check_only =true |
109 | 109 | * @return array with messages / found problems |
110 | 110 | */ |
111 | - public static function fsck($check_only=true) |
|
111 | + public static function fsck($check_only = true) |
|
112 | 112 | { |
113 | 113 | if (!is_object(self::$pdo)) |
114 | 114 | { |
115 | 115 | self::_pdo(); |
116 | 116 | } |
117 | 117 | $msgs = array(); |
118 | - foreach(array( |
|
118 | + foreach (array( |
|
119 | 119 | self::fsck_fix_required_nodes($check_only), |
120 | 120 | self::fsck_fix_multiple_active($check_only), |
121 | 121 | self::fsck_fix_unconnected($check_only), |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @param boolean $check_only =true |
142 | 142 | * @return array with messages / found problems |
143 | 143 | */ |
144 | - private static function fsck_fix_required_nodes($check_only=true) |
|
144 | + private static function fsck_fix_required_nodes($check_only = true) |
|
145 | 145 | { |
146 | 146 | static $dirs = array( |
147 | 147 | '/' => 1, |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | ); |
151 | 151 | $stmt = $delete_stmt = null; |
152 | 152 | $msgs = array(); |
153 | - foreach($dirs as $path => $id) |
|
153 | + foreach ($dirs as $path => $id) |
|
154 | 154 | { |
155 | 155 | if (!($stat = self::url_stat($path, STREAM_URL_STAT_LINK))) |
156 | 156 | { |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | try { |
169 | 169 | $ok = $stmt->execute($data = array( |
170 | 170 | 'fs_id' => $id, |
171 | - 'fs_name' => substr($path,1), |
|
171 | + 'fs_name' => substr($path, 1), |
|
172 | 172 | 'fs_dir' => $path == '/' ? 0 : $dirs['/'], |
173 | 173 | 'fs_mode' => 05, |
174 | 174 | 'fs_uid' => 0, |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | catch (\PDOException $e) |
184 | 184 | { |
185 | 185 | $ok = false; |
186 | - unset($e); // ignore exception |
|
186 | + unset($e); // ignore exception |
|
187 | 187 | } |
188 | 188 | if (!$ok) // can not insert it, try deleting it first |
189 | 189 | { |
@@ -196,15 +196,14 @@ discard block |
||
196 | 196 | } |
197 | 197 | catch (\PDOException $e) |
198 | 198 | { |
199 | - unset($e); // ignore exception |
|
199 | + unset($e); // ignore exception |
|
200 | 200 | } |
201 | 201 | } |
202 | - $msgs[] = $ok ? lang('Required directory "%1" created.', $path) : |
|
203 | - lang('Failed to create required directory "%1"!', $path); |
|
202 | + $msgs[] = $ok ? lang('Required directory "%1" created.', $path) : lang('Failed to create required directory "%1"!', $path); |
|
204 | 203 | } |
205 | 204 | } |
206 | 205 | // check if directory is at least world readable and executable (r-x), we allow more but not less |
207 | - elseif (($stat['mode'] & 05) != 05) |
|
206 | + elseif (($stat['mode']&05) != 05) |
|
208 | 207 | { |
209 | 208 | if ($check_only) |
210 | 209 | { |
@@ -244,20 +243,20 @@ discard block |
||
244 | 243 | * @param boolean $check_only =true |
245 | 244 | * @return array with messages / found problems |
246 | 245 | */ |
247 | - private static function fsck_fix_no_content($check_only=true) |
|
246 | + private static function fsck_fix_no_content($check_only = true) |
|
248 | 247 | { |
249 | 248 | $stmt = null; |
250 | 249 | $msgs = array(); |
251 | - foreach(self::$pdo->query('SELECT fs_id FROM '.self::TABLE. |
|
250 | + foreach (self::$pdo->query('SELECT fs_id FROM '.self::TABLE. |
|
252 | 251 | " WHERE fs_mime!='httpd/unix-directory' AND fs_content IS NULL AND fs_link IS NULL") as $row) |
253 | 252 | { |
254 | - if (!file_exists($phy_path=self::_fs_path($row['fs_id']))) |
|
253 | + if (!file_exists($phy_path = self::_fs_path($row['fs_id']))) |
|
255 | 254 | { |
256 | 255 | $path = self::id2path($row['fs_id']); |
257 | 256 | if ($check_only) |
258 | 257 | { |
259 | 258 | $msgs[] = lang('File %1 has no content in physical filesystem %2!', |
260 | - $path.' (#'.$row['fs_id'].')',$phy_path); |
|
259 | + $path.' (#'.$row['fs_id'].')', $phy_path); |
|
261 | 260 | } |
262 | 261 | else |
263 | 262 | { |
@@ -269,12 +268,12 @@ discard block |
||
269 | 268 | if ($stmt->execute(array('fs_id' => $row['fs_id'])) && |
270 | 269 | $stmt_props->execute(array('fs_id' => $row['fs_id']))) |
271 | 270 | { |
272 | - $msgs[] = lang('File %1 has no content in physical filesystem %2 --> file removed!',$path,$phy_path); |
|
271 | + $msgs[] = lang('File %1 has no content in physical filesystem %2 --> file removed!', $path, $phy_path); |
|
273 | 272 | } |
274 | 273 | else |
275 | 274 | { |
276 | 275 | $msgs[] = lang('File %1 has no content in physical filesystem %2 --> failed to remove file!', |
277 | - $path.' (#'.$row['fs_id'].')',$phy_path); |
|
276 | + $path.' (#'.$row['fs_id'].')', $phy_path); |
|
278 | 277 | } |
279 | 278 | } |
280 | 279 | } |
@@ -304,11 +303,11 @@ discard block |
||
304 | 303 | * @param boolean $check_only =true |
305 | 304 | * @return array with messages / found problems |
306 | 305 | */ |
307 | - private static function fsck_fix_unconnected($check_only=true) |
|
306 | + private static function fsck_fix_unconnected($check_only = true) |
|
308 | 307 | { |
309 | 308 | $lostnfound = null; |
310 | 309 | $msgs = array(); |
311 | - foreach(self::$pdo->query('SELECT fs.* FROM '.self::TABLE.' fs'. |
|
310 | + foreach (self::$pdo->query('SELECT fs.* FROM '.self::TABLE.' fs'. |
|
312 | 311 | ' LEFT JOIN '.self::TABLE.' dir ON dir.fs_id=fs.fs_dir'. |
313 | 312 | ' WHERE fs.fs_id > 1 AND dir.fs_id IS NULL') as $row) |
314 | 313 | { |
@@ -327,14 +326,14 @@ discard block |
||
327 | 326 | Vfs::$is_root = true; |
328 | 327 | if (!self::mkdir(self::LOST_N_FOUND, self::LOST_N_FOUND_MOD, 0) || |
329 | 328 | !(!($admins = $GLOBALS['egw']->accounts->name2id(self::LOST_N_FOUND_GRP)) || |
330 | - self::chgrp(self::LOST_N_FOUND, $admins) && self::chmod(self::LOST_N_FOUND,self::LOST_N_FOUND_MOD)) || |
|
329 | + self::chgrp(self::LOST_N_FOUND, $admins) && self::chmod(self::LOST_N_FOUND, self::LOST_N_FOUND_MOD)) || |
|
331 | 330 | !($lostnfound = self::url_stat(self::LOST_N_FOUND, STREAM_URL_STAT_QUIET))) |
332 | 331 | { |
333 | - $msgs[] = lang("Can't create directory %1 to connect found unconnected nodes to it!",self::LOST_N_FOUND); |
|
332 | + $msgs[] = lang("Can't create directory %1 to connect found unconnected nodes to it!", self::LOST_N_FOUND); |
|
334 | 333 | } |
335 | 334 | else |
336 | 335 | { |
337 | - $msgs[] = lang('Successful created new directory %1 for unconnected nods.',self::LOST_N_FOUND); |
|
336 | + $msgs[] = lang('Successful created new directory %1 for unconnected nods.', self::LOST_N_FOUND); |
|
338 | 337 | } |
339 | 338 | Vfs::$is_root = false; |
340 | 339 | if (!$lostnfound) break; |
@@ -359,7 +358,7 @@ discard block |
||
359 | 358 | } |
360 | 359 | if ($check_only && $msgs) |
361 | 360 | { |
362 | - $msgs[] = lang('Unconnected nodes will be moved to %1.',self::LOST_N_FOUND); |
|
361 | + $msgs[] = lang('Unconnected nodes will be moved to %1.', self::LOST_N_FOUND); |
|
363 | 362 | } |
364 | 363 | return $msgs; |
365 | 364 | } |
@@ -372,20 +371,20 @@ discard block |
||
372 | 371 | * @param boolean $check_only =true |
373 | 372 | * @return array with messages / found problems |
374 | 373 | */ |
375 | - private static function fsck_fix_multiple_active($check_only=true) |
|
374 | + private static function fsck_fix_multiple_active($check_only = true) |
|
376 | 375 | { |
377 | 376 | $stmt = $inactivate_msg_added = null; |
378 | 377 | $msgs = array(); |
379 | - foreach(self::$pdo->query('SELECT fs_dir,fs_name,COUNT(*) FROM '.self::TABLE. |
|
378 | + foreach (self::$pdo->query('SELECT fs_dir,fs_name,COUNT(*) FROM '.self::TABLE. |
|
380 | 379 | ' WHERE fs_active='.self::_pdo_boolean(true)." OR fs_mime='httpd/unix-directory'". |
381 | - ' GROUP BY fs_dir,'.(self::$pdo_type == 'mysql' ? 'BINARY ' : '').'fs_name'. // fs_name is casesensitive! |
|
380 | + ' GROUP BY fs_dir,'.(self::$pdo_type == 'mysql' ? 'BINARY ' : '').'fs_name'.// fs_name is casesensitive! |
|
382 | 381 | ' HAVING COUNT(*) > 1') as $row) |
383 | 382 | { |
384 | 383 | if (!isset($stmt)) |
385 | 384 | { |
386 | 385 | $stmt = self::$pdo->prepare('SELECT *,(SELECT COUNT(*) FROM '.self::TABLE.' sub WHERE sub.fs_dir=fs.fs_id) AS children'. |
387 | 386 | ' FROM '.self::TABLE.' fs'. |
388 | - ' WHERE fs.fs_dir=:fs_dir AND (fs.fs_active='.self::_pdo_boolean(true)." OR fs_mime='httpd/unix-directory')" . |
|
387 | + ' WHERE fs.fs_dir=:fs_dir AND (fs.fs_active='.self::_pdo_boolean(true)." OR fs_mime='httpd/unix-directory')". |
|
389 | 388 | ' AND fs.fs_name'.self::$case_sensitive_equal.':fs_name'. |
390 | 389 | " ORDER BY fs.fs_mime='httpd/unix-directory' DESC,fs.fs_active DESC,children DESC,fs.fs_modified DESC"); |
391 | 390 | $inactivate_stmt = self::$pdo->prepare('UPDATE '.self::TABLE. |
@@ -399,14 +398,14 @@ discard block |
||
399 | 398 | 'fs_dir' => $row['fs_dir'], |
400 | 399 | 'fs_name' => $row['fs_name'], |
401 | 400 | )); |
402 | - foreach($stmt as $n => $entry) |
|
401 | + foreach ($stmt as $n => $entry) |
|
403 | 402 | { |
404 | 403 | if ($entry['fs_mime'] == 'httpd/unix-directory') |
405 | 404 | { |
406 | 405 | // by sorting active directores first (fs.fs_active DESC), we make sure active one is kept |
407 | 406 | if (!$n) |
408 | 407 | { |
409 | - $dir = $entry; // directory to keep |
|
408 | + $dir = $entry; // directory to keep |
|
410 | 409 | $msgs[] = lang('%1 directories %2 found!', $row[2], self::id2path($entry['fs_id'])); |
411 | 410 | if ($check_only) break; |
412 | 411 | } |
@@ -422,7 +421,7 @@ discard block |
||
422 | 421 | $dir['children'] += $children; |
423 | 422 | } |
424 | 423 | self::$pdo->query('DELETE FROM '.self::TABLE.' WHERE fs_id='.(int)$entry['fs_id']); |
425 | - $msgs[] = lang('Removed (now) empty directory fs_id=%1',$entry['fs_id']); |
|
424 | + $msgs[] = lang('Removed (now) empty directory fs_id=%1', $entry['fs_id']); |
|
426 | 425 | } |
427 | 426 | } |
428 | 427 | elseif (isset($dir)) // file and directory with same name exist! |
@@ -438,9 +437,9 @@ discard block |
||
438 | 437 | } |
439 | 438 | else |
440 | 439 | { |
441 | - $cnt = ucfirst(lang('none of %1', $row[2]-1)); |
|
440 | + $cnt = ucfirst(lang('none of %1', $row[2] - 1)); |
|
442 | 441 | } |
443 | - $msgs[] = lang('%1 active file(s) with same name as directory inactivated!',$cnt); |
|
442 | + $msgs[] = lang('%1 active file(s) with same name as directory inactivated!', $cnt); |
|
444 | 443 | break; |
445 | 444 | } |
446 | 445 | else // newest file --> set for all other fs_active=false |
@@ -456,7 +455,7 @@ discard block |
||
456 | 455 | } |
457 | 456 | else |
458 | 457 | { |
459 | - $cnt = lang('none of %1', $row[2]-1); |
|
458 | + $cnt = lang('none of %1', $row[2] - 1); |
|
460 | 459 | } |
461 | 460 | $msgs[] = lang('More then one active file %1 found, inactivating %2 older revisions!', |
462 | 461 | self::id2path($entry['fs_id']), $cnt); |
@@ -80,22 +80,32 @@ discard block |
||
80 | 80 | { |
81 | 81 | throw new Api\Exception\AssertionFailed(__METHOD__."(): fs_id=$fs_id ($fs_name) $bytes bytes copied != size of $fs_size bytes!"); |
82 | 82 | } |
83 | - if ($debug) error_log("$fs_id: $fs_name: $bytes bytes copied to fs"); |
|
83 | + if ($debug) |
|
84 | + { |
|
85 | + error_log("$fs_id: $fs_name: $bytes bytes copied to fs"); |
|
86 | + } |
|
84 | 87 | fclose($dest); |
85 | 88 | fclose($content); unset($content); |
86 | 89 | |
87 | 90 | ++$n; |
88 | 91 | } |
89 | - if (!$n) break; // just in case nothing is found, statement will execute just fine |
|
92 | + if (!$n) |
|
93 | + { |
|
94 | + break; |
|
95 | + } |
|
96 | + // just in case nothing is found, statement will execute just fine |
|
90 | 97 | |
91 | 98 | $stmt->bindValue(':offset', $n, \PDO::PARAM_INT); |
92 | 99 | } |
93 | 100 | unset($row); // not used, as we access bound variables |
94 | 101 | unset($stmt); |
95 | 102 | |
96 | - if ($n) // delete all content in DB, if there was some AND no error (exception thrown!) |
|
103 | + if ($n) |
|
104 | + { |
|
105 | + // delete all content in DB, if there was some AND no error (exception thrown!) |
|
97 | 106 | { |
98 | 107 | $query = 'UPDATE '.self::TABLE.' SET fs_content=NULL'; |
108 | + } |
|
99 | 109 | $stmt = self::$pdo->prepare($query); |
100 | 110 | $stmt->execute(); |
101 | 111 | } |
@@ -122,7 +132,10 @@ discard block |
||
122 | 132 | self::fsck_fix_no_content($check_only), |
123 | 133 | ) as $check_msgs) |
124 | 134 | { |
125 | - if ($check_msgs) $msgs = array_merge($msgs, $check_msgs); |
|
135 | + if ($check_msgs) |
|
136 | + { |
|
137 | + $msgs = array_merge($msgs, $check_msgs); |
|
138 | + } |
|
126 | 139 | } |
127 | 140 | |
128 | 141 | foreach (Api\Hooks::process(array( |
@@ -130,7 +143,10 @@ discard block |
||
130 | 143 | 'check_only' => $check_only) |
131 | 144 | ) as $app_msgs) |
132 | 145 | { |
133 | - if ($app_msgs) $msgs = array_merge($msgs, $app_msgs); |
|
146 | + if ($app_msgs) |
|
147 | + { |
|
148 | + $msgs = array_merge($msgs, $app_msgs); |
|
149 | + } |
|
134 | 150 | } |
135 | 151 | return $msgs; |
136 | 152 | } |
@@ -185,11 +201,14 @@ discard block |
||
185 | 201 | $ok = false; |
186 | 202 | unset($e); // ignore exception |
187 | 203 | } |
188 | - if (!$ok) // can not insert it, try deleting it first |
|
204 | + if (!$ok) |
|
205 | + { |
|
206 | + // can not insert it, try deleting it first |
|
189 | 207 | { |
190 | 208 | if (!isset($delete_stmt)) |
191 | 209 | { |
192 | 210 | $delete_stmt = self::$pdo->prepare('DELETE FROM '.self::TABLE.' WHERE fs_id=:fs_id'); |
211 | + } |
|
193 | 212 | } |
194 | 213 | try { |
195 | 214 | $ok = $delete_stmt->execute(array('fs_id' => $id)) && $stmt->execute($data); |
@@ -231,7 +250,10 @@ discard block |
||
231 | 250 | if (!$check_only && $msgs) |
232 | 251 | { |
233 | 252 | global $oProc; |
234 | - if (!isset($oProc)) $oProc = new Api\Db\Schema(); |
|
253 | + if (!isset($oProc)) |
|
254 | + { |
|
255 | + $oProc = new Api\Db\Schema(); |
|
256 | + } |
|
235 | 257 | // PostgreSQL seems to require to update the sequenz, after manually inserting id's |
236 | 258 | $oProc->UpdateSequence('egw_sqlfs', 'fs_id'); |
237 | 259 | } |
@@ -337,7 +359,10 @@ discard block |
||
337 | 359 | $msgs[] = lang('Successful created new directory %1 for unconnected nods.',self::LOST_N_FOUND); |
338 | 360 | } |
339 | 361 | Vfs::$is_root = false; |
340 | - if (!$lostnfound) break; |
|
362 | + if (!$lostnfound) |
|
363 | + { |
|
364 | + break; |
|
365 | + } |
|
341 | 366 | } |
342 | 367 | $stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_dir=:fs_dir WHERE fs_id=:fs_id'); |
343 | 368 | } |
@@ -408,7 +433,10 @@ discard block |
||
408 | 433 | { |
409 | 434 | $dir = $entry; // directory to keep |
410 | 435 | $msgs[] = lang('%1 directories %2 found!', $row[2], self::id2path($entry['fs_id'])); |
411 | - if ($check_only) break; |
|
436 | + if ($check_only) |
|
437 | + { |
|
438 | + break; |
|
439 | + } |
|
412 | 440 | } |
413 | 441 | else |
414 | 442 | { |
@@ -425,7 +453,9 @@ discard block |
||
425 | 453 | $msgs[] = lang('Removed (now) empty directory fs_id=%1',$entry['fs_id']); |
426 | 454 | } |
427 | 455 | } |
428 | - elseif (isset($dir)) // file and directory with same name exist! |
|
456 | + elseif (isset($dir)) |
|
457 | + { |
|
458 | + // file and directory with same name exist! |
|
429 | 459 | { |
430 | 460 | if (!$check_only) |
431 | 461 | { |
@@ -434,6 +464,7 @@ discard block |
||
434 | 464 | 'fs_name' => $row['fs_name'], |
435 | 465 | 'fs_id' => $dir['fs_id'], |
436 | 466 | )); |
467 | + } |
|
437 | 468 | $cnt = $inactivate_stmt->rowCount(); |
438 | 469 | } |
439 | 470 | else |
@@ -43,209 +43,209 @@ |
||
43 | 43 | */ |
44 | 44 | class _parse_lockinfo |
45 | 45 | { |
46 | - /** |
|
47 | - * success state flag |
|
48 | - * |
|
49 | - * @var bool |
|
50 | - * @access public |
|
51 | - */ |
|
52 | - var $success = false; |
|
53 | - |
|
54 | - /** |
|
55 | - * lock type, currently only "write" |
|
56 | - * |
|
57 | - * @var string |
|
58 | - * @access public |
|
59 | - */ |
|
60 | - var $locktype = ""; |
|
61 | - |
|
62 | - /** |
|
63 | - * lock scope, "shared" or "exclusive" |
|
64 | - * |
|
65 | - * @var string |
|
66 | - * @access public |
|
67 | - */ |
|
68 | - var $lockscope = ""; |
|
69 | - |
|
70 | - /** |
|
71 | - * lock owner information |
|
72 | - * |
|
73 | - * @var string |
|
74 | - * @access public |
|
75 | - */ |
|
76 | - var $owner = ""; |
|
77 | - |
|
78 | - /** |
|
79 | - * flag that is set during lock owner read |
|
80 | - * |
|
81 | - * @var bool |
|
82 | - * @access private |
|
83 | - */ |
|
84 | - var $collect_owner = false; |
|
85 | - |
|
86 | - /** |
|
87 | - * constructor |
|
88 | - * |
|
89 | - * @param string path of stream to read |
|
90 | - * @access public |
|
91 | - */ |
|
92 | - function __construct($path) |
|
93 | - { |
|
94 | - // we assume success unless problems occur |
|
95 | - $this->success = true; |
|
96 | - |
|
97 | - // remember if any input was parsed |
|
98 | - $had_input = false; |
|
99 | - |
|
100 | - // open stream |
|
101 | - $f_in = fopen($path, "r"); |
|
102 | - if (!$f_in) { |
|
103 | - $this->success = false; |
|
104 | - return; |
|
105 | - } |
|
106 | - |
|
107 | - // create namespace aware parser |
|
108 | - $xml_parser = xml_parser_create_ns("UTF-8", " "); |
|
109 | - |
|
110 | - // set tag and data handlers |
|
111 | - xml_set_element_handler($xml_parser, |
|
112 | - array(&$this, "_startElement"), |
|
113 | - array(&$this, "_endElement")); |
|
114 | - xml_set_character_data_handler($xml_parser, |
|
115 | - array(&$this, "_data")); |
|
116 | - |
|
117 | - // we want a case sensitive parser |
|
118 | - xml_parser_set_option($xml_parser, |
|
119 | - XML_OPTION_CASE_FOLDING, false); |
|
120 | - |
|
121 | - // parse input |
|
122 | - while ($this->success && !feof($f_in)) { |
|
123 | - $line = fgets($f_in); |
|
124 | - if (is_string($line)) { |
|
125 | - $had_input = true; |
|
126 | - $this->success &= xml_parse($xml_parser, $line, false); |
|
127 | - } |
|
128 | - } |
|
129 | - |
|
130 | - // finish parsing |
|
131 | - if ($had_input) { |
|
132 | - $this->success &= xml_parse($xml_parser, "", true); |
|
133 | - } |
|
134 | - |
|
135 | - // check if required tags where found |
|
136 | - $this->success &= !empty($this->locktype); |
|
137 | - $this->success &= !empty($this->lockscope); |
|
138 | - |
|
139 | - // free parser resource |
|
140 | - xml_parser_free($xml_parser); |
|
141 | - |
|
142 | - // close input stream |
|
143 | - fclose($f_in); |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * tag start handler |
|
149 | - * |
|
150 | - * @param resource parser |
|
151 | - * @param string tag name |
|
152 | - * @param array tag attributes |
|
153 | - * @return void |
|
154 | - * @access private |
|
155 | - */ |
|
156 | - function _startElement($parser, $name, $attrs) |
|
157 | - { |
|
158 | - // namespace handling |
|
159 | - if (strstr($name, " ")) { |
|
160 | - list($ns, $tag) = explode(" ", $name); |
|
161 | - } else { |
|
162 | - $ns = ""; |
|
163 | - $tag = $name; |
|
164 | - } |
|
165 | - |
|
166 | - |
|
167 | - if ($this->collect_owner) { |
|
168 | - // everything within the <owner> tag needs to be collected |
|
169 | - $ns_short = ""; |
|
170 | - $ns_attr = ""; |
|
171 | - if ($ns) { |
|
172 | - if ($ns == "DAV:") { |
|
173 | - $ns_short = "D:"; |
|
174 | - } else { |
|
175 | - $ns_attr = " xmlns='$ns'"; |
|
176 | - } |
|
177 | - } |
|
178 | - $this->owner .= "<$ns_short$tag$ns_attr>"; |
|
179 | - } else if ($ns == "DAV:") { |
|
180 | - // parse only the essential tags |
|
181 | - switch ($tag) { |
|
182 | - case "write": |
|
183 | - $this->locktype = $tag; |
|
184 | - break; |
|
185 | - case "exclusive": |
|
186 | - case "shared": |
|
187 | - $this->lockscope = $tag; |
|
188 | - break; |
|
189 | - case "owner": |
|
190 | - $this->collect_owner = true; |
|
191 | - break; |
|
192 | - } |
|
193 | - } |
|
194 | - } |
|
195 | - |
|
196 | - /** |
|
197 | - * data handler |
|
198 | - * |
|
199 | - * @param resource parser |
|
200 | - * @param string data |
|
201 | - * @return void |
|
202 | - * @access private |
|
203 | - */ |
|
204 | - function _data($parser, $data) |
|
205 | - { |
|
206 | - // only the <owner> tag has data content |
|
207 | - if ($this->collect_owner) { |
|
208 | - $this->owner .= $data; |
|
209 | - } |
|
210 | - } |
|
211 | - |
|
212 | - /** |
|
213 | - * tag end handler |
|
214 | - * |
|
215 | - * @param resource parser |
|
216 | - * @param string tag name |
|
217 | - * @return void |
|
218 | - * @access private |
|
219 | - */ |
|
220 | - function _endElement($parser, $name) |
|
221 | - { |
|
222 | - // namespace handling |
|
223 | - if (strstr($name, " ")) { |
|
224 | - list($ns, $tag) = explode(" ", $name); |
|
225 | - } else { |
|
226 | - $ns = ""; |
|
227 | - $tag = $name; |
|
228 | - } |
|
229 | - |
|
230 | - // <owner> finished? |
|
231 | - if (($ns == "DAV:") && ($tag == "owner")) { |
|
232 | - $this->collect_owner = false; |
|
233 | - } |
|
234 | - |
|
235 | - // within <owner> we have to collect everything |
|
236 | - if ($this->collect_owner) { |
|
237 | - $ns_short = ""; |
|
238 | - $ns_attr = ""; |
|
239 | - if ($ns) { |
|
240 | - if ($ns == "DAV:") { |
|
241 | - $ns_short = "D:"; |
|
242 | - } else { |
|
243 | - $ns_attr = " xmlns='$ns'"; |
|
244 | - } |
|
245 | - } |
|
246 | - $this->owner .= "</$ns_short$tag$ns_attr>"; |
|
247 | - } |
|
248 | - } |
|
46 | + /** |
|
47 | + * success state flag |
|
48 | + * |
|
49 | + * @var bool |
|
50 | + * @access public |
|
51 | + */ |
|
52 | + var $success = false; |
|
53 | + |
|
54 | + /** |
|
55 | + * lock type, currently only "write" |
|
56 | + * |
|
57 | + * @var string |
|
58 | + * @access public |
|
59 | + */ |
|
60 | + var $locktype = ""; |
|
61 | + |
|
62 | + /** |
|
63 | + * lock scope, "shared" or "exclusive" |
|
64 | + * |
|
65 | + * @var string |
|
66 | + * @access public |
|
67 | + */ |
|
68 | + var $lockscope = ""; |
|
69 | + |
|
70 | + /** |
|
71 | + * lock owner information |
|
72 | + * |
|
73 | + * @var string |
|
74 | + * @access public |
|
75 | + */ |
|
76 | + var $owner = ""; |
|
77 | + |
|
78 | + /** |
|
79 | + * flag that is set during lock owner read |
|
80 | + * |
|
81 | + * @var bool |
|
82 | + * @access private |
|
83 | + */ |
|
84 | + var $collect_owner = false; |
|
85 | + |
|
86 | + /** |
|
87 | + * constructor |
|
88 | + * |
|
89 | + * @param string path of stream to read |
|
90 | + * @access public |
|
91 | + */ |
|
92 | + function __construct($path) |
|
93 | + { |
|
94 | + // we assume success unless problems occur |
|
95 | + $this->success = true; |
|
96 | + |
|
97 | + // remember if any input was parsed |
|
98 | + $had_input = false; |
|
99 | + |
|
100 | + // open stream |
|
101 | + $f_in = fopen($path, "r"); |
|
102 | + if (!$f_in) { |
|
103 | + $this->success = false; |
|
104 | + return; |
|
105 | + } |
|
106 | + |
|
107 | + // create namespace aware parser |
|
108 | + $xml_parser = xml_parser_create_ns("UTF-8", " "); |
|
109 | + |
|
110 | + // set tag and data handlers |
|
111 | + xml_set_element_handler($xml_parser, |
|
112 | + array(&$this, "_startElement"), |
|
113 | + array(&$this, "_endElement")); |
|
114 | + xml_set_character_data_handler($xml_parser, |
|
115 | + array(&$this, "_data")); |
|
116 | + |
|
117 | + // we want a case sensitive parser |
|
118 | + xml_parser_set_option($xml_parser, |
|
119 | + XML_OPTION_CASE_FOLDING, false); |
|
120 | + |
|
121 | + // parse input |
|
122 | + while ($this->success && !feof($f_in)) { |
|
123 | + $line = fgets($f_in); |
|
124 | + if (is_string($line)) { |
|
125 | + $had_input = true; |
|
126 | + $this->success &= xml_parse($xml_parser, $line, false); |
|
127 | + } |
|
128 | + } |
|
129 | + |
|
130 | + // finish parsing |
|
131 | + if ($had_input) { |
|
132 | + $this->success &= xml_parse($xml_parser, "", true); |
|
133 | + } |
|
134 | + |
|
135 | + // check if required tags where found |
|
136 | + $this->success &= !empty($this->locktype); |
|
137 | + $this->success &= !empty($this->lockscope); |
|
138 | + |
|
139 | + // free parser resource |
|
140 | + xml_parser_free($xml_parser); |
|
141 | + |
|
142 | + // close input stream |
|
143 | + fclose($f_in); |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * tag start handler |
|
149 | + * |
|
150 | + * @param resource parser |
|
151 | + * @param string tag name |
|
152 | + * @param array tag attributes |
|
153 | + * @return void |
|
154 | + * @access private |
|
155 | + */ |
|
156 | + function _startElement($parser, $name, $attrs) |
|
157 | + { |
|
158 | + // namespace handling |
|
159 | + if (strstr($name, " ")) { |
|
160 | + list($ns, $tag) = explode(" ", $name); |
|
161 | + } else { |
|
162 | + $ns = ""; |
|
163 | + $tag = $name; |
|
164 | + } |
|
165 | + |
|
166 | + |
|
167 | + if ($this->collect_owner) { |
|
168 | + // everything within the <owner> tag needs to be collected |
|
169 | + $ns_short = ""; |
|
170 | + $ns_attr = ""; |
|
171 | + if ($ns) { |
|
172 | + if ($ns == "DAV:") { |
|
173 | + $ns_short = "D:"; |
|
174 | + } else { |
|
175 | + $ns_attr = " xmlns='$ns'"; |
|
176 | + } |
|
177 | + } |
|
178 | + $this->owner .= "<$ns_short$tag$ns_attr>"; |
|
179 | + } else if ($ns == "DAV:") { |
|
180 | + // parse only the essential tags |
|
181 | + switch ($tag) { |
|
182 | + case "write": |
|
183 | + $this->locktype = $tag; |
|
184 | + break; |
|
185 | + case "exclusive": |
|
186 | + case "shared": |
|
187 | + $this->lockscope = $tag; |
|
188 | + break; |
|
189 | + case "owner": |
|
190 | + $this->collect_owner = true; |
|
191 | + break; |
|
192 | + } |
|
193 | + } |
|
194 | + } |
|
195 | + |
|
196 | + /** |
|
197 | + * data handler |
|
198 | + * |
|
199 | + * @param resource parser |
|
200 | + * @param string data |
|
201 | + * @return void |
|
202 | + * @access private |
|
203 | + */ |
|
204 | + function _data($parser, $data) |
|
205 | + { |
|
206 | + // only the <owner> tag has data content |
|
207 | + if ($this->collect_owner) { |
|
208 | + $this->owner .= $data; |
|
209 | + } |
|
210 | + } |
|
211 | + |
|
212 | + /** |
|
213 | + * tag end handler |
|
214 | + * |
|
215 | + * @param resource parser |
|
216 | + * @param string tag name |
|
217 | + * @return void |
|
218 | + * @access private |
|
219 | + */ |
|
220 | + function _endElement($parser, $name) |
|
221 | + { |
|
222 | + // namespace handling |
|
223 | + if (strstr($name, " ")) { |
|
224 | + list($ns, $tag) = explode(" ", $name); |
|
225 | + } else { |
|
226 | + $ns = ""; |
|
227 | + $tag = $name; |
|
228 | + } |
|
229 | + |
|
230 | + // <owner> finished? |
|
231 | + if (($ns == "DAV:") && ($tag == "owner")) { |
|
232 | + $this->collect_owner = false; |
|
233 | + } |
|
234 | + |
|
235 | + // within <owner> we have to collect everything |
|
236 | + if ($this->collect_owner) { |
|
237 | + $ns_short = ""; |
|
238 | + $ns_attr = ""; |
|
239 | + if ($ns) { |
|
240 | + if ($ns == "DAV:") { |
|
241 | + $ns_short = "D:"; |
|
242 | + } else { |
|
243 | + $ns_attr = " xmlns='$ns'"; |
|
244 | + } |
|
245 | + } |
|
246 | + $this->owner .= "</$ns_short$tag$ns_attr>"; |
|
247 | + } |
|
248 | + } |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | ?> |
@@ -179,16 +179,16 @@ |
||
179 | 179 | } else if ($ns == "DAV:") { |
180 | 180 | // parse only the essential tags |
181 | 181 | switch ($tag) { |
182 | - case "write": |
|
183 | - $this->locktype = $tag; |
|
184 | - break; |
|
185 | - case "exclusive": |
|
186 | - case "shared": |
|
187 | - $this->lockscope = $tag; |
|
188 | - break; |
|
189 | - case "owner": |
|
190 | - $this->collect_owner = true; |
|
191 | - break; |
|
182 | + case "write": |
|
183 | + $this->locktype = $tag; |
|
184 | + break; |
|
185 | + case "exclusive": |
|
186 | + case "shared": |
|
187 | + $this->lockscope = $tag; |
|
188 | + break; |
|
189 | + case "owner": |
|
190 | + $this->collect_owner = true; |
|
191 | + break; |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | } |
@@ -95,6 +95,7 @@ |
||
95 | 95 | * |
96 | 96 | * @param string path of input stream |
97 | 97 | * @param boolean $store_request =false if true whole request data will be made available in $this->request |
98 | + * @param string $path |
|
98 | 99 | * @access public |
99 | 100 | */ |
100 | 101 | function __construct($path, $store_request=false) |
@@ -99,7 +99,8 @@ discard block |
||
99 | 99 | |
100 | 100 | // open stream |
101 | 101 | $f_in = fopen($path, "r"); |
102 | - if (!$f_in) { |
|
102 | + if (!$f_in) |
|
103 | + { |
|
103 | 104 | $this->success = false; |
104 | 105 | return; |
105 | 106 | } |
@@ -119,16 +120,19 @@ discard block |
||
119 | 120 | XML_OPTION_CASE_FOLDING, false); |
120 | 121 | |
121 | 122 | // parse input |
122 | - while ($this->success && !feof($f_in)) { |
|
123 | + while ($this->success && !feof($f_in)) |
|
124 | + { |
|
123 | 125 | $line = fgets($f_in); |
124 | - if (is_string($line)) { |
|
126 | + if (is_string($line)) |
|
127 | + { |
|
125 | 128 | $had_input = true; |
126 | 129 | $this->success &= xml_parse($xml_parser, $line, false); |
127 | 130 | } |
128 | 131 | } |
129 | 132 | |
130 | 133 | // finish parsing |
131 | - if ($had_input) { |
|
134 | + if ($had_input) |
|
135 | + { |
|
132 | 136 | $this->success &= xml_parse($xml_parser, "", true); |
133 | 137 | } |
134 | 138 | |
@@ -156,29 +160,40 @@ discard block |
||
156 | 160 | function _startElement($parser, $name, $attrs) |
157 | 161 | { |
158 | 162 | // namespace handling |
159 | - if (strstr($name, " ")) { |
|
163 | + if (strstr($name, " ")) |
|
164 | + { |
|
160 | 165 | list($ns, $tag) = explode(" ", $name); |
161 | - } else { |
|
166 | + } |
|
167 | + else |
|
168 | + { |
|
162 | 169 | $ns = ""; |
163 | 170 | $tag = $name; |
164 | 171 | } |
165 | 172 | |
166 | 173 | |
167 | - if ($this->collect_owner) { |
|
174 | + if ($this->collect_owner) |
|
175 | + { |
|
168 | 176 | // everything within the <owner> tag needs to be collected |
169 | 177 | $ns_short = ""; |
170 | 178 | $ns_attr = ""; |
171 | - if ($ns) { |
|
172 | - if ($ns == "DAV:") { |
|
179 | + if ($ns) |
|
180 | + { |
|
181 | + if ($ns == "DAV:") |
|
182 | + { |
|
173 | 183 | $ns_short = "D:"; |
174 | - } else { |
|
184 | + } |
|
185 | + else |
|
186 | + { |
|
175 | 187 | $ns_attr = " xmlns='$ns'"; |
176 | 188 | } |
177 | 189 | } |
178 | 190 | $this->owner .= "<$ns_short$tag$ns_attr>"; |
179 | - } else if ($ns == "DAV:") { |
|
191 | + } |
|
192 | + else if ($ns == "DAV:") |
|
193 | + { |
|
180 | 194 | // parse only the essential tags |
181 | - switch ($tag) { |
|
195 | + switch ($tag) |
|
196 | + { |
|
182 | 197 | case "write": |
183 | 198 | $this->locktype = $tag; |
184 | 199 | break; |
@@ -204,7 +219,8 @@ discard block |
||
204 | 219 | function _data($parser, $data) |
205 | 220 | { |
206 | 221 | // only the <owner> tag has data content |
207 | - if ($this->collect_owner) { |
|
222 | + if ($this->collect_owner) |
|
223 | + { |
|
208 | 224 | $this->owner .= $data; |
209 | 225 | } |
210 | 226 | } |
@@ -220,26 +236,35 @@ discard block |
||
220 | 236 | function _endElement($parser, $name) |
221 | 237 | { |
222 | 238 | // namespace handling |
223 | - if (strstr($name, " ")) { |
|
239 | + if (strstr($name, " ")) |
|
240 | + { |
|
224 | 241 | list($ns, $tag) = explode(" ", $name); |
225 | - } else { |
|
242 | + } |
|
243 | + else |
|
244 | + { |
|
226 | 245 | $ns = ""; |
227 | 246 | $tag = $name; |
228 | 247 | } |
229 | 248 | |
230 | 249 | // <owner> finished? |
231 | - if (($ns == "DAV:") && ($tag == "owner")) { |
|
250 | + if (($ns == "DAV:") && ($tag == "owner")) |
|
251 | + { |
|
232 | 252 | $this->collect_owner = false; |
233 | 253 | } |
234 | 254 | |
235 | 255 | // within <owner> we have to collect everything |
236 | - if ($this->collect_owner) { |
|
256 | + if ($this->collect_owner) |
|
257 | + { |
|
237 | 258 | $ns_short = ""; |
238 | 259 | $ns_attr = ""; |
239 | - if ($ns) { |
|
240 | - if ($ns == "DAV:") { |
|
260 | + if ($ns) |
|
261 | + { |
|
262 | + if ($ns == "DAV:") |
|
263 | + { |
|
241 | 264 | $ns_short = "D:"; |
242 | - } else { |
|
265 | + } |
|
266 | + else |
|
267 | + { |
|
243 | 268 | $ns_attr = " xmlns='$ns'"; |
244 | 269 | } |
245 | 270 | } |