@@ -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 | /** |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | * |
516 | 516 | * If you have cached data in your stream but not yet stored it into the underlying storage, you should do so now. |
517 | 517 | * |
518 | - * @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. |
|
518 | + * @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. |
|
519 | 519 | */ |
520 | 520 | function stream_flush ( ) |
521 | 521 | { |
@@ -556,6 +556,7 @@ discard block |
||
556 | 556 | * In order for the appropriate error message to be returned, do not define this method if your wrapper does not support unlinking! |
557 | 557 | * |
558 | 558 | * @param string $url |
559 | + * @param integer $parent_stat |
|
559 | 560 | * @return boolean TRUE on success or FALSE on failure |
560 | 561 | */ |
561 | 562 | static function unlink ( $url, $parent_stat=null ) |
@@ -684,6 +685,8 @@ discard block |
||
684 | 685 | |
685 | 686 | /** |
686 | 687 | * due to problems with recursive directory creation, we have our own here |
688 | + * @param false|string $pathname |
|
689 | + * @param integer $mode |
|
687 | 690 | */ |
688 | 691 | protected static function mkdir_recursive($pathname, $mode, $depth=0) |
689 | 692 | { |
@@ -1014,7 +1017,7 @@ discard block |
||
1014 | 1017 | * |
1015 | 1018 | * @param string $url URL that was passed to opendir() and that this object is expected to explore. |
1016 | 1019 | * @param int $options |
1017 | - * @return booelan |
|
1020 | + * @return boolean |
|
1018 | 1021 | */ |
1019 | 1022 | function dir_opendir ( $url, $options ) |
1020 | 1023 | { |
@@ -1717,7 +1720,7 @@ discard block |
||
1717 | 1720 | /** |
1718 | 1721 | * Just a little abstration 'til I know how to organise stuff like that with PDO |
1719 | 1722 | * |
1720 | - * @param mixed $time |
|
1723 | + * @param integer $time |
|
1721 | 1724 | * @return string Y-m-d H:i:s |
1722 | 1725 | */ |
1723 | 1726 | static protected function _pdo_timestamp($time) |
@@ -1802,6 +1805,7 @@ discard block |
||
1802 | 1805 | * Replace the password of an url with '...' for error messages |
1803 | 1806 | * |
1804 | 1807 | * @param string &$url |
1808 | + * @param string $url |
|
1805 | 1809 | */ |
1806 | 1810 | static protected function _remove_password(&$url) |
1807 | 1811 | { |
@@ -1817,7 +1821,7 @@ discard block |
||
1817 | 1821 | /** |
1818 | 1822 | * Get storage mode from url (get parameter 'storage', eg. ?storage=db) |
1819 | 1823 | * |
1820 | - * @param string|array $url complete url or array of url-parts from parse_url |
|
1824 | + * @param string $url complete url or array of url-parts from parse_url |
|
1821 | 1825 | * @return int self::STORE2FS or self::STORE2DB |
1822 | 1826 | */ |
1823 | 1827 | static function url2operation($url) |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | /** |
77 | 77 | * mode-bits, which have to be set for directories |
78 | 78 | */ |
79 | - const MODE_DIR = 040000; |
|
79 | + const MODE_DIR = 040000; |
|
80 | 80 | /** |
81 | 81 | * mode-bits, which have to be set for links |
82 | 82 | */ |
@@ -179,10 +179,10 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @param string $path ='/' |
181 | 181 | */ |
182 | - public static function clearstatcache($path='/') |
|
182 | + public static function clearstatcache($path = '/') |
|
183 | 183 | { |
184 | 184 | //error_log(__METHOD__."('$path')"); |
185 | - unset($path); // not used |
|
185 | + unset($path); // not used |
|
186 | 186 | |
187 | 187 | self::$stat_cache = array(); |
188 | 188 | |
@@ -202,32 +202,32 @@ discard block |
||
202 | 202 | * @param array $overwrite_new =null if set create new file with values overwriten by the given ones |
203 | 203 | * @return boolean true if the ressource was opened successful, otherwise false |
204 | 204 | */ |
205 | - function stream_open ( $url, $mode, $options, &$opened_path, array $overwrite_new=null ) |
|
205 | + function stream_open($url, $mode, $options, &$opened_path, array $overwrite_new = null) |
|
206 | 206 | { |
207 | 207 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$mode,$options)"); |
208 | 208 | |
209 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
209 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
210 | 210 | $this->operation = self::url2operation($url); |
211 | 211 | $dir = Vfs::dirname($url); |
212 | 212 | |
213 | 213 | $this->opened_path = $opened_path = $path; |
214 | - $this->opened_mode = $mode = str_replace('b','',$mode); // we are always binary, like every Linux system |
|
214 | + $this->opened_mode = $mode = str_replace('b', '', $mode); // we are always binary, like every Linux system |
|
215 | 215 | $this->opened_stream = null; |
216 | 216 | |
217 | 217 | parse_str(parse_url($url, PHP_URL_QUERY), $this->dir_url_params); |
218 | 218 | |
219 | - 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 |
|
219 | + 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 |
|
220 | 220 | { |
221 | - if ($mode[0] == 'r' || // does $mode require the file to exist (r,r+) |
|
222 | - $mode[0] == 'x' && $stat || // or file should not exist, but does |
|
223 | - !($dir_stat=static::url_stat($dir,STREAM_URL_STAT_QUIET)) || // or parent dir does not exist create it |
|
224 | - !Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat)) // or we are not allowed to create it |
|
221 | + if ($mode[0] == 'r' || // does $mode require the file to exist (r,r+) |
|
222 | + $mode[0] == 'x' && $stat || // or file should not exist, but does |
|
223 | + !($dir_stat = static::url_stat($dir, STREAM_URL_STAT_QUIET)) || // or parent dir does not exist create it |
|
224 | + !Vfs::check_access($dir, Vfs::WRITABLE, $dir_stat)) // or we are not allowed to create it |
|
225 | 225 | { |
226 | 226 | self::_remove_password($url); |
227 | 227 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) file does not exist or can not be created!"); |
228 | - if (($options & STREAM_REPORT_ERRORS)) |
|
228 | + if (($options&STREAM_REPORT_ERRORS)) |
|
229 | 229 | { |
230 | - trigger_error(__METHOD__."($url,$mode,$options) file does not exist or can not be created!",E_USER_WARNING); |
|
230 | + trigger_error(__METHOD__."($url,$mode,$options) file does not exist or can not be created!", E_USER_WARNING); |
|
231 | 231 | } |
232 | 232 | $this->opened_stream = $this->opened_path = $this->opened_mode = null; |
233 | 233 | return false; |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | 'fs_name' => self::limit_filename(Vfs::basename($path)), |
243 | 243 | 'fs_dir' => $dir_stat['ino'], |
244 | 244 | // we use the mode of the dir, so files in group dirs stay accessible by all members |
245 | - 'fs_mode' => $dir_stat['mode'] & 0666, |
|
245 | + 'fs_mode' => $dir_stat['mode']&0666, |
|
246 | 246 | // for the uid we use the uid of the dir if not 0=root or the current user otherwise |
247 | 247 | 'fs_uid' => $dir_stat['uid'] ? $dir_stat['uid'] : Vfs::$user, |
248 | 248 | // we allways use the group of the dir |
@@ -250,11 +250,11 @@ discard block |
||
250 | 250 | 'fs_created' => self::_pdo_timestamp(time()), |
251 | 251 | 'fs_modified' => self::_pdo_timestamp(time()), |
252 | 252 | 'fs_creator' => Vfs::$user, |
253 | - 'fs_mime' => 'application/octet-stream', // required NOT NULL! |
|
253 | + 'fs_mime' => 'application/octet-stream', // required NOT NULL! |
|
254 | 254 | 'fs_size' => 0, |
255 | 255 | 'fs_active' => self::_pdo_boolean(true), |
256 | 256 | ); |
257 | - if ($overwrite_new) $values = array_merge($values,$overwrite_new); |
|
257 | + if ($overwrite_new) $values = array_merge($values, $overwrite_new); |
|
258 | 258 | if (!$stmt->execute($values) || !($this->opened_fs_id = self::$pdo->lastInsertId('egw_sqlfs_fs_id_seq'))) |
259 | 259 | { |
260 | 260 | $this->opened_stream = $this->opened_path = $this->opened_mode = null; |
@@ -267,35 +267,35 @@ discard block |
||
267 | 267 | $this->opened_stream = tmpfile(); |
268 | 268 | } |
269 | 269 | // create the hash-dirs, if they not yet exist |
270 | - elseif(!file_exists($fs_dir=Vfs::dirname(self::_fs_path($this->opened_fs_id)))) |
|
270 | + elseif (!file_exists($fs_dir = Vfs::dirname(self::_fs_path($this->opened_fs_id)))) |
|
271 | 271 | { |
272 | 272 | $umaskbefore = umask(); |
273 | 273 | if (self::LOG_LEVEL > 1) error_log(__METHOD__." about to call mkdir for $fs_dir # Present UMASK:".decoct($umaskbefore)." called from:".function_backtrace()); |
274 | - self::mkdir_recursive($fs_dir,0700,true); |
|
274 | + self::mkdir_recursive($fs_dir, 0700, true); |
|
275 | 275 | } |
276 | 276 | } |
277 | 277 | // check if opend file is a directory |
278 | - elseif($stat && ($stat['mode'] & self::MODE_DIR) == self::MODE_DIR) |
|
278 | + elseif ($stat && ($stat['mode']&self::MODE_DIR) == self::MODE_DIR) |
|
279 | 279 | { |
280 | 280 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) Is a directory!"); |
281 | - if (($options & STREAM_REPORT_ERRORS)) |
|
281 | + if (($options&STREAM_REPORT_ERRORS)) |
|
282 | 282 | { |
283 | - trigger_error(__METHOD__."($url,$mode,$options) Is a directory!",E_USER_WARNING); |
|
283 | + trigger_error(__METHOD__."($url,$mode,$options) Is a directory!", E_USER_WARNING); |
|
284 | 284 | } |
285 | 285 | $this->opened_stream = $this->opened_path = $this->opened_mode = null; |
286 | 286 | return false; |
287 | 287 | } |
288 | 288 | else |
289 | 289 | { |
290 | - if ($mode == 'r' && !Vfs::check_access($url,Vfs::READABLE ,$stat) ||// we are not allowed to read |
|
291 | - $mode != 'r' && !Vfs::check_access($url,Vfs::WRITABLE,$stat)) // or edit it |
|
290 | + if ($mode == 'r' && !Vfs::check_access($url, Vfs::READABLE, $stat) || // we are not allowed to read |
|
291 | + $mode != 'r' && !Vfs::check_access($url, Vfs::WRITABLE, $stat)) // or edit it |
|
292 | 292 | { |
293 | 293 | self::_remove_password($url); |
294 | 294 | $op = $mode == 'r' ? 'read' : 'edited'; |
295 | 295 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) file can not be $op!"); |
296 | - if (($options & STREAM_REPORT_ERRORS)) |
|
296 | + if (($options&STREAM_REPORT_ERRORS)) |
|
297 | 297 | { |
298 | - trigger_error(__METHOD__."($url,$mode,$options) file can not be $op!",E_USER_WARNING); |
|
298 | + trigger_error(__METHOD__."($url,$mode,$options) file can not be $op!", E_USER_WARNING); |
|
299 | 299 | } |
300 | 300 | $this->opened_stream = $this->opened_path = $this->opened_mode = null; |
301 | 301 | return false; |
@@ -304,9 +304,9 @@ discard block |
||
304 | 304 | |
305 | 305 | if ($this->operation == self::STORE2DB) |
306 | 306 | { |
307 | - $stmt = self::$pdo->prepare($sql='SELECT fs_content FROM '.self::TABLE.' WHERE fs_id=?'); |
|
307 | + $stmt = self::$pdo->prepare($sql = 'SELECT fs_content FROM '.self::TABLE.' WHERE fs_id=?'); |
|
308 | 308 | $stmt->execute(array($stat['ino'])); |
309 | - $stmt->bindColumn(1,$this->opened_stream,\PDO::PARAM_LOB); |
|
309 | + $stmt->bindColumn(1, $this->opened_stream, \PDO::PARAM_LOB); |
|
310 | 310 | $stmt->fetch(\PDO::FETCH_BOUND); |
311 | 311 | // hack to work around a current php bug (http://bugs.php.net/bug.php?id=40913) |
312 | 312 | // PDOStatement::bindColumn(,,\PDO::PARAM_LOB) is not working for MySQL, content is returned as string :-( |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | if ($this->operation == self::STORE2FS) |
326 | 326 | { |
327 | 327 | if (self::LOG_LEVEL > 1) error_log(__METHOD__." fopen (may create a directory? mkdir) ($this->opened_fs_id,$mode,$options)"); |
328 | - if (!($this->opened_stream = fopen(self::_fs_path($this->opened_fs_id),$mode)) && $new_file) |
|
328 | + if (!($this->opened_stream = fopen(self::_fs_path($this->opened_fs_id), $mode)) && $new_file) |
|
329 | 329 | { |
330 | 330 | // delete db entry again, if we are not able to open a new(!) file |
331 | 331 | unset($stmt); |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | } |
336 | 336 | if ($mode[0] == 'a') // append modes: a, a+ |
337 | 337 | { |
338 | - $this->stream_seek(0,SEEK_END); |
|
338 | + $this->stream_seek(0, SEEK_END); |
|
339 | 339 | } |
340 | 340 | if (!is_resource($this->opened_stream)) error_log(__METHOD__."($url,$mode,$options) NO stream, returning false!"); |
341 | 341 | |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | * |
348 | 348 | * You must release any resources that were locked or allocated by the stream. |
349 | 349 | */ |
350 | - function stream_close ( ) |
|
350 | + function stream_close( ) |
|
351 | 351 | { |
352 | 352 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."()"); |
353 | 353 | |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | |
359 | 359 | if ($this->opened_mode != 'r') |
360 | 360 | { |
361 | - $this->stream_seek(0,SEEK_END); |
|
361 | + $this->stream_seek(0, SEEK_END); |
|
362 | 362 | |
363 | 363 | // we need to update the mime-type, size and content (if STORE2DB) |
364 | 364 | $values = array( |
@@ -381,10 +381,10 @@ discard block |
||
381 | 381 | else |
382 | 382 | { |
383 | 383 | $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'); |
384 | - $this->stream_seek(0,SEEK_SET); // rewind to the start |
|
385 | - foreach($values as $name => &$value) |
|
384 | + $this->stream_seek(0, SEEK_SET); // rewind to the start |
|
385 | + foreach ($values as $name => &$value) |
|
386 | 386 | { |
387 | - $stmt->bindParam($name,$value); |
|
387 | + $stmt->bindParam($name, $value); |
|
388 | 388 | } |
389 | 389 | $stmt->bindParam('fs_content', $this->opened_stream, \PDO::PARAM_LOB); |
390 | 390 | if (!($ret = $stmt->execute())) |
@@ -417,13 +417,13 @@ discard block |
||
417 | 417 | * @param int $count |
418 | 418 | * @return string/false up to count bytes read or false on EOF |
419 | 419 | */ |
420 | - function stream_read ( $count ) |
|
420 | + function stream_read($count) |
|
421 | 421 | { |
422 | 422 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($count) pos=$this->opened_pos"); |
423 | 423 | |
424 | 424 | if (is_resource($this->opened_stream)) |
425 | 425 | { |
426 | - return fread($this->opened_stream,$count); |
|
426 | + return fread($this->opened_stream, $count); |
|
427 | 427 | } |
428 | 428 | return false; |
429 | 429 | } |
@@ -439,13 +439,13 @@ discard block |
||
439 | 439 | * @param string $data |
440 | 440 | * @return integer |
441 | 441 | */ |
442 | - function stream_write ( $data ) |
|
442 | + function stream_write($data) |
|
443 | 443 | { |
444 | 444 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($data)"); |
445 | 445 | |
446 | 446 | if (is_resource($this->opened_stream)) |
447 | 447 | { |
448 | - return fwrite($this->opened_stream,$data); |
|
448 | + return fwrite($this->opened_stream, $data); |
|
449 | 449 | } |
450 | 450 | return false; |
451 | 451 | } |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | * |
463 | 463 | * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise |
464 | 464 | */ |
465 | - function stream_eof ( ) |
|
465 | + function stream_eof( ) |
|
466 | 466 | { |
467 | 467 | if (is_resource($this->opened_stream)) |
468 | 468 | { |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | * |
477 | 477 | * @return integer current read/write position of the stream |
478 | 478 | */ |
479 | - function stream_tell ( ) |
|
479 | + function stream_tell( ) |
|
480 | 480 | { |
481 | 481 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."()"); |
482 | 482 | |
@@ -499,13 +499,13 @@ discard block |
||
499 | 499 | * 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.) |
500 | 500 | * @return boolean TRUE if the position was updated, FALSE otherwise. |
501 | 501 | */ |
502 | - function stream_seek ( $offset, $whence ) |
|
502 | + function stream_seek($offset, $whence) |
|
503 | 503 | { |
504 | 504 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($offset,$whence)"); |
505 | 505 | |
506 | 506 | if (is_resource($this->opened_stream)) |
507 | 507 | { |
508 | - return !fseek($this->opened_stream,$offset,$whence); // fseek returns 0 on success and -1 on failure |
|
508 | + return !fseek($this->opened_stream, $offset, $whence); // fseek returns 0 on success and -1 on failure |
|
509 | 509 | } |
510 | 510 | return false; |
511 | 511 | } |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | * |
518 | 518 | * @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. |
519 | 519 | */ |
520 | - function stream_flush ( ) |
|
520 | + function stream_flush( ) |
|
521 | 521 | { |
522 | 522 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."()"); |
523 | 523 | |
@@ -542,11 +542,11 @@ discard block |
||
542 | 542 | * |
543 | 543 | * @return array containing the same values as appropriate for the stream. |
544 | 544 | */ |
545 | - function stream_stat ( ) |
|
545 | + function stream_stat( ) |
|
546 | 546 | { |
547 | 547 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($this->opened_path)"); |
548 | 548 | |
549 | - return $this->url_stat($this->opened_path,0); |
|
549 | + return $this->url_stat($this->opened_path, 0); |
|
550 | 550 | } |
551 | 551 | |
552 | 552 | /** |
@@ -558,27 +558,27 @@ discard block |
||
558 | 558 | * @param string $url |
559 | 559 | * @return boolean TRUE on success or FALSE on failure |
560 | 560 | */ |
561 | - static function unlink ( $url, $parent_stat=null ) |
|
561 | + static function unlink($url, $parent_stat = null) |
|
562 | 562 | { |
563 | 563 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url)"); |
564 | 564 | |
565 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
565 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
566 | 566 | |
567 | 567 | // need to get parent stat from Sqlfs, not Vfs |
568 | 568 | if (!isset($parent_stat)) $parent_stat = static::url_stat(Vfs::dirname($path), STREAM_URL_STAT_LINK); |
569 | 569 | |
570 | - if (!$parent_stat || !($stat = self::url_stat($path,STREAM_URL_STAT_LINK)) || |
|
571 | - !Vfs::check_access(Vfs::dirname($path),Vfs::WRITABLE, $parent_stat)) |
|
570 | + if (!$parent_stat || !($stat = self::url_stat($path, STREAM_URL_STAT_LINK)) || |
|
571 | + !Vfs::check_access(Vfs::dirname($path), Vfs::WRITABLE, $parent_stat)) |
|
572 | 572 | { |
573 | 573 | self::_remove_password($url); |
574 | 574 | if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!"); |
575 | - return false; // no permission or file does not exist |
|
575 | + return false; // no permission or file does not exist |
|
576 | 576 | } |
577 | 577 | if ($stat['mime'] == self::DIR_MIME_TYPE) |
578 | 578 | { |
579 | 579 | self::_remove_password($url); |
580 | 580 | if (self::LOG_LEVEL) error_log(__METHOD__."($url) is NO file!"); |
581 | - return false; // no permission or file does not exist |
|
581 | + return false; // no permission or file does not exist |
|
582 | 582 | } |
583 | 583 | $stmt = self::$pdo->prepare('DELETE FROM '.self::TABLE.' WHERE fs_id=:fs_id'); |
584 | 584 | unset(self::$stat_cache[$path]); |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | if (($ret = $stmt->execute(array('fs_id' => $stat['ino'])))) |
587 | 587 | { |
588 | 588 | if (self::url2operation($url) == self::STORE2FS && |
589 | - ($stat['mode'] & self::MODE_LINK) != self::MODE_LINK) |
|
589 | + ($stat['mode']&self::MODE_LINK) != self::MODE_LINK) |
|
590 | 590 | { |
591 | 591 | unlink(self::_fs_path($stat['ino'])); |
592 | 592 | } |
@@ -610,13 +610,13 @@ discard block |
||
610 | 610 | * @param string $url_to |
611 | 611 | * @return boolean TRUE on success or FALSE on failure |
612 | 612 | */ |
613 | - static function rename ( $url_from, $url_to) |
|
613 | + static function rename($url_from, $url_to) |
|
614 | 614 | { |
615 | 615 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url_from,$url_to)"); |
616 | 616 | |
617 | - $path_from = Vfs::parse_url($url_from,PHP_URL_PATH); |
|
617 | + $path_from = Vfs::parse_url($url_from, PHP_URL_PATH); |
|
618 | 618 | $from_dir = Vfs::dirname($path_from); |
619 | - $path_to = Vfs::parse_url($url_to,PHP_URL_PATH); |
|
619 | + $path_to = Vfs::parse_url($url_to, PHP_URL_PATH); |
|
620 | 620 | $to_dir = Vfs::dirname($path_to); |
621 | 621 | $operation = self::url2operation($url_from); |
622 | 622 | |
@@ -627,14 +627,14 @@ discard block |
||
627 | 627 | self::_remove_password($url_from); |
628 | 628 | self::_remove_password($url_to); |
629 | 629 | if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $path_from permission denied!"); |
630 | - return false; // no permission or file does not exist |
|
630 | + return false; // no permission or file does not exist |
|
631 | 631 | } |
632 | 632 | if (!Vfs::check_access($to_dir, Vfs::WRITABLE, $to_dir_stat = static::url_stat($to_dir, 0))) |
633 | 633 | { |
634 | 634 | self::_remove_password($url_from); |
635 | 635 | self::_remove_password($url_to); |
636 | 636 | if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $path_to permission denied!"); |
637 | - return false; // no permission or parent-dir does not exist |
|
637 | + return false; // no permission or parent-dir does not exist |
|
638 | 638 | } |
639 | 639 | // the filesystem stream-wrapper does NOT allow to rename files to directories, as this makes problems |
640 | 640 | // for our vfs too, we abort here with an error, like the filesystem one does |
@@ -645,10 +645,10 @@ discard block |
||
645 | 645 | self::_remove_password($url_to); |
646 | 646 | $is_dir = $to_stat['mime'] === self::DIR_MIME_TYPE ? 'a' : 'no'; |
647 | 647 | if (self::LOG_LEVEL) error_log(__METHOD__."($url_to,$url_from) $path_to is $is_dir directory!"); |
648 | - return false; // no permission or file does not exist |
|
648 | + return false; // no permission or file does not exist |
|
649 | 649 | } |
650 | 650 | // if destination file already exists, delete it |
651 | - if ($to_stat && !static::unlink($url_to,$operation)) |
|
651 | + if ($to_stat && !static::unlink($url_to, $operation)) |
|
652 | 652 | { |
653 | 653 | self::_remove_password($url_to); |
654 | 654 | if (self::LOG_LEVEL) error_log(__METHOD__."($url_to,$url_from) can't unlink existing $url_to!"); |
@@ -669,7 +669,7 @@ discard block |
||
669 | 669 | |
670 | 670 | // check if extension changed and update mime-type in that case (as we currently determine mime-type by it's extension!) |
671 | 671 | // fixes eg. problems with MsWord storing file with .tmp extension and then renaming to .doc |
672 | - if ($ok && ($new_mime = Vfs::mime_content_type($url_to,true)) != Vfs::mime_content_type($url_to)) |
|
672 | + if ($ok && ($new_mime = Vfs::mime_content_type($url_to, true)) != Vfs::mime_content_type($url_to)) |
|
673 | 673 | { |
674 | 674 | //echo "<p>Vfs::nime_content_type($url_to,true) = $new_mime</p>\n"; |
675 | 675 | $stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_mime=:fs_mime WHERE fs_id=:fs_id'); |
@@ -685,9 +685,9 @@ discard block |
||
685 | 685 | /** |
686 | 686 | * due to problems with recursive directory creation, we have our own here |
687 | 687 | */ |
688 | - protected static function mkdir_recursive($pathname, $mode, $depth=0) |
|
688 | + protected static function mkdir_recursive($pathname, $mode, $depth = 0) |
|
689 | 689 | { |
690 | - $maxdepth=10; |
|
690 | + $maxdepth = 10; |
|
691 | 691 | $depth2propagate = (int)$depth + 1; |
692 | 692 | if ($depth2propagate > $maxdepth) return is_dir($pathname); |
693 | 693 | is_dir(Vfs::dirname($pathname)) || self::mkdir_recursive(Vfs::dirname($pathname), $mode, $depth2propagate); |
@@ -705,47 +705,47 @@ discard block |
||
705 | 705 | * @param int $options Posible values include STREAM_REPORT_ERRORS and STREAM_MKDIR_RECURSIVE |
706 | 706 | * @return boolean TRUE on success or FALSE on failure |
707 | 707 | */ |
708 | - static function mkdir ( $url, $mode, $options ) |
|
708 | + static function mkdir($url, $mode, $options) |
|
709 | 709 | { |
710 | 710 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$mode,$options)"); |
711 | 711 | if (self::LOG_LEVEL > 1) error_log(__METHOD__." called from:".function_backtrace()); |
712 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
712 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
713 | 713 | |
714 | - if (self::url_stat($path,STREAM_URL_STAT_QUIET)) |
|
714 | + if (self::url_stat($path, STREAM_URL_STAT_QUIET)) |
|
715 | 715 | { |
716 | 716 | self::_remove_password($url); |
717 | 717 | if (self::LOG_LEVEL) error_log(__METHOD__."('$url',$mode,$options) already exist!"); |
718 | - if (!($options & STREAM_REPORT_ERRORS)) |
|
718 | + if (!($options&STREAM_REPORT_ERRORS)) |
|
719 | 719 | { |
720 | 720 | //throw new Exception(__METHOD__."('$url',$mode,$options) already exist!"); |
721 | - trigger_error(__METHOD__."('$url',$mode,$options) already exist!",E_USER_WARNING); |
|
721 | + trigger_error(__METHOD__."('$url',$mode,$options) already exist!", E_USER_WARNING); |
|
722 | 722 | } |
723 | 723 | return false; |
724 | 724 | } |
725 | 725 | $parent_path = Vfs::dirname($path); |
726 | - if (($query = Vfs::parse_url($url,PHP_URL_QUERY))) $parent_path .= '?'.$query; |
|
727 | - $parent = self::url_stat($parent_path,STREAM_URL_STAT_QUIET); |
|
726 | + if (($query = Vfs::parse_url($url, PHP_URL_QUERY))) $parent_path .= '?'.$query; |
|
727 | + $parent = self::url_stat($parent_path, STREAM_URL_STAT_QUIET); |
|
728 | 728 | |
729 | 729 | // check if we should also create all non-existing path components and our parent does not exist, |
730 | 730 | // if yes call ourself recursive with the parent directory |
731 | - if (($options & STREAM_MKDIR_RECURSIVE) && $parent_path != '/' && !$parent) |
|
731 | + if (($options&STREAM_MKDIR_RECURSIVE) && $parent_path != '/' && !$parent) |
|
732 | 732 | { |
733 | 733 | if (self::LOG_LEVEL > 1) error_log(__METHOD__." creating parents: $parent_path, $mode"); |
734 | - if (!self::mkdir($parent_path,$mode,$options)) |
|
734 | + if (!self::mkdir($parent_path, $mode, $options)) |
|
735 | 735 | { |
736 | 736 | return false; |
737 | 737 | } |
738 | - $parent = self::url_stat($parent_path,0); |
|
738 | + $parent = self::url_stat($parent_path, 0); |
|
739 | 739 | } |
740 | - if (!$parent || !Vfs::check_access($parent_path,Vfs::WRITABLE,$parent)) |
|
740 | + if (!$parent || !Vfs::check_access($parent_path, Vfs::WRITABLE, $parent)) |
|
741 | 741 | { |
742 | 742 | self::_remove_password($url); |
743 | 743 | if (self::LOG_LEVEL) error_log(__METHOD__."('$url',$mode,$options) permission denied!"); |
744 | - if (!($options & STREAM_REPORT_ERRORS)) |
|
744 | + if (!($options&STREAM_REPORT_ERRORS)) |
|
745 | 745 | { |
746 | - trigger_error(__METHOD__."('$url',$mode,$options) permission denied!",E_USER_WARNING); |
|
746 | + trigger_error(__METHOD__."('$url',$mode,$options) permission denied!", E_USER_WARNING); |
|
747 | 747 | } |
748 | - return false; // no permission or file does not exist |
|
748 | + return false; // no permission or file does not exist |
|
749 | 749 | } |
750 | 750 | unset(self::$stat_cache[$path]); |
751 | 751 | $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'. |
@@ -766,9 +766,9 @@ discard block |
||
766 | 766 | // check if some other process created the directory parallel to us (sqlfs would gives SQL errors later!) |
767 | 767 | $new_fs_id = self::$pdo->lastInsertId('egw_sqlfs_fs_id_seq'); |
768 | 768 | |
769 | - unset($stmt); // free statement object, on some installs a new prepare fails otherwise! |
|
769 | + unset($stmt); // free statement object, on some installs a new prepare fails otherwise! |
|
770 | 770 | |
771 | - $stmt = self::$pdo->prepare($q='SELECT COUNT(*) FROM '.self::TABLE. |
|
771 | + $stmt = self::$pdo->prepare($q = 'SELECT COUNT(*) FROM '.self::TABLE. |
|
772 | 772 | ' WHERE fs_dir=:fs_dir AND fs_active=:fs_active AND fs_name'.self::$case_sensitive_equal.':fs_name'); |
773 | 773 | if ($stmt->execute(array( |
774 | 774 | 'fs_dir' => $parent['ino'], |
@@ -792,25 +792,24 @@ discard block |
||
792 | 792 | * @param int $options Possible values include STREAM_REPORT_ERRORS. |
793 | 793 | * @return boolean TRUE on success or FALSE on failure. |
794 | 794 | */ |
795 | - static function rmdir ( $url, $options ) |
|
795 | + static function rmdir($url, $options) |
|
796 | 796 | { |
797 | 797 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url)"); |
798 | 798 | |
799 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
799 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
800 | 800 | $parent = Vfs::dirname($path); |
801 | 801 | |
802 | - if (!($stat = self::url_stat($path,0)) || $stat['mime'] != self::DIR_MIME_TYPE || |
|
803 | - !Vfs::check_access($parent, Vfs::WRITABLE, static::url_stat($parent,0))) |
|
802 | + if (!($stat = self::url_stat($path, 0)) || $stat['mime'] != self::DIR_MIME_TYPE || |
|
803 | + !Vfs::check_access($parent, Vfs::WRITABLE, static::url_stat($parent, 0))) |
|
804 | 804 | { |
805 | 805 | self::_remove_password($url); |
806 | - $err_msg = __METHOD__."($url,$options) ".(!$stat ? 'not found!' : |
|
807 | - ($stat['mime'] != self::DIR_MIME_TYPE ? 'not a directory!' : 'permission denied!')); |
|
806 | + $err_msg = __METHOD__."($url,$options) ".(!$stat ? 'not found!' : ($stat['mime'] != self::DIR_MIME_TYPE ? 'not a directory!' : 'permission denied!')); |
|
808 | 807 | if (self::LOG_LEVEL) error_log($err_msg); |
809 | - if (!($options & STREAM_REPORT_ERRORS)) |
|
808 | + if (!($options&STREAM_REPORT_ERRORS)) |
|
810 | 809 | { |
811 | - trigger_error($err_msg,E_USER_WARNING); |
|
810 | + trigger_error($err_msg, E_USER_WARNING); |
|
812 | 811 | } |
813 | - return false; // no permission or file does not exist |
|
812 | + return false; // no permission or file does not exist |
|
814 | 813 | } |
815 | 814 | $stmt = self::$pdo->prepare('SELECT COUNT(*) FROM '.self::TABLE.' WHERE fs_dir=?'); |
816 | 815 | $stmt->execute(array($stat['ino'])); |
@@ -818,19 +817,19 @@ discard block |
||
818 | 817 | { |
819 | 818 | self::_remove_password($url); |
820 | 819 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$options) dir is not empty!"); |
821 | - if (!($options & STREAM_REPORT_ERRORS)) |
|
820 | + if (!($options&STREAM_REPORT_ERRORS)) |
|
822 | 821 | { |
823 | - trigger_error(__METHOD__."('$url',$options) dir is not empty!",E_USER_WARNING); |
|
822 | + trigger_error(__METHOD__."('$url',$options) dir is not empty!", E_USER_WARNING); |
|
824 | 823 | } |
825 | 824 | return false; |
826 | 825 | } |
827 | 826 | unset(self::$stat_cache[$path]); |
828 | - unset($stmt); // free statement object, on some installs a new prepare fails otherwise! |
|
827 | + unset($stmt); // free statement object, on some installs a new prepare fails otherwise! |
|
829 | 828 | |
830 | 829 | $del_stmt = self::$pdo->prepare('DELETE FROM '.self::TABLE.' WHERE fs_id=?'); |
831 | 830 | if (($ret = $del_stmt->execute(array($stat['ino'])))) |
832 | 831 | { |
833 | - self::eacl($path,null,false,$stat['ino']); // remove all (=false) evtl. existing extended acl for that dir |
|
832 | + self::eacl($path, null, false, $stat['ino']); // remove all (=false) evtl. existing extended acl for that dir |
|
834 | 833 | // delete props |
835 | 834 | unset($del_stmt); |
836 | 835 | $del_stmt = self::$pdo->prepare('DELETE FROM '.self::PROPS_TABLE.' WHERE fs_id=?'); |
@@ -846,25 +845,25 @@ discard block |
||
846 | 845 | * @param int $time =null modification time (unix timestamp), default null = current time |
847 | 846 | * @param int $atime =null access time (unix timestamp), default null = current time, not implemented in the vfs! |
848 | 847 | */ |
849 | - static function touch($url,$time=null,$atime=null) |
|
848 | + static function touch($url, $time = null, $atime = null) |
|
850 | 849 | { |
851 | - unset($atime); // not used |
|
850 | + unset($atime); // not used |
|
852 | 851 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url, $time)"); |
853 | 852 | |
854 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
853 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
855 | 854 | |
856 | - if (!($stat = self::url_stat($path,STREAM_URL_STAT_QUIET))) |
|
855 | + if (!($stat = self::url_stat($path, STREAM_URL_STAT_QUIET))) |
|
857 | 856 | { |
858 | 857 | // file does not exist --> create an empty one |
859 | - if (!($f = fopen(self::SCHEME.'://default'.$path,'w')) || !fclose($f)) |
|
858 | + if (!($f = fopen(self::SCHEME.'://default'.$path, 'w')) || !fclose($f)) |
|
860 | 859 | { |
861 | 860 | return false; |
862 | 861 | } |
863 | 862 | if (is_null($time)) |
864 | 863 | { |
865 | - return true; // new (empty) file created with current mod time |
|
864 | + return true; // new (empty) file created with current mod time |
|
866 | 865 | } |
867 | - $stat = self::url_stat($path,0); |
|
866 | + $stat = self::url_stat($path, 0); |
|
868 | 867 | } |
869 | 868 | unset(self::$stat_cache[$path]); |
870 | 869 | $stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_modified=:fs_modified,fs_modifier=:fs_modifier WHERE fs_id=:fs_id'); |
@@ -883,39 +882,39 @@ discard block |
||
883 | 882 | * @param int $owner |
884 | 883 | * @return boolean |
885 | 884 | */ |
886 | - static function chown($url,$owner) |
|
885 | + static function chown($url, $owner) |
|
887 | 886 | { |
888 | 887 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$owner)"); |
889 | 888 | |
890 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
889 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
891 | 890 | |
892 | - if (!($stat = self::url_stat($path,0))) |
|
891 | + if (!($stat = self::url_stat($path, 0))) |
|
893 | 892 | { |
894 | 893 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) no such file or directory!"); |
895 | - trigger_error("No such file or directory $url !",E_USER_WARNING); |
|
894 | + trigger_error("No such file or directory $url !", E_USER_WARNING); |
|
896 | 895 | return false; |
897 | 896 | } |
898 | 897 | if (!Vfs::$is_root) |
899 | 898 | { |
900 | 899 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) only root can do that!"); |
901 | - trigger_error("Only root can do that!",E_USER_WARNING); |
|
900 | + trigger_error("Only root can do that!", E_USER_WARNING); |
|
902 | 901 | return false; |
903 | 902 | } |
904 | 903 | if ($owner < 0 || $owner && !$GLOBALS['egw']->accounts->id2name($owner)) // not a user (0 == root) |
905 | 904 | { |
906 | 905 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) unknown (numeric) user id!"); |
907 | - trigger_error(__METHOD__."($url,$owner) Unknown (numeric) user id!",E_USER_WARNING); |
|
906 | + trigger_error(__METHOD__."($url,$owner) Unknown (numeric) user id!", E_USER_WARNING); |
|
908 | 907 | //throw new Exception(__METHOD__."($url,$owner) Unknown (numeric) user id!"); |
909 | 908 | return false; |
910 | 909 | } |
911 | 910 | $stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_uid=:fs_uid WHERE fs_id=:fs_id'); |
912 | 911 | |
913 | 912 | // update stat-cache |
914 | - if ($path != '/' && substr($path,-1) == '/') $path = substr($path, 0, -1); |
|
913 | + if ($path != '/' && substr($path, -1) == '/') $path = substr($path, 0, -1); |
|
915 | 914 | self::$stat_cache[$path]['fs_uid'] = $owner; |
916 | 915 | |
917 | 916 | return $stmt->execute(array( |
918 | - 'fs_uid' => (int) $owner, |
|
917 | + 'fs_uid' => (int)$owner, |
|
919 | 918 | 'fs_id' => $stat['ino'], |
920 | 919 | )); |
921 | 920 | } |
@@ -927,36 +926,36 @@ discard block |
||
927 | 926 | * @param int $owner |
928 | 927 | * @return boolean |
929 | 928 | */ |
930 | - static function chgrp($url,$owner) |
|
929 | + static function chgrp($url, $owner) |
|
931 | 930 | { |
932 | 931 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$owner)"); |
933 | 932 | |
934 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
933 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
935 | 934 | |
936 | - if (!($stat = self::url_stat($path,0))) |
|
935 | + if (!($stat = self::url_stat($path, 0))) |
|
937 | 936 | { |
938 | 937 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) no such file or directory!"); |
939 | - trigger_error("No such file or directory $url !",E_USER_WARNING); |
|
938 | + trigger_error("No such file or directory $url !", E_USER_WARNING); |
|
940 | 939 | return false; |
941 | 940 | } |
942 | - if (!Vfs::has_owner_rights($path,$stat)) |
|
941 | + if (!Vfs::has_owner_rights($path, $stat)) |
|
943 | 942 | { |
944 | 943 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) only owner or root can do that!"); |
945 | - trigger_error("Only owner or root can do that!",E_USER_WARNING); |
|
944 | + trigger_error("Only owner or root can do that!", E_USER_WARNING); |
|
946 | 945 | return false; |
947 | 946 | } |
948 | - if ($owner < 0) $owner = -$owner; // sqlfs uses a positiv group id's! |
|
947 | + if ($owner < 0) $owner = -$owner; // sqlfs uses a positiv group id's! |
|
949 | 948 | |
950 | 949 | if ($owner && !$GLOBALS['egw']->accounts->id2name(-$owner)) // not a group |
951 | 950 | { |
952 | 951 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) unknown (numeric) group id!"); |
953 | - trigger_error("Unknown (numeric) group id!",E_USER_WARNING); |
|
952 | + trigger_error("Unknown (numeric) group id!", E_USER_WARNING); |
|
954 | 953 | return false; |
955 | 954 | } |
956 | 955 | $stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_gid=:fs_gid WHERE fs_id=:fs_id'); |
957 | 956 | |
958 | 957 | // update stat-cache |
959 | - if ($path != '/' && substr($path,-1) == '/') $path = substr($path, 0, -1); |
|
958 | + if ($path != '/' && substr($path, -1) == '/') $path = substr($path, 0, -1); |
|
960 | 959 | self::$stat_cache[$path]['fs_gid'] = $owner; |
961 | 960 | |
962 | 961 | return $stmt->execute(array( |
@@ -972,38 +971,38 @@ discard block |
||
972 | 971 | * @param int $mode |
973 | 972 | * @return boolean |
974 | 973 | */ |
975 | - static function chmod($url,$mode) |
|
974 | + static function chmod($url, $mode) |
|
976 | 975 | { |
977 | 976 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url, $mode)"); |
978 | 977 | |
979 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
978 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
980 | 979 | |
981 | - if (!($stat = self::url_stat($path,0))) |
|
980 | + if (!($stat = self::url_stat($path, 0))) |
|
982 | 981 | { |
983 | 982 | if (self::LOG_LEVEL) error_log(__METHOD__."($url, $mode) no such file or directory!"); |
984 | - trigger_error("No such file or directory $url !",E_USER_WARNING); |
|
983 | + trigger_error("No such file or directory $url !", E_USER_WARNING); |
|
985 | 984 | return false; |
986 | 985 | } |
987 | - if (!Vfs::has_owner_rights($path,$stat)) |
|
986 | + if (!Vfs::has_owner_rights($path, $stat)) |
|
988 | 987 | { |
989 | 988 | if (self::LOG_LEVEL) error_log(__METHOD__."($url, $mode) only owner or root can do that!"); |
990 | - trigger_error("Only owner or root can do that!",E_USER_WARNING); |
|
989 | + trigger_error("Only owner or root can do that!", E_USER_WARNING); |
|
991 | 990 | return false; |
992 | 991 | } |
993 | 992 | if (!is_numeric($mode)) // not a mode |
994 | 993 | { |
995 | 994 | if (self::LOG_LEVEL) error_log(__METHOD__."($url, $mode) no (numeric) mode!"); |
996 | - trigger_error("No (numeric) mode!",E_USER_WARNING); |
|
995 | + trigger_error("No (numeric) mode!", E_USER_WARNING); |
|
997 | 996 | return false; |
998 | 997 | } |
999 | 998 | $stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_mode=:fs_mode WHERE fs_id=:fs_id'); |
1000 | 999 | |
1001 | 1000 | // update stat cache |
1002 | - if ($path != '/' && substr($path,-1) == '/') $path = substr($path, 0, -1); |
|
1003 | - self::$stat_cache[$path]['fs_mode'] = ((int) $mode) & 0777; |
|
1001 | + if ($path != '/' && substr($path, -1) == '/') $path = substr($path, 0, -1); |
|
1002 | + self::$stat_cache[$path]['fs_mode'] = ((int)$mode)&0777; |
|
1004 | 1003 | |
1005 | 1004 | return $stmt->execute(array( |
1006 | - 'fs_mode' => ((int) $mode) & 0777, // we dont store the file and dir bits, give int overflow! |
|
1005 | + 'fs_mode' => ((int)$mode)&0777, // we dont store the file and dir bits, give int overflow! |
|
1007 | 1006 | 'fs_id' => $stat['ino'], |
1008 | 1007 | )); |
1009 | 1008 | } |
@@ -1016,15 +1015,15 @@ discard block |
||
1016 | 1015 | * @param int $options |
1017 | 1016 | * @return booelan |
1018 | 1017 | */ |
1019 | - function dir_opendir ( $url, $options ) |
|
1018 | + function dir_opendir($url, $options) |
|
1020 | 1019 | { |
1021 | 1020 | $this->opened_dir = null; |
1022 | 1021 | |
1023 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
1022 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
1024 | 1023 | |
1025 | - if (!($stat = self::url_stat($url,0)) || // dir not found |
|
1026 | - $stat['mime'] != self::DIR_MIME_TYPE || // no dir |
|
1027 | - !Vfs::check_access($url,Vfs::EXECUTABLE|Vfs::READABLE,$stat)) // no access |
|
1024 | + if (!($stat = self::url_stat($url, 0)) || // dir not found |
|
1025 | + $stat['mime'] != self::DIR_MIME_TYPE || // no dir |
|
1026 | + !Vfs::check_access($url, Vfs::EXECUTABLE|Vfs::READABLE, $stat)) // no access |
|
1028 | 1027 | { |
1029 | 1028 | self::_remove_password($url); |
1030 | 1029 | $msg = $stat['mime'] != self::DIR_MIME_TYPE ? "$url is no directory" : 'permission denied'; |
@@ -1043,13 +1042,13 @@ discard block |
||
1043 | 1042 | $stmt->setFetchMode(\PDO::FETCH_ASSOC); |
1044 | 1043 | if ($stmt->execute(array($stat['ino']))) |
1045 | 1044 | { |
1046 | - foreach($stmt as $file) |
|
1045 | + foreach ($stmt as $file) |
|
1047 | 1046 | { |
1048 | 1047 | $this->opened_dir[] = $file['fs_name']; |
1049 | - self::$stat_cache[Vfs::concat($path,$file['fs_name'])] = $file; |
|
1048 | + self::$stat_cache[Vfs::concat($path, $file['fs_name'])] = $file; |
|
1050 | 1049 | } |
1051 | 1050 | } |
1052 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$options): ".implode(', ',$this->opened_dir)); |
|
1051 | + if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$options): ".implode(', ', $this->opened_dir)); |
|
1053 | 1052 | reset($this->opened_dir); |
1054 | 1053 | |
1055 | 1054 | return true; |
@@ -1082,26 +1081,26 @@ discard block |
||
1082 | 1081 | * @param boolean $eacl_access =null allows extending classes to pass the value of their check_extended_acl() method (no lsb!) |
1083 | 1082 | * @return array |
1084 | 1083 | */ |
1085 | - static function url_stat ( $url, $flags, $eacl_access=null ) |
|
1084 | + static function url_stat($url, $flags, $eacl_access = null) |
|
1086 | 1085 | { |
1087 | - static $max_subquery_depth=null; |
|
1086 | + static $max_subquery_depth = null; |
|
1088 | 1087 | if (is_null($max_subquery_depth)) |
1089 | 1088 | { |
1090 | 1089 | $max_subquery_depth = $GLOBALS['egw_info']['server']['max_subquery_depth']; |
1091 | - if (!$max_subquery_depth) $max_subquery_depth = 7; // setting current default of 7, if nothing set |
|
1090 | + if (!$max_subquery_depth) $max_subquery_depth = 7; // setting current default of 7, if nothing set |
|
1092 | 1091 | } |
1093 | 1092 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$url',$flags,$eacl_access)"); |
1094 | 1093 | |
1095 | - $path = Vfs::parse_url($url,PHP_URL_PATH); |
|
1094 | + $path = Vfs::parse_url($url, PHP_URL_PATH); |
|
1096 | 1095 | |
1097 | 1096 | // webdav adds a trailing slash to dirs, which causes url_stat to NOT find the file otherwise |
1098 | - if ($path != '/' && substr($path,-1) == '/') |
|
1097 | + if ($path != '/' && substr($path, -1) == '/') |
|
1099 | 1098 | { |
1100 | - $path = substr($path,0,-1); |
|
1099 | + $path = substr($path, 0, -1); |
|
1101 | 1100 | } |
1102 | 1101 | if (empty($path)) |
1103 | 1102 | { |
1104 | - return false; // is invalid and gives sql error |
|
1103 | + return false; // is invalid and gives sql error |
|
1105 | 1104 | } |
1106 | 1105 | // check if we already have the info from the last dir_open call, as the old vfs reads it anyway from the db |
1107 | 1106 | if (self::$stat_cache && isset(self::$stat_cache[$path]) && (is_null($eacl_access) || self::$stat_cache[$path] !== false)) |
@@ -1116,28 +1115,28 @@ discard block |
||
1116 | 1115 | $base_query = 'SELECT fs_id,fs_name,fs_mode,fs_uid,fs_gid,fs_size,fs_mime,fs_created,fs_modified'.self::$extra_columns. |
1117 | 1116 | ' FROM '.self::TABLE.' WHERE fs_active='.self::_pdo_boolean(true). |
1118 | 1117 | ' AND fs_name'.self::$case_sensitive_equal.'? AND fs_dir='; |
1119 | - $parts = explode('/',$path); |
|
1118 | + $parts = explode('/', $path); |
|
1120 | 1119 | |
1121 | 1120 | // if we have extendes acl access to the url, we dont need and can NOT include the sql for the readable check |
1122 | 1121 | if (is_null($eacl_access)) |
1123 | 1122 | { |
1124 | - $eacl_access = self::check_extended_acl($path,Vfs::READABLE); // should be static::check_extended_acl, but no lsb! |
|
1123 | + $eacl_access = self::check_extended_acl($path, Vfs::READABLE); // should be static::check_extended_acl, but no lsb! |
|
1125 | 1124 | } |
1126 | 1125 | |
1127 | 1126 | try { |
1128 | - foreach($parts as $n => $name) |
|
1127 | + foreach ($parts as $n => $name) |
|
1129 | 1128 | { |
1130 | 1129 | if ($n == 0) |
1131 | 1130 | { |
1132 | - $query = (int) ($path != '/'); // / always has fs_id == 1, no need to query it ($path=='/' needs fs_dir=0!) |
|
1131 | + $query = (int)($path != '/'); // / always has fs_id == 1, no need to query it ($path=='/' needs fs_dir=0!) |
|
1133 | 1132 | } |
1134 | - elseif ($n < count($parts)-1) |
|
1133 | + elseif ($n < count($parts) - 1) |
|
1135 | 1134 | { |
1136 | 1135 | // MySQL 5.0 has a nesting limit for subqueries |
1137 | 1136 | // --> we replace the so far cumulated subqueries with their result |
1138 | 1137 | // no idea about the other DBMS, but this does NOT hurt ... |
1139 | 1138 | // --> depth limit of subqueries is now dynamicly decremented in catch |
1140 | - if ($n > 1 && !(($n-1) % $max_subquery_depth) && !($query = self::$pdo->query($query)->fetchColumn())) |
|
1139 | + if ($n > 1 && !(($n - 1) % $max_subquery_depth) && !($query = self::$pdo->query($query)->fetchColumn())) |
|
1141 | 1140 | { |
1142 | 1141 | if (self::LOG_LEVEL > 1) |
1143 | 1142 | { |
@@ -1164,7 +1163,7 @@ discard block |
||
1164 | 1163 | } |
1165 | 1164 | else |
1166 | 1165 | { |
1167 | - $query = str_replace('fs_name'.self::$case_sensitive_equal.'?','fs_name'.self::$case_sensitive_equal.self::$pdo->quote($name),$base_query).'('.$query.')'; |
|
1166 | + $query = str_replace('fs_name'.self::$case_sensitive_equal.'?', 'fs_name'.self::$case_sensitive_equal.self::$pdo->quote($name), $base_query).'('.$query.')'; |
|
1168 | 1167 | } |
1169 | 1168 | } |
1170 | 1169 | if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__."($url,$flags,$eacl_access)".' */ '.$query; |
@@ -1190,7 +1189,7 @@ discard block |
||
1190 | 1189 | $GLOBALS['egw_info']['server']['max_subquery_depth'] = --$max_subquery_depth; |
1191 | 1190 | error_log(__METHOD__."() decremented max_subquery_depth to $max_subquery_depth"); |
1192 | 1191 | config::save_value('max_subquery_depth', $max_subquery_depth, 'phpgwapi'); |
1193 | - if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) $GLOBALS['egw']->invalidate_session_cache(); |
|
1192 | + if (method_exists($GLOBALS['egw'], 'invalidate_session_cache')) $GLOBALS['egw']->invalidate_session_cache(); |
|
1194 | 1193 | return self::url_stat($url, $flags, $eacl_access); |
1195 | 1194 | } |
1196 | 1195 | self::$stat_cache[$path] = $info; |
@@ -1206,18 +1205,18 @@ discard block |
||
1206 | 1205 | */ |
1207 | 1206 | protected function _sql_readable() |
1208 | 1207 | { |
1209 | - static $sql_read_acl=null; |
|
1208 | + static $sql_read_acl = null; |
|
1210 | 1209 | |
1211 | 1210 | if (is_null($sql_read_acl)) |
1212 | 1211 | { |
1213 | - foreach($GLOBALS['egw']->accounts->memberships(Vfs::$user,true) as $gid) |
|
1212 | + foreach ($GLOBALS['egw']->accounts->memberships(Vfs::$user, true) as $gid) |
|
1214 | 1213 | { |
1215 | - $memberships[] = abs($gid); // sqlfs stores the gid's positiv |
|
1214 | + $memberships[] = abs($gid); // sqlfs stores the gid's positiv |
|
1216 | 1215 | } |
1217 | 1216 | // using octal numbers with mysql leads to funny results (select 384 & 0400 --> 384 not 256=0400) |
1218 | 1217 | // 256 = 0400, 32 = 040 |
1219 | 1218 | $sql_read_acl = '((fs_mode & 4)=4 OR (fs_mode & 256)=256 AND fs_uid='.(int)Vfs::$user. |
1220 | - ($memberships ? ' OR (fs_mode & 32)=32 AND fs_gid IN('.implode(',',$memberships).')' : '').')'; |
|
1219 | + ($memberships ? ' OR (fs_mode & 32)=32 AND fs_gid IN('.implode(',', $memberships).')' : '').')'; |
|
1221 | 1220 | //error_log(__METHOD__."() Vfs::\$user=".array2string(Vfs::$user).' --> memberships='.array2string($memberships).' --> '.$sql_read_acl.($memberships?'':': '.function_backtrace())); |
1222 | 1221 | } |
1223 | 1222 | return $sql_read_acl; |
@@ -1230,7 +1229,7 @@ discard block |
||
1230 | 1229 | * |
1231 | 1230 | * @return string |
1232 | 1231 | */ |
1233 | - function dir_readdir ( ) |
|
1232 | + function dir_readdir( ) |
|
1234 | 1233 | { |
1235 | 1234 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."( )"); |
1236 | 1235 | |
@@ -1249,7 +1248,7 @@ discard block |
||
1249 | 1248 | * |
1250 | 1249 | * @return boolean |
1251 | 1250 | */ |
1252 | - function dir_rewinddir ( ) |
|
1251 | + function dir_rewinddir( ) |
|
1253 | 1252 | { |
1254 | 1253 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."( )"); |
1255 | 1254 | |
@@ -1267,7 +1266,7 @@ discard block |
||
1267 | 1266 | * |
1268 | 1267 | * @return boolean |
1269 | 1268 | */ |
1270 | - function dir_closedir ( ) |
|
1269 | + function dir_closedir( ) |
|
1271 | 1270 | { |
1272 | 1271 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."( )"); |
1273 | 1272 | |
@@ -1288,7 +1287,7 @@ discard block |
||
1288 | 1287 | */ |
1289 | 1288 | static function readlink($path) |
1290 | 1289 | { |
1291 | - $link = !($lstat = self::url_stat($path,STREAM_URL_STAT_LINK)) || is_null($lstat['readlink']) ? false : $lstat['readlink']; |
|
1290 | + $link = !($lstat = self::url_stat($path, STREAM_URL_STAT_LINK)) || is_null($lstat['readlink']) ? false : $lstat['readlink']; |
|
1292 | 1291 | |
1293 | 1292 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = $link"); |
1294 | 1293 | |
@@ -1302,31 +1301,31 @@ discard block |
||
1302 | 1301 | * @param string $link |
1303 | 1302 | * @return boolean true on success false on error |
1304 | 1303 | */ |
1305 | - static function symlink($target,$link) |
|
1304 | + static function symlink($target, $link) |
|
1306 | 1305 | { |
1307 | 1306 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$target','$link')"); |
1308 | 1307 | |
1309 | - if (self::url_stat($link,0)) |
|
1308 | + if (self::url_stat($link, 0)) |
|
1310 | 1309 | { |
1311 | 1310 | if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$target','$link') $link exists, returning false!"); |
1312 | - return false; // $link already exists |
|
1311 | + return false; // $link already exists |
|
1313 | 1312 | } |
1314 | 1313 | if (!($dir = Vfs::dirname($link)) || |
1315 | - !Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat=static::url_stat($dir,0))) |
|
1314 | + !Vfs::check_access($dir, Vfs::WRITABLE, $dir_stat = static::url_stat($dir, 0))) |
|
1316 | 1315 | { |
1317 | 1316 | if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$target','$link') returning false! (!is_writable('$dir'), dir_stat=".array2string($dir_stat).")"); |
1318 | - return false; // parent dir does not exist or is not writable |
|
1317 | + return false; // parent dir does not exist or is not writable |
|
1319 | 1318 | } |
1320 | 1319 | $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'. |
1321 | 1320 | ') VALUES (:fs_name,:fs_dir,:fs_mode,:fs_uid,:fs_gid,:fs_created,:fs_modified,:fs_creator,:fs_mime,:fs_size,:fs_link)'; |
1322 | 1321 | if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; |
1323 | 1322 | $stmt = self::$pdo->prepare($query); |
1324 | - unset(self::$stat_cache[Vfs::parse_url($link,PHP_URL_PATH)]); |
|
1323 | + unset(self::$stat_cache[Vfs::parse_url($link, PHP_URL_PATH)]); |
|
1325 | 1324 | |
1326 | 1325 | return !!$stmt->execute(array( |
1327 | 1326 | 'fs_name' => self::limit_filename(Vfs::basename($link)), |
1328 | 1327 | 'fs_dir' => $dir_stat['ino'], |
1329 | - 'fs_mode' => ($dir_stat['mode'] & 0666), |
|
1328 | + 'fs_mode' => ($dir_stat['mode']&0666), |
|
1330 | 1329 | 'fs_uid' => $dir_stat['uid'] ? $dir_stat['uid'] : Vfs::$user, |
1331 | 1330 | 'fs_gid' => $dir_stat['gid'], |
1332 | 1331 | 'fs_created' => self::_pdo_timestamp(time()), |
@@ -1350,24 +1349,24 @@ discard block |
||
1350 | 1349 | * @param int $check mode to check: one or more or'ed together of: 4 = read, 2 = write, 1 = executable |
1351 | 1350 | * @return boolean |
1352 | 1351 | */ |
1353 | - static function check_extended_acl($url,$check) |
|
1352 | + static function check_extended_acl($url, $check) |
|
1354 | 1353 | { |
1355 | - $url_path = Vfs::parse_url($url,PHP_URL_PATH); |
|
1354 | + $url_path = Vfs::parse_url($url, PHP_URL_PATH); |
|
1356 | 1355 | |
1357 | 1356 | if (is_null(self::$extended_acl)) |
1358 | 1357 | { |
1359 | 1358 | self::_read_extended_acl(); |
1360 | 1359 | } |
1361 | 1360 | $access = false; |
1362 | - foreach(self::$extended_acl as $path => $rights) |
|
1361 | + foreach (self::$extended_acl as $path => $rights) |
|
1363 | 1362 | { |
1364 | - if ($path == $url_path || substr($url_path,0,strlen($path)+1) == $path.'/') |
|
1363 | + if ($path == $url_path || substr($url_path, 0, strlen($path) + 1) == $path.'/') |
|
1365 | 1364 | { |
1366 | - $access = ($rights & $check) == $check; |
|
1365 | + $access = ($rights&$check) == $check; |
|
1367 | 1366 | break; |
1368 | 1367 | } |
1369 | 1368 | } |
1370 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$check) ".($access?"access granted by $path=$rights":'no access!!!')); |
|
1369 | + if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$check) ".($access ? "access granted by $path=$rights" : 'no access!!!')); |
|
1371 | 1370 | return $access; |
1372 | 1371 | } |
1373 | 1372 | |
@@ -1379,14 +1378,14 @@ discard block |
||
1379 | 1378 | { |
1380 | 1379 | if ((self::$extended_acl = egw_cache::getSession(self::EACL_APPNAME, 'extended_acl'))) |
1381 | 1380 | { |
1382 | - return; // ext. ACL read from session. |
|
1381 | + return; // ext. ACL read from session. |
|
1383 | 1382 | } |
1384 | 1383 | self::$extended_acl = array(); |
1385 | - if (($rights = $GLOBALS['egw']->acl->get_all_location_rights(Vfs::$user,self::EACL_APPNAME))) |
|
1384 | + if (($rights = $GLOBALS['egw']->acl->get_all_location_rights(Vfs::$user, self::EACL_APPNAME))) |
|
1386 | 1385 | { |
1387 | 1386 | $pathes = self::id2path(array_keys($rights)); |
1388 | 1387 | } |
1389 | - foreach($rights as $fs_id => $right) |
|
1388 | + foreach ($rights as $fs_id => $right) |
|
1390 | 1389 | { |
1391 | 1390 | $path = $pathes[$fs_id]; |
1392 | 1391 | if (isset($path)) |
@@ -1395,8 +1394,8 @@ discard block |
||
1395 | 1394 | } |
1396 | 1395 | } |
1397 | 1396 | // sort by length descending, to allow more specific pathes to have precedence |
1398 | - uksort(self::$extended_acl, function($a,$b) { |
|
1399 | - return strlen($b)-strlen($a); |
|
1397 | + uksort(self::$extended_acl, function($a, $b) { |
|
1398 | + return strlen($b) - strlen($a); |
|
1400 | 1399 | }); |
1401 | 1400 | egw_cache::setSession(self::EACL_APPNAME, 'extended_acl', self::$extended_acl); |
1402 | 1401 | if (self::LOG_LEVEL > 1) error_log(__METHOD__.'() '.array2string(self::$extended_acl)); |
@@ -1418,23 +1417,23 @@ discard block |
||
1418 | 1417 | * @param int $fs_id =null fs_id to use, to not query it again (eg. because it's already deleted) |
1419 | 1418 | * @return boolean true if acl is set/deleted, false on error |
1420 | 1419 | */ |
1421 | - static function eacl($path,$rights=null,$owner=null,$fs_id=null) |
|
1420 | + static function eacl($path, $rights = null, $owner = null, $fs_id = null) |
|
1422 | 1421 | { |
1423 | 1422 | if ($path[0] != '/') |
1424 | 1423 | { |
1425 | - $path = Vfs::parse_url($path,PHP_URL_PATH); |
|
1424 | + $path = Vfs::parse_url($path, PHP_URL_PATH); |
|
1426 | 1425 | } |
1427 | 1426 | if (is_null($fs_id)) |
1428 | 1427 | { |
1429 | - if (!($stat = self::url_stat($path,0))) |
|
1428 | + if (!($stat = self::url_stat($path, 0))) |
|
1430 | 1429 | { |
1431 | 1430 | if (self::LOG_LEVEL) error_log(__METHOD__."($path,$rights,$owner,$fs_id) no such file or directory!"); |
1432 | - return false; // $path not found |
|
1431 | + return false; // $path not found |
|
1433 | 1432 | } |
1434 | - if (!Vfs::has_owner_rights($path,$stat)) // not group dir and user is eGW admin |
|
1433 | + if (!Vfs::has_owner_rights($path, $stat)) // not group dir and user is eGW admin |
|
1435 | 1434 | { |
1436 | 1435 | if (self::LOG_LEVEL) error_log(__METHOD__."($path,$rights,$owner,$fs_id) permission denied!"); |
1437 | - return false; // permission denied |
|
1436 | + return false; // permission denied |
|
1438 | 1437 | } |
1439 | 1438 | $fs_id = $stat['ino']; |
1440 | 1439 | } |
@@ -1446,21 +1445,21 @@ discard block |
||
1446 | 1445 | { |
1447 | 1446 | // delete eacl |
1448 | 1447 | if (is_null($owner) || $owner == Vfs::$user || |
1449 | - $owner < 0 && Vfs::$user && in_array($owner,$GLOBALS['egw']->accounts->memberships(Vfs::$user,true))) |
|
1448 | + $owner < 0 && Vfs::$user && in_array($owner, $GLOBALS['egw']->accounts->memberships(Vfs::$user, true))) |
|
1450 | 1449 | { |
1451 | - self::$extended_acl = null; // force new read of eACL, as there could be multiple eACL for that path |
|
1450 | + self::$extended_acl = null; // force new read of eACL, as there could be multiple eACL for that path |
|
1452 | 1451 | } |
1453 | - $ret = $GLOBALS['egw']->acl->delete_repository(self::EACL_APPNAME,$fs_id,(int)$owner); |
|
1452 | + $ret = $GLOBALS['egw']->acl->delete_repository(self::EACL_APPNAME, $fs_id, (int)$owner); |
|
1454 | 1453 | } |
1455 | 1454 | else |
1456 | 1455 | { |
1457 | 1456 | if (isset(self::$extended_acl) && ($owner == Vfs::$user || |
1458 | - $owner < 0 && Vfs::$user && in_array($owner,$GLOBALS['egw']->accounts->memberships(Vfs::$user,true)))) |
|
1457 | + $owner < 0 && Vfs::$user && in_array($owner, $GLOBALS['egw']->accounts->memberships(Vfs::$user, true)))) |
|
1459 | 1458 | { |
1460 | 1459 | // set rights for this class, if applicable |
1461 | 1460 | self::$extended_acl[$path] |= $rights; |
1462 | 1461 | } |
1463 | - $ret = $GLOBALS['egw']->acl->add_repository(self::EACL_APPNAME,$fs_id,$owner,$rights); |
|
1462 | + $ret = $GLOBALS['egw']->acl->add_repository(self::EACL_APPNAME, $fs_id, $owner, $rights); |
|
1464 | 1463 | } |
1465 | 1464 | if ($ret) |
1466 | 1465 | { |
@@ -1483,10 +1482,10 @@ discard block |
||
1483 | 1482 | if (!($stat = static::url_stat($path, STREAM_URL_STAT_QUIET))) |
1484 | 1483 | { |
1485 | 1484 | error_log(__METHOD__.__LINE__.' '.array2string($path).' not found!'); |
1486 | - return false; // not found |
|
1485 | + return false; // not found |
|
1487 | 1486 | } |
1488 | 1487 | $eacls = array(); |
1489 | - foreach($GLOBALS['egw']->acl->get_all_rights($stat['ino'],self::EACL_APPNAME) as $owner => $rights) |
|
1488 | + foreach ($GLOBALS['egw']->acl->get_all_rights($stat['ino'], self::EACL_APPNAME) as $owner => $rights) |
|
1490 | 1489 | { |
1491 | 1490 | $eacls[] = array( |
1492 | 1491 | 'path' => $path, |
@@ -1497,7 +1496,7 @@ discard block |
||
1497 | 1496 | } |
1498 | 1497 | if (($path = Vfs::dirname($path))) |
1499 | 1498 | { |
1500 | - $eacls = array_merge((array)self::get_eacl($path),$eacls); |
|
1499 | + $eacls = array_merge((array)self::get_eacl($path), $eacls); |
|
1501 | 1500 | } |
1502 | 1501 | // sort by length descending, to show precedence |
1503 | 1502 | usort($eacls, function($a, $b) { |
@@ -1522,9 +1521,9 @@ discard block |
||
1522 | 1521 | $ids = (array)$fs_ids; |
1523 | 1522 | $pathes = array(); |
1524 | 1523 | // first check our stat-cache for the ids |
1525 | - foreach(self::$stat_cache as $path => $stat) |
|
1524 | + foreach (self::$stat_cache as $path => $stat) |
|
1526 | 1525 | { |
1527 | - if (($key = array_search($stat['fs_id'],$ids)) !== false) |
|
1526 | + if (($key = array_search($stat['fs_id'], $ids)) !== false) |
|
1528 | 1527 | { |
1529 | 1528 | $pathes[$stat['fs_id']] = $path; |
1530 | 1529 | unset($ids[$key]); |
@@ -1538,7 +1537,7 @@ discard block |
||
1538 | 1537 | // now search via the database |
1539 | 1538 | if (count($ids) > 1) array_map(function(&$v) { $v = (int)$v; },$ids); |
1540 | 1539 | $query = 'SELECT fs_id,fs_dir,fs_name FROM '.self::TABLE.' WHERE fs_id'. |
1541 | - (count($ids) == 1 ? '='.(int)$ids[0] : ' IN ('.implode(',',$ids).')'); |
|
1540 | + (count($ids) == 1 ? '='.(int)$ids[0] : ' IN ('.implode(',', $ids).')'); |
|
1542 | 1541 | if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; |
1543 | 1542 | |
1544 | 1543 | if (!is_object(self::$pdo)) |
@@ -1549,12 +1548,12 @@ discard block |
||
1549 | 1548 | $stmt->setFetchMode(\PDO::FETCH_ASSOC); |
1550 | 1549 | if (!$stmt->execute()) |
1551 | 1550 | { |
1552 | - return false; // not found |
|
1551 | + return false; // not found |
|
1553 | 1552 | } |
1554 | 1553 | $parents = array(); |
1555 | - foreach($stmt as $row) |
|
1554 | + foreach ($stmt as $row) |
|
1556 | 1555 | { |
1557 | - if ($row['fs_dir'] > 1 && !in_array($row['fs_dir'],$parents)) |
|
1556 | + if ($row['fs_dir'] > 1 && !in_array($row['fs_dir'], $parents)) |
|
1558 | 1557 | { |
1559 | 1558 | $parents[] = $row['fs_dir']; |
1560 | 1559 | } |
@@ -1564,14 +1563,14 @@ discard block |
||
1564 | 1563 | |
1565 | 1564 | if ($parents && !($parents = self::id2path($parents))) |
1566 | 1565 | { |
1567 | - return false; // parent not found, should never happen ... |
|
1566 | + return false; // parent not found, should never happen ... |
|
1568 | 1567 | } |
1569 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__." trying foreach with:".print_r($rows,true)."#"); |
|
1570 | - foreach((array)$rows as $fs_id => $row) |
|
1568 | + if (self::LOG_LEVEL > 1) error_log(__METHOD__." trying foreach with:".print_r($rows, true)."#"); |
|
1569 | + foreach ((array)$rows as $fs_id => $row) |
|
1571 | 1570 | { |
1572 | 1571 | $parent = $row['fs_dir'] > 1 ? $parents[$row['fs_dir']] : ''; |
1573 | 1572 | |
1574 | - $pathes[$fs_id] = $parent . '/' . $row['fs_name']; |
|
1573 | + $pathes[$fs_id] = $parent.'/'.$row['fs_name']; |
|
1575 | 1574 | } |
1576 | 1575 | if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($fs_ids).')='.array2string($pathes)); |
1577 | 1576 | return is_array($fs_ids) ? $pathes : array_shift($pathes); |
@@ -1595,7 +1594,7 @@ discard block |
||
1595 | 1594 | $parts = explode('.', $name); |
1596 | 1595 | if ($parts > 1 && mb_strlen($extension = '.'.array_pop($parts)) <= $fs_name_precision) |
1597 | 1596 | { |
1598 | - $name = mb_substr(implode('.', $parts), 0, $fs_name_precision-mb_strlen($extension)).$extension; |
|
1597 | + $name = mb_substr(implode('.', $parts), 0, $fs_name_precision - mb_strlen($extension)).$extension; |
|
1599 | 1598 | } |
1600 | 1599 | else |
1601 | 1600 | { |
@@ -1616,9 +1615,8 @@ discard block |
||
1616 | 1615 | $stat = array( |
1617 | 1616 | 'ino' => $info['fs_id'], |
1618 | 1617 | 'name' => $info['fs_name'], |
1619 | - 'mode' => $info['fs_mode'] | |
|
1620 | - ($info['fs_mime'] == self::DIR_MIME_TYPE ? self::MODE_DIR : |
|
1621 | - ($info['fs_mime'] == self::SYMLINK_MIME_TYPE ? self::MODE_LINK : self::MODE_FILE)), // required by the stream wrapper |
|
1618 | + 'mode' => $info['fs_mode']| |
|
1619 | + ($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 |
|
1622 | 1620 | 'size' => $info['fs_size'], |
1623 | 1621 | 'uid' => $info['fs_uid'], |
1624 | 1622 | 'gid' => $info['fs_gid'], |
@@ -1658,7 +1656,7 @@ discard block |
||
1658 | 1656 | { |
1659 | 1657 | $egw_db = isset($GLOBALS['egw_setup']) ? $GLOBALS['egw_setup']->db : $GLOBALS['egw']->db; |
1660 | 1658 | |
1661 | - switch($egw_db->Type) |
|
1659 | + switch ($egw_db->Type) |
|
1662 | 1660 | { |
1663 | 1661 | case 'mysqli': |
1664 | 1662 | case 'mysqlt': |
@@ -1676,29 +1674,29 @@ discard block |
||
1676 | 1674 | |
1677 | 1675 | $dsn = self::$pdo_type.':dbname='.$egw_db->Database.($host ? ';host='.$host.($egw_db->Port ? ';port='.$egw_db->Port : '') : ''); |
1678 | 1676 | // check once if pdo extension and DB specific driver is loaded or can be loaded |
1679 | - static $pdo_available=null; |
|
1677 | + static $pdo_available = null; |
|
1680 | 1678 | if (is_null($pdo_available)) |
1681 | 1679 | { |
1682 | - foreach(array('pdo','pdo_'.self::$pdo_type) as $ext) |
|
1680 | + foreach (array('pdo', 'pdo_'.self::$pdo_type) as $ext) |
|
1683 | 1681 | { |
1684 | - check_load_extension($ext,true); // true = throw Exception |
|
1682 | + check_load_extension($ext, true); // true = throw Exception |
|
1685 | 1683 | } |
1686 | 1684 | $pdo_available = true; |
1687 | 1685 | } |
1688 | 1686 | try { |
1689 | - self::$pdo = new \PDO($dsn,$egw_db->User,$egw_db->Password,array( |
|
1687 | + self::$pdo = new \PDO($dsn, $egw_db->User, $egw_db->Password, array( |
|
1690 | 1688 | \PDO::ATTR_ERRMODE=>\PDO::ERRMODE_EXCEPTION, |
1691 | 1689 | )); |
1692 | 1690 | } |
1693 | - catch(Exception $e) |
|
1691 | + catch (Exception $e) |
|
1694 | 1692 | { |
1695 | 1693 | unset($e); |
1696 | 1694 | // Exception reveals password, so we ignore the exception and connect again without pw, to get the right exception without pw |
1697 | - self::$pdo = new \PDO($dsn,$egw_db->User,'$egw_db->Password'); |
|
1695 | + self::$pdo = new \PDO($dsn, $egw_db->User, '$egw_db->Password'); |
|
1698 | 1696 | } |
1699 | 1697 | // set client charset of the connection |
1700 | 1698 | $charset = translation::charset(); |
1701 | - switch(self::$pdo_type) |
|
1699 | + switch (self::$pdo_type) |
|
1702 | 1700 | { |
1703 | 1701 | case 'mysql': |
1704 | 1702 | if (isset($egw_db->Link_ID->charset2mysql[$charset])) $charset = $egw_db->Link_ID->charset2mysql[$charset]; |
@@ -1724,7 +1722,7 @@ discard block |
||
1724 | 1722 | { |
1725 | 1723 | if (is_numeric($time)) |
1726 | 1724 | { |
1727 | - $time = date('Y-m-d H:i:s',$time); |
|
1725 | + $time = date('Y-m-d H:i:s', $time); |
|
1728 | 1726 | } |
1729 | 1727 | return $time; |
1730 | 1728 | } |
@@ -1774,10 +1772,10 @@ discard block |
||
1774 | 1772 | { |
1775 | 1773 | if (is_object($GLOBALS['egw_setup']->db)) // if we run under setup, query the db for the files dir |
1776 | 1774 | { |
1777 | - $GLOBALS['egw_info']['server']['files_dir'] = $GLOBALS['egw_setup']->db->select('egw_config','config_value',array( |
|
1775 | + $GLOBALS['egw_info']['server']['files_dir'] = $GLOBALS['egw_setup']->db->select('egw_config', 'config_value', array( |
|
1778 | 1776 | 'config_name' => 'files_dir', |
1779 | 1777 | 'config_app' => 'phpgwapi', |
1780 | - ),__LINE__,__FILE__)->fetchColumn(); |
|
1778 | + ), __LINE__, __FILE__)->fetchColumn(); |
|
1781 | 1779 | } |
1782 | 1780 | } |
1783 | 1781 | if (!$GLOBALS['egw_info']['server']['files_dir']) |
@@ -1786,14 +1784,14 @@ discard block |
||
1786 | 1784 | } |
1787 | 1785 | $hash = array(); |
1788 | 1786 | $n = $id; |
1789 | - while(($n = (int) ($n / self::HASH_MAX))) |
|
1787 | + while (($n = (int)($n / self::HASH_MAX))) |
|
1790 | 1788 | { |
1791 | - $hash[] = sprintf('%02d',$n % self::HASH_MAX); |
|
1789 | + $hash[] = sprintf('%02d', $n % self::HASH_MAX); |
|
1792 | 1790 | } |
1793 | - if (!$hash) $hash[] = '00'; // we need at least one directory, to not conflict with the dir-names |
|
1794 | - array_unshift($hash,$id); |
|
1791 | + if (!$hash) $hash[] = '00'; // we need at least one directory, to not conflict with the dir-names |
|
1792 | + array_unshift($hash, $id); |
|
1795 | 1793 | |
1796 | - $path = '/sqlfs/'.implode('/',array_reverse($hash)); |
|
1794 | + $path = '/sqlfs/'.implode('/', array_reverse($hash)); |
|
1797 | 1795 | //error_log(__METHOD__."($id) = '$path'"); |
1798 | 1796 | return $GLOBALS['egw_info']['server']['files_dir'].$path; |
1799 | 1797 | } |
@@ -1809,7 +1807,7 @@ discard block |
||
1809 | 1807 | |
1810 | 1808 | if ($parts['pass'] || $parts['scheme']) |
1811 | 1809 | { |
1812 | - $url = $parts['scheme'].'://'.($parts['user'] ? $parts['user'].($parts['pass']?':...':'').'@' : ''). |
|
1810 | + $url = $parts['scheme'].'://'.($parts['user'] ? $parts['user'].($parts['pass'] ? ':...' : '').'@' : ''). |
|
1813 | 1811 | $parts['host'].$parts['path']; |
1814 | 1812 | } |
1815 | 1813 | } |
@@ -1824,10 +1822,10 @@ discard block |
||
1824 | 1822 | { |
1825 | 1823 | $operation = self::DEFAULT_OPERATION; |
1826 | 1824 | |
1827 | - if (strpos(is_array($url) ? $url['query'] : $url,'storage=') !== false) |
|
1825 | + if (strpos(is_array($url) ? $url['query'] : $url, 'storage=') !== false) |
|
1828 | 1826 | { |
1829 | 1827 | $query = null; |
1830 | - parse_str(is_array($url) ? $url['query'] : Vfs::parse_url($url,PHP_URL_QUERY), $query); |
|
1828 | + parse_str(is_array($url) ? $url['query'] : Vfs::parse_url($url, PHP_URL_QUERY), $query); |
|
1831 | 1829 | switch ($query['storage']) |
1832 | 1830 | { |
1833 | 1831 | case 'db': |
@@ -1850,27 +1848,27 @@ discard block |
||
1850 | 1848 | * @param array $props array of array with values for keys 'name', 'ns', 'val' (null to delete the prop) |
1851 | 1849 | * @return boolean true if props are updated, false otherwise (eg. ressource not found) |
1852 | 1850 | */ |
1853 | - static function proppatch($path,array $props) |
|
1851 | + static function proppatch($path, array $props) |
|
1854 | 1852 | { |
1855 | 1853 | if (self::LOG_LEVEL > 1) error_log(__METHOD__."(".array2string($path).','.array2string($props)); |
1856 | 1854 | if (!is_numeric($path)) |
1857 | 1855 | { |
1858 | - if (!($stat = self::url_stat($path,0))) |
|
1856 | + if (!($stat = self::url_stat($path, 0))) |
|
1859 | 1857 | { |
1860 | 1858 | return false; |
1861 | 1859 | } |
1862 | 1860 | $id = $stat['ino']; |
1863 | 1861 | } |
1864 | - elseif(!($path = self::id2path($id=$path))) |
|
1862 | + elseif (!($path = self::id2path($id = $path))) |
|
1865 | 1863 | { |
1866 | 1864 | return false; |
1867 | 1865 | } |
1868 | - if (!Vfs::check_access($path,EGW_ACL_EDIT,$stat)) |
|
1866 | + if (!Vfs::check_access($path, EGW_ACL_EDIT, $stat)) |
|
1869 | 1867 | { |
1870 | - return false; // permission denied |
|
1868 | + return false; // permission denied |
|
1871 | 1869 | } |
1872 | 1870 | $ins_stmt = $del_stmt = null; |
1873 | - foreach($props as &$prop) |
|
1871 | + foreach ($props as &$prop) |
|
1874 | 1872 | { |
1875 | 1873 | if (!isset($prop['ns'])) $prop['ns'] = Vfs::DEFAULT_PROP_NAMESPACE; |
1876 | 1874 | |
@@ -1915,14 +1913,14 @@ discard block |
||
1915 | 1913 | * @return array|boolean false on error ($path_ids does not exist), array with props (values for keys 'name', 'ns', 'value'), or |
1916 | 1914 | * fs_id/path => array of props for $depth==1 or is_array($path_ids) |
1917 | 1915 | */ |
1918 | - static function propfind($path_ids,$ns=Vfs::DEFAULT_PROP_NAMESPACE) |
|
1916 | + static function propfind($path_ids, $ns = Vfs::DEFAULT_PROP_NAMESPACE) |
|
1919 | 1917 | { |
1920 | 1918 | $ids = is_array($path_ids) ? $path_ids : array($path_ids); |
1921 | - foreach($ids as &$id) |
|
1919 | + foreach ($ids as &$id) |
|
1922 | 1920 | { |
1923 | 1921 | if (!is_numeric($id)) |
1924 | 1922 | { |
1925 | - if (!($stat = self::url_stat($id,0))) |
|
1923 | + if (!($stat = self::url_stat($id, 0))) |
|
1926 | 1924 | { |
1927 | 1925 | if (self::LOG_LEVEL) error_log(__METHOD__."(".array2string($path_ids).",$ns) path '$id' not found!"); |
1928 | 1926 | return false; |
@@ -1932,7 +1930,7 @@ discard block |
||
1932 | 1930 | } |
1933 | 1931 | if (count($ids) >= 1) array_map(function(&$v) { $v = (int)$v; },$ids); |
1934 | 1932 | $query = 'SELECT * FROM '.self::PROPS_TABLE.' WHERE (fs_id'. |
1935 | - (count($ids) == 1 ? '='.(int)implode('',$ids) : ' IN ('.implode(',',$ids).')').')'. |
|
1933 | + (count($ids) == 1 ? '='.(int)implode('', $ids) : ' IN ('.implode(',', $ids).')').')'. |
|
1936 | 1934 | (!is_null($ns) ? ' AND prop_namespace=?' : ''); |
1937 | 1935 | if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; |
1938 | 1936 | |
@@ -1941,7 +1939,7 @@ discard block |
||
1941 | 1939 | $stmt->execute(!is_null($ns) ? array($ns) : array()); |
1942 | 1940 | |
1943 | 1941 | $props = array(); |
1944 | - foreach($stmt as $row) |
|
1942 | + foreach ($stmt as $row) |
|
1945 | 1943 | { |
1946 | 1944 | $props[$row['fs_id']][] = array( |
1947 | 1945 | 'val' => $row['prop_value'], |
@@ -1951,19 +1949,19 @@ discard block |
||
1951 | 1949 | } |
1952 | 1950 | if (!is_array($path_ids)) |
1953 | 1951 | { |
1954 | - $props = $props[$row['fs_id']] ? $props[$row['fs_id']] : array(); // return empty array for no props |
|
1952 | + $props = $props[$row['fs_id']] ? $props[$row['fs_id']] : array(); // return empty array for no props |
|
1955 | 1953 | } |
1956 | 1954 | elseif ($props && isset($stat)) // need to map fs_id's to pathes |
1957 | 1955 | { |
1958 | - foreach(self::id2path(array_keys($props)) as $id => $path) |
|
1956 | + foreach (self::id2path(array_keys($props)) as $id => $path) |
|
1959 | 1957 | { |
1960 | - $props[$path] =& $props[$id]; |
|
1958 | + $props[$path] = & $props[$id]; |
|
1961 | 1959 | unset($props[$id]); |
1962 | 1960 | } |
1963 | 1961 | } |
1964 | 1962 | if (self::LOG_LEVEL > 1) |
1965 | 1963 | { |
1966 | - foreach((array)$props as $k => $v) |
|
1964 | + foreach ((array)$props as $k => $v) |
|
1967 | 1965 | { |
1968 | 1966 | error_log(__METHOD__."($path_ids,$ns) $k => ".array2string($v)); |
1969 | 1967 | } |
@@ -204,7 +204,10 @@ discard block |
||
204 | 204 | */ |
205 | 205 | function stream_open ( $url, $mode, $options, &$opened_path, array $overwrite_new=null ) |
206 | 206 | { |
207 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$mode,$options)"); |
|
207 | + if (self::LOG_LEVEL > 1) |
|
208 | + { |
|
209 | + error_log(__METHOD__."($url,$mode,$options)"); |
|
210 | + } |
|
208 | 211 | |
209 | 212 | $path = Vfs::parse_url($url,PHP_URL_PATH); |
210 | 213 | $this->operation = self::url2operation($url); |
@@ -216,7 +219,9 @@ discard block |
||
216 | 219 | |
217 | 220 | parse_str(parse_url($url, PHP_URL_QUERY), $this->dir_url_params); |
218 | 221 | |
219 | - 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 |
|
222 | + if (!is_null($overwrite_new) || !($stat = static::url_stat($path,STREAM_URL_STAT_QUIET)) || $mode[0] == 'x') |
|
223 | + { |
|
224 | + // file not found or file should NOT exist |
|
220 | 225 | { |
221 | 226 | if ($mode[0] == 'r' || // does $mode require the file to exist (r,r+) |
222 | 227 | $mode[0] == 'x' && $stat || // or file should not exist, but does |
@@ -224,7 +229,11 @@ discard block |
||
224 | 229 | !Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat)) // or we are not allowed to create it |
225 | 230 | { |
226 | 231 | self::_remove_password($url); |
227 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) file does not exist or can not be created!"); |
|
232 | + } |
|
233 | + if (self::LOG_LEVEL) |
|
234 | + { |
|
235 | + error_log(__METHOD__."($url,$mode,$options) file does not exist or can not be created!"); |
|
236 | + } |
|
228 | 237 | if (($options & STREAM_REPORT_ERRORS)) |
229 | 238 | { |
230 | 239 | trigger_error(__METHOD__."($url,$mode,$options) file does not exist or can not be created!",E_USER_WARNING); |
@@ -236,7 +245,10 @@ discard block |
||
236 | 245 | $new_file = true; |
237 | 246 | $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'. |
238 | 247 | ') VALUES (:fs_name,:fs_dir,:fs_mode,:fs_uid,:fs_gid,:fs_created,:fs_modified,:fs_creator,:fs_mime,:fs_size,:fs_active)'; |
239 | - if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; |
|
248 | + if (self::LOG_LEVEL > 2) |
|
249 | + { |
|
250 | + $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; |
|
251 | + } |
|
240 | 252 | $stmt = self::$pdo->prepare($query); |
241 | 253 | $values = array( |
242 | 254 | 'fs_name' => self::limit_filename(Vfs::basename($path)), |
@@ -254,11 +266,17 @@ discard block |
||
254 | 266 | 'fs_size' => 0, |
255 | 267 | 'fs_active' => self::_pdo_boolean(true), |
256 | 268 | ); |
257 | - if ($overwrite_new) $values = array_merge($values,$overwrite_new); |
|
269 | + if ($overwrite_new) |
|
270 | + { |
|
271 | + $values = array_merge($values,$overwrite_new); |
|
272 | + } |
|
258 | 273 | if (!$stmt->execute($values) || !($this->opened_fs_id = self::$pdo->lastInsertId('egw_sqlfs_fs_id_seq'))) |
259 | 274 | { |
260 | 275 | $this->opened_stream = $this->opened_path = $this->opened_mode = null; |
261 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) execute() failed: ".self::$pdo->errorInfo()); |
|
276 | + if (self::LOG_LEVEL) |
|
277 | + { |
|
278 | + error_log(__METHOD__."($url,$mode,$options) execute() failed: ".self::$pdo->errorInfo()); |
|
279 | + } |
|
262 | 280 | return false; |
263 | 281 | } |
264 | 282 | if ($this->operation == self::STORE2DB) |
@@ -270,14 +288,20 @@ discard block |
||
270 | 288 | elseif(!file_exists($fs_dir=Vfs::dirname(self::_fs_path($this->opened_fs_id)))) |
271 | 289 | { |
272 | 290 | $umaskbefore = umask(); |
273 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__." about to call mkdir for $fs_dir # Present UMASK:".decoct($umaskbefore)." called from:".function_backtrace()); |
|
291 | + if (self::LOG_LEVEL > 1) |
|
292 | + { |
|
293 | + error_log(__METHOD__." about to call mkdir for $fs_dir # Present UMASK:".decoct($umaskbefore)." called from:".function_backtrace()); |
|
294 | + } |
|
274 | 295 | self::mkdir_recursive($fs_dir,0700,true); |
275 | 296 | } |
276 | 297 | } |
277 | 298 | // check if opend file is a directory |
278 | 299 | elseif($stat && ($stat['mode'] & self::MODE_DIR) == self::MODE_DIR) |
279 | 300 | { |
280 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) Is a directory!"); |
|
301 | + if (self::LOG_LEVEL) |
|
302 | + { |
|
303 | + error_log(__METHOD__."($url,$mode,$options) Is a directory!"); |
|
304 | + } |
|
281 | 305 | if (($options & STREAM_REPORT_ERRORS)) |
282 | 306 | { |
283 | 307 | trigger_error(__METHOD__."($url,$mode,$options) Is a directory!",E_USER_WARNING); |
@@ -288,11 +312,17 @@ discard block |
||
288 | 312 | else |
289 | 313 | { |
290 | 314 | if ($mode == 'r' && !Vfs::check_access($url,Vfs::READABLE ,$stat) ||// we are not allowed to read |
291 | - $mode != 'r' && !Vfs::check_access($url,Vfs::WRITABLE,$stat)) // or edit it |
|
315 | + $mode != 'r' && !Vfs::check_access($url,Vfs::WRITABLE,$stat)) |
|
316 | + { |
|
317 | + // or edit it |
|
292 | 318 | { |
293 | 319 | self::_remove_password($url); |
320 | + } |
|
294 | 321 | $op = $mode == 'r' ? 'read' : 'edited'; |
295 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) file can not be $op!"); |
|
322 | + if (self::LOG_LEVEL) |
|
323 | + { |
|
324 | + error_log(__METHOD__."($url,$mode,$options) file can not be $op!"); |
|
325 | + } |
|
296 | 326 | if (($options & STREAM_REPORT_ERRORS)) |
297 | 327 | { |
298 | 328 | trigger_error(__METHOD__."($url,$mode,$options) file can not be $op!",E_USER_WARNING); |
@@ -324,7 +354,10 @@ discard block |
||
324 | 354 | // do we operate directly on the filesystem --> open file from there |
325 | 355 | if ($this->operation == self::STORE2FS) |
326 | 356 | { |
327 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__." fopen (may create a directory? mkdir) ($this->opened_fs_id,$mode,$options)"); |
|
357 | + if (self::LOG_LEVEL > 1) |
|
358 | + { |
|
359 | + error_log(__METHOD__." fopen (may create a directory? mkdir) ($this->opened_fs_id,$mode,$options)"); |
|
360 | + } |
|
328 | 361 | if (!($this->opened_stream = fopen(self::_fs_path($this->opened_fs_id),$mode)) && $new_file) |
329 | 362 | { |
330 | 363 | // delete db entry again, if we are not able to open a new(!) file |
@@ -333,11 +366,17 @@ discard block |
||
333 | 366 | $stmt->execute(array('fs_id' => $this->opened_fs_id)); |
334 | 367 | } |
335 | 368 | } |
336 | - if ($mode[0] == 'a') // append modes: a, a+ |
|
369 | + if ($mode[0] == 'a') |
|
370 | + { |
|
371 | + // append modes: a, a+ |
|
337 | 372 | { |
338 | 373 | $this->stream_seek(0,SEEK_END); |
339 | 374 | } |
340 | - if (!is_resource($this->opened_stream)) error_log(__METHOD__."($url,$mode,$options) NO stream, returning false!"); |
|
375 | + } |
|
376 | + if (!is_resource($this->opened_stream)) |
|
377 | + { |
|
378 | + error_log(__METHOD__."($url,$mode,$options) NO stream, returning false!"); |
|
379 | + } |
|
341 | 380 | |
342 | 381 | return is_resource($this->opened_stream); |
343 | 382 | } |
@@ -349,7 +388,10 @@ discard block |
||
349 | 388 | */ |
350 | 389 | function stream_close ( ) |
351 | 390 | { |
352 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."()"); |
|
391 | + if (self::LOG_LEVEL > 1) |
|
392 | + { |
|
393 | + error_log(__METHOD__."()"); |
|
394 | + } |
|
353 | 395 | |
354 | 396 | if (is_null($this->opened_path) || !is_resource($this->opened_stream) || !$this->opened_fs_id) |
355 | 397 | { |
@@ -419,7 +461,10 @@ discard block |
||
419 | 461 | */ |
420 | 462 | function stream_read ( $count ) |
421 | 463 | { |
422 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($count) pos=$this->opened_pos"); |
|
464 | + if (self::LOG_LEVEL > 1) |
|
465 | + { |
|
466 | + error_log(__METHOD__."($count) pos=$this->opened_pos"); |
|
467 | + } |
|
423 | 468 | |
424 | 469 | if (is_resource($this->opened_stream)) |
425 | 470 | { |
@@ -441,7 +486,10 @@ discard block |
||
441 | 486 | */ |
442 | 487 | function stream_write ( $data ) |
443 | 488 | { |
444 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($data)"); |
|
489 | + if (self::LOG_LEVEL > 1) |
|
490 | + { |
|
491 | + error_log(__METHOD__."($data)"); |
|
492 | + } |
|
445 | 493 | |
446 | 494 | if (is_resource($this->opened_stream)) |
447 | 495 | { |
@@ -478,7 +526,10 @@ discard block |
||
478 | 526 | */ |
479 | 527 | function stream_tell ( ) |
480 | 528 | { |
481 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."()"); |
|
529 | + if (self::LOG_LEVEL > 1) |
|
530 | + { |
|
531 | + error_log(__METHOD__."()"); |
|
532 | + } |
|
482 | 533 | |
483 | 534 | if (is_resource($this->opened_stream)) |
484 | 535 | { |
@@ -501,7 +552,10 @@ discard block |
||
501 | 552 | */ |
502 | 553 | function stream_seek ( $offset, $whence ) |
503 | 554 | { |
504 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($offset,$whence)"); |
|
555 | + if (self::LOG_LEVEL > 1) |
|
556 | + { |
|
557 | + error_log(__METHOD__."($offset,$whence)"); |
|
558 | + } |
|
505 | 559 | |
506 | 560 | if (is_resource($this->opened_stream)) |
507 | 561 | { |
@@ -519,7 +573,10 @@ discard block |
||
519 | 573 | */ |
520 | 574 | function stream_flush ( ) |
521 | 575 | { |
522 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."()"); |
|
576 | + if (self::LOG_LEVEL > 1) |
|
577 | + { |
|
578 | + error_log(__METHOD__."()"); |
|
579 | + } |
|
523 | 580 | |
524 | 581 | if (is_resource($this->opened_stream)) |
525 | 582 | { |
@@ -544,7 +601,10 @@ discard block |
||
544 | 601 | */ |
545 | 602 | function stream_stat ( ) |
546 | 603 | { |
547 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($this->opened_path)"); |
|
604 | + if (self::LOG_LEVEL > 1) |
|
605 | + { |
|
606 | + error_log(__METHOD__."($this->opened_path)"); |
|
607 | + } |
|
548 | 608 | |
549 | 609 | return $this->url_stat($this->opened_path,0); |
550 | 610 | } |
@@ -560,24 +620,36 @@ discard block |
||
560 | 620 | */ |
561 | 621 | static function unlink ( $url, $parent_stat=null ) |
562 | 622 | { |
563 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url)"); |
|
623 | + if (self::LOG_LEVEL > 1) |
|
624 | + { |
|
625 | + error_log(__METHOD__."($url)"); |
|
626 | + } |
|
564 | 627 | |
565 | 628 | $path = Vfs::parse_url($url,PHP_URL_PATH); |
566 | 629 | |
567 | 630 | // need to get parent stat from Sqlfs, not Vfs |
568 | - if (!isset($parent_stat)) $parent_stat = static::url_stat(Vfs::dirname($path), STREAM_URL_STAT_LINK); |
|
631 | + if (!isset($parent_stat)) |
|
632 | + { |
|
633 | + $parent_stat = static::url_stat(Vfs::dirname($path), STREAM_URL_STAT_LINK); |
|
634 | + } |
|
569 | 635 | |
570 | 636 | if (!$parent_stat || !($stat = self::url_stat($path,STREAM_URL_STAT_LINK)) || |
571 | 637 | !Vfs::check_access(Vfs::dirname($path),Vfs::WRITABLE, $parent_stat)) |
572 | 638 | { |
573 | 639 | self::_remove_password($url); |
574 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!"); |
|
640 | + if (self::LOG_LEVEL) |
|
641 | + { |
|
642 | + error_log(__METHOD__."($url) permission denied!"); |
|
643 | + } |
|
575 | 644 | return false; // no permission or file does not exist |
576 | 645 | } |
577 | 646 | if ($stat['mime'] == self::DIR_MIME_TYPE) |
578 | 647 | { |
579 | 648 | self::_remove_password($url); |
580 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url) is NO file!"); |
|
649 | + if (self::LOG_LEVEL) |
|
650 | + { |
|
651 | + error_log(__METHOD__."($url) is NO file!"); |
|
652 | + } |
|
581 | 653 | return false; // no permission or file does not exist |
582 | 654 | } |
583 | 655 | $stmt = self::$pdo->prepare('DELETE FROM '.self::TABLE.' WHERE fs_id=:fs_id'); |
@@ -612,7 +684,10 @@ discard block |
||
612 | 684 | */ |
613 | 685 | static function rename ( $url_from, $url_to) |
614 | 686 | { |
615 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url_from,$url_to)"); |
|
687 | + if (self::LOG_LEVEL > 1) |
|
688 | + { |
|
689 | + error_log(__METHOD__."($url_from,$url_to)"); |
|
690 | + } |
|
616 | 691 | |
617 | 692 | $path_from = Vfs::parse_url($url_from,PHP_URL_PATH); |
618 | 693 | $from_dir = Vfs::dirname($path_from); |
@@ -626,14 +701,20 @@ discard block |
||
626 | 701 | { |
627 | 702 | self::_remove_password($url_from); |
628 | 703 | self::_remove_password($url_to); |
629 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $path_from permission denied!"); |
|
704 | + if (self::LOG_LEVEL) |
|
705 | + { |
|
706 | + error_log(__METHOD__."($url_from,$url_to): $path_from permission denied!"); |
|
707 | + } |
|
630 | 708 | return false; // no permission or file does not exist |
631 | 709 | } |
632 | 710 | if (!Vfs::check_access($to_dir, Vfs::WRITABLE, $to_dir_stat = static::url_stat($to_dir, 0))) |
633 | 711 | { |
634 | 712 | self::_remove_password($url_from); |
635 | 713 | self::_remove_password($url_to); |
636 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $path_to permission denied!"); |
|
714 | + if (self::LOG_LEVEL) |
|
715 | + { |
|
716 | + error_log(__METHOD__."($url_from,$url_to): $path_to permission denied!"); |
|
717 | + } |
|
637 | 718 | return false; // no permission or parent-dir does not exist |
638 | 719 | } |
639 | 720 | // the filesystem stream-wrapper does NOT allow to rename files to directories, as this makes problems |
@@ -644,14 +725,20 @@ discard block |
||
644 | 725 | self::_remove_password($url_from); |
645 | 726 | self::_remove_password($url_to); |
646 | 727 | $is_dir = $to_stat['mime'] === self::DIR_MIME_TYPE ? 'a' : 'no'; |
647 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url_to,$url_from) $path_to is $is_dir directory!"); |
|
728 | + if (self::LOG_LEVEL) |
|
729 | + { |
|
730 | + error_log(__METHOD__."($url_to,$url_from) $path_to is $is_dir directory!"); |
|
731 | + } |
|
648 | 732 | return false; // no permission or file does not exist |
649 | 733 | } |
650 | 734 | // if destination file already exists, delete it |
651 | 735 | if ($to_stat && !static::unlink($url_to,$operation)) |
652 | 736 | { |
653 | 737 | self::_remove_password($url_to); |
654 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url_to,$url_from) can't unlink existing $url_to!"); |
|
738 | + if (self::LOG_LEVEL) |
|
739 | + { |
|
740 | + error_log(__METHOD__."($url_to,$url_from) can't unlink existing $url_to!"); |
|
741 | + } |
|
655 | 742 | return false; |
656 | 743 | } |
657 | 744 | unset(self::$stat_cache[$path_from]); |
@@ -689,7 +776,10 @@ discard block |
||
689 | 776 | { |
690 | 777 | $maxdepth=10; |
691 | 778 | $depth2propagate = (int)$depth + 1; |
692 | - if ($depth2propagate > $maxdepth) return is_dir($pathname); |
|
779 | + if ($depth2propagate > $maxdepth) |
|
780 | + { |
|
781 | + return is_dir($pathname); |
|
782 | + } |
|
693 | 783 | is_dir(Vfs::dirname($pathname)) || self::mkdir_recursive(Vfs::dirname($pathname), $mode, $depth2propagate); |
694 | 784 | return is_dir($pathname) || @mkdir($pathname, $mode); |
695 | 785 | } |
@@ -707,14 +797,23 @@ discard block |
||
707 | 797 | */ |
708 | 798 | static function mkdir ( $url, $mode, $options ) |
709 | 799 | { |
710 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$mode,$options)"); |
|
711 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__." called from:".function_backtrace()); |
|
800 | + if (self::LOG_LEVEL > 1) |
|
801 | + { |
|
802 | + error_log(__METHOD__."($url,$mode,$options)"); |
|
803 | + } |
|
804 | + if (self::LOG_LEVEL > 1) |
|
805 | + { |
|
806 | + error_log(__METHOD__." called from:".function_backtrace()); |
|
807 | + } |
|
712 | 808 | $path = Vfs::parse_url($url,PHP_URL_PATH); |
713 | 809 | |
714 | 810 | if (self::url_stat($path,STREAM_URL_STAT_QUIET)) |
715 | 811 | { |
716 | 812 | self::_remove_password($url); |
717 | - if (self::LOG_LEVEL) error_log(__METHOD__."('$url',$mode,$options) already exist!"); |
|
813 | + if (self::LOG_LEVEL) |
|
814 | + { |
|
815 | + error_log(__METHOD__."('$url',$mode,$options) already exist!"); |
|
816 | + } |
|
718 | 817 | if (!($options & STREAM_REPORT_ERRORS)) |
719 | 818 | { |
720 | 819 | //throw new Exception(__METHOD__."('$url',$mode,$options) already exist!"); |
@@ -723,14 +822,20 @@ discard block |
||
723 | 822 | return false; |
724 | 823 | } |
725 | 824 | $parent_path = Vfs::dirname($path); |
726 | - if (($query = Vfs::parse_url($url,PHP_URL_QUERY))) $parent_path .= '?'.$query; |
|
825 | + if (($query = Vfs::parse_url($url,PHP_URL_QUERY))) |
|
826 | + { |
|
827 | + $parent_path .= '?'.$query; |
|
828 | + } |
|
727 | 829 | $parent = self::url_stat($parent_path,STREAM_URL_STAT_QUIET); |
728 | 830 | |
729 | 831 | // check if we should also create all non-existing path components and our parent does not exist, |
730 | 832 | // if yes call ourself recursive with the parent directory |
731 | 833 | if (($options & STREAM_MKDIR_RECURSIVE) && $parent_path != '/' && !$parent) |
732 | 834 | { |
733 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__." creating parents: $parent_path, $mode"); |
|
835 | + if (self::LOG_LEVEL > 1) |
|
836 | + { |
|
837 | + error_log(__METHOD__." creating parents: $parent_path, $mode"); |
|
838 | + } |
|
734 | 839 | if (!self::mkdir($parent_path,$mode,$options)) |
735 | 840 | { |
736 | 841 | return false; |
@@ -740,7 +845,10 @@ discard block |
||
740 | 845 | if (!$parent || !Vfs::check_access($parent_path,Vfs::WRITABLE,$parent)) |
741 | 846 | { |
742 | 847 | self::_remove_password($url); |
743 | - if (self::LOG_LEVEL) error_log(__METHOD__."('$url',$mode,$options) permission denied!"); |
|
848 | + if (self::LOG_LEVEL) |
|
849 | + { |
|
850 | + error_log(__METHOD__."('$url',$mode,$options) permission denied!"); |
|
851 | + } |
|
744 | 852 | if (!($options & STREAM_REPORT_ERRORS)) |
745 | 853 | { |
746 | 854 | trigger_error(__METHOD__."('$url',$mode,$options) permission denied!",E_USER_WARNING); |
@@ -774,10 +882,13 @@ discard block |
||
774 | 882 | 'fs_dir' => $parent['ino'], |
775 | 883 | 'fs_active' => self::_pdo_boolean(true), |
776 | 884 | 'fs_name' => self::limit_filename(Vfs::basename($path)), |
777 | - )) && $stmt->fetchColumn() > 1) // if there's more then one --> remove our new dir |
|
885 | + )) && $stmt->fetchColumn() > 1) |
|
886 | + { |
|
887 | + // if there's more then one --> remove our new dir |
|
778 | 888 | { |
779 | 889 | self::$pdo->query('DELETE FROM '.self::TABLE.' WHERE fs_id='.$new_fs_id); |
780 | 890 | } |
891 | + } |
|
781 | 892 | } |
782 | 893 | return $ok; |
783 | 894 | } |
@@ -794,7 +905,10 @@ discard block |
||
794 | 905 | */ |
795 | 906 | static function rmdir ( $url, $options ) |
796 | 907 | { |
797 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url)"); |
|
908 | + if (self::LOG_LEVEL > 1) |
|
909 | + { |
|
910 | + error_log(__METHOD__."($url)"); |
|
911 | + } |
|
798 | 912 | |
799 | 913 | $path = Vfs::parse_url($url,PHP_URL_PATH); |
800 | 914 | $parent = Vfs::dirname($path); |
@@ -805,7 +919,10 @@ discard block |
||
805 | 919 | self::_remove_password($url); |
806 | 920 | $err_msg = __METHOD__."($url,$options) ".(!$stat ? 'not found!' : |
807 | 921 | ($stat['mime'] != self::DIR_MIME_TYPE ? 'not a directory!' : 'permission denied!')); |
808 | - if (self::LOG_LEVEL) error_log($err_msg); |
|
922 | + if (self::LOG_LEVEL) |
|
923 | + { |
|
924 | + error_log($err_msg); |
|
925 | + } |
|
809 | 926 | if (!($options & STREAM_REPORT_ERRORS)) |
810 | 927 | { |
811 | 928 | trigger_error($err_msg,E_USER_WARNING); |
@@ -817,7 +934,10 @@ discard block |
||
817 | 934 | if ($stmt->fetchColumn()) |
818 | 935 | { |
819 | 936 | self::_remove_password($url); |
820 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url,$options) dir is not empty!"); |
|
937 | + if (self::LOG_LEVEL) |
|
938 | + { |
|
939 | + error_log(__METHOD__."($url,$options) dir is not empty!"); |
|
940 | + } |
|
821 | 941 | if (!($options & STREAM_REPORT_ERRORS)) |
822 | 942 | { |
823 | 943 | trigger_error(__METHOD__."('$url',$options) dir is not empty!",E_USER_WARNING); |
@@ -849,7 +969,10 @@ discard block |
||
849 | 969 | static function touch($url,$time=null,$atime=null) |
850 | 970 | { |
851 | 971 | unset($atime); // not used |
852 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url, $time)"); |
|
972 | + if (self::LOG_LEVEL > 1) |
|
973 | + { |
|
974 | + error_log(__METHOD__."($url, $time)"); |
|
975 | + } |
|
853 | 976 | |
854 | 977 | $path = Vfs::parse_url($url,PHP_URL_PATH); |
855 | 978 | |
@@ -885,25 +1008,37 @@ discard block |
||
885 | 1008 | */ |
886 | 1009 | static function chown($url,$owner) |
887 | 1010 | { |
888 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$owner)"); |
|
1011 | + if (self::LOG_LEVEL > 1) |
|
1012 | + { |
|
1013 | + error_log(__METHOD__."($url,$owner)"); |
|
1014 | + } |
|
889 | 1015 | |
890 | 1016 | $path = Vfs::parse_url($url,PHP_URL_PATH); |
891 | 1017 | |
892 | 1018 | if (!($stat = self::url_stat($path,0))) |
893 | 1019 | { |
894 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) no such file or directory!"); |
|
1020 | + if (self::LOG_LEVEL) |
|
1021 | + { |
|
1022 | + error_log(__METHOD__."($url,$owner) no such file or directory!"); |
|
1023 | + } |
|
895 | 1024 | trigger_error("No such file or directory $url !",E_USER_WARNING); |
896 | 1025 | return false; |
897 | 1026 | } |
898 | 1027 | if (!Vfs::$is_root) |
899 | 1028 | { |
900 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) only root can do that!"); |
|
1029 | + if (self::LOG_LEVEL) |
|
1030 | + { |
|
1031 | + error_log(__METHOD__."($url,$owner) only root can do that!"); |
|
1032 | + } |
|
901 | 1033 | trigger_error("Only root can do that!",E_USER_WARNING); |
902 | 1034 | return false; |
903 | 1035 | } |
904 | - if ($owner < 0 || $owner && !$GLOBALS['egw']->accounts->id2name($owner)) // not a user (0 == root) |
|
1036 | + if ($owner < 0 || $owner && !$GLOBALS['egw']->accounts->id2name($owner)) |
|
1037 | + { |
|
1038 | + // not a user (0 == root) |
|
905 | 1039 | { |
906 | 1040 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) unknown (numeric) user id!"); |
1041 | + } |
|
907 | 1042 | trigger_error(__METHOD__."($url,$owner) Unknown (numeric) user id!",E_USER_WARNING); |
908 | 1043 | //throw new Exception(__METHOD__."($url,$owner) Unknown (numeric) user id!"); |
909 | 1044 | return false; |
@@ -911,7 +1046,10 @@ discard block |
||
911 | 1046 | $stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_uid=:fs_uid WHERE fs_id=:fs_id'); |
912 | 1047 | |
913 | 1048 | // update stat-cache |
914 | - if ($path != '/' && substr($path,-1) == '/') $path = substr($path, 0, -1); |
|
1049 | + if ($path != '/' && substr($path,-1) == '/') |
|
1050 | + { |
|
1051 | + $path = substr($path, 0, -1); |
|
1052 | + } |
|
915 | 1053 | self::$stat_cache[$path]['fs_uid'] = $owner; |
916 | 1054 | |
917 | 1055 | return $stmt->execute(array( |
@@ -929,34 +1067,53 @@ discard block |
||
929 | 1067 | */ |
930 | 1068 | static function chgrp($url,$owner) |
931 | 1069 | { |
932 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$owner)"); |
|
1070 | + if (self::LOG_LEVEL > 1) |
|
1071 | + { |
|
1072 | + error_log(__METHOD__."($url,$owner)"); |
|
1073 | + } |
|
933 | 1074 | |
934 | 1075 | $path = Vfs::parse_url($url,PHP_URL_PATH); |
935 | 1076 | |
936 | 1077 | if (!($stat = self::url_stat($path,0))) |
937 | 1078 | { |
938 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) no such file or directory!"); |
|
1079 | + if (self::LOG_LEVEL) |
|
1080 | + { |
|
1081 | + error_log(__METHOD__."($url,$owner) no such file or directory!"); |
|
1082 | + } |
|
939 | 1083 | trigger_error("No such file or directory $url !",E_USER_WARNING); |
940 | 1084 | return false; |
941 | 1085 | } |
942 | 1086 | if (!Vfs::has_owner_rights($path,$stat)) |
943 | 1087 | { |
944 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) only owner or root can do that!"); |
|
1088 | + if (self::LOG_LEVEL) |
|
1089 | + { |
|
1090 | + error_log(__METHOD__."($url,$owner) only owner or root can do that!"); |
|
1091 | + } |
|
945 | 1092 | trigger_error("Only owner or root can do that!",E_USER_WARNING); |
946 | 1093 | return false; |
947 | 1094 | } |
948 | - if ($owner < 0) $owner = -$owner; // sqlfs uses a positiv group id's! |
|
1095 | + if ($owner < 0) |
|
1096 | + { |
|
1097 | + $owner = -$owner; |
|
1098 | + } |
|
1099 | + // sqlfs uses a positiv group id's! |
|
949 | 1100 | |
950 | - if ($owner && !$GLOBALS['egw']->accounts->id2name(-$owner)) // not a group |
|
1101 | + if ($owner && !$GLOBALS['egw']->accounts->id2name(-$owner)) |
|
1102 | + { |
|
1103 | + // not a group |
|
951 | 1104 | { |
952 | 1105 | if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) unknown (numeric) group id!"); |
1106 | + } |
|
953 | 1107 | trigger_error("Unknown (numeric) group id!",E_USER_WARNING); |
954 | 1108 | return false; |
955 | 1109 | } |
956 | 1110 | $stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_gid=:fs_gid WHERE fs_id=:fs_id'); |
957 | 1111 | |
958 | 1112 | // update stat-cache |
959 | - if ($path != '/' && substr($path,-1) == '/') $path = substr($path, 0, -1); |
|
1113 | + if ($path != '/' && substr($path,-1) == '/') |
|
1114 | + { |
|
1115 | + $path = substr($path, 0, -1); |
|
1116 | + } |
|
960 | 1117 | self::$stat_cache[$path]['fs_gid'] = $owner; |
961 | 1118 | |
962 | 1119 | return $stmt->execute(array( |
@@ -974,32 +1131,47 @@ discard block |
||
974 | 1131 | */ |
975 | 1132 | static function chmod($url,$mode) |
976 | 1133 | { |
977 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url, $mode)"); |
|
1134 | + if (self::LOG_LEVEL > 1) |
|
1135 | + { |
|
1136 | + error_log(__METHOD__."($url, $mode)"); |
|
1137 | + } |
|
978 | 1138 | |
979 | 1139 | $path = Vfs::parse_url($url,PHP_URL_PATH); |
980 | 1140 | |
981 | 1141 | if (!($stat = self::url_stat($path,0))) |
982 | 1142 | { |
983 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url, $mode) no such file or directory!"); |
|
1143 | + if (self::LOG_LEVEL) |
|
1144 | + { |
|
1145 | + error_log(__METHOD__."($url, $mode) no such file or directory!"); |
|
1146 | + } |
|
984 | 1147 | trigger_error("No such file or directory $url !",E_USER_WARNING); |
985 | 1148 | return false; |
986 | 1149 | } |
987 | 1150 | if (!Vfs::has_owner_rights($path,$stat)) |
988 | 1151 | { |
989 | - if (self::LOG_LEVEL) error_log(__METHOD__."($url, $mode) only owner or root can do that!"); |
|
1152 | + if (self::LOG_LEVEL) |
|
1153 | + { |
|
1154 | + error_log(__METHOD__."($url, $mode) only owner or root can do that!"); |
|
1155 | + } |
|
990 | 1156 | trigger_error("Only owner or root can do that!",E_USER_WARNING); |
991 | 1157 | return false; |
992 | 1158 | } |
993 | - if (!is_numeric($mode)) // not a mode |
|
1159 | + if (!is_numeric($mode)) |
|
1160 | + { |
|
1161 | + // not a mode |
|
994 | 1162 | { |
995 | 1163 | if (self::LOG_LEVEL) error_log(__METHOD__."($url, $mode) no (numeric) mode!"); |
1164 | + } |
|
996 | 1165 | trigger_error("No (numeric) mode!",E_USER_WARNING); |
997 | 1166 | return false; |
998 | 1167 | } |
999 | 1168 | $stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_mode=:fs_mode WHERE fs_id=:fs_id'); |
1000 | 1169 | |
1001 | 1170 | // update stat cache |
1002 | - if ($path != '/' && substr($path,-1) == '/') $path = substr($path, 0, -1); |
|
1171 | + if ($path != '/' && substr($path,-1) == '/') |
|
1172 | + { |
|
1173 | + $path = substr($path, 0, -1); |
|
1174 | + } |
|
1003 | 1175 | self::$stat_cache[$path]['fs_mode'] = ((int) $mode) & 0777; |
1004 | 1176 | |
1005 | 1177 | return $stmt->execute(array( |
@@ -1024,11 +1196,17 @@ discard block |
||
1024 | 1196 | |
1025 | 1197 | if (!($stat = self::url_stat($url,0)) || // dir not found |
1026 | 1198 | $stat['mime'] != self::DIR_MIME_TYPE || // no dir |
1027 | - !Vfs::check_access($url,Vfs::EXECUTABLE|Vfs::READABLE,$stat)) // no access |
|
1199 | + !Vfs::check_access($url,Vfs::EXECUTABLE|Vfs::READABLE,$stat)) |
|
1200 | + { |
|
1201 | + // no access |
|
1028 | 1202 | { |
1029 | 1203 | self::_remove_password($url); |
1204 | + } |
|
1030 | 1205 | $msg = $stat['mime'] != self::DIR_MIME_TYPE ? "$url is no directory" : 'permission denied'; |
1031 | - if (self::LOG_LEVEL) error_log(__METHOD__."('$url',$options) $msg!"); |
|
1206 | + if (self::LOG_LEVEL) |
|
1207 | + { |
|
1208 | + error_log(__METHOD__."('$url',$options) $msg!"); |
|
1209 | + } |
|
1032 | 1210 | $this->opened_dir = null; |
1033 | 1211 | return false; |
1034 | 1212 | } |
@@ -1037,7 +1215,10 @@ discard block |
||
1037 | 1215 | ' FROM '.self::TABLE.' WHERE fs_dir=? AND fs_active='.self::_pdo_boolean(true). |
1038 | 1216 | " ORDER BY fs_mime='httpd/unix-directory' DESC, fs_name ASC"; |
1039 | 1217 | //if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; |
1040 | - if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__."($url,$options)".' */ '.$query; |
|
1218 | + if (self::LOG_LEVEL > 2) |
|
1219 | + { |
|
1220 | + $query = '/* '.__METHOD__."($url,$options)".' */ '.$query; |
|
1221 | + } |
|
1041 | 1222 | |
1042 | 1223 | $stmt = self::$pdo->prepare($query); |
1043 | 1224 | $stmt->setFetchMode(\PDO::FETCH_ASSOC); |
@@ -1049,7 +1230,10 @@ discard block |
||
1049 | 1230 | self::$stat_cache[Vfs::concat($path,$file['fs_name'])] = $file; |
1050 | 1231 | } |
1051 | 1232 | } |
1052 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$options): ".implode(', ',$this->opened_dir)); |
|
1233 | + if (self::LOG_LEVEL > 1) |
|
1234 | + { |
|
1235 | + error_log(__METHOD__."($url,$options): ".implode(', ',$this->opened_dir)); |
|
1236 | + } |
|
1053 | 1237 | reset($this->opened_dir); |
1054 | 1238 | |
1055 | 1239 | return true; |
@@ -1088,9 +1272,16 @@ discard block |
||
1088 | 1272 | if (is_null($max_subquery_depth)) |
1089 | 1273 | { |
1090 | 1274 | $max_subquery_depth = $GLOBALS['egw_info']['server']['max_subquery_depth']; |
1091 | - if (!$max_subquery_depth) $max_subquery_depth = 7; // setting current default of 7, if nothing set |
|
1275 | + if (!$max_subquery_depth) |
|
1276 | + { |
|
1277 | + $max_subquery_depth = 7; |
|
1278 | + } |
|
1279 | + // setting current default of 7, if nothing set |
|
1280 | + } |
|
1281 | + if (self::LOG_LEVEL > 1) |
|
1282 | + { |
|
1283 | + error_log(__METHOD__."('$url',$flags,$eacl_access)"); |
|
1092 | 1284 | } |
1093 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$url',$flags,$eacl_access)"); |
|
1094 | 1285 | |
1095 | 1286 | $path = Vfs::parse_url($url,PHP_URL_PATH); |
1096 | 1287 | |
@@ -1156,7 +1347,10 @@ discard block |
||
1156 | 1347 | if (!Vfs::$user) |
1157 | 1348 | { |
1158 | 1349 | self::_remove_password($url); |
1159 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$url',$flags) permission denied, no user-id and not root!"); |
|
1350 | + if (self::LOG_LEVEL > 1) |
|
1351 | + { |
|
1352 | + error_log(__METHOD__."('$url',$flags) permission denied, no user-id and not root!"); |
|
1353 | + } |
|
1160 | 1354 | return false; |
1161 | 1355 | } |
1162 | 1356 | $query .= ' AND '.self::_sql_readable(); |
@@ -1167,7 +1361,10 @@ discard block |
||
1167 | 1361 | $query = str_replace('fs_name'.self::$case_sensitive_equal.'?','fs_name'.self::$case_sensitive_equal.self::$pdo->quote($name),$base_query).'('.$query.')'; |
1168 | 1362 | } |
1169 | 1363 | } |
1170 | - if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__."($url,$flags,$eacl_access)".' */ '.$query; |
|
1364 | + if (self::LOG_LEVEL > 2) |
|
1365 | + { |
|
1366 | + $query = '/* '.__METHOD__."($url,$flags,$eacl_access)".' */ '.$query; |
|
1367 | + } |
|
1171 | 1368 | //if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; |
1172 | 1369 | |
1173 | 1370 | if (!($result = self::$pdo->query($query)) || !($info = $result->fetch(\PDO::FETCH_ASSOC))) |
@@ -1190,12 +1387,18 @@ discard block |
||
1190 | 1387 | $GLOBALS['egw_info']['server']['max_subquery_depth'] = --$max_subquery_depth; |
1191 | 1388 | error_log(__METHOD__."() decremented max_subquery_depth to $max_subquery_depth"); |
1192 | 1389 | config::save_value('max_subquery_depth', $max_subquery_depth, 'phpgwapi'); |
1193 | - if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) $GLOBALS['egw']->invalidate_session_cache(); |
|
1390 | + if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) |
|
1391 | + { |
|
1392 | + $GLOBALS['egw']->invalidate_session_cache(); |
|
1393 | + } |
|
1194 | 1394 | return self::url_stat($url, $flags, $eacl_access); |
1195 | 1395 | } |
1196 | 1396 | self::$stat_cache[$path] = $info; |
1197 | 1397 | |
1198 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$flags)=".array2string($info)); |
|
1398 | + if (self::LOG_LEVEL > 1) |
|
1399 | + { |
|
1400 | + error_log(__METHOD__."($url,$flags)=".array2string($info)); |
|
1401 | + } |
|
1199 | 1402 | return self::_vfsinfo2stat($info); |
1200 | 1403 | } |
1201 | 1404 | |
@@ -1232,9 +1435,15 @@ discard block |
||
1232 | 1435 | */ |
1233 | 1436 | function dir_readdir ( ) |
1234 | 1437 | { |
1235 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."( )"); |
|
1438 | + if (self::LOG_LEVEL > 1) |
|
1439 | + { |
|
1440 | + error_log(__METHOD__."( )"); |
|
1441 | + } |
|
1236 | 1442 | |
1237 | - if (!is_array($this->opened_dir)) return false; |
|
1443 | + if (!is_array($this->opened_dir)) |
|
1444 | + { |
|
1445 | + return false; |
|
1446 | + } |
|
1238 | 1447 | |
1239 | 1448 | $file = current($this->opened_dir); next($this->opened_dir); |
1240 | 1449 | |
@@ -1251,9 +1460,15 @@ discard block |
||
1251 | 1460 | */ |
1252 | 1461 | function dir_rewinddir ( ) |
1253 | 1462 | { |
1254 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."( )"); |
|
1463 | + if (self::LOG_LEVEL > 1) |
|
1464 | + { |
|
1465 | + error_log(__METHOD__."( )"); |
|
1466 | + } |
|
1255 | 1467 | |
1256 | - if (!is_array($this->opened_dir)) return false; |
|
1468 | + if (!is_array($this->opened_dir)) |
|
1469 | + { |
|
1470 | + return false; |
|
1471 | + } |
|
1257 | 1472 | |
1258 | 1473 | reset($this->opened_dir); |
1259 | 1474 | |
@@ -1269,9 +1484,15 @@ discard block |
||
1269 | 1484 | */ |
1270 | 1485 | function dir_closedir ( ) |
1271 | 1486 | { |
1272 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."( )"); |
|
1487 | + if (self::LOG_LEVEL > 1) |
|
1488 | + { |
|
1489 | + error_log(__METHOD__."( )"); |
|
1490 | + } |
|
1273 | 1491 | |
1274 | - if (!is_array($this->opened_dir)) return false; |
|
1492 | + if (!is_array($this->opened_dir)) |
|
1493 | + { |
|
1494 | + return false; |
|
1495 | + } |
|
1275 | 1496 | |
1276 | 1497 | $this->opened_dir = null; |
1277 | 1498 | |
@@ -1290,7 +1511,10 @@ discard block |
||
1290 | 1511 | { |
1291 | 1512 | $link = !($lstat = self::url_stat($path,STREAM_URL_STAT_LINK)) || is_null($lstat['readlink']) ? false : $lstat['readlink']; |
1292 | 1513 | |
1293 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = $link"); |
|
1514 | + if (self::LOG_LEVEL > 1) |
|
1515 | + { |
|
1516 | + error_log(__METHOD__."('$path') = $link"); |
|
1517 | + } |
|
1294 | 1518 | |
1295 | 1519 | return $link; |
1296 | 1520 | } |
@@ -1304,22 +1528,34 @@ discard block |
||
1304 | 1528 | */ |
1305 | 1529 | static function symlink($target,$link) |
1306 | 1530 | { |
1307 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$target','$link')"); |
|
1531 | + if (self::LOG_LEVEL > 1) |
|
1532 | + { |
|
1533 | + error_log(__METHOD__."('$target','$link')"); |
|
1534 | + } |
|
1308 | 1535 | |
1309 | 1536 | if (self::url_stat($link,0)) |
1310 | 1537 | { |
1311 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$target','$link') $link exists, returning false!"); |
|
1538 | + if (self::LOG_LEVEL > 0) |
|
1539 | + { |
|
1540 | + error_log(__METHOD__."('$target','$link') $link exists, returning false!"); |
|
1541 | + } |
|
1312 | 1542 | return false; // $link already exists |
1313 | 1543 | } |
1314 | 1544 | if (!($dir = Vfs::dirname($link)) || |
1315 | 1545 | !Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat=static::url_stat($dir,0))) |
1316 | 1546 | { |
1317 | - if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$target','$link') returning false! (!is_writable('$dir'), dir_stat=".array2string($dir_stat).")"); |
|
1547 | + if (self::LOG_LEVEL > 0) |
|
1548 | + { |
|
1549 | + error_log(__METHOD__."('$target','$link') returning false! (!is_writable('$dir'), dir_stat=".array2string($dir_stat).")"); |
|
1550 | + } |
|
1318 | 1551 | return false; // parent dir does not exist or is not writable |
1319 | 1552 | } |
1320 | 1553 | $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'. |
1321 | 1554 | ') VALUES (:fs_name,:fs_dir,:fs_mode,:fs_uid,:fs_gid,:fs_created,:fs_modified,:fs_creator,:fs_mime,:fs_size,:fs_link)'; |
1322 | - if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; |
|
1555 | + if (self::LOG_LEVEL > 2) |
|
1556 | + { |
|
1557 | + $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; |
|
1558 | + } |
|
1323 | 1559 | $stmt = self::$pdo->prepare($query); |
1324 | 1560 | unset(self::$stat_cache[Vfs::parse_url($link,PHP_URL_PATH)]); |
1325 | 1561 | |
@@ -1367,7 +1603,10 @@ discard block |
||
1367 | 1603 | break; |
1368 | 1604 | } |
1369 | 1605 | } |
1370 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$check) ".($access?"access granted by $path=$rights":'no access!!!')); |
|
1606 | + if (self::LOG_LEVEL > 1) |
|
1607 | + { |
|
1608 | + error_log(__METHOD__."($url,$check) ".($access?"access granted by $path=$rights":'no access!!!')); |
|
1609 | + } |
|
1371 | 1610 | return $access; |
1372 | 1611 | } |
1373 | 1612 | |
@@ -1395,11 +1634,15 @@ discard block |
||
1395 | 1634 | } |
1396 | 1635 | } |
1397 | 1636 | // sort by length descending, to allow more specific pathes to have precedence |
1398 | - uksort(self::$extended_acl, function($a,$b) { |
|
1637 | + uksort(self::$extended_acl, function($a,$b) |
|
1638 | + { |
|
1399 | 1639 | return strlen($b)-strlen($a); |
1400 | 1640 | }); |
1401 | 1641 | egw_cache::setSession(self::EACL_APPNAME, 'extended_acl', self::$extended_acl); |
1402 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__.'() '.array2string(self::$extended_acl)); |
|
1642 | + if (self::LOG_LEVEL > 1) |
|
1643 | + { |
|
1644 | + error_log(__METHOD__.'() '.array2string(self::$extended_acl)); |
|
1645 | + } |
|
1403 | 1646 | } |
1404 | 1647 | |
1405 | 1648 | /** |
@@ -1428,12 +1671,18 @@ discard block |
||
1428 | 1671 | { |
1429 | 1672 | if (!($stat = self::url_stat($path,0))) |
1430 | 1673 | { |
1431 | - if (self::LOG_LEVEL) error_log(__METHOD__."($path,$rights,$owner,$fs_id) no such file or directory!"); |
|
1674 | + if (self::LOG_LEVEL) |
|
1675 | + { |
|
1676 | + error_log(__METHOD__."($path,$rights,$owner,$fs_id) no such file or directory!"); |
|
1677 | + } |
|
1432 | 1678 | return false; // $path not found |
1433 | 1679 | } |
1434 | - if (!Vfs::has_owner_rights($path,$stat)) // not group dir and user is eGW admin |
|
1680 | + if (!Vfs::has_owner_rights($path,$stat)) |
|
1681 | + { |
|
1682 | + // not group dir and user is eGW admin |
|
1435 | 1683 | { |
1436 | 1684 | if (self::LOG_LEVEL) error_log(__METHOD__."($path,$rights,$owner,$fs_id) permission denied!"); |
1685 | + } |
|
1437 | 1686 | return false; // permission denied |
1438 | 1687 | } |
1439 | 1688 | $fs_id = $stat['ino']; |
@@ -1466,7 +1715,10 @@ discard block |
||
1466 | 1715 | { |
1467 | 1716 | egw_cache::setSession(self::EACL_APPNAME, 'extended_acl', self::$extended_acl); |
1468 | 1717 | } |
1469 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path,$rights,$owner,$fs_id)=".(int)$ret); |
|
1718 | + if (self::LOG_LEVEL > 1) |
|
1719 | + { |
|
1720 | + error_log(__METHOD__."($path,$rights,$owner,$fs_id)=".(int)$ret); |
|
1721 | + } |
|
1470 | 1722 | return $ret; |
1471 | 1723 | } |
1472 | 1724 | |
@@ -1500,7 +1752,8 @@ discard block |
||
1500 | 1752 | $eacls = array_merge((array)self::get_eacl($path),$eacls); |
1501 | 1753 | } |
1502 | 1754 | // sort by length descending, to show precedence |
1503 | - usort($eacls, function($a, $b) { |
|
1755 | + usort($eacls, function($a, $b) |
|
1756 | + { |
|
1504 | 1757 | return strlen($b['path']) - strlen($a['path']); |
1505 | 1758 | }); |
1506 | 1759 | //error_log(__METHOD__."('$_path') returning ".array2string($eacls)); |
@@ -1518,7 +1771,10 @@ discard block |
||
1518 | 1771 | */ |
1519 | 1772 | static function id2path($fs_ids) |
1520 | 1773 | { |
1521 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($fs_ids).')'); |
|
1774 | + if (self::LOG_LEVEL > 1) |
|
1775 | + { |
|
1776 | + error_log(__METHOD__.'('.array2string($fs_ids).')'); |
|
1777 | + } |
|
1522 | 1778 | $ids = (array)$fs_ids; |
1523 | 1779 | $pathes = array(); |
1524 | 1780 | // first check our stat-cache for the ids |
@@ -1530,16 +1786,26 @@ discard block |
||
1530 | 1786 | unset($ids[$key]); |
1531 | 1787 | if (!$ids) |
1532 | 1788 | { |
1533 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($fs_ids).')='.array2string($pathes).' *from stat_cache*'); |
|
1789 | + if (self::LOG_LEVEL > 1) |
|
1790 | + { |
|
1791 | + error_log(__METHOD__.'('.array2string($fs_ids).')='.array2string($pathes).' *from stat_cache*'); |
|
1792 | + } |
|
1534 | 1793 | return is_array($fs_ids) ? $pathes : array_shift($pathes); |
1535 | 1794 | } |
1536 | 1795 | } |
1537 | 1796 | } |
1538 | 1797 | // now search via the database |
1539 | - if (count($ids) > 1) array_map(function(&$v) { $v = (int)$v; },$ids); |
|
1798 | + if (count($ids) > 1) |
|
1799 | + { |
|
1800 | + array_map(function(&$v) { $v = (int)$v; |
|
1801 | + } |
|
1802 | + },$ids); |
|
1540 | 1803 | $query = 'SELECT fs_id,fs_dir,fs_name FROM '.self::TABLE.' WHERE fs_id'. |
1541 | 1804 | (count($ids) == 1 ? '='.(int)$ids[0] : ' IN ('.implode(',',$ids).')'); |
1542 | - if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; |
|
1805 | + if (self::LOG_LEVEL > 2) |
|
1806 | + { |
|
1807 | + $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; |
|
1808 | + } |
|
1543 | 1809 | |
1544 | 1810 | if (!is_object(self::$pdo)) |
1545 | 1811 | { |
@@ -1566,14 +1832,20 @@ discard block |
||
1566 | 1832 | { |
1567 | 1833 | return false; // parent not found, should never happen ... |
1568 | 1834 | } |
1569 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__." trying foreach with:".print_r($rows,true)."#"); |
|
1835 | + if (self::LOG_LEVEL > 1) |
|
1836 | + { |
|
1837 | + error_log(__METHOD__." trying foreach with:".print_r($rows,true)."#"); |
|
1838 | + } |
|
1570 | 1839 | foreach((array)$rows as $fs_id => $row) |
1571 | 1840 | { |
1572 | 1841 | $parent = $row['fs_dir'] > 1 ? $parents[$row['fs_dir']] : ''; |
1573 | 1842 | |
1574 | 1843 | $pathes[$fs_id] = $parent . '/' . $row['fs_name']; |
1575 | 1844 | } |
1576 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($fs_ids).')='.array2string($pathes)); |
|
1845 | + if (self::LOG_LEVEL > 1) |
|
1846 | + { |
|
1847 | + error_log(__METHOD__.'('.array2string($fs_ids).')='.array2string($pathes)); |
|
1848 | + } |
|
1577 | 1849 | return is_array($fs_ids) ? $pathes : array_shift($pathes); |
1578 | 1850 | } |
1579 | 1851 | |
@@ -1629,7 +1901,10 @@ discard block |
||
1629 | 1901 | 'mime' => $info['fs_mime'], |
1630 | 1902 | 'readlink' => $info['fs_link'], |
1631 | 1903 | ); |
1632 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."($info[name]) = ".array2string($stat)); |
|
1904 | + if (self::LOG_LEVEL > 1) |
|
1905 | + { |
|
1906 | + error_log(__METHOD__."($info[name]) = ".array2string($stat)); |
|
1907 | + } |
|
1633 | 1908 | return $stat; |
1634 | 1909 | } |
1635 | 1910 | |
@@ -1701,7 +1976,10 @@ discard block |
||
1701 | 1976 | switch(self::$pdo_type) |
1702 | 1977 | { |
1703 | 1978 | case 'mysql': |
1704 | - if (isset($egw_db->Link_ID->charset2mysql[$charset])) $charset = $egw_db->Link_ID->charset2mysql[$charset]; |
|
1979 | + if (isset($egw_db->Link_ID->charset2mysql[$charset])) |
|
1980 | + { |
|
1981 | + $charset = $egw_db->Link_ID->charset2mysql[$charset]; |
|
1982 | + } |
|
1705 | 1983 | // fall throught |
1706 | 1984 | case 'pgsql': |
1707 | 1985 | $query = "SET NAMES '$charset'"; |
@@ -1772,13 +2050,16 @@ discard block |
||
1772 | 2050 | } |
1773 | 2051 | if (!isset($GLOBALS['egw_info']['server']['files_dir'])) |
1774 | 2052 | { |
1775 | - if (is_object($GLOBALS['egw_setup']->db)) // if we run under setup, query the db for the files dir |
|
2053 | + if (is_object($GLOBALS['egw_setup']->db)) |
|
2054 | + { |
|
2055 | + // if we run under setup, query the db for the files dir |
|
1776 | 2056 | { |
1777 | 2057 | $GLOBALS['egw_info']['server']['files_dir'] = $GLOBALS['egw_setup']->db->select('egw_config','config_value',array( |
1778 | 2058 | 'config_name' => 'files_dir', |
1779 | 2059 | 'config_app' => 'phpgwapi', |
1780 | 2060 | ),__LINE__,__FILE__)->fetchColumn(); |
1781 | 2061 | } |
2062 | + } |
|
1782 | 2063 | } |
1783 | 2064 | if (!$GLOBALS['egw_info']['server']['files_dir']) |
1784 | 2065 | { |
@@ -1790,7 +2071,11 @@ discard block |
||
1790 | 2071 | { |
1791 | 2072 | $hash[] = sprintf('%02d',$n % self::HASH_MAX); |
1792 | 2073 | } |
1793 | - if (!$hash) $hash[] = '00'; // we need at least one directory, to not conflict with the dir-names |
|
2074 | + if (!$hash) |
|
2075 | + { |
|
2076 | + $hash[] = '00'; |
|
2077 | + } |
|
2078 | + // we need at least one directory, to not conflict with the dir-names |
|
1794 | 2079 | array_unshift($hash,$id); |
1795 | 2080 | |
1796 | 2081 | $path = '/sqlfs/'.implode('/',array_reverse($hash)); |
@@ -1852,7 +2137,10 @@ discard block |
||
1852 | 2137 | */ |
1853 | 2138 | static function proppatch($path,array $props) |
1854 | 2139 | { |
1855 | - if (self::LOG_LEVEL > 1) error_log(__METHOD__."(".array2string($path).','.array2string($props)); |
|
2140 | + if (self::LOG_LEVEL > 1) |
|
2141 | + { |
|
2142 | + error_log(__METHOD__."(".array2string($path).','.array2string($props)); |
|
2143 | + } |
|
1856 | 2144 | if (!is_numeric($path)) |
1857 | 2145 | { |
1858 | 2146 | if (!($stat = self::url_stat($path,0))) |
@@ -1872,13 +2160,19 @@ discard block |
||
1872 | 2160 | $ins_stmt = $del_stmt = null; |
1873 | 2161 | foreach($props as &$prop) |
1874 | 2162 | { |
1875 | - if (!isset($prop['ns'])) $prop['ns'] = Vfs::DEFAULT_PROP_NAMESPACE; |
|
2163 | + if (!isset($prop['ns'])) |
|
2164 | + { |
|
2165 | + $prop['ns'] = Vfs::DEFAULT_PROP_NAMESPACE; |
|
2166 | + } |
|
1876 | 2167 | |
1877 | - if (!isset($prop['val']) || self::$pdo_type != 'mysql') // for non mysql, we have to delete the prop anyway, as there's no REPLACE! |
|
2168 | + if (!isset($prop['val']) || self::$pdo_type != 'mysql') |
|
2169 | + { |
|
2170 | + // for non mysql, we have to delete the prop anyway, as there's no REPLACE! |
|
1878 | 2171 | { |
1879 | 2172 | if (!isset($del_stmt)) |
1880 | 2173 | { |
1881 | 2174 | $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'); |
2175 | + } |
|
1882 | 2176 | } |
1883 | 2177 | $del_stmt->execute(array( |
1884 | 2178 | 'fs_id' => $id, |
@@ -1924,17 +2218,27 @@ discard block |
||
1924 | 2218 | { |
1925 | 2219 | if (!($stat = self::url_stat($id,0))) |
1926 | 2220 | { |
1927 | - if (self::LOG_LEVEL) error_log(__METHOD__."(".array2string($path_ids).",$ns) path '$id' not found!"); |
|
2221 | + if (self::LOG_LEVEL) |
|
2222 | + { |
|
2223 | + error_log(__METHOD__."(".array2string($path_ids).",$ns) path '$id' not found!"); |
|
2224 | + } |
|
1928 | 2225 | return false; |
1929 | 2226 | } |
1930 | 2227 | $id = $stat['ino']; |
1931 | 2228 | } |
1932 | 2229 | } |
1933 | - if (count($ids) >= 1) array_map(function(&$v) { $v = (int)$v; },$ids); |
|
2230 | + if (count($ids) >= 1) |
|
2231 | + { |
|
2232 | + array_map(function(&$v) { $v = (int)$v; |
|
2233 | + } |
|
2234 | + },$ids); |
|
1934 | 2235 | $query = 'SELECT * FROM '.self::PROPS_TABLE.' WHERE (fs_id'. |
1935 | 2236 | (count($ids) == 1 ? '='.(int)implode('',$ids) : ' IN ('.implode(',',$ids).')').')'. |
1936 | 2237 | (!is_null($ns) ? ' AND prop_namespace=?' : ''); |
1937 | - if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; |
|
2238 | + if (self::LOG_LEVEL > 2) |
|
2239 | + { |
|
2240 | + $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query; |
|
2241 | + } |
|
1938 | 2242 | |
1939 | 2243 | $stmt = self::$pdo->prepare($query); |
1940 | 2244 | $stmt->setFetchMode(\PDO::FETCH_ASSOC); |
@@ -1953,11 +2257,14 @@ discard block |
||
1953 | 2257 | { |
1954 | 2258 | $props = $props[$row['fs_id']] ? $props[$row['fs_id']] : array(); // return empty array for no props |
1955 | 2259 | } |
1956 | - elseif ($props && isset($stat)) // need to map fs_id's to pathes |
|
2260 | + elseif ($props && isset($stat)) |
|
2261 | + { |
|
2262 | + // need to map fs_id's to pathes |
|
1957 | 2263 | { |
1958 | 2264 | foreach(self::id2path(array_keys($props)) as $id => $path) |
1959 | 2265 | { |
1960 | 2266 | $props[$path] =& $props[$id]; |
2267 | + } |
|
1961 | 2268 | unset($props[$id]); |
1962 | 2269 | } |
1963 | 2270 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | // if we are NOT called as part of an update script, behave like a regular setup script |
13 | 13 | if (!isset($GLOBALS['egw_setup']) || !is_object($GLOBALS['egw_setup'])) |
14 | 14 | { |
15 | - $diagnostics = 1; // can be set to 0=non, 1=some (default for now), 2=all |
|
15 | + $diagnostics = 1; // can be set to 0=non, 1=some (default for now), 2=all |
|
16 | 16 | |
17 | 17 | include('./inc/functions.inc.php'); |
18 | 18 | // Authorize the user to use setup app and load the database |
@@ -25,50 +25,50 @@ discard block |
||
25 | 25 | $GLOBALS['egw_setup']->loaddb(); |
26 | 26 | |
27 | 27 | $tpl_root = $GLOBALS['egw_setup']->html->setup_tpl_dir('setup'); |
28 | - $setup_tpl = CreateObject('phpgwapi.Template',$tpl_root); |
|
28 | + $setup_tpl = CreateObject('phpgwapi.Template', $tpl_root); |
|
29 | 29 | $setup_tpl->set_file(array( |
30 | 30 | 'T_head' => 'head.tpl', |
31 | 31 | 'T_footer' => 'footer.tpl', |
32 | 32 | )); |
33 | - $GLOBALS['egw_setup']->html->show_header('',False,'config',$GLOBALS['egw_setup']->ConfigDomain . '(' . $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'] . ')'); |
|
33 | + $GLOBALS['egw_setup']->html->show_header('', False, 'config', $GLOBALS['egw_setup']->ConfigDomain.'('.$GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'].')'); |
|
34 | 34 | echo '<h3>'.'Fix mysql DB to match the eGroupWare system_charset'."</h3>\n"; |
35 | 35 | $running_standalone = true; |
36 | 36 | } |
37 | -$db =& $GLOBALS['egw_setup']->db; |
|
38 | -$charset2mysql =& $GLOBALS['egw_setup']->db->Link_ID->charset2mysql; |
|
37 | +$db = & $GLOBALS['egw_setup']->db; |
|
38 | +$charset2mysql = & $GLOBALS['egw_setup']->db->Link_ID->charset2mysql; |
|
39 | 39 | $mysql2charset = array_flip($charset2mysql); |
40 | 40 | |
41 | 41 | $ServerInfo = $db->Link_ID->ServerInfo(); |
42 | -$db_version = (float) $ServerInfo['version']; |
|
42 | +$db_version = (float)$ServerInfo['version']; |
|
43 | 43 | |
44 | 44 | if ($running_standalone || $_REQUEST['debug']) echo "<p>DB-Type='<b>{$GLOBALS['egw_setup']->db->Type}</b>', DB-Version=<b>$db_version</b> ($ServerInfo[description]), eGroupWare system_charset='<b>{$GLOBALS['egw_setup']->system_charset}</b>', DB-connection charset was '<b>{$GLOBALS['egw_setup']->db_charset_was}</b>'</p>\n"; |
45 | 45 | |
46 | 46 | $mysql_system_charset = isset($charset2mysql[$GLOBALS['egw_setup']->system_charset]) ? |
47 | 47 | $charset2mysql[$GLOBALS['egw_setup']->system_charset] : $GLOBALS['egw_setup']->system_charset; |
48 | 48 | |
49 | -if (substr($db->Type,0,5) == 'mysql' && $db_version >= 4.1 && $GLOBALS['egw_setup']->system_charset && $GLOBALS['egw_setup']->db_charset_was && |
|
49 | +if (substr($db->Type, 0, 5) == 'mysql' && $db_version >= 4.1 && $GLOBALS['egw_setup']->system_charset && $GLOBALS['egw_setup']->db_charset_was && |
|
50 | 50 | $GLOBALS['egw_setup']->system_charset != $GLOBALS['egw_setup']->db_charset_was) |
51 | 51 | { |
52 | 52 | $tables_modified = 'no'; |
53 | 53 | |
54 | 54 | $tables = array(); |
55 | - $db->query("SHOW TABLE STATUS",__LINE__,__FILE__); |
|
55 | + $db->query("SHOW TABLE STATUS", __LINE__, __FILE__); |
|
56 | 56 | while (($row = $db->row(true))) |
57 | 57 | { |
58 | 58 | $tables[$row['Name']] = $row['Collation']; |
59 | 59 | } |
60 | - foreach($tables as $table => $collation) |
|
60 | + foreach ($tables as $table => $collation) |
|
61 | 61 | { |
62 | 62 | $columns = array(); |
63 | - $db->query("SHOW FULL FIELDS FROM `$table`",__LINE__,__FILE__); |
|
64 | - while(($row = $db->row(true))) |
|
63 | + $db->query("SHOW FULL FIELDS FROM `$table`", __LINE__, __FILE__); |
|
64 | + while (($row = $db->row(true))) |
|
65 | 65 | { |
66 | 66 | $columns[] = $row; |
67 | 67 | } |
68 | 68 | //echo $table; _debug_array($columns); |
69 | 69 | $fulltext = $fulltext_back = array(); |
70 | - $db->query("SHOW KEYS FROM `$table`",__LINE__,__FILE__); |
|
71 | - while(($row = $db->row(true))) |
|
70 | + $db->query("SHOW KEYS FROM `$table`", __LINE__, __FILE__); |
|
71 | + while (($row = $db->row(true))) |
|
72 | 72 | { |
73 | 73 | if ($row['Index_type'] == 'FULLTEXT') |
74 | 74 | { |
@@ -77,12 +77,12 @@ discard block |
||
77 | 77 | } |
78 | 78 | |
79 | 79 | $alter_table = $alter_table_back = array(); |
80 | - foreach($columns as $column) |
|
80 | + foreach ($columns as $column) |
|
81 | 81 | { |
82 | - if ($column['Collation'] && preg_match('/^(char|varchar|.*text)\(?([0-9]*)\)?$/i',$column['Type'],$matches)) |
|
82 | + if ($column['Collation'] && preg_match('/^(char|varchar|.*text)\(?([0-9]*)\)?$/i', $column['Type'], $matches)) |
|
83 | 83 | { |
84 | - list(,$type,$size) = $matches; |
|
85 | - list($charset) = explode('_',$column['Collation']); |
|
84 | + list(,$type, $size) = $matches; |
|
85 | + list($charset) = explode('_', $column['Collation']); |
|
86 | 86 | |
87 | 87 | if (isset($mysql2charset[$charset])) $charset = $mysql2charset[$charset]; |
88 | 88 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | } |
98 | 98 | else |
99 | 99 | { |
100 | - $bintype = str_replace('text','blob',$type); |
|
100 | + $bintype = str_replace('text', 'blob', $type); |
|
101 | 101 | } |
102 | 102 | //echo "<p>$table.$col $type CHARACTER SET $charset $default $null</p>\n"; |
103 | 103 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | { |
109 | 109 | $idx_name = $fulltext[$col]; |
110 | 110 | $idx_cols = array(); |
111 | - foreach($fulltext as $c => $i) |
|
111 | + foreach ($fulltext as $c => $i) |
|
112 | 112 | { |
113 | 113 | if ($i == $idx_name) |
114 | 114 | { |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | } |
125 | 125 | } |
126 | 126 | } |
127 | - list($charset) = explode('_',$collation); |
|
127 | + list($charset) = explode('_', $collation); |
|
128 | 128 | if (isset($mysql2charset[$charset])) $charset = $mysql2charset[$charset]; |
129 | 129 | if ($charset != $GLOBALS['egw_setup']->system_charset) |
130 | 130 | { |
@@ -132,26 +132,26 @@ discard block |
||
132 | 132 | } |
133 | 133 | if (count($alter_table)) |
134 | 134 | { |
135 | - $alter_table = "ALTER TABLE $table\n".implode(",\n",$alter_table); |
|
135 | + $alter_table = "ALTER TABLE $table\n".implode(",\n", $alter_table); |
|
136 | 136 | |
137 | 137 | if ($running_standalone || $_REQUEST['debug']) echo '<p>'.nl2br($alter_table)."</p>\n"; |
138 | - if (!$db->query($alter_table,__LINE__,__FILE__)) |
|
138 | + if (!$db->query($alter_table, __LINE__, __FILE__)) |
|
139 | 139 | { |
140 | 140 | echo "<p>SQL Error: ".nl2br($alter_table)."</p>\n"; |
141 | 141 | echo "<b>{$db->Type} Error</b>: {$db->Errno} ({$db->Error})</p>\n"; |
142 | 142 | echo "<p>continuing ...</p>\n"; |
143 | 143 | continue; |
144 | 144 | } |
145 | - foreach($fulltext_back as $idx_name => $idx_cols) |
|
145 | + foreach ($fulltext_back as $idx_name => $idx_cols) |
|
146 | 146 | { |
147 | - $alter_table_back[] = " ADD FULLTEXT `$idx_name` (`".implode('`,`',$idx_cols)."`)"; |
|
147 | + $alter_table_back[] = " ADD FULLTEXT `$idx_name` (`".implode('`,`', $idx_cols)."`)"; |
|
148 | 148 | } |
149 | 149 | if (count($alter_table_back)) |
150 | 150 | { |
151 | - $alter_table_back = "ALTER TABLE $table\n".implode(",\n",$alter_table_back); |
|
151 | + $alter_table_back = "ALTER TABLE $table\n".implode(",\n", $alter_table_back); |
|
152 | 152 | |
153 | 153 | if ($running_standalone || $_REQUEST['debug']) echo '<p>'.nl2br($alter_table_back)."</p>\n"; |
154 | - if (!$db->query($alter_table_back,__LINE__,__FILE__)) |
|
154 | + if (!$db->query($alter_table_back, __LINE__, __FILE__)) |
|
155 | 155 | { |
156 | 156 | echo "<p><b>SQL Error</b>: ".nl2br($alter_table_back)."</p>\n"; |
157 | 157 | echo "<b>{$db->Type} Error</b>: {$db->Errno} ({$db->Error})</p>\n"; |
@@ -163,13 +163,13 @@ discard block |
||
163 | 163 | } |
164 | 164 | } |
165 | 165 | // change the default charset of the DB |
166 | - $db->query("SHOW CREATE DATABASE `$db->Database`",__LINE__,__FILE__); |
|
166 | + $db->query("SHOW CREATE DATABASE `$db->Database`", __LINE__, __FILE__); |
|
167 | 167 | $create_db = $db->next_record() ? $db->f(1) : ''; |
168 | - if (preg_match('/CHARACTER SET ([a-z1-9_-]+) /i',$create_db,$matches) && $matches[1] != $mysql_system_charset) |
|
168 | + if (preg_match('/CHARACTER SET ([a-z1-9_-]+) /i', $create_db, $matches) && $matches[1] != $mysql_system_charset) |
|
169 | 169 | { |
170 | 170 | $alter_db = "ALTER DATABASE `$db->Database` DEFAULT CHARACTER SET $mysql_system_charset"; |
171 | 171 | if ($running_standalone || $_REQUEST['debug']) echo '<p>'.$alter_db."</p>\n"; |
172 | - $db->query($alter_db,__LINE__,__FILE__); |
|
172 | + $db->query($alter_db, __LINE__, __FILE__); |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | if ($running_standalone || $_REQUEST['debug']) |
@@ -41,7 +41,10 @@ discard block |
||
41 | 41 | $ServerInfo = $db->Link_ID->ServerInfo(); |
42 | 42 | $db_version = (float) $ServerInfo['version']; |
43 | 43 | |
44 | -if ($running_standalone || $_REQUEST['debug']) echo "<p>DB-Type='<b>{$GLOBALS['egw_setup']->db->Type}</b>', DB-Version=<b>$db_version</b> ($ServerInfo[description]), eGroupWare system_charset='<b>{$GLOBALS['egw_setup']->system_charset}</b>', DB-connection charset was '<b>{$GLOBALS['egw_setup']->db_charset_was}</b>'</p>\n"; |
|
44 | +if ($running_standalone || $_REQUEST['debug']) |
|
45 | +{ |
|
46 | + echo "<p>DB-Type='<b>{$GLOBALS['egw_setup']->db->Type}</b>', DB-Version=<b>$db_version</b> ($ServerInfo[description]), eGroupWare system_charset='<b>{$GLOBALS['egw_setup']->system_charset}</b>', DB-connection charset was '<b>{$GLOBALS['egw_setup']->db_charset_was}</b>'</p>\n"; |
|
47 | +} |
|
45 | 48 | |
46 | 49 | $mysql_system_charset = isset($charset2mysql[$GLOBALS['egw_setup']->system_charset]) ? |
47 | 50 | $charset2mysql[$GLOBALS['egw_setup']->system_charset] : $GLOBALS['egw_setup']->system_charset; |
@@ -84,15 +87,21 @@ discard block |
||
84 | 87 | list(,$type,$size) = $matches; |
85 | 88 | list($charset) = explode('_',$column['Collation']); |
86 | 89 | |
87 | - if (isset($mysql2charset[$charset])) $charset = $mysql2charset[$charset]; |
|
90 | + if (isset($mysql2charset[$charset])) |
|
91 | + { |
|
92 | + $charset = $mysql2charset[$charset]; |
|
93 | + } |
|
88 | 94 | |
89 | 95 | if ($charset != $GLOBALS['egw_setup']->system_charset) |
90 | 96 | { |
91 | 97 | $col = $column['Field']; |
92 | 98 | |
93 | - if ($type == 'varchar' || $type == 'char') // old schema_proc (pre 1.0.1) used also char |
|
99 | + if ($type == 'varchar' || $type == 'char') |
|
100 | + { |
|
101 | + // old schema_proc (pre 1.0.1) used also char |
|
94 | 102 | { |
95 | 103 | $type = 'varchar('.$size.')'; |
104 | + } |
|
96 | 105 | $bintype = 'varbinary('.$size.')'; |
97 | 106 | } |
98 | 107 | else |
@@ -125,7 +134,10 @@ discard block |
||
125 | 134 | } |
126 | 135 | } |
127 | 136 | list($charset) = explode('_',$collation); |
128 | - if (isset($mysql2charset[$charset])) $charset = $mysql2charset[$charset]; |
|
137 | + if (isset($mysql2charset[$charset])) |
|
138 | + { |
|
139 | + $charset = $mysql2charset[$charset]; |
|
140 | + } |
|
129 | 141 | if ($charset != $GLOBALS['egw_setup']->system_charset) |
130 | 142 | { |
131 | 143 | $alter_table[] = " DEFAULT CHARACTER SET $mysql_system_charset"; |
@@ -134,7 +146,10 @@ discard block |
||
134 | 146 | { |
135 | 147 | $alter_table = "ALTER TABLE $table\n".implode(",\n",$alter_table); |
136 | 148 | |
137 | - if ($running_standalone || $_REQUEST['debug']) echo '<p>'.nl2br($alter_table)."</p>\n"; |
|
149 | + if ($running_standalone || $_REQUEST['debug']) |
|
150 | + { |
|
151 | + echo '<p>'.nl2br($alter_table)."</p>\n"; |
|
152 | + } |
|
138 | 153 | if (!$db->query($alter_table,__LINE__,__FILE__)) |
139 | 154 | { |
140 | 155 | echo "<p>SQL Error: ".nl2br($alter_table)."</p>\n"; |
@@ -150,7 +165,10 @@ discard block |
||
150 | 165 | { |
151 | 166 | $alter_table_back = "ALTER TABLE $table\n".implode(",\n",$alter_table_back); |
152 | 167 | |
153 | - if ($running_standalone || $_REQUEST['debug']) echo '<p>'.nl2br($alter_table_back)."</p>\n"; |
|
168 | + if ($running_standalone || $_REQUEST['debug']) |
|
169 | + { |
|
170 | + echo '<p>'.nl2br($alter_table_back)."</p>\n"; |
|
171 | + } |
|
154 | 172 | if (!$db->query($alter_table_back,__LINE__,__FILE__)) |
155 | 173 | { |
156 | 174 | echo "<p><b>SQL Error</b>: ".nl2br($alter_table_back)."</p>\n"; |
@@ -168,7 +186,10 @@ discard block |
||
168 | 186 | if (preg_match('/CHARACTER SET ([a-z1-9_-]+) /i',$create_db,$matches) && $matches[1] != $mysql_system_charset) |
169 | 187 | { |
170 | 188 | $alter_db = "ALTER DATABASE `$db->Database` DEFAULT CHARACTER SET $mysql_system_charset"; |
171 | - if ($running_standalone || $_REQUEST['debug']) echo '<p>'.$alter_db."</p>\n"; |
|
189 | + if ($running_standalone || $_REQUEST['debug']) |
|
190 | + { |
|
191 | + echo '<p>'.$alter_db."</p>\n"; |
|
192 | + } |
|
172 | 193 | $db->query($alter_db,__LINE__,__FILE__); |
173 | 194 | } |
174 | 195 | } |
@@ -176,5 +197,8 @@ discard block |
||
176 | 197 | { |
177 | 198 | echo "<p>$tables_modified tables changed to our system_charset {$GLOBALS['egw_setup']->system_charset}($mysql_system_charset)</p>\n"; |
178 | 199 | |
179 | - if ($running_standalone) $GLOBALS['egw_setup']->html->show_footer(); |
|
180 | -} |
|
200 | + if ($running_standalone) |
|
201 | + { |
|
202 | + $GLOBALS['egw_setup']->html->show_footer(); |
|
203 | + } |
|
204 | + } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @param string $config_passwd=null pw of above user |
24 | 24 | * @param boolean $verbose=false if true, echos out some status information during the run |
25 | 25 | */ |
26 | - function __construct($domain,$config_user=null,$config_passwd=null) |
|
26 | + function __construct($domain, $config_user = null, $config_passwd = null) |
|
27 | 27 | { |
28 | 28 | if (!is_array($domain)) |
29 | 29 | { |
@@ -45,17 +45,17 @@ discard block |
||
45 | 45 | * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); |
46 | 46 | * @throws Exception('header.inc.php not found!'); |
47 | 47 | */ |
48 | - protected function exec($check_only=false) |
|
48 | + protected function exec($check_only = false) |
|
49 | 49 | { |
50 | - if ($check_only) return true; // nothing to check, no arguments ... |
|
50 | + if ($check_only) return true; // nothing to check, no arguments ... |
|
51 | 51 | |
52 | 52 | // instanciate setup object and check authorisation |
53 | - $this->check_setup_auth($this->config_user,$this->config_passwd,$this->domain); |
|
53 | + $this->check_setup_auth($this->config_user, $this->config_passwd, $this->domain); |
|
54 | 54 | |
55 | - $this->check_installed($this->domain,15,$this->verbose); |
|
55 | + $this->check_installed($this->domain, 15, $this->verbose); |
|
56 | 56 | |
57 | 57 | global $setup_info; |
58 | - foreach($setup_info as $appname => $info) |
|
58 | + foreach ($setup_info as $appname => $info) |
|
59 | 59 | { |
60 | 60 | if ($info['currentver']) self::$egw_setup->register_hooks($appname); |
61 | 61 | } |
@@ -47,7 +47,11 @@ discard block |
||
47 | 47 | */ |
48 | 48 | protected function exec($check_only=false) |
49 | 49 | { |
50 | - if ($check_only) return true; // nothing to check, no arguments ... |
|
50 | + if ($check_only) |
|
51 | + { |
|
52 | + return true; |
|
53 | + } |
|
54 | + // nothing to check, no arguments ... |
|
51 | 55 | |
52 | 56 | // instanciate setup object and check authorisation |
53 | 57 | $this->check_setup_auth($this->config_user,$this->config_passwd,$this->domain); |
@@ -57,7 +61,10 @@ discard block |
||
57 | 61 | global $setup_info; |
58 | 62 | foreach($setup_info as $appname => $info) |
59 | 63 | { |
60 | - if ($info['currentver']) self::$egw_setup->register_hooks($appname); |
|
64 | + if ($info['currentver']) |
|
65 | + { |
|
66 | + self::$egw_setup->register_hooks($appname); |
|
67 | + } |
|
61 | 68 | } |
62 | 69 | $this->restore_db(); |
63 | 70 |
@@ -19,9 +19,8 @@ discard block |
||
19 | 19 | * Constructor |
20 | 20 | * |
21 | 21 | * @param string $domain string with domain-name or array with all arguments |
22 | - * @param string $config_user=null user to config the domain (or header_admin_user) |
|
23 | - * @param string $config_passwd=null pw of above user |
|
24 | - * @param boolean $verbose=false if true, echos out some status information during the run |
|
22 | + * @param string $config_user user to config the domain (or header_admin_user) |
|
23 | + * @param string $config_passwd pw of above user |
|
25 | 24 | */ |
26 | 25 | function __construct($domain,$config_user=null,$config_passwd=null) |
27 | 26 | { |
@@ -40,7 +39,7 @@ discard block |
||
40 | 39 | /** |
41 | 40 | * run the command: register all hooks |
42 | 41 | * |
43 | - * @param boolean $check_only=false only run the checks (and throw the exceptions), but not the command itself |
|
42 | + * @param boolean $check_only only run the checks (and throw the exceptions), but not the command itself |
|
44 | 43 | * @return string success message |
45 | 44 | * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); |
46 | 45 | * @throws Exception('header.inc.php not found!'); |
@@ -20,14 +20,14 @@ discard block |
||
20 | 20 | */ |
21 | 21 | function vfs_storage_mode_options($config) |
22 | 22 | { |
23 | - if (!isset($config['vfs_fstab']) || $config['vfs_fstab'] == json_encode($default=array( |
|
23 | + if (!isset($config['vfs_fstab']) || $config['vfs_fstab'] == json_encode($default = array( |
|
24 | 24 | '/' => 'sqlfs://$host/', |
25 | 25 | '/apps' => 'links://$host/apps', |
26 | 26 | )) || $config['vfs_fstab'] == serialize($default)) // detect old serialized value too |
27 | 27 | { |
28 | 28 | $config['vfs_storage_mode'] = 'fs'; |
29 | 29 | } |
30 | - elseif($config['vfs_fstab'] == json_encode($default_db=array( |
|
30 | + elseif ($config['vfs_fstab'] == json_encode($default_db = array( |
|
31 | 31 | '/' => 'sqlfs://$host/?storage=db', |
32 | 32 | '/apps' => 'links://$host/apps?storage=db', |
33 | 33 | )) || $config['vfs_fstab'] == serialize($default_db)) // detect old serialized value too |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | $config['vfs_storage_mode'] = 'custom'; |
40 | 40 | } |
41 | 41 | //_debug_array(array_intersect_key($config,array('vfs_fstab'=>1,'vfs_storage_mode'=>1))); |
42 | - foreach(array( |
|
42 | + foreach (array( |
|
43 | 43 | 'fs' => lang('Filesystem (default)'), |
44 | 44 | 'db' => lang('Database').' (problems with files > 1MB)', |
45 | - 'custom' => lang('Custom set via %1','filemanager/cli.php mount'), |
|
45 | + 'custom' => lang('Custom set via %1', 'filemanager/cli.php mount'), |
|
46 | 46 | ) as $name => $label) |
47 | 47 | { |
48 | 48 | if ($name != 'custom' || $name === $config['vfs_storage_mode']) // dont show custom, if not custom |
@@ -57,24 +57,24 @@ discard block |
||
57 | 57 | |
58 | 58 | function encryptalgo($config) |
59 | 59 | { |
60 | - if(@function_exists('mcrypt_list_algorithms')) |
|
60 | + if (@function_exists('mcrypt_list_algorithms')) |
|
61 | 61 | { |
62 | 62 | $listed = array(); |
63 | - if(!isset($config['mcrypt_algo'])) |
|
63 | + if (!isset($config['mcrypt_algo'])) |
|
64 | 64 | { |
65 | - $config['mcrypt_algo'] = 'tripledes'; /* MCRYPT_TRIPLEDES */ |
|
65 | + $config['mcrypt_algo'] = 'tripledes'; /* MCRYPT_TRIPLEDES */ |
|
66 | 66 | } |
67 | 67 | $algos = @mcrypt_list_algorithms(); |
68 | 68 | $found = False; |
69 | 69 | |
70 | 70 | $out = ''; |
71 | - while(list($key,$value) = each($algos)) |
|
71 | + while (list($key, $value) = each($algos)) |
|
72 | 72 | { |
73 | 73 | $found = True; |
74 | 74 | /* Only show each once - seems this is a problem in some installs */ |
75 | - if(!in_array($value,$listed)) |
|
75 | + if (!in_array($value, $listed)) |
|
76 | 76 | { |
77 | - if($config['mcrypt_algo'] == $value) |
|
77 | + if ($config['mcrypt_algo'] == $value) |
|
78 | 78 | { |
79 | 79 | $selected = ' selected="selected"'; |
80 | 80 | } |
@@ -84,29 +84,29 @@ discard block |
||
84 | 84 | } |
85 | 85 | $descr = strtoupper($value); |
86 | 86 | |
87 | - $out .= '<option value="' . $value . '"' . $selected . '>' . $descr . '</option>' . "\n"; |
|
87 | + $out .= '<option value="'.$value.'"'.$selected.'>'.$descr.'</option>'."\n"; |
|
88 | 88 | $listed[] = $value; |
89 | 89 | } |
90 | 90 | } |
91 | - if(!$found) |
|
91 | + if (!$found) |
|
92 | 92 | { |
93 | 93 | /* Something is wrong with their mcrypt install or php.ini */ |
94 | - $out = '<option value="">' . lang('no algorithms available') . '</option>' . "\n"; |
|
94 | + $out = '<option value="">'.lang('no algorithms available').'</option>'."\n"; |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 | else |
98 | 98 | { |
99 | - $out = '<option value="tripledes">TRIPLEDES</option>' . "\n"; |
|
99 | + $out = '<option value="tripledes">TRIPLEDES</option>'."\n"; |
|
100 | 100 | } |
101 | 101 | return $out; |
102 | 102 | } |
103 | 103 | |
104 | 104 | function encryptmode($config) |
105 | 105 | { |
106 | - if(@function_exists('mcrypt_list_modes')) |
|
106 | + if (@function_exists('mcrypt_list_modes')) |
|
107 | 107 | { |
108 | 108 | $listed = array(); |
109 | - if(!isset($config['mcrypt_mode'])) |
|
109 | + if (!isset($config['mcrypt_mode'])) |
|
110 | 110 | { |
111 | 111 | $config['mcrypt_mode'] = 'cbc'; /* MCRYPT_MODE_CBC */ |
112 | 112 | } |
@@ -114,13 +114,13 @@ discard block |
||
114 | 114 | $found = False; |
115 | 115 | |
116 | 116 | $out = ''; |
117 | - while(list($key,$value) = each($modes)) |
|
117 | + while (list($key, $value) = each($modes)) |
|
118 | 118 | { |
119 | 119 | $found = True; |
120 | 120 | /* Only show each once - seems this is a problem in some installs */ |
121 | - if(!in_array($value,$listed)) |
|
121 | + if (!in_array($value, $listed)) |
|
122 | 122 | { |
123 | - if($config['mcrypt_mode'] == $value) |
|
123 | + if ($config['mcrypt_mode'] == $value) |
|
124 | 124 | { |
125 | 125 | $selected = ' selected="selected"'; |
126 | 126 | } |
@@ -130,34 +130,34 @@ discard block |
||
130 | 130 | } |
131 | 131 | $descr = strtoupper($value); |
132 | 132 | |
133 | - $out .= '<option value="' . $value . '"' . $selected . '>' . $descr . '</option>' . "\n"; |
|
133 | + $out .= '<option value="'.$value.'"'.$selected.'>'.$descr.'</option>'."\n"; |
|
134 | 134 | $listed[] = $value; |
135 | 135 | } |
136 | 136 | } |
137 | - if(!$found) |
|
137 | + if (!$found) |
|
138 | 138 | { |
139 | 139 | /* Something is wrong with their mcrypt install or php.ini */ |
140 | - $out = '<option value="" selected="selected">' . lang('no modes available') . '</option>' . "\n"; |
|
140 | + $out = '<option value="" selected="selected">'.lang('no modes available').'</option>'."\n"; |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 | else |
144 | 144 | { |
145 | - $out = '<option value="cbc" selected="selected">CBC</option>' . "\n"; |
|
145 | + $out = '<option value="cbc" selected="selected">CBC</option>'."\n"; |
|
146 | 146 | } |
147 | 147 | return $out; |
148 | 148 | } |
149 | 149 | |
150 | -function passwdhashes($config,$return_hashes=false) |
|
150 | +function passwdhashes($config, $return_hashes = false) |
|
151 | 151 | { |
152 | - $hashes = sql_passwdhashes($config,true); |
|
152 | + $hashes = sql_passwdhashes($config, true); |
|
153 | 153 | if (isset($hashes['crypt'])) |
154 | 154 | { |
155 | - $hashes['des'] = 'des (=crypt)'; // old LDAP name for crypt |
|
155 | + $hashes['des'] = 'des (=crypt)'; // old LDAP name for crypt |
|
156 | 156 | } |
157 | 157 | return $return_hashes ? $hashes : _options_from($hashes, $config['ldap_encryption_type'] ? $config['ldap_encryption_type'] : 'des'); |
158 | 158 | } |
159 | 159 | |
160 | -function sql_passwdhashes($config, $return_hashes=false, &$securest=null) |
|
160 | +function sql_passwdhashes($config, $return_hashes = false, &$securest = null) |
|
161 | 161 | { |
162 | 162 | $hashes = Api\Auth::passwdhashes($securest); |
163 | 163 | |
@@ -172,19 +172,19 @@ discard block |
||
172 | 172 | */ |
173 | 173 | function auth_types($config) |
174 | 174 | { |
175 | - return _options_from(setup_cmd_config::auth_types(),$config['auth_type']); |
|
175 | + return _options_from(setup_cmd_config::auth_types(), $config['auth_type']); |
|
176 | 176 | } |
177 | 177 | function auth_type_syncml($config) |
178 | 178 | { |
179 | - return _options_from(setup_cmd_config::auth_types(),$config['auth_type_syncml']); |
|
179 | + return _options_from(setup_cmd_config::auth_types(), $config['auth_type_syncml']); |
|
180 | 180 | } |
181 | 181 | function auth_type_groupdav($config) |
182 | 182 | { |
183 | - return _options_from(setup_cmd_config::auth_types(),$config['auth_type_groupdav']); |
|
183 | + return _options_from(setup_cmd_config::auth_types(), $config['auth_type_groupdav']); |
|
184 | 184 | } |
185 | 185 | function auth_type_activesync($config) |
186 | 186 | { |
187 | - return _options_from(setup_cmd_config::auth_types(),$config['auth_type_activesync']); |
|
187 | + return _options_from(setup_cmd_config::auth_types(), $config['auth_type_activesync']); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -205,12 +205,12 @@ discard block |
||
205 | 205 | * @param string $selected value of selected optino |
206 | 206 | * @return string |
207 | 207 | */ |
208 | -function _options_from(array $options,$selected) |
|
208 | +function _options_from(array $options, $selected) |
|
209 | 209 | { |
210 | - foreach($options as $value => $label) |
|
210 | + foreach ($options as $value => $label) |
|
211 | 211 | { |
212 | - $out .= '<option value="' . htmlspecialchars($value) . '"' . |
|
213 | - ($selected == $value ? ' selected="selected"' : '') . '>' . $label . '</option>' . "\n"; |
|
212 | + $out .= '<option value="'.htmlspecialchars($value).'"'. |
|
213 | + ($selected == $value ? ' selected="selected"' : '').'>'.$label.'</option>'."\n"; |
|
214 | 214 | } |
215 | 215 | return $out; |
216 | 216 | } |
@@ -23,17 +23,23 @@ discard block |
||
23 | 23 | if (!isset($config['vfs_fstab']) || $config['vfs_fstab'] == json_encode($default=array( |
24 | 24 | '/' => 'sqlfs://$host/', |
25 | 25 | '/apps' => 'links://$host/apps', |
26 | - )) || $config['vfs_fstab'] == serialize($default)) // detect old serialized value too |
|
26 | + )) || $config['vfs_fstab'] == serialize($default)) |
|
27 | + { |
|
28 | + // detect old serialized value too |
|
27 | 29 | { |
28 | 30 | $config['vfs_storage_mode'] = 'fs'; |
29 | 31 | } |
32 | + } |
|
30 | 33 | elseif($config['vfs_fstab'] == json_encode($default_db=array( |
31 | 34 | '/' => 'sqlfs://$host/?storage=db', |
32 | 35 | '/apps' => 'links://$host/apps?storage=db', |
33 | - )) || $config['vfs_fstab'] == serialize($default_db)) // detect old serialized value too |
|
36 | + )) || $config['vfs_fstab'] == serialize($default_db)) |
|
37 | + { |
|
38 | + // detect old serialized value too |
|
34 | 39 | { |
35 | 40 | $config['vfs_storage_mode'] = 'db'; |
36 | 41 | } |
42 | + } |
|
37 | 43 | else |
38 | 44 | { |
39 | 45 | $config['vfs_storage_mode'] = 'custom'; |
@@ -45,11 +51,14 @@ discard block |
||
45 | 51 | 'custom' => lang('Custom set via %1','filemanager/cli.php mount'), |
46 | 52 | ) as $name => $label) |
47 | 53 | { |
48 | - if ($name != 'custom' || $name === $config['vfs_storage_mode']) // dont show custom, if not custom |
|
54 | + if ($name != 'custom' || $name === $config['vfs_storage_mode']) |
|
55 | + { |
|
56 | + // dont show custom, if not custom |
|
49 | 57 | { |
50 | 58 | $options .= '<option value="'.$name.($name === $config['vfs_storage_mode'] ? '" selected="selected' : ''). |
51 | 59 | '">'.htmlspecialchars($label)."</options>\n"; |
52 | 60 | } |
61 | + } |
|
53 | 62 | } |
54 | 63 | //echo "<pre>".htmlspecialchars($options)."</pre>\n"; |
55 | 64 | return $options; |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @param boolean $verbose =false if true, echos out some status information during the run |
31 | 31 | * @param string $app =null single application to update or install |
32 | 32 | */ |
33 | - function __construct($domain,$config_user=null,$config_passwd=null,$backup=null,$verbose=false,$app=null) |
|
33 | + function __construct($domain, $config_user = null, $config_passwd = null, $backup = null, $verbose = false, $app = null) |
|
34 | 34 | { |
35 | 35 | if (!is_array($domain)) |
36 | 36 | { |
@@ -55,32 +55,32 @@ discard block |
||
55 | 55 | * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); |
56 | 56 | * @throws Exception('header.inc.php not found!'); |
57 | 57 | */ |
58 | - protected function exec($check_only=false) |
|
58 | + protected function exec($check_only = false) |
|
59 | 59 | { |
60 | 60 | global $setup_info; |
61 | 61 | |
62 | 62 | // instanciate setup object and check authorisation |
63 | - $this->check_setup_auth($this->config_user,$this->config_passwd,$this->domain); |
|
63 | + $this->check_setup_auth($this->config_user, $this->config_passwd, $this->domain); |
|
64 | 64 | |
65 | - $this->check_installed($this->domain,array(14),$this->verbose); |
|
65 | + $this->check_installed($this->domain, array(14), $this->verbose); |
|
66 | 66 | |
67 | 67 | if ($GLOBALS['egw_info']['setup']['stage']['db'] != 4 && |
68 | 68 | (!$this->app || !in_array($this->app, self::$apps_to_install) && !in_array($this->app, self::$apps_to_upgrade)) && |
69 | 69 | !self::check_autoinstall()) |
70 | 70 | { |
71 | - return lang('No update necessary, domain %1(%2) is up to date.',$this->domain,$GLOBALS['egw_domain'][$this->domain]['db_type']); |
|
71 | + return lang('No update necessary, domain %1(%2) is up to date.', $this->domain, $GLOBALS['egw_domain'][$this->domain]['db_type']); |
|
72 | 72 | } |
73 | 73 | if ($check_only) return lang('Update necessary.'); |
74 | 74 | |
75 | 75 | $setup_info = self::$egw_setup->detection->upgrade_exclude($setup_info); |
76 | 76 | |
77 | - self::$egw_setup->process->init_process(); // we need a new schema-proc instance for each new domain |
|
77 | + self::$egw_setup->process->init_process(); // we need a new schema-proc instance for each new domain |
|
78 | 78 | |
79 | 79 | // request to install a single app |
80 | 80 | if ($this->app && in_array($this->app, self::$apps_to_install)) |
81 | 81 | { |
82 | 82 | $app_title = $setup_info[$this->app]['title'] ? $setup_info[$this->app]['title'] : $setup_info[$this->app]['name']; |
83 | - self::_echo_message($this->verbose,lang('Start installing application %1 ...',$app_title)); |
|
83 | + self::_echo_message($this->verbose, lang('Start installing application %1 ...', $app_title)); |
|
84 | 84 | ob_start(); |
85 | 85 | $terror = array($this->app => $setup_info[$this->app]); |
86 | 86 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | { |
89 | 89 | $errors = self::$egw_setup->process->current($terror, $this->verbose); |
90 | 90 | $terror = self::$egw_setup->process->default_records($errors, $this->verbose); |
91 | - echo $app_title . ' ' . lang('tables installed, unless there are errors printed above') . '.'; |
|
91 | + echo $app_title.' '.lang('tables installed, unless there are errors printed above').'.'; |
|
92 | 92 | } |
93 | 93 | else |
94 | 94 | { |
@@ -102,20 +102,20 @@ discard block |
||
102 | 102 | { |
103 | 103 | self::$egw_setup->register_app($setup_info[$this->app]['name']); |
104 | 104 | } |
105 | - echo $app_title . ' ' . lang('registered') . '.'; |
|
105 | + echo $app_title.' '.lang('registered').'.'; |
|
106 | 106 | |
107 | 107 | if ($setup_info[$this->app]['hooks']) |
108 | 108 | { |
109 | 109 | self::$egw_setup->register_hooks($setup_info[$this->app]['name']); |
110 | - echo "\n".$app_title . ' ' . lang('hooks registered') . '.'; |
|
110 | + echo "\n".$app_title.' '.lang('hooks registered').'.'; |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | } |
114 | 114 | else |
115 | 115 | { |
116 | - self::_echo_message($this->verbose,lang('Start updating the database ...')); |
|
116 | + self::_echo_message($this->verbose, lang('Start updating the database ...')); |
|
117 | 117 | ob_start(); |
118 | - self::$egw_setup->process->pass($setup_info,'upgrade',false); |
|
118 | + self::$egw_setup->process->pass($setup_info, 'upgrade', false); |
|
119 | 119 | } |
120 | 120 | $messages = ob_get_contents(); |
121 | 121 | ob_end_clean(); |
@@ -70,7 +70,10 @@ discard block |
||
70 | 70 | { |
71 | 71 | return lang('No update necessary, domain %1(%2) is up to date.',$this->domain,$GLOBALS['egw_domain'][$this->domain]['db_type']); |
72 | 72 | } |
73 | - if ($check_only) return lang('Update necessary.'); |
|
73 | + if ($check_only) |
|
74 | + { |
|
75 | + return lang('Update necessary.'); |
|
76 | + } |
|
74 | 77 | |
75 | 78 | $setup_info = self::$egw_setup->detection->upgrade_exclude($setup_info); |
76 | 79 | |
@@ -119,7 +122,10 @@ discard block |
||
119 | 122 | } |
120 | 123 | $messages = ob_get_contents(); |
121 | 124 | ob_end_clean(); |
122 | - if ($messages && $this->verbose) echo strip_tags($messages)."\n"; |
|
125 | + if ($messages && $this->verbose) |
|
126 | + { |
|
127 | + echo strip_tags($messages)."\n"; |
|
128 | + } |
|
123 | 129 | |
124 | 130 | $this->restore_db(); |
125 | 131 |
@@ -24,11 +24,10 @@ discard block |
||
24 | 24 | * Constructor |
25 | 25 | * |
26 | 26 | * @param string|array $domain string with domain-name or array with all arguments |
27 | - * @param string $config_user=null user to config the domain (or header_admin_user) |
|
28 | - * @param string $config_passwd=null pw of above user |
|
29 | - * @param string $backup=null filename of backup to use instead of new install, default new install |
|
30 | - * @param boolean $verbose=false if true, echos out some status information during the run |
|
31 | - * @param string $app=null single application to update or install |
|
27 | + * @param string $config_user user to config the domain (or header_admin_user) |
|
28 | + * @param string $config_passwd pw of above user |
|
29 | + * @param string $backup filename of backup to use instead of new install, default new install |
|
30 | + * @param boolean $verbose if true, echos out some status information during the run |
|
32 | 31 | */ |
33 | 32 | function __construct($domain,$config_user=null,$config_passwd=null,$backup=null,$verbose=false,$app=null) |
34 | 33 | { |
@@ -50,7 +49,7 @@ discard block |
||
50 | 49 | /** |
51 | 50 | * run the command: update or install/update a single app ($this->app) |
52 | 51 | * |
53 | - * @param boolean $check_only=false only run the checks (and throw the exceptions), but not the command itself |
|
52 | + * @param boolean $check_only only run the checks (and throw the exceptions), but not the command itself |
|
54 | 53 | * @return string success message |
55 | 54 | * @throws Exception(lang('Wrong credentials to access the header.inc.php file!'),2); |
56 | 55 | * @throws Exception('header.inc.php not found!'); |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
154 | - * Set the domain used for cookies |
|
155 | - * |
|
156 | - * @return string domain |
|
157 | - */ |
|
154 | + * Set the domain used for cookies |
|
155 | + * |
|
156 | + * @return string domain |
|
157 | + */ |
|
158 | 158 | static function cookiedomain() |
159 | 159 | { |
160 | 160 | // Use HTTP_X_FORWARDED_HOST if set, which is the case behind a none-transparent proxy |
@@ -175,12 +175,12 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
178 | - * Set a cookie |
|
179 | - * |
|
180 | - * @param string $cookiename name of cookie to be set |
|
181 | - * @param string $cookievalue value to be used, if unset cookie is cleared (optional) |
|
182 | - * @param int $cookietime when cookie should expire, 0 for session only (optional) |
|
183 | - */ |
|
178 | + * Set a cookie |
|
179 | + * |
|
180 | + * @param string $cookiename name of cookie to be set |
|
181 | + * @param string $cookievalue value to be used, if unset cookie is cleared (optional) |
|
182 | + * @param int $cookietime when cookie should expire, 0 for session only (optional) |
|
183 | + */ |
|
184 | 184 | function set_cookie($cookiename,$cookievalue='',$cookietime=0) |
185 | 185 | { |
186 | 186 | if(!isset($this->cookie_domain)) |
@@ -344,19 +344,19 @@ discard block |
||
344 | 344 | return true; |
345 | 345 | } |
346 | 346 | |
347 | - /** |
|
348 | - * check if username and password is valid |
|
349 | - * |
|
350 | - * this function compares the supplied and stored username and password |
|
351 | - * as any of the passwords can be clear text or md5 we convert them to md5 |
|
352 | - * internal and compare always the md5 hashs |
|
353 | - * |
|
354 | - * @param string $user the user supplied username |
|
355 | - * @param string $pw the user supplied password |
|
356 | - * @param string $conf_user the configured username |
|
357 | - * @param string $hash hash to check password agains (no {prefix} for plain and md5!) |
|
358 | - * @returns bool true on success |
|
359 | - */ |
|
347 | + /** |
|
348 | + * check if username and password is valid |
|
349 | + * |
|
350 | + * this function compares the supplied and stored username and password |
|
351 | + * as any of the passwords can be clear text or md5 we convert them to md5 |
|
352 | + * internal and compare always the md5 hashs |
|
353 | + * |
|
354 | + * @param string $user the user supplied username |
|
355 | + * @param string $pw the user supplied password |
|
356 | + * @param string $conf_user the configured username |
|
357 | + * @param string $hash hash to check password agains (no {prefix} for plain and md5!) |
|
358 | + * @returns bool true on success |
|
359 | + */ |
|
360 | 360 | static function check_auth($user, $pw, $conf_user, $hash) |
361 | 361 | { |
362 | 362 | if ($user !== $conf_user) |
@@ -728,10 +728,10 @@ discard block |
||
728 | 728 | } |
729 | 729 | |
730 | 730 | /** |
731 | - * call the hooks for a single application |
|
732 | - * |
|
733 | - * @param $location hook location - required |
|
734 | - * @param $appname application name - optional |
|
731 | + * call the hooks for a single application |
|
732 | + * |
|
733 | + * @param $location hook location - required |
|
734 | + * @param $appname application name - optional |
|
735 | 735 | */ |
736 | 736 | static function hook($location, $appname='') |
737 | 737 | { |
@@ -793,9 +793,9 @@ discard block |
||
793 | 793 | |
794 | 794 | /** |
795 | 795 | * egw version checking, is param 1 < param 2 in phpgw versionspeak? |
796 | - * @param $a phpgw version number to check if less than $b |
|
797 | - * @param $b phpgw version number to check $a against |
|
798 | - * @return True if $a < $b |
|
796 | + * @param string $a phpgw version number to check if less than $b |
|
797 | + * @param string $b phpgw version number to check $a against |
|
798 | + * @return boolean if $a < $b |
|
799 | 799 | */ |
800 | 800 | function alessthanb($a,$b,$DEBUG=False) |
801 | 801 | { |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | * |
883 | 883 | * @param $a phpgw version number to check if more than $b |
884 | 884 | * @param $b phpgw version number to check $a against |
885 | - * @return True if $a < $b |
|
885 | + * @return boolean if $a < $b |
|
886 | 886 | */ |
887 | 887 | function amorethanb($a,$b,$DEBUG=False) |
888 | 888 | { |
@@ -1152,7 +1152,7 @@ discard block |
||
1152 | 1152 | * |
1153 | 1153 | * Dont use it to set group-membership, use set_memberships instead! |
1154 | 1154 | * |
1155 | - * @param string|array $apps app-names |
|
1155 | + * @param string $apps app-names |
|
1156 | 1156 | * @param string $location eg. "run" |
1157 | 1157 | * @param int|string $account accountid or account_lid |
1158 | 1158 | * @param int $rights rights to set, default 1 |
@@ -1198,7 +1198,7 @@ discard block |
||
1198 | 1198 | /** |
1199 | 1199 | * checks if one of the given tables exist, returns the first match |
1200 | 1200 | * |
1201 | - * @param array $tables array with possible table-names |
|
1201 | + * @param string[] $tables array with possible table-names |
|
1202 | 1202 | * @return string/boolean tablename or false |
1203 | 1203 | */ |
1204 | 1204 | function table_exist($tables,$force_refresh=False) |
@@ -75,10 +75,10 @@ discard block |
||
75 | 75 | */ |
76 | 76 | var $recommended_php_version = '5.5'; |
77 | 77 | |
78 | - function __construct($html=False, $translation=False) |
|
78 | + function __construct($html = False, $translation = False) |
|
79 | 79 | { |
80 | 80 | // setup us as $GLOBALS['egw_setup'], as this gets used in our sub-objects |
81 | - $GLOBALS['egw_setup'] =& $this; |
|
81 | + $GLOBALS['egw_setup'] = & $this; |
|
82 | 82 | |
83 | 83 | if (!is_object($GLOBALS['egw'])) |
84 | 84 | { |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | /** |
99 | 99 | * include api db class for the ConfigDomain and connect to the db |
100 | 100 | */ |
101 | - function loaddb($connect_and_setcharset=true) |
|
101 | + function loaddb($connect_and_setcharset = true) |
|
102 | 102 | { |
103 | - if(!isset($this->ConfigDomain) || empty($this->ConfigDomain)) |
|
103 | + if (!isset($this->ConfigDomain) || empty($this->ConfigDomain)) |
|
104 | 104 | { |
105 | - $this->ConfigDomain = get_var('ConfigDomain',array('COOKIE','POST'),$_POST['FormDomain']); |
|
105 | + $this->ConfigDomain = get_var('ConfigDomain', array('COOKIE', 'POST'), $_POST['FormDomain']); |
|
106 | 106 | } |
107 | 107 | $GLOBALS['egw_info']['server']['db_type'] = $GLOBALS['egw_domain'][$this->ConfigDomain]['db_type']; |
108 | 108 | |
@@ -123,27 +123,27 @@ discard block |
||
123 | 123 | if ($connect_and_setcharset) |
124 | 124 | { |
125 | 125 | try { |
126 | - $this->set_table_names(); // sets/checks config- and applications-table-name |
|
126 | + $this->set_table_names(); // sets/checks config- and applications-table-name |
|
127 | 127 | |
128 | 128 | // Set the DB's client charset if a system-charset is set |
129 | - $this->db->select($this->config_table,'config_value',array( |
|
129 | + $this->db->select($this->config_table, 'config_value', array( |
|
130 | 130 | 'config_app' => 'phpgwapi', |
131 | 131 | 'config_name' => 'system_charset', |
132 | - ),__LINE__,__FILE__); |
|
132 | + ), __LINE__, __FILE__); |
|
133 | 133 | if ($this->db->next_record() && $this->db->f(0)) |
134 | 134 | { |
135 | 135 | $this->system_charset = $this->db->f(0); |
136 | - $this->db_charset_was = $this->db->Link_ID->GetCharSet(); // needed for the update |
|
136 | + $this->db_charset_was = $this->db->Link_ID->GetCharSet(); // needed for the update |
|
137 | 137 | |
138 | 138 | // we can NOT set the DB charset for mysql, if the api version < 1.0.1.019, as it would mess up the DB content!!! |
139 | - if (substr($this->db->Type,0,5) == 'mysql') // we need to check the api version |
|
139 | + if (substr($this->db->Type, 0, 5) == 'mysql') // we need to check the api version |
|
140 | 140 | { |
141 | - $this->db->select($this->applications_table,'app_version',array( |
|
141 | + $this->db->select($this->applications_table, 'app_version', array( |
|
142 | 142 | 'app_name' => 'phpgwapi', |
143 | - ),__LINE__,__FILE__); |
|
143 | + ), __LINE__, __FILE__); |
|
144 | 144 | $api_version = $this->db->next_record() ? $this->db->f(0) : false; |
145 | 145 | } |
146 | - if (!$api_version || !$this->alessthanb($api_version,'1.0.1.019')) |
|
146 | + if (!$api_version || !$this->alessthanb($api_version, '1.0.1.019')) |
|
147 | 147 | { |
148 | 148 | $this->db->Link_ID->SetCharSet($this->system_charset); |
149 | 149 | } |
@@ -163,15 +163,15 @@ discard block |
||
163 | 163 | static function cookiedomain() |
164 | 164 | { |
165 | 165 | // Use HTTP_X_FORWARDED_HOST if set, which is the case behind a none-transparent proxy |
166 | - $cookie_domain = isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']; |
|
166 | + $cookie_domain = isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']; |
|
167 | 167 | |
168 | 168 | // remove port from HTTP_HOST |
169 | 169 | $arr = null; |
170 | - if (preg_match("/^(.*):(.*)$/",$cookie_domain,$arr)) |
|
170 | + if (preg_match("/^(.*):(.*)$/", $cookie_domain, $arr)) |
|
171 | 171 | { |
172 | 172 | $cookie_domain = $arr[1]; |
173 | 173 | } |
174 | - if (count(explode('.',$cookie_domain)) <= 1) |
|
174 | + if (count(explode('.', $cookie_domain)) <= 1) |
|
175 | 175 | { |
176 | 176 | // setcookie dont likes domains without dots, leaving it empty, gets setcookie to fill the domain in |
177 | 177 | $cookie_domain = ''; |
@@ -186,9 +186,9 @@ discard block |
||
186 | 186 | * @param string $cookievalue value to be used, if unset cookie is cleared (optional) |
187 | 187 | * @param int $cookietime when cookie should expire, 0 for session only (optional) |
188 | 188 | */ |
189 | - function set_cookie($cookiename,$cookievalue='',$cookietime=0) |
|
189 | + function set_cookie($cookiename, $cookievalue = '', $cookietime = 0) |
|
190 | 190 | { |
191 | - if(!isset($this->cookie_domain)) |
|
191 | + if (!isset($this->cookie_domain)) |
|
192 | 192 | { |
193 | 193 | $this->cookie_domain = self::cookiedomain(); |
194 | 194 | } |
@@ -213,9 +213,9 @@ discard block |
||
213 | 213 | if (!isset($_SESSION)) self::session_start(); |
214 | 214 | $ConfigLang = $_SESSION['ConfigLang']; |
215 | 215 | } |
216 | - if (!preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$ConfigLang)) |
|
216 | + if (!preg_match('/^[a-z]{2}(-[a-z]{2})?$/', $ConfigLang)) |
|
217 | 217 | { |
218 | - $ConfigLang = null; // not returning 'en', as it suppresses the language selection in check_install and manageheader |
|
218 | + $ConfigLang = null; // not returning 'en', as it suppresses the language selection in check_install and manageheader |
|
219 | 219 | } |
220 | 220 | //error_log(__METHOD__."() \$_POST['ConfigLang']=".array2string($_POST['ConfigLang']).", \$_SESSION['ConfigLang']=".array2string($_SESSION['ConfigLang'])." returning ".array2string($ConfigLang)); |
221 | 221 | return $ConfigLang; |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | |
248 | 248 | if (isset($_COOKIE[self::SESSIONID])) session_id($_COOKIE[self::SESSIONID]); |
249 | 249 | |
250 | - $ok = @session_start(); // suppress notice if session already started or warning in CLI |
|
250 | + $ok = @session_start(); // suppress notice if session already started or warning in CLI |
|
251 | 251 | // need to decrypt session, in case session encryption is switched on in header.inc.php |
252 | 252 | egw_session::decrypt(); |
253 | 253 | //error_log(__METHOD__."() returning ".array2string($ok).' _SESSION='.array2string($_SESSION)); |
@@ -259,12 +259,12 @@ discard block |
||
259 | 259 | * |
260 | 260 | * @param string $_auth_type ='config' 'config' or 'header' (caseinsensitiv) |
261 | 261 | */ |
262 | - function auth($_auth_type='config') |
|
262 | + function auth($_auth_type = 'config') |
|
263 | 263 | { |
264 | 264 | $auth_type = strtolower($_auth_type); |
265 | 265 | $GLOBALS['egw_info']['setup']['HeaderLoginMSG'] = $GLOBALS['egw_info']['setup']['ConfigLoginMSG'] = ''; |
266 | 266 | |
267 | - if(!$this->checkip($_SERVER['REMOTE_ADDR'])) |
|
267 | + if (!$this->checkip($_SERVER['REMOTE_ADDR'])) |
|
268 | 268 | { |
269 | 269 | //error_log(__METHOD__."('$auth_type') invalid IP"); |
270 | 270 | return false; |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | //error_log(__METHOD__."('$auth_type') \$_COOKIE['".self::SESSIONID."'] = ".array2string($_COOKIE[self::SESSIONID]).", \$_SESSION=".array2string($_SESSION).", \$_POST=".array2string($_POST)); |
277 | 277 | if (isset($_REQUEST['FormLogout'])) |
278 | 278 | { |
279 | - $this->set_cookie(self::SESSIONID, '', time()-86400); |
|
279 | + $this->set_cookie(self::SESSIONID, '', time() - 86400); |
|
280 | 280 | session_destroy(); |
281 | 281 | if ($_REQUEST['FormLogout'] == 'config') |
282 | 282 | { |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | { |
293 | 293 | return false; |
294 | 294 | } |
295 | - switch($auth_type) |
|
295 | + switch ($auth_type) |
|
296 | 296 | { |
297 | 297 | case 'config': |
298 | 298 | if (!isset($GLOBALS['egw_domain'][$_POST['FormDomain']]) || |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | //error_log(__METHOD__."('$auth_type') \$_COOKIE['".self::SESSIONID."'] = ".array2string($_COOKIE[self::SESSIONID]).", \$_SESSION=".array2string($_SESSION)); |
333 | 333 | if ($_SESSION['egw_last_action_time'] < time() - self::TIMEOUT) |
334 | 334 | { |
335 | - $this->set_cookie(self::SESSIONID, '', time()-86400); |
|
335 | + $this->set_cookie(self::SESSIONID, '', time() - 86400); |
|
336 | 336 | session_destroy(); |
337 | 337 | $GLOBALS['egw_info']['setup'][$_SESSION['egw_setup_auth_type'] == 'config' ? 'ConfigLoginMSG' : 'HeaderLoginMSG'] = |
338 | 338 | lang('Session expired'); |
@@ -387,37 +387,37 @@ discard block |
||
387 | 387 | * @param string $remoteip |
388 | 388 | * @return boolean |
389 | 389 | */ |
390 | - function checkip($remoteip='') |
|
390 | + function checkip($remoteip = '') |
|
391 | 391 | { |
392 | 392 | //echo "<p>setup::checkip($remoteip) against setup_acl='".$GLOBALS['egw_info']['server']['setup_acl']."'</p>\n"; |
393 | - $allowed_ips = explode(',',@$GLOBALS['egw_info']['server']['setup_acl']); |
|
394 | - if(empty($GLOBALS['egw_info']['server']['setup_acl']) || !is_array($allowed_ips)) |
|
393 | + $allowed_ips = explode(',', @$GLOBALS['egw_info']['server']['setup_acl']); |
|
394 | + if (empty($GLOBALS['egw_info']['server']['setup_acl']) || !is_array($allowed_ips)) |
|
395 | 395 | { |
396 | - return True; // no test |
|
396 | + return True; // no test |
|
397 | 397 | } |
398 | - $remotes = explode('.',$remoteip); |
|
399 | - foreach($allowed_ips as $value) |
|
398 | + $remotes = explode('.', $remoteip); |
|
399 | + foreach ($allowed_ips as $value) |
|
400 | 400 | { |
401 | - if (!preg_match('/^[0-9.]+$/',$value)) |
|
401 | + if (!preg_match('/^[0-9.]+$/', $value)) |
|
402 | 402 | { |
403 | - $value = gethostbyname($was=$value); // resolve domain-name, eg. a dyndns account |
|
403 | + $value = gethostbyname($was = $value); // resolve domain-name, eg. a dyndns account |
|
404 | 404 | //echo "resolving '$was' to '$value'<br>\n"; |
405 | 405 | } |
406 | - $values = explode('.',$value); |
|
407 | - for($i = 0; $i < count($values); ++$i) |
|
406 | + $values = explode('.', $value); |
|
407 | + for ($i = 0; $i < count($values); ++$i) |
|
408 | 408 | { |
409 | - if ((int) $values[$i] != (int) $remotes[$i]) |
|
409 | + if ((int)$values[$i] != (int)$remotes[$i]) |
|
410 | 410 | { |
411 | 411 | break; |
412 | 412 | } |
413 | 413 | } |
414 | 414 | if ($i == count($values)) |
415 | 415 | { |
416 | - return True; // match |
|
416 | + return True; // match |
|
417 | 417 | } |
418 | 418 | } |
419 | 419 | $GLOBALS['egw_info']['setup']['ConfigLoginMSG'] = lang('Invalid IP address').' '.$remoteip; |
420 | - error_log(__METHOD__.'-> checking IP failed:'.print_r($remoteip,true)); |
|
420 | + error_log(__METHOD__.'-> checking IP failed:'.print_r($remoteip, true)); |
|
421 | 421 | return False; |
422 | 422 | } |
423 | 423 | |
@@ -428,14 +428,14 @@ discard block |
||
428 | 428 | */ |
429 | 429 | function get_major($versionstring) |
430 | 430 | { |
431 | - if(!$versionstring) |
|
431 | + if (!$versionstring) |
|
432 | 432 | { |
433 | 433 | return False; |
434 | 434 | } |
435 | 435 | |
436 | - $version = str_replace('pre','.',$versionstring); |
|
437 | - $varray = explode('.',$version); |
|
438 | - $major = implode('.',array($varray[0],$varray[1],$varray[2])); |
|
436 | + $version = str_replace('pre', '.', $versionstring); |
|
437 | + $varray = explode('.', $version); |
|
438 | + $major = implode('.', array($varray[0], $varray[1], $varray[2])); |
|
439 | 439 | |
440 | 440 | return $major; |
441 | 441 | } |
@@ -455,55 +455,55 @@ discard block |
||
455 | 455 | * @param $appname Application 'name' with a matching $setup_info[$appname] array slice |
456 | 456 | * @param $_enable =99 set to True/False to override setup.inc.php setting |
457 | 457 | */ |
458 | - function register_app($appname, $_enable=99) |
|
458 | + function register_app($appname, $_enable = 99) |
|
459 | 459 | { |
460 | 460 | $setup_info = $GLOBALS['setup_info']; |
461 | 461 | |
462 | - if(!$appname) |
|
462 | + if (!$appname) |
|
463 | 463 | { |
464 | 464 | return False; |
465 | 465 | } |
466 | 466 | |
467 | - if($_enable == 99) |
|
467 | + if ($_enable == 99) |
|
468 | 468 | { |
469 | 469 | $_enable = $setup_info[$appname]['enable']; |
470 | 470 | } |
471 | 471 | $enable = (int)$_enable; |
472 | 472 | |
473 | - if($GLOBALS['DEBUG']) |
|
473 | + if ($GLOBALS['DEBUG']) |
|
474 | 474 | { |
475 | - echo '<br>register_app(): ' . $appname . ', version: ' . $setup_info[$appname]['version'] . ', tables: ' . implode(', ',$setup_info[$appname]['tables']) . '<br>'; |
|
475 | + echo '<br>register_app(): '.$appname.', version: '.$setup_info[$appname]['version'].', tables: '.implode(', ', $setup_info[$appname]['tables']).'<br>'; |
|
476 | 476 | // _debug_array($setup_info[$appname]); |
477 | 477 | } |
478 | 478 | |
479 | - if($setup_info[$appname]['version']) |
|
479 | + if ($setup_info[$appname]['version']) |
|
480 | 480 | { |
481 | - if($setup_info[$appname]['tables']) |
|
481 | + if ($setup_info[$appname]['tables']) |
|
482 | 482 | { |
483 | - $tables = implode(',',$setup_info[$appname]['tables']); |
|
483 | + $tables = implode(',', $setup_info[$appname]['tables']); |
|
484 | 484 | } |
485 | 485 | if ($setup_info[$appname]['tables_use_prefix'] == True) |
486 | 486 | { |
487 | - if($GLOBALS['DEBUG']) |
|
487 | + if ($GLOBALS['DEBUG']) |
|
488 | 488 | { |
489 | - echo "<br>$appname uses tables_use_prefix, storing ". $setup_info[$appname]['tables_prefix']." as prefix for tables\n"; |
|
489 | + echo "<br>$appname uses tables_use_prefix, storing ".$setup_info[$appname]['tables_prefix']." as prefix for tables\n"; |
|
490 | 490 | } |
491 | - $this->db->insert($this->config_table,array( |
|
491 | + $this->db->insert($this->config_table, array( |
|
492 | 492 | 'config_app' => $appname, |
493 | 493 | 'config_name' => $appname.'_tables_prefix', |
494 | 494 | 'config_value' => $setup_info[$appname]['tables_prefix'], |
495 | - ),False,__LINE__,__FILE__); |
|
495 | + ), False, __LINE__, __FILE__); |
|
496 | 496 | } |
497 | - $this->db->insert($this->applications_table,array( |
|
497 | + $this->db->insert($this->applications_table, array( |
|
498 | 498 | 'app_name' => $appname, |
499 | 499 | 'app_enabled' => $enable, |
500 | 500 | 'app_order' => $setup_info[$appname]['app_order'], |
501 | - 'app_tables' => (string)$tables, // app_tables is NOT NULL |
|
501 | + 'app_tables' => (string)$tables, // app_tables is NOT NULL |
|
502 | 502 | 'app_version' => $setup_info[$appname]['version'], |
503 | 503 | 'app_index' => $setup_info[$appname]['index'], |
504 | 504 | 'app_icon' => $setup_info[$appname]['icon'], |
505 | 505 | 'app_icon_app' => $setup_info[$appname]['icon_app'], |
506 | - ),False,__LINE__,__FILE__); |
|
506 | + ), False, __LINE__, __FILE__); |
|
507 | 507 | |
508 | 508 | $this->clear_session_cache(); |
509 | 509 | } |
@@ -517,27 +517,27 @@ discard block |
||
517 | 517 | */ |
518 | 518 | function app_registered($appname) |
519 | 519 | { |
520 | - if(!$appname) |
|
520 | + if (!$appname) |
|
521 | 521 | { |
522 | 522 | return False; |
523 | 523 | } |
524 | 524 | |
525 | - if(@$GLOBALS['DEBUG']) |
|
525 | + if (@$GLOBALS['DEBUG']) |
|
526 | 526 | { |
527 | - echo '<br>app_registered(): checking ' . $appname . ', table: ' . $this->applications_table; |
|
527 | + echo '<br>app_registered(): checking '.$appname.', table: '.$this->applications_table; |
|
528 | 528 | // _debug_array($setup_info[$appname]); |
529 | 529 | } |
530 | 530 | |
531 | - $this->db->select($this->applications_table,'COUNT(*)',array('app_name' => $appname),__LINE__,__FILE__); |
|
532 | - if($this->db->next_record() && $this->db->f(0)) |
|
531 | + $this->db->select($this->applications_table, 'COUNT(*)', array('app_name' => $appname), __LINE__, __FILE__); |
|
532 | + if ($this->db->next_record() && $this->db->f(0)) |
|
533 | 533 | { |
534 | - if(@$GLOBALS['DEBUG']) |
|
534 | + if (@$GLOBALS['DEBUG']) |
|
535 | 535 | { |
536 | 536 | echo '... app previously registered.'; |
537 | 537 | } |
538 | 538 | return True; |
539 | 539 | } |
540 | - if(@$GLOBALS['DEBUG']) |
|
540 | + if (@$GLOBALS['DEBUG']) |
|
541 | 541 | { |
542 | 542 | echo '... app not registered'; |
543 | 543 | } |
@@ -554,38 +554,38 @@ discard block |
||
554 | 554 | { |
555 | 555 | $setup_info = $GLOBALS['setup_info']; |
556 | 556 | |
557 | - if(!$appname) |
|
557 | + if (!$appname) |
|
558 | 558 | { |
559 | 559 | return False; |
560 | 560 | } |
561 | 561 | |
562 | - if($GLOBALS['DEBUG']) |
|
562 | + if ($GLOBALS['DEBUG']) |
|
563 | 563 | { |
564 | - echo '<br>update_app(): ' . $appname . ', version: ' . $setup_info[$appname]['currentver'] . ', table: ' . $this->applications_table . '<br>'; |
|
564 | + echo '<br>update_app(): '.$appname.', version: '.$setup_info[$appname]['currentver'].', table: '.$this->applications_table.'<br>'; |
|
565 | 565 | // _debug_array($setup_info[$appname]); |
566 | 566 | } |
567 | 567 | |
568 | - if(!$this->app_registered($appname)) |
|
568 | + if (!$this->app_registered($appname)) |
|
569 | 569 | { |
570 | 570 | return False; |
571 | 571 | } |
572 | 572 | |
573 | - if($setup_info[$appname]['version']) |
|
573 | + if ($setup_info[$appname]['version']) |
|
574 | 574 | { |
575 | 575 | //echo '<br>' . $setup_info[$appname]['version']; |
576 | - if($setup_info[$appname]['tables']) |
|
576 | + if ($setup_info[$appname]['tables']) |
|
577 | 577 | { |
578 | - $tables = implode(',',$setup_info[$appname]['tables']); |
|
578 | + $tables = implode(',', $setup_info[$appname]['tables']); |
|
579 | 579 | } |
580 | - $this->db->update($this->applications_table,array( |
|
580 | + $this->db->update($this->applications_table, array( |
|
581 | 581 | 'app_enabled' => $setup_info[$appname]['enable'], |
582 | 582 | 'app_order' => $setup_info[$appname]['app_order'], |
583 | - 'app_tables' => (string)$tables, // app_tables is NOT NULL |
|
583 | + 'app_tables' => (string)$tables, // app_tables is NOT NULL |
|
584 | 584 | 'app_version' => $setup_info[$appname]['version'], |
585 | 585 | 'app_index' => $setup_info[$appname]['index'], |
586 | 586 | 'app_icon' => $setup_info[$appname]['icon'], |
587 | 587 | 'app_icon_app' => $setup_info[$appname]['icon_app'], |
588 | - ),array('app_name'=>$appname),__LINE__,__FILE__); |
|
588 | + ), array('app_name'=>$appname), __LINE__, __FILE__); |
|
589 | 589 | } |
590 | 590 | } |
591 | 591 | |
@@ -598,20 +598,20 @@ discard block |
||
598 | 598 | */ |
599 | 599 | function update_app_version($setup_info, $appname, $tableschanged = True) |
600 | 600 | { |
601 | - if(!$appname) |
|
601 | + if (!$appname) |
|
602 | 602 | { |
603 | 603 | return False; |
604 | 604 | } |
605 | 605 | |
606 | - if($tableschanged == True) |
|
606 | + if ($tableschanged == True) |
|
607 | 607 | { |
608 | 608 | $GLOBALS['egw_info']['setup']['tableschanged'] = True; |
609 | 609 | } |
610 | - if($setup_info[$appname]['currentver']) |
|
610 | + if ($setup_info[$appname]['currentver']) |
|
611 | 611 | { |
612 | - $this->db->update($this->applications_table,array( |
|
612 | + $this->db->update($this->applications_table, array( |
|
613 | 613 | 'app_version' => $setup_info[$appname]['currentver'], |
614 | - ),array('app_name'=>$appname),__LINE__,__FILE__); |
|
614 | + ), array('app_name'=>$appname), __LINE__, __FILE__); |
|
615 | 615 | } |
616 | 616 | return $setup_info; |
617 | 617 | } |
@@ -623,19 +623,19 @@ discard block |
||
623 | 623 | */ |
624 | 624 | function deregister_app($appname) |
625 | 625 | { |
626 | - if(!$appname) |
|
626 | + if (!$appname) |
|
627 | 627 | { |
628 | 628 | return False; |
629 | 629 | } |
630 | 630 | |
631 | 631 | // Remove categories |
632 | - $this->db->delete(categories::TABLE, array('cat_appname'=>$appname),__LINE__,__FILE__); |
|
632 | + $this->db->delete(categories::TABLE, array('cat_appname'=>$appname), __LINE__, __FILE__); |
|
633 | 633 | categories::invalidate_cache($appname); |
634 | 634 | |
635 | 635 | // Remove config |
636 | - $this->db->delete(config::TABLE, array('config_app'=>$appname),__LINE__,__FILE__); |
|
636 | + $this->db->delete(config::TABLE, array('config_app'=>$appname), __LINE__, __FILE__); |
|
637 | 637 | //echo 'DELETING application: ' . $appname; |
638 | - $this->db->delete($this->applications_table,array('app_name'=>$appname),__LINE__,__FILE__); |
|
638 | + $this->db->delete($this->applications_table, array('app_name'=>$appname), __LINE__, __FILE__); |
|
639 | 639 | |
640 | 640 | // Remove links to the app |
641 | 641 | egw_link::unlink(0, $appname); |
@@ -652,21 +652,21 @@ discard block |
||
652 | 652 | { |
653 | 653 | $setup_info = $GLOBALS['setup_info']; |
654 | 654 | |
655 | - if(!$appname) |
|
655 | + if (!$appname) |
|
656 | 656 | { |
657 | 657 | return False; |
658 | 658 | } |
659 | 659 | |
660 | - if(!$this->hooks_table) // No hooks table yet |
|
660 | + if (!$this->hooks_table) // No hooks table yet |
|
661 | 661 | { |
662 | 662 | return False; |
663 | 663 | } |
664 | 664 | |
665 | 665 | if (!is_object($this->hooks)) |
666 | 666 | { |
667 | - $this->hooks =& CreateObject('phpgwapi.hooks',$this->db,$this->hooks_table); |
|
667 | + $this->hooks = & CreateObject('phpgwapi.hooks', $this->db, $this->hooks_table); |
|
668 | 668 | } |
669 | - $this->hooks->register_hooks($appname,$setup_info[$appname]['hooks']); |
|
669 | + $this->hooks->register_hooks($appname, $setup_info[$appname]['hooks']); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | /** |
@@ -681,20 +681,20 @@ discard block |
||
681 | 681 | |
682 | 682 | if (!isset($setup_info) || !isset($setup_info['hooks'])) |
683 | 683 | { |
684 | - return false; // app not found or no hook |
|
684 | + return false; // app not found or no hook |
|
685 | 685 | } |
686 | 686 | $GLOBALS['settings'] = array(); |
687 | 687 | if (isset($setup_info['hooks']['settings'])) |
688 | 688 | { |
689 | - $settings = ExecMethod($setup_info['hooks']['settings'],array('location' => 'settings','setup' => true)); |
|
689 | + $settings = ExecMethod($setup_info['hooks']['settings'], array('location' => 'settings', 'setup' => true)); |
|
690 | 690 | } |
691 | - elseif(in_array('settings',$setup_info['hooks']) && file_exists($file = EGW_INCLUDE_ROOT.'/'.$appname.'/inc/hook_settings.inc.php')) |
|
691 | + elseif (in_array('settings', $setup_info['hooks']) && file_exists($file = EGW_INCLUDE_ROOT.'/'.$appname.'/inc/hook_settings.inc.php')) |
|
692 | 692 | { |
693 | 693 | include_once($file); |
694 | 694 | } |
695 | 695 | if (!isset($settings) || !is_array($settings)) |
696 | 696 | { |
697 | - $settings = $GLOBALS['settings']; // old file hook or not updated new hook |
|
697 | + $settings = $GLOBALS['settings']; // old file hook or not updated new hook |
|
698 | 698 | } |
699 | 699 | if (!is_array($settings) || !count($settings)) |
700 | 700 | { |
@@ -705,10 +705,10 @@ discard block |
||
705 | 705 | { |
706 | 706 | $GLOBALS['settings'] = array(); |
707 | 707 | include_once($file); |
708 | - if ($GLOBALS['settings']) $settings = array_merge($settings,$GLOBALS['settings']); |
|
708 | + if ($GLOBALS['settings']) $settings = array_merge($settings, $GLOBALS['settings']); |
|
709 | 709 | } |
710 | 710 | $default = $forced = array(); |
711 | - foreach($settings as $name => $setting) |
|
711 | + foreach ($settings as $name => $setting) |
|
712 | 712 | { |
713 | 713 | if (isset($setting['default'])) |
714 | 714 | { |
@@ -722,14 +722,14 @@ discard block |
||
722 | 722 | // store default/forced preferences, if any found |
723 | 723 | $preferences = new preferences(); |
724 | 724 | $preferences->read_repository(false); |
725 | - foreach(array( |
|
725 | + foreach (array( |
|
726 | 726 | 'default' => $default, |
727 | 727 | 'forced' => $forced, |
728 | 728 | ) as $type => $prefs) |
729 | 729 | { |
730 | 730 | if ($prefs) |
731 | 731 | { |
732 | - foreach($prefs as $name => $value) |
|
732 | + foreach ($prefs as $name => $value) |
|
733 | 733 | { |
734 | 734 | $preferences->add($appname == 'preferences' ? 'common' : $appname, $name, $value, $type); |
735 | 735 | } |
@@ -758,12 +758,12 @@ discard block |
||
758 | 758 | */ |
759 | 759 | function deregister_hooks($appname) |
760 | 760 | { |
761 | - if(!$this->hooks_table) // No hooks table yet |
|
761 | + if (!$this->hooks_table) // No hooks table yet |
|
762 | 762 | { |
763 | 763 | return False; |
764 | 764 | } |
765 | 765 | |
766 | - if(!$appname) |
|
766 | + if (!$appname) |
|
767 | 767 | { |
768 | 768 | return False; |
769 | 769 | } |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | //echo "DELETING hooks for: " . $setup_info[$appname]['name']; |
772 | 772 | if (!is_object($this->hooks)) |
773 | 773 | { |
774 | - $this->hooks =& CreateObject('phpgwapi.hooks',$this->db,$this->hooks_table); |
|
774 | + $this->hooks = & CreateObject('phpgwapi.hooks', $this->db, $this->hooks_table); |
|
775 | 775 | } |
776 | 776 | return $this->hooks->register_hooks($appname); |
777 | 777 | } |
@@ -782,13 +782,13 @@ discard block |
||
782 | 782 | * @param $location hook location - required |
783 | 783 | * @param $appname application name - optional |
784 | 784 | */ |
785 | - function hook($location, $appname='') |
|
785 | + function hook($location, $appname = '') |
|
786 | 786 | { |
787 | 787 | if (!is_object($this->hooks)) |
788 | 788 | { |
789 | - $this->hooks =& CreateObject('phpgwapi.hooks',$this->db,$this->hooks_table); |
|
789 | + $this->hooks = & CreateObject('phpgwapi.hooks', $this->db, $this->hooks_table); |
|
790 | 790 | } |
791 | - return $this->hooks->single($location,$appname,True,True); |
|
791 | + return $this->hooks->single($location, $appname, True, True); |
|
792 | 792 | } |
793 | 793 | |
794 | 794 | /** |
@@ -797,82 +797,82 @@ discard block |
||
797 | 797 | * @param $b phpgw version number to check $a against |
798 | 798 | * @return True if $a < $b |
799 | 799 | */ |
800 | - function alessthanb($a,$b,$DEBUG=False) |
|
800 | + function alessthanb($a, $b, $DEBUG = False) |
|
801 | 801 | { |
802 | - $num = array('1st','2nd','3rd','4th'); |
|
802 | + $num = array('1st', '2nd', '3rd', '4th'); |
|
803 | 803 | |
804 | - if($DEBUG) |
|
804 | + if ($DEBUG) |
|
805 | 805 | { |
806 | 806 | echo'<br>Input values: ' |
807 | 807 | . 'A="'.$a.'", B="'.$b.'"'; |
808 | 808 | } |
809 | - $newa = str_replace('pre','.',$a); |
|
810 | - $newb = str_replace('pre','.',$b); |
|
811 | - $testa = explode('.',$newa); |
|
812 | - if(@$testa[1] == '') |
|
809 | + $newa = str_replace('pre', '.', $a); |
|
810 | + $newb = str_replace('pre', '.', $b); |
|
811 | + $testa = explode('.', $newa); |
|
812 | + if (@$testa[1] == '') |
|
813 | 813 | { |
814 | 814 | $testa[1] = 0; |
815 | 815 | } |
816 | 816 | |
817 | - $testb = explode('.',$newb); |
|
818 | - if(@$testb[1] == '') |
|
817 | + $testb = explode('.', $newb); |
|
818 | + if (@$testb[1] == '') |
|
819 | 819 | { |
820 | 820 | $testb[1] = 0; |
821 | 821 | } |
822 | - if(@$testb[3] == '') |
|
822 | + if (@$testb[3] == '') |
|
823 | 823 | { |
824 | 824 | $testb[3] = 0; |
825 | 825 | } |
826 | 826 | $less = 0; |
827 | 827 | |
828 | - for($i=0;$i<count($testa);$i++) |
|
828 | + for ($i = 0; $i < count($testa); $i++) |
|
829 | 829 | { |
830 | - if($DEBUG) { echo'<br>Checking if '. (int)$testa[$i] . ' is less than ' . (int)$testb[$i] . ' ...'; } |
|
831 | - if((int)$testa[$i] < (int)$testb[$i]) |
|
830 | + if ($DEBUG) { echo'<br>Checking if '.(int)$testa[$i].' is less than '.(int)$testb[$i].' ...'; } |
|
831 | + if ((int)$testa[$i] < (int)$testb[$i]) |
|
832 | 832 | { |
833 | 833 | if ($DEBUG) { echo ' yes.'; } |
834 | 834 | $less++; |
835 | - if($i<3) |
|
835 | + if ($i < 3) |
|
836 | 836 | { |
837 | 837 | /* Ensure that this is definitely smaller */ |
838 | - if($DEBUG) { echo" This is the $num[$i] octet, so A is definitely less than B."; } |
|
838 | + if ($DEBUG) { echo" This is the $num[$i] octet, so A is definitely less than B."; } |
|
839 | 839 | $less = 5; |
840 | 840 | break; |
841 | 841 | } |
842 | 842 | } |
843 | - elseif((int)$testa[$i] > (int)$testb[$i]) |
|
843 | + elseif ((int)$testa[$i] > (int)$testb[$i]) |
|
844 | 844 | { |
845 | - if($DEBUG) { echo ' no.'; } |
|
845 | + if ($DEBUG) { echo ' no.'; } |
|
846 | 846 | $less--; |
847 | - if($i<2) |
|
847 | + if ($i < 2) |
|
848 | 848 | { |
849 | 849 | /* Ensure that this is definitely greater */ |
850 | - if($DEBUG) { echo" This is the $num[$i] octet, so A is definitely greater than B."; } |
|
850 | + if ($DEBUG) { echo" This is the $num[$i] octet, so A is definitely greater than B."; } |
|
851 | 851 | $less = -5; |
852 | 852 | break; |
853 | 853 | } |
854 | 854 | } |
855 | 855 | else |
856 | 856 | { |
857 | - if($DEBUG) { echo ' no, they are equal or of different length.'; } |
|
857 | + if ($DEBUG) { echo ' no, they are equal or of different length.'; } |
|
858 | 858 | // makes sure eg. '1.0.0' is counted less the '1.0.0.xxx' ! |
859 | 859 | $less = count($testa) < count($testb) ? 1 : 0; |
860 | 860 | } |
861 | 861 | } |
862 | - if($DEBUG) { echo '<br>Check value is: "'.$less.'"'; } |
|
863 | - if($less>0) |
|
862 | + if ($DEBUG) { echo '<br>Check value is: "'.$less.'"'; } |
|
863 | + if ($less > 0) |
|
864 | 864 | { |
865 | - if($DEBUG) { echo '<br>A is less than B'; } |
|
865 | + if ($DEBUG) { echo '<br>A is less than B'; } |
|
866 | 866 | return True; |
867 | 867 | } |
868 | - elseif($less<0) |
|
868 | + elseif ($less < 0) |
|
869 | 869 | { |
870 | - if($DEBUG) { echo '<br>A is greater than B'; } |
|
870 | + if ($DEBUG) { echo '<br>A is greater than B'; } |
|
871 | 871 | return False; |
872 | 872 | } |
873 | 873 | else |
874 | 874 | { |
875 | - if($DEBUG) { echo '<br>A is equal to B'; } |
|
875 | + if ($DEBUG) { echo '<br>A is equal to B'; } |
|
876 | 876 | return False; |
877 | 877 | } |
878 | 878 | } |
@@ -884,76 +884,76 @@ discard block |
||
884 | 884 | * @param $b phpgw version number to check $a against |
885 | 885 | * @return True if $a < $b |
886 | 886 | */ |
887 | - function amorethanb($a,$b,$DEBUG=False) |
|
887 | + function amorethanb($a, $b, $DEBUG = False) |
|
888 | 888 | { |
889 | - $num = array('1st','2nd','3rd','4th'); |
|
889 | + $num = array('1st', '2nd', '3rd', '4th'); |
|
890 | 890 | |
891 | - if($DEBUG) |
|
891 | + if ($DEBUG) |
|
892 | 892 | { |
893 | 893 | echo'<br>Input values: ' |
894 | 894 | . 'A="'.$a.'", B="'.$b.'"'; |
895 | 895 | } |
896 | - $newa = str_replace('pre','.',$a); |
|
897 | - $newb = str_replace('pre','.',$b); |
|
898 | - $testa = explode('.',$newa); |
|
899 | - if($testa[3] == '') |
|
896 | + $newa = str_replace('pre', '.', $a); |
|
897 | + $newb = str_replace('pre', '.', $b); |
|
898 | + $testa = explode('.', $newa); |
|
899 | + if ($testa[3] == '') |
|
900 | 900 | { |
901 | 901 | $testa[3] = 0; |
902 | 902 | } |
903 | - $testb = explode('.',$newb); |
|
904 | - if($testb[3] == '') |
|
903 | + $testb = explode('.', $newb); |
|
904 | + if ($testb[3] == '') |
|
905 | 905 | { |
906 | 906 | $testb[3] = 0; |
907 | 907 | } |
908 | 908 | $less = 0; |
909 | 909 | |
910 | - for($i=0;$i<count($testa);$i++) |
|
910 | + for ($i = 0; $i < count($testa); $i++) |
|
911 | 911 | { |
912 | - if($DEBUG) { echo'<br>Checking if '. (int)$testa[$i] . ' is more than ' . (int)$testb[$i] . ' ...'; } |
|
913 | - if((int)$testa[$i] > (int)$testb[$i]) |
|
912 | + if ($DEBUG) { echo'<br>Checking if '.(int)$testa[$i].' is more than '.(int)$testb[$i].' ...'; } |
|
913 | + if ((int)$testa[$i] > (int)$testb[$i]) |
|
914 | 914 | { |
915 | - if($DEBUG) { echo ' yes.'; } |
|
915 | + if ($DEBUG) { echo ' yes.'; } |
|
916 | 916 | $less++; |
917 | - if($i<3) |
|
917 | + if ($i < 3) |
|
918 | 918 | { |
919 | 919 | /* Ensure that this is definitely greater */ |
920 | - if($DEBUG) { echo" This is the $num[$i] octet, so A is definitely greater than B."; } |
|
920 | + if ($DEBUG) { echo" This is the $num[$i] octet, so A is definitely greater than B."; } |
|
921 | 921 | $less = 5; |
922 | 922 | break; |
923 | 923 | } |
924 | 924 | } |
925 | - elseif((int)$testa[$i] < (int)$testb[$i]) |
|
925 | + elseif ((int)$testa[$i] < (int)$testb[$i]) |
|
926 | 926 | { |
927 | - if($DEBUG) { echo ' no.'; } |
|
927 | + if ($DEBUG) { echo ' no.'; } |
|
928 | 928 | $less--; |
929 | - if($i<2) |
|
929 | + if ($i < 2) |
|
930 | 930 | { |
931 | 931 | /* Ensure that this is definitely smaller */ |
932 | - if($DEBUG) { echo" This is the $num[$i] octet, so A is definitely less than B."; } |
|
932 | + if ($DEBUG) { echo" This is the $num[$i] octet, so A is definitely less than B."; } |
|
933 | 933 | $less = -5; |
934 | 934 | break; |
935 | 935 | } |
936 | 936 | } |
937 | 937 | else |
938 | 938 | { |
939 | - if($DEBUG) { echo ' no, they are equal.'; } |
|
939 | + if ($DEBUG) { echo ' no, they are equal.'; } |
|
940 | 940 | $less = 0; |
941 | 941 | } |
942 | 942 | } |
943 | - if($DEBUG) { echo '<br>Check value is: "'.$less.'"'; } |
|
944 | - if($less>0) |
|
943 | + if ($DEBUG) { echo '<br>Check value is: "'.$less.'"'; } |
|
944 | + if ($less > 0) |
|
945 | 945 | { |
946 | - if($DEBUG) { echo '<br>A is greater than B'; } |
|
946 | + if ($DEBUG) { echo '<br>A is greater than B'; } |
|
947 | 947 | return True; |
948 | 948 | } |
949 | - elseif($less<0) |
|
949 | + elseif ($less < 0) |
|
950 | 950 | { |
951 | - if($DEBUG) { echo '<br>A is less than B'; } |
|
951 | + if ($DEBUG) { echo '<br>A is less than B'; } |
|
952 | 952 | return False; |
953 | 953 | } |
954 | 954 | else |
955 | 955 | { |
956 | - if($DEBUG) { echo '<br>A is equal to B'; } |
|
956 | + if ($DEBUG) { echo '<br>A is equal to B'; } |
|
957 | 957 | return False; |
958 | 958 | } |
959 | 959 | } |
@@ -965,7 +965,7 @@ discard block |
||
965 | 965 | */ |
966 | 966 | var $accounts; |
967 | 967 | |
968 | - function setup_account_object(array $config=array()) |
|
968 | + function setup_account_object(array $config = array()) |
|
969 | 969 | { |
970 | 970 | if (!isset($this->accounts) || $this->accounts->config || $config) |
971 | 971 | { |
@@ -976,9 +976,9 @@ discard block |
||
976 | 976 | if (!$config) |
977 | 977 | { |
978 | 978 | // load the configuration from the database |
979 | - foreach($this->db->select($this->config_table,'config_name,config_value', |
|
979 | + foreach ($this->db->select($this->config_table, 'config_name,config_value', |
|
980 | 980 | "config_name LIKE 'ads%' OR config_name LIKE 'ldap%' OR config_name LIKE 'account_%' OR config_name LIKE '%encryption%' OR config_name='auth_type'", |
981 | - __LINE__,__FILE__) as $row) |
|
981 | + __LINE__, __FILE__) as $row) |
|
982 | 982 | { |
983 | 983 | $GLOBALS['egw_info']['server'][$row['config_name']] = $config[$row['config_name']] = $row['config_value']; |
984 | 984 | } |
@@ -991,7 +991,7 @@ discard block |
||
991 | 991 | return false; |
992 | 992 | } |
993 | 993 | if (!isset($GLOBALS['egw']->accounts)) $GLOBALS['egw']->accounts = $this->accounts; |
994 | - accounts::cache_invalidate(); // the cache is shared for all instances of the class |
|
994 | + accounts::cache_invalidate(); // the cache is shared for all instances of the class |
|
995 | 995 | } |
996 | 996 | return true; |
997 | 997 | } |
@@ -1017,7 +1017,7 @@ discard block |
||
1017 | 1017 | * @param string &$anonpw=null on return password for anonymous user |
1018 | 1018 | * @return int the numerical user-id |
1019 | 1019 | */ |
1020 | - function add_account($username,$first,$last,$passwd,$primary_group='Default',$changepw=False,$email='',&$anonpw=null) |
|
1020 | + function add_account($username, $first, $last, $passwd, $primary_group = 'Default', $changepw = False, $email = '', &$anonpw = null) |
|
1021 | 1021 | { |
1022 | 1022 | $this->setup_account_object(); |
1023 | 1023 | |
@@ -1029,7 +1029,7 @@ discard block |
||
1029 | 1029 | $passwd = $anonpw = $this->anonpw; |
1030 | 1030 | } |
1031 | 1031 | |
1032 | - if(!($accountid = $this->accounts->name2id($username, 'account_lid', $primary_group ? 'u' : 'g'))) |
|
1032 | + if (!($accountid = $this->accounts->name2id($username, 'account_lid', $primary_group ? 'u' : 'g'))) |
|
1033 | 1033 | { |
1034 | 1034 | $account = array( |
1035 | 1035 | 'account_type' => $primary_group ? 'u' : 'g', |
@@ -1050,7 +1050,7 @@ discard block |
||
1050 | 1050 | } |
1051 | 1051 | } |
1052 | 1052 | // set password for existing account, if given and not '*unchanged*' |
1053 | - elseif($passwd && $passwd != '*unchanged*') |
|
1053 | + elseif ($passwd && $passwd != '*unchanged*') |
|
1054 | 1054 | { |
1055 | 1055 | try { |
1056 | 1056 | $auth = new auth; |
@@ -1088,7 +1088,7 @@ discard block |
||
1088 | 1088 | { |
1089 | 1089 | $this->set_memberships(array($primary_group_id), $accountid); |
1090 | 1090 | |
1091 | - if (!$changepw) $this->add_acl('preferences','nopasswordchange',$accountid); |
|
1091 | + if (!$changepw) $this->add_acl('preferences', 'nopasswordchange', $accountid); |
|
1092 | 1092 | } |
1093 | 1093 | //error_log("setup::add_account('$username','$first','$last',\$passwd,'$primary_group',$changepw,'$email') successfull created accountid=$accountid"); |
1094 | 1094 | return $accountid; |
@@ -1136,7 +1136,7 @@ discard block |
||
1136 | 1136 | { |
1137 | 1137 | return false; |
1138 | 1138 | } |
1139 | - foreach($accounts as $account) |
|
1139 | + foreach ($accounts as $account) |
|
1140 | 1140 | { |
1141 | 1141 | if ($account['account_lid'] != 'anonymous') |
1142 | 1142 | { |
@@ -1157,7 +1157,7 @@ discard block |
||
1157 | 1157 | * @param int|string $account accountid or account_lid |
1158 | 1158 | * @param int $rights rights to set, default 1 |
1159 | 1159 | */ |
1160 | - function add_acl($apps,$location,$account,$rights=1) |
|
1160 | + function add_acl($apps, $location, $account, $rights = 1) |
|
1161 | 1161 | { |
1162 | 1162 | //error_log("setup::add_acl(".(is_array($apps) ? "array('".implode("','",$apps)."')" : "'$apps'").",'$location',$account,$rights)"); |
1163 | 1163 | if (!is_numeric($account)) |
@@ -1165,32 +1165,32 @@ discard block |
||
1165 | 1165 | $this->setup_account_object(); |
1166 | 1166 | $account = $this->accounts->name2id($account); |
1167 | 1167 | } |
1168 | - if(!is_object($this->db)) |
|
1168 | + if (!is_object($this->db)) |
|
1169 | 1169 | { |
1170 | 1170 | $this->loaddb(); |
1171 | 1171 | } |
1172 | 1172 | |
1173 | - if(!is_array($apps)) |
|
1173 | + if (!is_array($apps)) |
|
1174 | 1174 | { |
1175 | 1175 | $apps = array($apps); |
1176 | 1176 | } |
1177 | - foreach($apps as $app) |
|
1177 | + foreach ($apps as $app) |
|
1178 | 1178 | { |
1179 | - $this->db->delete($this->acl_table,array( |
|
1179 | + $this->db->delete($this->acl_table, array( |
|
1180 | 1180 | 'acl_appname' => $app, |
1181 | 1181 | 'acl_location' => $location, |
1182 | 1182 | 'acl_account' => $account |
1183 | - ),__LINE__,__FILE__); |
|
1183 | + ), __LINE__, __FILE__); |
|
1184 | 1184 | |
1185 | - if ((int) $rights) |
|
1185 | + if ((int)$rights) |
|
1186 | 1186 | { |
1187 | - $this->db->insert($this->acl_table,array( |
|
1187 | + $this->db->insert($this->acl_table, array( |
|
1188 | 1188 | 'acl_rights' => $rights |
1189 | - ),array( |
|
1189 | + ), array( |
|
1190 | 1190 | 'acl_appname' => $app, |
1191 | 1191 | 'acl_location' => $location, |
1192 | 1192 | 'acl_account' => $account, |
1193 | - ),__LINE__,__FILE__); |
|
1193 | + ), __LINE__, __FILE__); |
|
1194 | 1194 | } |
1195 | 1195 | } |
1196 | 1196 | } |
@@ -1201,7 +1201,7 @@ discard block |
||
1201 | 1201 | * @param array $tables array with possible table-names |
1202 | 1202 | * @return string/boolean tablename or false |
1203 | 1203 | */ |
1204 | - function table_exist($tables,$force_refresh=False) |
|
1204 | + function table_exist($tables, $force_refresh = False) |
|
1205 | 1205 | { |
1206 | 1206 | static $table_names = False; |
1207 | 1207 | |
@@ -1209,9 +1209,9 @@ discard block |
||
1209 | 1209 | |
1210 | 1210 | if (!$table_names) return false; |
1211 | 1211 | |
1212 | - foreach($table_names as $data) |
|
1212 | + foreach ($table_names as $data) |
|
1213 | 1213 | { |
1214 | - if (($key = array_search($data['table_name'],$tables)) !== false) |
|
1214 | + if (($key = array_search($data['table_name'], $tables)) !== false) |
|
1215 | 1215 | { |
1216 | 1216 | return $tables[$key]; |
1217 | 1217 | } |
@@ -1224,18 +1224,18 @@ discard block |
||
1224 | 1224 | * |
1225 | 1225 | * Other tables can always use the most up to date name |
1226 | 1226 | */ |
1227 | - function set_table_names($force_refresh=False) |
|
1227 | + function set_table_names($force_refresh = False) |
|
1228 | 1228 | { |
1229 | - foreach(array( |
|
1230 | - 'config_table' => array('egw_config','phpgw_config','config'), |
|
1231 | - 'applications_table' => array('egw_applications','phpgw_applications','applications'), |
|
1232 | - 'accounts_table' => array('egw_accounts','phpgw_accounts'), |
|
1233 | - 'acl_table' => array('egw_acl','phpgw_acl'), |
|
1234 | - 'lang_table' => array('egw_lang','phpgw_lang','lang'), |
|
1235 | - 'languages_table' => array('egw_languages','phpgw_languages','languages'), |
|
1229 | + foreach (array( |
|
1230 | + 'config_table' => array('egw_config', 'phpgw_config', 'config'), |
|
1231 | + 'applications_table' => array('egw_applications', 'phpgw_applications', 'applications'), |
|
1232 | + 'accounts_table' => array('egw_accounts', 'phpgw_accounts'), |
|
1233 | + 'acl_table' => array('egw_acl', 'phpgw_acl'), |
|
1234 | + 'lang_table' => array('egw_lang', 'phpgw_lang', 'lang'), |
|
1235 | + 'languages_table' => array('egw_languages', 'phpgw_languages', 'languages'), |
|
1236 | 1236 | ) as $name => $tables) |
1237 | 1237 | { |
1238 | - $table = $this->table_exist($tables,$force_refresh); |
|
1238 | + $table = $this->table_exist($tables, $force_refresh); |
|
1239 | 1239 | |
1240 | 1240 | if ($table && $table != $this->$name) // only overwrite the default name, if we realy got one (important for new installs) |
1241 | 1241 | { |
@@ -88,11 +88,20 @@ discard block |
||
88 | 88 | $this->detection = new setup_detection(); |
89 | 89 | $this->process = new setup_process(); |
90 | 90 | |
91 | - if (preg_match('/^[a-z0-9-]+$/i', $_REQUEST['system_charset'])) $this->system_charset = $_REQUEST['system_charset']; |
|
91 | + if (preg_match('/^[a-z0-9-]+$/i', $_REQUEST['system_charset'])) |
|
92 | + { |
|
93 | + $this->system_charset = $_REQUEST['system_charset']; |
|
94 | + } |
|
92 | 95 | |
93 | 96 | /* The setup application needs these */ |
94 | - if ($html) $this->html = new setup_html(); |
|
95 | - if ($translation) $this->translation = new setup_translation(); |
|
97 | + if ($html) |
|
98 | + { |
|
99 | + $this->html = new setup_html(); |
|
100 | + } |
|
101 | + if ($translation) |
|
102 | + { |
|
103 | + $this->translation = new setup_translation(); |
|
104 | + } |
|
96 | 105 | } |
97 | 106 | |
98 | 107 | /** |
@@ -136,11 +145,14 @@ discard block |
||
136 | 145 | $this->db_charset_was = $this->db->Link_ID->GetCharSet(); // needed for the update |
137 | 146 | |
138 | 147 | // we can NOT set the DB charset for mysql, if the api version < 1.0.1.019, as it would mess up the DB content!!! |
139 | - if (substr($this->db->Type,0,5) == 'mysql') // we need to check the api version |
|
148 | + if (substr($this->db->Type,0,5) == 'mysql') |
|
149 | + { |
|
150 | + // we need to check the api version |
|
140 | 151 | { |
141 | 152 | $this->db->select($this->applications_table,'app_version',array( |
142 | 153 | 'app_name' => 'phpgwapi', |
143 | 154 | ),__LINE__,__FILE__); |
155 | + } |
|
144 | 156 | $api_version = $this->db->next_record() ? $this->db->f(0) : false; |
145 | 157 | } |
146 | 158 | if (!$api_version || !$this->alessthanb($api_version,'1.0.1.019')) |
@@ -210,7 +222,10 @@ discard block |
||
210 | 222 | } |
211 | 223 | else |
212 | 224 | { |
213 | - if (!isset($_SESSION)) self::session_start(); |
|
225 | + if (!isset($_SESSION)) |
|
226 | + { |
|
227 | + self::session_start(); |
|
228 | + } |
|
214 | 229 | $ConfigLang = $_SESSION['ConfigLang']; |
215 | 230 | } |
216 | 231 | if (!preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$ConfigLang)) |
@@ -245,7 +260,10 @@ discard block |
||
245 | 260 | // if called via HTTPS, only send cookie for https and only allow cookie access via HTTP (true) |
246 | 261 | !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off', true); |
247 | 262 | |
248 | - if (isset($_COOKIE[self::SESSIONID])) session_id($_COOKIE[self::SESSIONID]); |
|
263 | + if (isset($_COOKIE[self::SESSIONID])) |
|
264 | + { |
|
265 | + session_id($_COOKIE[self::SESSIONID]); |
|
266 | + } |
|
249 | 267 | |
250 | 268 | $ok = @session_start(); // suppress notice if session already started or warning in CLI |
251 | 269 | // need to decrypt session, in case session encryption is switched on in header.inc.php |
@@ -657,10 +675,13 @@ discard block |
||
657 | 675 | return False; |
658 | 676 | } |
659 | 677 | |
660 | - if(!$this->hooks_table) // No hooks table yet |
|
678 | + if(!$this->hooks_table) |
|
679 | + { |
|
680 | + // No hooks table yet |
|
661 | 681 | { |
662 | 682 | return False; |
663 | 683 | } |
684 | + } |
|
664 | 685 | |
665 | 686 | if (!is_object($this->hooks)) |
666 | 687 | { |
@@ -705,7 +726,10 @@ discard block |
||
705 | 726 | { |
706 | 727 | $GLOBALS['settings'] = array(); |
707 | 728 | include_once($file); |
708 | - if ($GLOBALS['settings']) $settings = array_merge($settings,$GLOBALS['settings']); |
|
729 | + if ($GLOBALS['settings']) |
|
730 | + { |
|
731 | + $settings = array_merge($settings,$GLOBALS['settings']); |
|
732 | + } |
|
709 | 733 | } |
710 | 734 | $default = $forced = array(); |
711 | 735 | foreach($settings as $name => $setting) |
@@ -758,10 +782,13 @@ discard block |
||
758 | 782 | */ |
759 | 783 | function deregister_hooks($appname) |
760 | 784 | { |
761 | - if(!$this->hooks_table) // No hooks table yet |
|
785 | + if(!$this->hooks_table) |
|
786 | + { |
|
787 | + // No hooks table yet |
|
762 | 788 | { |
763 | 789 | return False; |
764 | 790 | } |
791 | + } |
|
765 | 792 | |
766 | 793 | if(!$appname) |
767 | 794 | { |
@@ -827,52 +854,72 @@ discard block |
||
827 | 854 | |
828 | 855 | for($i=0;$i<count($testa);$i++) |
829 | 856 | { |
830 | - if($DEBUG) { echo'<br>Checking if '. (int)$testa[$i] . ' is less than ' . (int)$testb[$i] . ' ...'; } |
|
857 | + if($DEBUG) |
|
858 | + { |
|
859 | +echo'<br>Checking if '. (int)$testa[$i] . ' is less than ' . (int)$testb[$i] . ' ...'; } |
|
831 | 860 | if((int)$testa[$i] < (int)$testb[$i]) |
832 | 861 | { |
833 | - if ($DEBUG) { echo ' yes.'; } |
|
862 | + if ($DEBUG) |
|
863 | + { |
|
864 | +echo ' yes.'; } |
|
834 | 865 | $less++; |
835 | 866 | if($i<3) |
836 | 867 | { |
837 | 868 | /* Ensure that this is definitely smaller */ |
838 | - if($DEBUG) { echo" This is the $num[$i] octet, so A is definitely less than B."; } |
|
869 | + if($DEBUG) |
|
870 | + { |
|
871 | +echo" This is the $num[$i] octet, so A is definitely less than B."; } |
|
839 | 872 | $less = 5; |
840 | 873 | break; |
841 | 874 | } |
842 | 875 | } |
843 | 876 | elseif((int)$testa[$i] > (int)$testb[$i]) |
844 | 877 | { |
845 | - if($DEBUG) { echo ' no.'; } |
|
878 | + if($DEBUG) |
|
879 | + { |
|
880 | +echo ' no.'; } |
|
846 | 881 | $less--; |
847 | 882 | if($i<2) |
848 | 883 | { |
849 | 884 | /* Ensure that this is definitely greater */ |
850 | - if($DEBUG) { echo" This is the $num[$i] octet, so A is definitely greater than B."; } |
|
885 | + if($DEBUG) |
|
886 | + { |
|
887 | +echo" This is the $num[$i] octet, so A is definitely greater than B."; } |
|
851 | 888 | $less = -5; |
852 | 889 | break; |
853 | 890 | } |
854 | 891 | } |
855 | 892 | else |
856 | 893 | { |
857 | - if($DEBUG) { echo ' no, they are equal or of different length.'; } |
|
894 | + if($DEBUG) |
|
895 | + { |
|
896 | +echo ' no, they are equal or of different length.'; } |
|
858 | 897 | // makes sure eg. '1.0.0' is counted less the '1.0.0.xxx' ! |
859 | 898 | $less = count($testa) < count($testb) ? 1 : 0; |
860 | 899 | } |
861 | 900 | } |
862 | - if($DEBUG) { echo '<br>Check value is: "'.$less.'"'; } |
|
901 | + if($DEBUG) |
|
902 | + { |
|
903 | +echo '<br>Check value is: "'.$less.'"'; } |
|
863 | 904 | if($less>0) |
864 | 905 | { |
865 | - if($DEBUG) { echo '<br>A is less than B'; } |
|
906 | + if($DEBUG) |
|
907 | + { |
|
908 | +echo '<br>A is less than B'; } |
|
866 | 909 | return True; |
867 | 910 | } |
868 | 911 | elseif($less<0) |
869 | 912 | { |
870 | - if($DEBUG) { echo '<br>A is greater than B'; } |
|
913 | + if($DEBUG) |
|
914 | + { |
|
915 | +echo '<br>A is greater than B'; } |
|
871 | 916 | return False; |
872 | 917 | } |
873 | 918 | else |
874 | 919 | { |
875 | - if($DEBUG) { echo '<br>A is equal to B'; } |
|
920 | + if($DEBUG) |
|
921 | + { |
|
922 | +echo '<br>A is equal to B'; } |
|
876 | 923 | return False; |
877 | 924 | } |
878 | 925 | } |
@@ -909,51 +956,71 @@ discard block |
||
909 | 956 | |
910 | 957 | for($i=0;$i<count($testa);$i++) |
911 | 958 | { |
912 | - if($DEBUG) { echo'<br>Checking if '. (int)$testa[$i] . ' is more than ' . (int)$testb[$i] . ' ...'; } |
|
959 | + if($DEBUG) |
|
960 | + { |
|
961 | +echo'<br>Checking if '. (int)$testa[$i] . ' is more than ' . (int)$testb[$i] . ' ...'; } |
|
913 | 962 | if((int)$testa[$i] > (int)$testb[$i]) |
914 | 963 | { |
915 | - if($DEBUG) { echo ' yes.'; } |
|
964 | + if($DEBUG) |
|
965 | + { |
|
966 | +echo ' yes.'; } |
|
916 | 967 | $less++; |
917 | 968 | if($i<3) |
918 | 969 | { |
919 | 970 | /* Ensure that this is definitely greater */ |
920 | - if($DEBUG) { echo" This is the $num[$i] octet, so A is definitely greater than B."; } |
|
971 | + if($DEBUG) |
|
972 | + { |
|
973 | +echo" This is the $num[$i] octet, so A is definitely greater than B."; } |
|
921 | 974 | $less = 5; |
922 | 975 | break; |
923 | 976 | } |
924 | 977 | } |
925 | 978 | elseif((int)$testa[$i] < (int)$testb[$i]) |
926 | 979 | { |
927 | - if($DEBUG) { echo ' no.'; } |
|
980 | + if($DEBUG) |
|
981 | + { |
|
982 | +echo ' no.'; } |
|
928 | 983 | $less--; |
929 | 984 | if($i<2) |
930 | 985 | { |
931 | 986 | /* Ensure that this is definitely smaller */ |
932 | - if($DEBUG) { echo" This is the $num[$i] octet, so A is definitely less than B."; } |
|
987 | + if($DEBUG) |
|
988 | + { |
|
989 | +echo" This is the $num[$i] octet, so A is definitely less than B."; } |
|
933 | 990 | $less = -5; |
934 | 991 | break; |
935 | 992 | } |
936 | 993 | } |
937 | 994 | else |
938 | 995 | { |
939 | - if($DEBUG) { echo ' no, they are equal.'; } |
|
996 | + if($DEBUG) |
|
997 | + { |
|
998 | +echo ' no, they are equal.'; } |
|
940 | 999 | $less = 0; |
941 | 1000 | } |
942 | 1001 | } |
943 | - if($DEBUG) { echo '<br>Check value is: "'.$less.'"'; } |
|
1002 | + if($DEBUG) |
|
1003 | + { |
|
1004 | +echo '<br>Check value is: "'.$less.'"'; } |
|
944 | 1005 | if($less>0) |
945 | 1006 | { |
946 | - if($DEBUG) { echo '<br>A is greater than B'; } |
|
1007 | + if($DEBUG) |
|
1008 | + { |
|
1009 | +echo '<br>A is greater than B'; } |
|
947 | 1010 | return True; |
948 | 1011 | } |
949 | 1012 | elseif($less<0) |
950 | 1013 | { |
951 | - if($DEBUG) { echo '<br>A is less than B'; } |
|
1014 | + if($DEBUG) |
|
1015 | + { |
|
1016 | +echo '<br>A is less than B'; } |
|
952 | 1017 | return False; |
953 | 1018 | } |
954 | 1019 | else |
955 | 1020 | { |
956 | - if($DEBUG) { echo '<br>A is equal to B'; } |
|
1021 | + if($DEBUG) |
|
1022 | + { |
|
1023 | +echo '<br>A is equal to B'; } |
|
957 | 1024 | return False; |
958 | 1025 | } |
959 | 1026 | } |
@@ -990,7 +1057,10 @@ discard block |
||
990 | 1057 | echo "<p><b>".$e->getMessage()."</b></p>\n"; |
991 | 1058 | return false; |
992 | 1059 | } |
993 | - if (!isset($GLOBALS['egw']->accounts)) $GLOBALS['egw']->accounts = $this->accounts; |
|
1060 | + if (!isset($GLOBALS['egw']->accounts)) |
|
1061 | + { |
|
1062 | + $GLOBALS['egw']->accounts = $this->accounts; |
|
1063 | + } |
|
994 | 1064 | accounts::cache_invalidate(); // the cache is shared for all instances of the class |
995 | 1065 | } |
996 | 1066 | return true; |
@@ -1025,7 +1095,10 @@ discard block |
||
1025 | 1095 | |
1026 | 1096 | if ($username == 'anonymous') |
1027 | 1097 | { |
1028 | - if (!isset($this->anonpw)) $this->anonpw = auth::randomstring(16); |
|
1098 | + if (!isset($this->anonpw)) |
|
1099 | + { |
|
1100 | + $this->anonpw = auth::randomstring(16); |
|
1101 | + } |
|
1029 | 1102 | $passwd = $anonpw = $this->anonpw; |
1030 | 1103 | } |
1031 | 1104 | |
@@ -1084,11 +1157,17 @@ discard block |
||
1084 | 1157 | 'account_lid' => $username, |
1085 | 1158 | )); |
1086 | 1159 | } |
1087 | - if ($primary_group) // only for users, NOT groups |
|
1160 | + if ($primary_group) |
|
1161 | + { |
|
1162 | + // only for users, NOT groups |
|
1088 | 1163 | { |
1089 | 1164 | $this->set_memberships(array($primary_group_id), $accountid); |
1165 | + } |
|
1090 | 1166 | |
1091 | - if (!$changepw) $this->add_acl('preferences','nopasswordchange',$accountid); |
|
1167 | + if (!$changepw) |
|
1168 | + { |
|
1169 | + $this->add_acl('preferences','nopasswordchange',$accountid); |
|
1170 | + } |
|
1092 | 1171 | } |
1093 | 1172 | //error_log("setup::add_account('$username','$first','$last',\$passwd,'$primary_group',$changepw,'$email') successfull created accountid=$accountid"); |
1094 | 1173 | return $accountid; |
@@ -1124,7 +1203,10 @@ discard block |
||
1124 | 1203 | */ |
1125 | 1204 | function accounts_exist() |
1126 | 1205 | { |
1127 | - if (!$this->setup_account_object()) return false; |
|
1206 | + if (!$this->setup_account_object()) |
|
1207 | + { |
|
1208 | + return false; |
|
1209 | + } |
|
1128 | 1210 | |
1129 | 1211 | $accounts = $this->accounts->search(array( |
1130 | 1212 | 'type' => 'accounts', |
@@ -1205,9 +1287,15 @@ discard block |
||
1205 | 1287 | { |
1206 | 1288 | static $table_names = False; |
1207 | 1289 | |
1208 | - if (!$table_names || $force_refresh) $table_names = $this->db->table_names(); |
|
1290 | + if (!$table_names || $force_refresh) |
|
1291 | + { |
|
1292 | + $table_names = $this->db->table_names(); |
|
1293 | + } |
|
1209 | 1294 | |
1210 | - if (!$table_names) return false; |
|
1295 | + if (!$table_names) |
|
1296 | + { |
|
1297 | + return false; |
|
1298 | + } |
|
1211 | 1299 | |
1212 | 1300 | foreach($table_names as $data) |
1213 | 1301 | { |
@@ -1237,10 +1325,13 @@ discard block |
||
1237 | 1325 | { |
1238 | 1326 | $table = $this->table_exist($tables,$force_refresh); |
1239 | 1327 | |
1240 | - if ($table && $table != $this->$name) // only overwrite the default name, if we realy got one (important for new installs) |
|
1328 | + if ($table && $table != $this->$name) |
|
1329 | + { |
|
1330 | + // only overwrite the default name, if we realy got one (important for new installs) |
|
1241 | 1331 | { |
1242 | 1332 | $this->$name = $table; |
1243 | 1333 | } |
1334 | + } |
|
1244 | 1335 | //echo "<p>setup::set_table_names: $name = '{$this->$name}'</p>\n"; |
1245 | 1336 | } |
1246 | 1337 | } |
@@ -222,7 +222,7 @@ |
||
222 | 222 | . '<br />'.lang('to allow password authentification add the following line to your pg_hba.conf (above all others) AND restart postgres:') |
223 | 223 | . '<br /><i># TYPE DATABASE USER CIDR-ADDRESS METHOD</i>' |
224 | 224 | .($info['db_host'] ? "<br /><i><b>host $info[db_name] $info[db_user] $ip/32 password</b></i>" : |
225 | - "<br /><i><b>local $info[db_name] $info[db_user] password</b></i>")); |
|
225 | + "<br /><i><b>local $info[db_name] $info[db_user] password</b></i>")); |
|
226 | 226 | //$setup_tpl->parse('V_db_stage_1','B_db_stage_1'); |
227 | 227 | //break; |
228 | 228 | default: |
@@ -49,10 +49,13 @@ discard block |
||
49 | 49 | $GLOBALS['egw_info']['setup']['stage']['header'] = $GLOBALS['egw_setup']->detection->check_header(); |
50 | 50 | if ($GLOBALS['egw_info']['setup']['stage']['header'] != '10') |
51 | 51 | { |
52 | - if ($GLOBALS['egw_info']['setup']['stage']['header'] == 4) // header needs update, go there direct |
|
52 | + if ($GLOBALS['egw_info']['setup']['stage']['header'] == 4) |
|
53 | + { |
|
54 | + // header needs update, go there direct |
|
53 | 55 | { |
54 | 56 | Header('Location: manageheader.php'); |
55 | 57 | } |
58 | + } |
|
56 | 59 | else // run check-install first |
57 | 60 | { |
58 | 61 | Header('Location: check_install.php?intro=1'); |
@@ -97,7 +100,9 @@ discard block |
||
97 | 100 | } |
98 | 101 | } |
99 | 102 | |
100 | -if ($GLOBALS['DEBUG']) { echo 'Stage: ' . $GLOBALS['egw_info']['setup']['stage']['db']; } |
|
103 | +if ($GLOBALS['DEBUG']) |
|
104 | +{ |
|
105 | +echo 'Stage: ' . $GLOBALS['egw_info']['setup']['stage']['db']; } |
|
101 | 106 | // begin DEBUG code |
102 | 107 | //$GLOBALS['egw_info']['setup']['stage']['db'] = 0; |
103 | 108 | //$action = 'Upgrade'; |
@@ -501,8 +506,14 @@ discard block |
||
501 | 506 | $msg = ''; |
502 | 507 | if ($to_upgrade || $to_install) |
503 | 508 | { |
504 | - if ($to_upgrade) $msg = '<b>'.lang('The following applications need to be upgraded:').'</b> '.implode(', ',$to_upgrade); |
|
505 | - if ($to_install) $msg .= ($msg?'<br />':'').'<b>'.lang('The following applications are required, but NOT installed:').'</b> '.implode(', ',$to_install); |
|
509 | + if ($to_upgrade) |
|
510 | + { |
|
511 | + $msg = '<b>'.lang('The following applications need to be upgraded:').'</b> '.implode(', ',$to_upgrade); |
|
512 | + } |
|
513 | + if ($to_install) |
|
514 | + { |
|
515 | + $msg .= ($msg?'<br />':'').'<b>'.lang('The following applications are required, but NOT installed:').'</b> '.implode(', ',$to_install); |
|
516 | + } |
|
506 | 517 | } |
507 | 518 | $btn_manage_apps = $GLOBALS['egw_setup']->html->make_frm_btn_simple( |
508 | 519 | $msg ? $msg : lang('This stage is completed<br />'), |
@@ -180,17 +180,17 @@ discard block |
||
180 | 180 | |
181 | 181 | switch($GLOBALS['egw_info']['setup']['stage']['db']) |
182 | 182 | { |
183 | - case 1: |
|
184 | - $setup_tpl->set_var('dbnotexist','<b>'.lang('Your Database is not working!').'</b>: '.$GLOBALS['egw_setup']->db->Error); |
|
185 | - $setup_tpl->set_var('makesure',lang('Make sure that your database is created and the account permissions are set')); |
|
186 | - $setup_tpl->set_var('notcomplete',lang('not complete')); |
|
187 | - $setup_tpl->set_var('oncesetup',lang('Once the database is setup correctly')); |
|
188 | - $setup_tpl->set_var('createdb','<b>'.lang('Or we can attempt to create the database for you:').'</b>'); |
|
189 | - $setup_tpl->set_var('create_database',lang('Create database')); |
|
190 | - $setup_tpl->set_var('instr',''); |
|
191 | - $info = $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]; |
|
192 | - switch ($info['db_type']) |
|
193 | - { |
|
183 | + case 1: |
|
184 | + $setup_tpl->set_var('dbnotexist','<b>'.lang('Your Database is not working!').'</b>: '.$GLOBALS['egw_setup']->db->Error); |
|
185 | + $setup_tpl->set_var('makesure',lang('Make sure that your database is created and the account permissions are set')); |
|
186 | + $setup_tpl->set_var('notcomplete',lang('not complete')); |
|
187 | + $setup_tpl->set_var('oncesetup',lang('Once the database is setup correctly')); |
|
188 | + $setup_tpl->set_var('createdb','<b>'.lang('Or we can attempt to create the database for you:').'</b>'); |
|
189 | + $setup_tpl->set_var('create_database',lang('Create database')); |
|
190 | + $setup_tpl->set_var('instr',''); |
|
191 | + $info = $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]; |
|
192 | + switch ($info['db_type']) |
|
193 | + { |
|
194 | 194 | case 'mysql': |
195 | 195 | case 'mysqli': |
196 | 196 | case 'mysqlt': |
@@ -223,76 +223,76 @@ discard block |
||
223 | 223 | //break; |
224 | 224 | default: |
225 | 225 | $setup_tpl->parse('V_db_stage_1','B_db_stage_1a'); |
226 | - } |
|
226 | + } |
|
227 | 227 | $db_filled_block = $setup_tpl->get_var('V_db_stage_1'); |
228 | 228 | $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
229 | 229 | break; |
230 | - case 2: |
|
231 | - $setup_tpl->set_var('prebeta',lang('You appear to be running a pre-beta version of eGroupWare.<br />These versions are no longer supported, and there is no upgrade path for them in setup.<br /> You may wish to first upgrade to 0.9.10 (the last version to support pre-beta upgrades) <br />and then upgrade from there with the current version.')); |
|
232 | - $setup_tpl->set_var('notcomplete',lang('not complete')); |
|
233 | - $setup_tpl->parse('V_db_stage_2','B_db_stage_2'); |
|
234 | - $db_filled_block = $setup_tpl->get_var('V_db_stage_2'); |
|
235 | - $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
|
236 | - break; |
|
237 | - case 3: |
|
238 | - $setup_tpl->set_var('dbexists','<b>'.lang('Your database is working, but you dont have any applications installed').'</b>'); |
|
239 | - $setup_tpl->set_var('install',lang('Install')); |
|
240 | - $setup_tpl->set_var('proceed',lang('We can proceed')); |
|
241 | - $setup_tpl->set_var('coreapps',lang('all applications')); |
|
242 | - $setup_tpl->set_var('lang_debug',lang('enable for extra debug-messages')); |
|
243 | - $setup_tpl->set_var('lang_restore',lang('Or you can install a previous backup.')); |
|
244 | - $setup_tpl->set_var('upload','<input type="file" name="uploaded" /> '. |
|
245 | - '<input type="submit" name="upload" value="'.htmlspecialchars(lang('install backup')).'" title="'.htmlspecialchars(lang("uploads a backup and installs it on your DB")).'" />'); |
|
246 | - $setup_tpl->set_var('convert_checkbox','<input type="checkbox" name="convert_charset" id="convert_checkbox" value="1"/>'); |
|
247 | - $setup_tpl->set_var('lang_convert_charset','<label for="convert_checkbox">'. |
|
248 | - lang('Convert backup to charset selected above').'</label>'); |
|
249 | - $setup_tpl->parse('V_db_stage_3','B_db_stage_3'); |
|
250 | - $db_filled_block = $setup_tpl->get_var('V_db_stage_3'); |
|
251 | - $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
|
252 | - break; |
|
253 | - case 4: |
|
254 | - $setup_tpl->set_var('hidden_vars', html::input_hidden('csrf_token', egw_csrf::token(__FILE__))); |
|
255 | - $setup_tpl->set_var('oldver',lang('You appear to be running version %1 of eGroupWare',$setup_info['phpgwapi']['currentver'])); |
|
256 | - $setup_tpl->set_var('automatic',lang('We will automatically update your tables/records to %1',$setup_info['phpgwapi']['version'])); |
|
257 | - $setup_tpl->set_var('backupwarn',lang('but we <u>highly recommend backing up</u> your tables in case the script causes damage to your data.<br /><strong>These automated scripts can easily destroy your data.</strong>')); |
|
258 | - $setup_tpl->set_var('lang_backup',lang('create a backup before upgrading the DB')); |
|
259 | - $setup_tpl->set_var('lang_debug',lang('enable for extra debug-messages')); |
|
260 | - $setup_tpl->set_var('upgrade',lang('Upgrade')); |
|
261 | - $setup_tpl->set_var('goto',lang('Go to')); |
|
262 | - $setup_tpl->set_var('configuration',lang('configuration')); |
|
263 | - $setup_tpl->set_var('admin_account',lang('Create admin account')); |
|
264 | - $setup_tpl->set_var('applications',lang('Manage Applications')); |
|
265 | - $setup_tpl->set_var('db_backup',lang('DB backup and restore')); |
|
266 | - $setup_tpl->set_var('language_management',lang('Manage Languages')); |
|
267 | - $setup_tpl->set_var('uninstall_all_applications',lang('Uninstall all applications')); |
|
268 | - $setup_tpl->set_var('dont_touch_my_data',lang('Dont touch my data')); |
|
269 | - $setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data')); |
|
230 | + case 2: |
|
231 | + $setup_tpl->set_var('prebeta',lang('You appear to be running a pre-beta version of eGroupWare.<br />These versions are no longer supported, and there is no upgrade path for them in setup.<br /> You may wish to first upgrade to 0.9.10 (the last version to support pre-beta upgrades) <br />and then upgrade from there with the current version.')); |
|
232 | + $setup_tpl->set_var('notcomplete',lang('not complete')); |
|
233 | + $setup_tpl->parse('V_db_stage_2','B_db_stage_2'); |
|
234 | + $db_filled_block = $setup_tpl->get_var('V_db_stage_2'); |
|
235 | + $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
|
236 | + break; |
|
237 | + case 3: |
|
238 | + $setup_tpl->set_var('dbexists','<b>'.lang('Your database is working, but you dont have any applications installed').'</b>'); |
|
239 | + $setup_tpl->set_var('install',lang('Install')); |
|
240 | + $setup_tpl->set_var('proceed',lang('We can proceed')); |
|
241 | + $setup_tpl->set_var('coreapps',lang('all applications')); |
|
242 | + $setup_tpl->set_var('lang_debug',lang('enable for extra debug-messages')); |
|
243 | + $setup_tpl->set_var('lang_restore',lang('Or you can install a previous backup.')); |
|
244 | + $setup_tpl->set_var('upload','<input type="file" name="uploaded" /> '. |
|
245 | + '<input type="submit" name="upload" value="'.htmlspecialchars(lang('install backup')).'" title="'.htmlspecialchars(lang("uploads a backup and installs it on your DB")).'" />'); |
|
246 | + $setup_tpl->set_var('convert_checkbox','<input type="checkbox" name="convert_charset" id="convert_checkbox" value="1"/>'); |
|
247 | + $setup_tpl->set_var('lang_convert_charset','<label for="convert_checkbox">'. |
|
248 | + lang('Convert backup to charset selected above').'</label>'); |
|
249 | + $setup_tpl->parse('V_db_stage_3','B_db_stage_3'); |
|
250 | + $db_filled_block = $setup_tpl->get_var('V_db_stage_3'); |
|
251 | + $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
|
252 | + break; |
|
253 | + case 4: |
|
254 | + $setup_tpl->set_var('hidden_vars', html::input_hidden('csrf_token', egw_csrf::token(__FILE__))); |
|
255 | + $setup_tpl->set_var('oldver',lang('You appear to be running version %1 of eGroupWare',$setup_info['phpgwapi']['currentver'])); |
|
256 | + $setup_tpl->set_var('automatic',lang('We will automatically update your tables/records to %1',$setup_info['phpgwapi']['version'])); |
|
257 | + $setup_tpl->set_var('backupwarn',lang('but we <u>highly recommend backing up</u> your tables in case the script causes damage to your data.<br /><strong>These automated scripts can easily destroy your data.</strong>')); |
|
258 | + $setup_tpl->set_var('lang_backup',lang('create a backup before upgrading the DB')); |
|
259 | + $setup_tpl->set_var('lang_debug',lang('enable for extra debug-messages')); |
|
260 | + $setup_tpl->set_var('upgrade',lang('Upgrade')); |
|
261 | + $setup_tpl->set_var('goto',lang('Go to')); |
|
262 | + $setup_tpl->set_var('configuration',lang('configuration')); |
|
263 | + $setup_tpl->set_var('admin_account',lang('Create admin account')); |
|
264 | + $setup_tpl->set_var('applications',lang('Manage Applications')); |
|
265 | + $setup_tpl->set_var('db_backup',lang('DB backup and restore')); |
|
266 | + $setup_tpl->set_var('language_management',lang('Manage Languages')); |
|
267 | + $setup_tpl->set_var('uninstall_all_applications',lang('Uninstall all applications')); |
|
268 | + $setup_tpl->set_var('dont_touch_my_data',lang('Dont touch my data')); |
|
269 | + $setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data')); |
|
270 | 270 | |
271 | - $setup_tpl->parse('V_db_stage_4','B_db_stage_4'); |
|
272 | - $db_filled_block = $setup_tpl->get_var('V_db_stage_4'); |
|
273 | - $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
|
274 | - break; |
|
275 | - case 5: |
|
276 | - $setup_tpl->set_var('hidden_vars', html::input_hidden('csrf_token', egw_csrf::token(__FILE__))); |
|
277 | - $setup_tpl->set_var('are_you_sure',lang('ARE YOU SURE?')); |
|
278 | - $setup_tpl->set_var('really_uninstall_all_applications',lang('REALLY Uninstall all applications')); |
|
279 | - $setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data')); |
|
280 | - $setup_tpl->set_var('cancel',lang('cancel')); |
|
281 | - $setup_tpl->parse('V_db_stage_5','B_db_stage_5'); |
|
282 | - $db_filled_block = $setup_tpl->get_var('V_db_stage_5'); |
|
283 | - $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
|
284 | - break; |
|
285 | - case 6: |
|
286 | - $setup_tpl->set_var('status',lang('Status')); |
|
287 | - $setup_tpl->set_var('notcomplete',lang('not complete')); |
|
288 | - $setup_tpl->set_var('tblchange',lang('Table Change Messages')); |
|
289 | - $setup_tpl->parse('V_db_stage_6_pre','B_db_stage_6_pre'); |
|
290 | - $db_filled_block = $setup_tpl->get_var('V_db_stage_6_pre'); |
|
291 | - $setup_tpl->set_var('tableshave',lang('If you did not receive any errors, your applications have been')); |
|
271 | + $setup_tpl->parse('V_db_stage_4','B_db_stage_4'); |
|
272 | + $db_filled_block = $setup_tpl->get_var('V_db_stage_4'); |
|
273 | + $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
|
274 | + break; |
|
275 | + case 5: |
|
276 | + $setup_tpl->set_var('hidden_vars', html::input_hidden('csrf_token', egw_csrf::token(__FILE__))); |
|
277 | + $setup_tpl->set_var('are_you_sure',lang('ARE YOU SURE?')); |
|
278 | + $setup_tpl->set_var('really_uninstall_all_applications',lang('REALLY Uninstall all applications')); |
|
279 | + $setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data')); |
|
280 | + $setup_tpl->set_var('cancel',lang('cancel')); |
|
281 | + $setup_tpl->parse('V_db_stage_5','B_db_stage_5'); |
|
282 | + $db_filled_block = $setup_tpl->get_var('V_db_stage_5'); |
|
283 | + $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
|
284 | + break; |
|
285 | + case 6: |
|
286 | + $setup_tpl->set_var('status',lang('Status')); |
|
287 | + $setup_tpl->set_var('notcomplete',lang('not complete')); |
|
288 | + $setup_tpl->set_var('tblchange',lang('Table Change Messages')); |
|
289 | + $setup_tpl->parse('V_db_stage_6_pre','B_db_stage_6_pre'); |
|
290 | + $db_filled_block = $setup_tpl->get_var('V_db_stage_6_pre'); |
|
291 | + $setup_tpl->set_var('tableshave',lang('If you did not receive any errors, your applications have been')); |
|
292 | 292 | |
293 | - try { // catch DB errors to report them |
|
294 | - switch ($GLOBALS['egw_info']['setup']['currentver']['phpgwapi']) |
|
295 | - { |
|
293 | + try { // catch DB errors to report them |
|
294 | + switch ($GLOBALS['egw_info']['setup']['currentver']['phpgwapi']) |
|
295 | + { |
|
296 | 296 | case 'dbcreate': |
297 | 297 | $GLOBALS['egw_setup']->db->create_database($_POST['db_root'], $_POST['db_pass'], 'utf8', // create all new db's with utf8 |
298 | 298 | !preg_match('/^[0-9.a-z_]+$/i', $_POST['db_grant_host']) ? 'localhost' : $_POST['db_grant_host']); |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | $GLOBALS['egw_info']['setup']['currentver']['phpgwapi'] = 'oldversion'; |
372 | 372 | } |
373 | 373 | break; |
374 | - } |
|
374 | + } |
|
375 | 375 | } |
376 | 376 | catch (egw_exception_db $e) |
377 | 377 | { |
@@ -383,21 +383,21 @@ discard block |
||
383 | 383 | $db_filled_block = $db_filled_block . $setup_tpl->get_var('V_db_stage_6_post'); |
384 | 384 | $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
385 | 385 | break; |
386 | - case 10: |
|
387 | - $setup_tpl->set_var('tablescurrent',lang('Your eGroupWare API is current')); |
|
388 | - $setup_tpl->set_var('uninstall_all_applications',lang('Uninstall all applications')); |
|
389 | - $setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data')); |
|
390 | - $setup_tpl->set_var('deletetables',lang('Uninstall all applications')); |
|
391 | - $setup_tpl->parse('V_db_stage_10','B_db_stage_10'); |
|
392 | - $db_filled_block = $setup_tpl->get_var('V_db_stage_10'); |
|
393 | - $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
|
394 | - break; |
|
395 | - default: |
|
396 | - $setup_tpl->set_var('dbnotexist',lang('Your database does not exist')); |
|
397 | - $setup_tpl->parse('V_db_stage_default','B_db_stage_default'); |
|
398 | - $db_filled_block = $setup_tpl->get_var('V_db_stage_default'); |
|
399 | - $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
|
400 | - break; |
|
386 | + case 10: |
|
387 | + $setup_tpl->set_var('tablescurrent',lang('Your eGroupWare API is current')); |
|
388 | + $setup_tpl->set_var('uninstall_all_applications',lang('Uninstall all applications')); |
|
389 | + $setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data')); |
|
390 | + $setup_tpl->set_var('deletetables',lang('Uninstall all applications')); |
|
391 | + $setup_tpl->parse('V_db_stage_10','B_db_stage_10'); |
|
392 | + $db_filled_block = $setup_tpl->get_var('V_db_stage_10'); |
|
393 | + $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
|
394 | + break; |
|
395 | + default: |
|
396 | + $setup_tpl->set_var('dbnotexist',lang('Your database does not exist')); |
|
397 | + $setup_tpl->parse('V_db_stage_default','B_db_stage_default'); |
|
398 | + $db_filled_block = $setup_tpl->get_var('V_db_stage_default'); |
|
399 | + $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
|
400 | + break; |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | // Config Section |
@@ -16,9 +16,8 @@ discard block |
||
16 | 16 | @set_time_limit(0); |
17 | 17 | |
18 | 18 | $tpl_root = $GLOBALS['egw_setup']->html->setup_tpl_dir('setup'); |
19 | -$setup_tpl = CreateObject('phpgwapi.Template',$tpl_root); |
|
20 | -$setup_tpl->set_file(array |
|
21 | -( |
|
19 | +$setup_tpl = CreateObject('phpgwapi.Template', $tpl_root); |
|
20 | +$setup_tpl->set_file(array( |
|
22 | 21 | 'T_head' => 'head.tpl', |
23 | 22 | 'T_footer' => 'footer.tpl', |
24 | 23 | 'T_alert_msg' => 'msg_alert_msg.tpl', |
@@ -28,19 +27,19 @@ discard block |
||
28 | 27 | 'T_setup_db_blocks' => 'setup_db_blocks.tpl' |
29 | 28 | )); |
30 | 29 | |
31 | -$setup_tpl->set_block('T_login_stage_header','B_multi_domain','V_multi_domain'); |
|
32 | -$setup_tpl->set_block('T_login_stage_header','B_single_domain','V_single_domain'); |
|
30 | +$setup_tpl->set_block('T_login_stage_header', 'B_multi_domain', 'V_multi_domain'); |
|
31 | +$setup_tpl->set_block('T_login_stage_header', 'B_single_domain', 'V_single_domain'); |
|
33 | 32 | |
34 | -$setup_tpl->set_block('T_setup_db_blocks','B_db_stage_1','V_db_stage_1'); |
|
35 | -$setup_tpl->set_block('T_setup_db_blocks','B_db_stage_1a','V_db_stage_1a'); |
|
36 | -$setup_tpl->set_block('T_setup_db_blocks','B_db_stage_2','V_db_stage_2'); |
|
37 | -$setup_tpl->set_block('T_setup_db_blocks','B_db_stage_3','V_db_stage_3'); |
|
38 | -$setup_tpl->set_block('T_setup_db_blocks','B_db_stage_4','V_db_stage_4'); |
|
39 | -$setup_tpl->set_block('T_setup_db_blocks','B_db_stage_5','V_db_stage_5'); |
|
40 | -$setup_tpl->set_block('T_setup_db_blocks','B_db_stage_6_pre','V_db_stage_6_pre'); |
|
41 | -$setup_tpl->set_block('T_setup_db_blocks','B_db_stage_6_post','V_db_stage_6_post'); |
|
42 | -$setup_tpl->set_block('T_setup_db_blocks','B_db_stage_10','V_db_stage_10'); |
|
43 | -$setup_tpl->set_block('T_setup_db_blocks','B_db_stage_default','V_db_stage_default'); |
|
33 | +$setup_tpl->set_block('T_setup_db_blocks', 'B_db_stage_1', 'V_db_stage_1'); |
|
34 | +$setup_tpl->set_block('T_setup_db_blocks', 'B_db_stage_1a', 'V_db_stage_1a'); |
|
35 | +$setup_tpl->set_block('T_setup_db_blocks', 'B_db_stage_2', 'V_db_stage_2'); |
|
36 | +$setup_tpl->set_block('T_setup_db_blocks', 'B_db_stage_3', 'V_db_stage_3'); |
|
37 | +$setup_tpl->set_block('T_setup_db_blocks', 'B_db_stage_4', 'V_db_stage_4'); |
|
38 | +$setup_tpl->set_block('T_setup_db_blocks', 'B_db_stage_5', 'V_db_stage_5'); |
|
39 | +$setup_tpl->set_block('T_setup_db_blocks', 'B_db_stage_6_pre', 'V_db_stage_6_pre'); |
|
40 | +$setup_tpl->set_block('T_setup_db_blocks', 'B_db_stage_6_post', 'V_db_stage_6_post'); |
|
41 | +$setup_tpl->set_block('T_setup_db_blocks', 'B_db_stage_10', 'V_db_stage_10'); |
|
42 | +$setup_tpl->set_block('T_setup_db_blocks', 'B_db_stage_default', 'V_db_stage_default'); |
|
44 | 43 | |
45 | 44 | // Check header and authentication |
46 | 45 | $GLOBALS['egw_info']['setup']['stage']['header'] = $GLOBALS['egw_setup']->detection->check_header(); |
@@ -56,9 +55,9 @@ discard block |
||
56 | 55 | } |
57 | 56 | exit; |
58 | 57 | } |
59 | -elseif(!$GLOBALS['egw_setup']->auth('Config')) |
|
58 | +elseif (!$GLOBALS['egw_setup']->auth('Config')) |
|
60 | 59 | { |
61 | - $GLOBALS['egw_setup']->html->show_header(lang('Please login'),True); |
|
60 | + $GLOBALS['egw_setup']->html->show_header(lang('Please login'), True); |
|
62 | 61 | $GLOBALS['egw_setup']->html->login_form(); |
63 | 62 | $GLOBALS['egw_setup']->html->show_footer(); |
64 | 63 | exit; |
@@ -70,11 +69,11 @@ discard block |
||
70 | 69 | $GLOBALS['egw_info']['setup']['header_msg'], |
71 | 70 | False, |
72 | 71 | 'config', |
73 | - $GLOBALS['egw_setup']->ConfigDomain . ' (' . $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'].'://'. |
|
72 | + $GLOBALS['egw_setup']->ConfigDomain.' ('.$GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'].'://'. |
|
74 | 73 | $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_user'].'@'. |
75 | 74 | $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_host'].':'. |
76 | 75 | $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_port'].'/'. |
77 | - $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_name'] . ')' |
|
76 | + $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_name'].')' |
|
78 | 77 | ); |
79 | 78 | /* Add cleaning of app_sessions per skeeter, but with a check for the table being there, just in case */ |
80 | 79 | /* $GLOBALS['egw_setup']->clear_session_cache(); */ |
@@ -87,23 +86,23 @@ discard block |
||
87 | 86 | $setup_info = $GLOBALS['egw_setup']->detection->get_versions(); |
88 | 87 | $setup_info = $GLOBALS['egw_setup']->detection->get_db_versions($setup_info); |
89 | 88 | $GLOBALS['egw_info']['setup']['stage']['db'] = $GLOBALS['egw_setup']->detection->check_db($setup_info); |
90 | - if($GLOBALS['DEBUG']) |
|
89 | + if ($GLOBALS['DEBUG']) |
|
91 | 90 | { |
92 | 91 | _debug_array($setup_info); |
93 | 92 | } |
94 | 93 | } |
95 | 94 | |
96 | -if ($GLOBALS['DEBUG']) { echo 'Stage: ' . $GLOBALS['egw_info']['setup']['stage']['db']; } |
|
95 | +if ($GLOBALS['DEBUG']) { echo 'Stage: '.$GLOBALS['egw_info']['setup']['stage']['db']; } |
|
97 | 96 | // begin DEBUG code |
98 | 97 | //$GLOBALS['egw_info']['setup']['stage']['db'] = 0; |
99 | 98 | //$action = 'Upgrade'; |
100 | 99 | // end DEBUG code |
101 | 100 | |
102 | -switch(@get_var('action',Array('POST'))) |
|
101 | +switch (@get_var('action', Array('POST'))) |
|
103 | 102 | { |
104 | 103 | case 'Uninstall all applications': |
105 | 104 | $subtitle = lang('Deleting Tables'); |
106 | - $submsg = lang('Are you sure you want to delete your existing tables and data?') . '.'; |
|
105 | + $submsg = lang('Are you sure you want to delete your existing tables and data?').'.'; |
|
107 | 106 | $subaction = lang('uninstall'); |
108 | 107 | $GLOBALS['egw_info']['setup']['currentver']['phpgwapi'] = 'predrop'; |
109 | 108 | $GLOBALS['egw_info']['setup']['stage']['db'] = 5; |
@@ -117,7 +116,7 @@ discard block |
||
117 | 116 | break; |
118 | 117 | case 'REALLY Uninstall all applications': |
119 | 118 | $subtitle = lang('Deleting Tables'); |
120 | - $submsg = lang('At your request, this script is going to take the evil action of uninstalling all your apps, which deletes your existing tables and data') . '.'; |
|
119 | + $submsg = lang('At your request, this script is going to take the evil action of uninstalling all your apps, which deletes your existing tables and data').'.'; |
|
121 | 120 | $subaction = lang('uninstalled'); |
122 | 121 | $GLOBALS['egw_info']['setup']['currentver']['phpgwapi'] = 'drop'; |
123 | 122 | $GLOBALS['egw_info']['setup']['stage']['db'] = 6; |
@@ -148,17 +147,17 @@ discard block |
||
148 | 147 | $GLOBALS['egw_info']['setup']['stage']['db'] = 6; |
149 | 148 | break; |
150 | 149 | } |
151 | -$setup_tpl->set_var('subtitle',@$subtitle); |
|
152 | -$setup_tpl->set_var('submsg',@$submsg); |
|
153 | -$setup_tpl->set_var('subaction',@$subaction); |
|
150 | +$setup_tpl->set_var('subtitle', @$subtitle); |
|
151 | +$setup_tpl->set_var('submsg', @$submsg); |
|
152 | +$setup_tpl->set_var('subaction', @$subaction); |
|
154 | 153 | |
155 | 154 | // Old PHP |
156 | -if ((float) PHP_VERSION < $GLOBALS['egw_setup']->required_php_version) |
|
155 | +if ((float)PHP_VERSION < $GLOBALS['egw_setup']->required_php_version) |
|
157 | 156 | { |
158 | - $GLOBALS['egw_setup']->html->show_header($GLOBALS['egw_info']['setup']['header_msg'],True); |
|
157 | + $GLOBALS['egw_setup']->html->show_header($GLOBALS['egw_info']['setup']['header_msg'], True); |
|
159 | 158 | $GLOBALS['egw_setup']->html->show_alert_msg('Error', |
160 | 159 | lang('You are using PHP version %1. eGroupWare now requires %2 or later, recommended is PHP %3.', |
161 | - PHP_VERSION,$GLOBALS['egw_setup']->required_php_version,$GLOBALS['egw_setup']->recommended_php_version)); |
|
160 | + PHP_VERSION, $GLOBALS['egw_setup']->required_php_version, $GLOBALS['egw_setup']->recommended_php_version)); |
|
162 | 161 | $GLOBALS['egw_setup']->html->show_footer(); |
163 | 162 | exit; |
164 | 163 | } |
@@ -167,134 +166,133 @@ discard block |
||
167 | 166 | |
168 | 167 | //$GLOBALS['egw_setup']->app_status(); |
169 | 168 | $GLOBALS['egw_info']['server']['app_images'] = 'templates/default/images'; |
170 | -$incomplete = $GLOBALS['egw_info']['server']['app_images'] . '/incomplete.png'; |
|
171 | -$completed = $GLOBALS['egw_info']['server']['app_images'] . '/completed.png'; |
|
169 | +$incomplete = $GLOBALS['egw_info']['server']['app_images'].'/incomplete.png'; |
|
170 | +$completed = $GLOBALS['egw_info']['server']['app_images'].'/completed.png'; |
|
172 | 171 | |
173 | -$setup_tpl->set_var('img_incomplete',$incomplete); |
|
174 | -$setup_tpl->set_var('img_completed',$completed); |
|
172 | +$setup_tpl->set_var('img_incomplete', $incomplete); |
|
173 | +$setup_tpl->set_var('img_completed', $completed); |
|
175 | 174 | |
176 | -$setup_tpl->set_var('db_step_text',lang('Step %1 - Simple Application Management', ++$num)); |
|
177 | -$setup_tpl->set_var('lang_system_charset',lang('<b>charset to use</b> (use utf-8 if you plan to use languages with different charsets):')); |
|
178 | -$setup_tpl->set_var('system_charset',str_replace('&','&', |
|
179 | - $GLOBALS['egw_setup']->translation->get_charsets('system_charset',$GLOBALS['egw_setup']->system_charset))); |
|
175 | +$setup_tpl->set_var('db_step_text', lang('Step %1 - Simple Application Management', ++$num)); |
|
176 | +$setup_tpl->set_var('lang_system_charset', lang('<b>charset to use</b> (use utf-8 if you plan to use languages with different charsets):')); |
|
177 | +$setup_tpl->set_var('system_charset', str_replace('&', '&', |
|
178 | + $GLOBALS['egw_setup']->translation->get_charsets('system_charset', $GLOBALS['egw_setup']->system_charset))); |
|
180 | 179 | |
181 | -switch($GLOBALS['egw_info']['setup']['stage']['db']) |
|
180 | +switch ($GLOBALS['egw_info']['setup']['stage']['db']) |
|
182 | 181 | { |
183 | 182 | case 1: |
184 | - $setup_tpl->set_var('dbnotexist','<b>'.lang('Your Database is not working!').'</b>: '.$GLOBALS['egw_setup']->db->Error); |
|
185 | - $setup_tpl->set_var('makesure',lang('Make sure that your database is created and the account permissions are set')); |
|
186 | - $setup_tpl->set_var('notcomplete',lang('not complete')); |
|
187 | - $setup_tpl->set_var('oncesetup',lang('Once the database is setup correctly')); |
|
188 | - $setup_tpl->set_var('createdb','<b>'.lang('Or we can attempt to create the database for you:').'</b>'); |
|
189 | - $setup_tpl->set_var('create_database',lang('Create database')); |
|
190 | - $setup_tpl->set_var('instr',''); |
|
183 | + $setup_tpl->set_var('dbnotexist', '<b>'.lang('Your Database is not working!').'</b>: '.$GLOBALS['egw_setup']->db->Error); |
|
184 | + $setup_tpl->set_var('makesure', lang('Make sure that your database is created and the account permissions are set')); |
|
185 | + $setup_tpl->set_var('notcomplete', lang('not complete')); |
|
186 | + $setup_tpl->set_var('oncesetup', lang('Once the database is setup correctly')); |
|
187 | + $setup_tpl->set_var('createdb', '<b>'.lang('Or we can attempt to create the database for you:').'</b>'); |
|
188 | + $setup_tpl->set_var('create_database', lang('Create database')); |
|
189 | + $setup_tpl->set_var('instr', ''); |
|
191 | 190 | $info = $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]; |
192 | 191 | switch ($info['db_type']) |
193 | 192 | { |
194 | 193 | case 'mysql': |
195 | 194 | case 'mysqli': |
196 | 195 | case 'mysqlt': |
197 | - $set_charset = (float) $GLOBALS['egw_setup']->db->ServerInfo['version'] >= 4.1 ? ' DEFAULT CHARACTER SET utf8' : ''; |
|
196 | + $set_charset = (float)$GLOBALS['egw_setup']->db->ServerInfo['version'] >= 4.1 ? ' DEFAULT CHARACTER SET utf8' : ''; |
|
198 | 197 | $setup_tpl->set_var('instr', |
199 | - '<b>'.lang("Instructions for creating the database in %1:",'MySql').'</b>' |
|
198 | + '<b>'.lang("Instructions for creating the database in %1:", 'MySql').'</b>' |
|
200 | 199 | . '<br />'.lang('Login to mysql -') |
201 | 200 | . '<br /><i>[user@server user]# <b>mysql -u root -p</b></i><br />' |
202 | 201 | . lang('Create the empty database and grant user permissions -') |
203 | 202 | . "<br /><i>mysql> <b>CREATE DATABASE $info[db_name]$set_charset;</b></i>" |
204 | - . "<br /><i>mysql> <b>GRANT ALL ON " . $info['db_name'] |
|
205 | - . ".* TO " . $info['db_user'] . "@localhost IDENTIFIED BY '" . $info['db_pass'] . "';</b></i>"); |
|
206 | - $setup_tpl->parse('V_db_stage_1','B_db_stage_1'); |
|
203 | + . "<br /><i>mysql> <b>GRANT ALL ON ".$info['db_name'] |
|
204 | + . ".* TO ".$info['db_user']."@localhost IDENTIFIED BY '".$info['db_pass']."';</b></i>"); |
|
205 | + $setup_tpl->parse('V_db_stage_1', 'B_db_stage_1'); |
|
207 | 206 | break; |
208 | 207 | case 'pgsql': |
209 | 208 | $ip = $info['db_host'] == 'localhost' ? '127.0.0.1' : '<ip-address webserver>'; |
210 | 209 | $setup_tpl->set_var('instr', |
211 | - '<b>'.lang('Instructions for creating the database in %1:','PostgreSQL').'</b>' |
|
210 | + '<b>'.lang('Instructions for creating the database in %1:', 'PostgreSQL').'</b>' |
|
212 | 211 | . '<br />'.lang('Login as user postgres, eg. by using su as root') |
213 | 212 | . "<br /><i>[root@server /root]# <b>su - postgres</b></i><br />" |
214 | 213 | . lang('Create the empty database and grant user permissions -') |
215 | - . "<br /><i>[postgres@server /var/lib/pgsql]\$ <b>createuser --no-adduser --no-createdb -P " . $info['db_user'] . "</b></i>" |
|
216 | - . "<br /><i>Enter password for new user: <b>" . $info['db_pass'] . "</b></i>" |
|
217 | - . "<br /><i>[postgres@server /var/lib/pgsql]\$ <b>createdb --encoding=utf-8 --owner " . $info['db_user'] . ' ' . $info['db_name'] . "</b></i>" |
|
214 | + . "<br /><i>[postgres@server /var/lib/pgsql]\$ <b>createuser --no-adduser --no-createdb -P ".$info['db_user']."</b></i>" |
|
215 | + . "<br /><i>Enter password for new user: <b>".$info['db_pass']."</b></i>" |
|
216 | + . "<br /><i>[postgres@server /var/lib/pgsql]\$ <b>createdb --encoding=utf-8 --owner ".$info['db_user'].' '.$info['db_name']."</b></i>" |
|
218 | 217 | . '<br />'.lang('to allow password authentification add the following line to your pg_hba.conf (above all others) AND restart postgres:') |
219 | 218 | . '<br /><i># TYPE DATABASE USER CIDR-ADDRESS METHOD</i>' |
220 | - .($info['db_host'] ? "<br /><i><b>host $info[db_name] $info[db_user] $ip/32 password</b></i>" : |
|
221 | - "<br /><i><b>local $info[db_name] $info[db_user] password</b></i>")); |
|
219 | + .($info['db_host'] ? "<br /><i><b>host $info[db_name] $info[db_user] $ip/32 password</b></i>" : "<br /><i><b>local $info[db_name] $info[db_user] password</b></i>")); |
|
222 | 220 | //$setup_tpl->parse('V_db_stage_1','B_db_stage_1'); |
223 | 221 | //break; |
224 | 222 | default: |
225 | - $setup_tpl->parse('V_db_stage_1','B_db_stage_1a'); |
|
223 | + $setup_tpl->parse('V_db_stage_1', 'B_db_stage_1a'); |
|
226 | 224 | } |
227 | 225 | $db_filled_block = $setup_tpl->get_var('V_db_stage_1'); |
228 | - $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
|
226 | + $setup_tpl->set_var('V_db_filled_block', $db_filled_block); |
|
229 | 227 | break; |
230 | 228 | case 2: |
231 | - $setup_tpl->set_var('prebeta',lang('You appear to be running a pre-beta version of eGroupWare.<br />These versions are no longer supported, and there is no upgrade path for them in setup.<br /> You may wish to first upgrade to 0.9.10 (the last version to support pre-beta upgrades) <br />and then upgrade from there with the current version.')); |
|
232 | - $setup_tpl->set_var('notcomplete',lang('not complete')); |
|
233 | - $setup_tpl->parse('V_db_stage_2','B_db_stage_2'); |
|
229 | + $setup_tpl->set_var('prebeta', lang('You appear to be running a pre-beta version of eGroupWare.<br />These versions are no longer supported, and there is no upgrade path for them in setup.<br /> You may wish to first upgrade to 0.9.10 (the last version to support pre-beta upgrades) <br />and then upgrade from there with the current version.')); |
|
230 | + $setup_tpl->set_var('notcomplete', lang('not complete')); |
|
231 | + $setup_tpl->parse('V_db_stage_2', 'B_db_stage_2'); |
|
234 | 232 | $db_filled_block = $setup_tpl->get_var('V_db_stage_2'); |
235 | - $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
|
233 | + $setup_tpl->set_var('V_db_filled_block', $db_filled_block); |
|
236 | 234 | break; |
237 | 235 | case 3: |
238 | - $setup_tpl->set_var('dbexists','<b>'.lang('Your database is working, but you dont have any applications installed').'</b>'); |
|
239 | - $setup_tpl->set_var('install',lang('Install')); |
|
240 | - $setup_tpl->set_var('proceed',lang('We can proceed')); |
|
241 | - $setup_tpl->set_var('coreapps',lang('all applications')); |
|
242 | - $setup_tpl->set_var('lang_debug',lang('enable for extra debug-messages')); |
|
243 | - $setup_tpl->set_var('lang_restore',lang('Or you can install a previous backup.')); |
|
244 | - $setup_tpl->set_var('upload','<input type="file" name="uploaded" /> '. |
|
236 | + $setup_tpl->set_var('dbexists', '<b>'.lang('Your database is working, but you dont have any applications installed').'</b>'); |
|
237 | + $setup_tpl->set_var('install', lang('Install')); |
|
238 | + $setup_tpl->set_var('proceed', lang('We can proceed')); |
|
239 | + $setup_tpl->set_var('coreapps', lang('all applications')); |
|
240 | + $setup_tpl->set_var('lang_debug', lang('enable for extra debug-messages')); |
|
241 | + $setup_tpl->set_var('lang_restore', lang('Or you can install a previous backup.')); |
|
242 | + $setup_tpl->set_var('upload', '<input type="file" name="uploaded" /> '. |
|
245 | 243 | '<input type="submit" name="upload" value="'.htmlspecialchars(lang('install backup')).'" title="'.htmlspecialchars(lang("uploads a backup and installs it on your DB")).'" />'); |
246 | - $setup_tpl->set_var('convert_checkbox','<input type="checkbox" name="convert_charset" id="convert_checkbox" value="1"/>'); |
|
247 | - $setup_tpl->set_var('lang_convert_charset','<label for="convert_checkbox">'. |
|
244 | + $setup_tpl->set_var('convert_checkbox', '<input type="checkbox" name="convert_charset" id="convert_checkbox" value="1"/>'); |
|
245 | + $setup_tpl->set_var('lang_convert_charset', '<label for="convert_checkbox">'. |
|
248 | 246 | lang('Convert backup to charset selected above').'</label>'); |
249 | - $setup_tpl->parse('V_db_stage_3','B_db_stage_3'); |
|
247 | + $setup_tpl->parse('V_db_stage_3', 'B_db_stage_3'); |
|
250 | 248 | $db_filled_block = $setup_tpl->get_var('V_db_stage_3'); |
251 | - $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
|
249 | + $setup_tpl->set_var('V_db_filled_block', $db_filled_block); |
|
252 | 250 | break; |
253 | 251 | case 4: |
254 | 252 | $setup_tpl->set_var('hidden_vars', html::input_hidden('csrf_token', egw_csrf::token(__FILE__))); |
255 | - $setup_tpl->set_var('oldver',lang('You appear to be running version %1 of eGroupWare',$setup_info['phpgwapi']['currentver'])); |
|
256 | - $setup_tpl->set_var('automatic',lang('We will automatically update your tables/records to %1',$setup_info['phpgwapi']['version'])); |
|
257 | - $setup_tpl->set_var('backupwarn',lang('but we <u>highly recommend backing up</u> your tables in case the script causes damage to your data.<br /><strong>These automated scripts can easily destroy your data.</strong>')); |
|
258 | - $setup_tpl->set_var('lang_backup',lang('create a backup before upgrading the DB')); |
|
259 | - $setup_tpl->set_var('lang_debug',lang('enable for extra debug-messages')); |
|
260 | - $setup_tpl->set_var('upgrade',lang('Upgrade')); |
|
261 | - $setup_tpl->set_var('goto',lang('Go to')); |
|
262 | - $setup_tpl->set_var('configuration',lang('configuration')); |
|
263 | - $setup_tpl->set_var('admin_account',lang('Create admin account')); |
|
264 | - $setup_tpl->set_var('applications',lang('Manage Applications')); |
|
265 | - $setup_tpl->set_var('db_backup',lang('DB backup and restore')); |
|
266 | - $setup_tpl->set_var('language_management',lang('Manage Languages')); |
|
267 | - $setup_tpl->set_var('uninstall_all_applications',lang('Uninstall all applications')); |
|
268 | - $setup_tpl->set_var('dont_touch_my_data',lang('Dont touch my data')); |
|
269 | - $setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data')); |
|
253 | + $setup_tpl->set_var('oldver', lang('You appear to be running version %1 of eGroupWare', $setup_info['phpgwapi']['currentver'])); |
|
254 | + $setup_tpl->set_var('automatic', lang('We will automatically update your tables/records to %1', $setup_info['phpgwapi']['version'])); |
|
255 | + $setup_tpl->set_var('backupwarn', lang('but we <u>highly recommend backing up</u> your tables in case the script causes damage to your data.<br /><strong>These automated scripts can easily destroy your data.</strong>')); |
|
256 | + $setup_tpl->set_var('lang_backup', lang('create a backup before upgrading the DB')); |
|
257 | + $setup_tpl->set_var('lang_debug', lang('enable for extra debug-messages')); |
|
258 | + $setup_tpl->set_var('upgrade', lang('Upgrade')); |
|
259 | + $setup_tpl->set_var('goto', lang('Go to')); |
|
260 | + $setup_tpl->set_var('configuration', lang('configuration')); |
|
261 | + $setup_tpl->set_var('admin_account', lang('Create admin account')); |
|
262 | + $setup_tpl->set_var('applications', lang('Manage Applications')); |
|
263 | + $setup_tpl->set_var('db_backup', lang('DB backup and restore')); |
|
264 | + $setup_tpl->set_var('language_management', lang('Manage Languages')); |
|
265 | + $setup_tpl->set_var('uninstall_all_applications', lang('Uninstall all applications')); |
|
266 | + $setup_tpl->set_var('dont_touch_my_data', lang('Dont touch my data')); |
|
267 | + $setup_tpl->set_var('dropwarn', lang('Your tables will be dropped and you will lose data')); |
|
270 | 268 | |
271 | - $setup_tpl->parse('V_db_stage_4','B_db_stage_4'); |
|
269 | + $setup_tpl->parse('V_db_stage_4', 'B_db_stage_4'); |
|
272 | 270 | $db_filled_block = $setup_tpl->get_var('V_db_stage_4'); |
273 | - $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
|
271 | + $setup_tpl->set_var('V_db_filled_block', $db_filled_block); |
|
274 | 272 | break; |
275 | 273 | case 5: |
276 | 274 | $setup_tpl->set_var('hidden_vars', html::input_hidden('csrf_token', egw_csrf::token(__FILE__))); |
277 | - $setup_tpl->set_var('are_you_sure',lang('ARE YOU SURE?')); |
|
278 | - $setup_tpl->set_var('really_uninstall_all_applications',lang('REALLY Uninstall all applications')); |
|
279 | - $setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data')); |
|
280 | - $setup_tpl->set_var('cancel',lang('cancel')); |
|
281 | - $setup_tpl->parse('V_db_stage_5','B_db_stage_5'); |
|
275 | + $setup_tpl->set_var('are_you_sure', lang('ARE YOU SURE?')); |
|
276 | + $setup_tpl->set_var('really_uninstall_all_applications', lang('REALLY Uninstall all applications')); |
|
277 | + $setup_tpl->set_var('dropwarn', lang('Your tables will be dropped and you will lose data')); |
|
278 | + $setup_tpl->set_var('cancel', lang('cancel')); |
|
279 | + $setup_tpl->parse('V_db_stage_5', 'B_db_stage_5'); |
|
282 | 280 | $db_filled_block = $setup_tpl->get_var('V_db_stage_5'); |
283 | - $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
|
281 | + $setup_tpl->set_var('V_db_filled_block', $db_filled_block); |
|
284 | 282 | break; |
285 | 283 | case 6: |
286 | - $setup_tpl->set_var('status',lang('Status')); |
|
287 | - $setup_tpl->set_var('notcomplete',lang('not complete')); |
|
288 | - $setup_tpl->set_var('tblchange',lang('Table Change Messages')); |
|
289 | - $setup_tpl->parse('V_db_stage_6_pre','B_db_stage_6_pre'); |
|
284 | + $setup_tpl->set_var('status', lang('Status')); |
|
285 | + $setup_tpl->set_var('notcomplete', lang('not complete')); |
|
286 | + $setup_tpl->set_var('tblchange', lang('Table Change Messages')); |
|
287 | + $setup_tpl->parse('V_db_stage_6_pre', 'B_db_stage_6_pre'); |
|
290 | 288 | $db_filled_block = $setup_tpl->get_var('V_db_stage_6_pre'); |
291 | - $setup_tpl->set_var('tableshave',lang('If you did not receive any errors, your applications have been')); |
|
289 | + $setup_tpl->set_var('tableshave', lang('If you did not receive any errors, your applications have been')); |
|
292 | 290 | |
293 | 291 | try { // catch DB errors to report them |
294 | 292 | switch ($GLOBALS['egw_info']['setup']['currentver']['phpgwapi']) |
295 | 293 | { |
296 | 294 | case 'dbcreate': |
297 | - $GLOBALS['egw_setup']->db->create_database($_POST['db_root'], $_POST['db_pass'], 'utf8', // create all new db's with utf8 |
|
295 | + $GLOBALS['egw_setup']->db->create_database($_POST['db_root'], $_POST['db_pass'], 'utf8', // create all new db's with utf8 |
|
298 | 296 | !preg_match('/^[0-9.a-z_]+$/i', $_POST['db_grant_host']) ? 'localhost' : $_POST['db_grant_host']); |
299 | 297 | break; |
300 | 298 | case 'drop': |
@@ -310,25 +308,25 @@ discard block |
||
310 | 308 | if (is_array($_FILES['uploaded']) && !$_FILES['uploaded']['error'] && |
311 | 309 | is_uploaded_file($_FILES['uploaded']['tmp_name'])) |
312 | 310 | { |
313 | - if (preg_match('/\.(bz2|gz)$/i',$_FILES['uploaded']['name'],$matches)) |
|
311 | + if (preg_match('/\.(bz2|gz)$/i', $_FILES['uploaded']['name'], $matches)) |
|
314 | 312 | { |
315 | 313 | $ext = '.'.$matches[1]; |
316 | - move_uploaded_file($_FILES['uploaded']['tmp_name'],$_FILES['uploaded']['tmp_name'].$ext); |
|
314 | + move_uploaded_file($_FILES['uploaded']['tmp_name'], $_FILES['uploaded']['tmp_name'].$ext); |
|
317 | 315 | $_FILES['uploaded']['tmp_name'] .= $ext; |
318 | 316 | } |
319 | - if (is_resource($f = $db_backup->fopen_backup($_FILES['uploaded']['tmp_name'],true))) |
|
317 | + if (is_resource($f = $db_backup->fopen_backup($_FILES['uploaded']['tmp_name'], true))) |
|
320 | 318 | { |
321 | - echo '<p align="center">'.lang('restore started, this might take a few minutes ...')."</p>\n".str_repeat(' ',4096); |
|
322 | - $db_backup->restore($f,$_POST['convert_charset'],$_FILES['uploaded']['tmp_name'],false); |
|
319 | + echo '<p align="center">'.lang('restore started, this might take a few minutes ...')."</p>\n".str_repeat(' ', 4096); |
|
320 | + $db_backup->restore($f, $_POST['convert_charset'], $_FILES['uploaded']['tmp_name'], false); |
|
323 | 321 | fclose($f); |
324 | 322 | echo '<p align="center">'.lang('restore finished')."</p>\n"; |
325 | 323 | unlink($_FILES['uploaded']['tmp_name']); |
326 | 324 | } |
327 | 325 | else // backup failed ==> dont start the upgrade |
328 | 326 | { |
329 | - $setup_tpl->set_var('submsg',lang('Restore failed')); |
|
330 | - $setup_tpl->set_var('tableshave','<b>'.$f.'</b>'); |
|
331 | - $setup_tpl->set_var('subaction',''); |
|
327 | + $setup_tpl->set_var('submsg', lang('Restore failed')); |
|
328 | + $setup_tpl->set_var('tableshave', '<b>'.$f.'</b>'); |
|
329 | + $setup_tpl->set_var('subaction', ''); |
|
332 | 330 | } |
333 | 331 | } |
334 | 332 | } |
@@ -341,7 +339,7 @@ discard block |
||
341 | 339 | $GLOBALS['egw_setup']->system_charset = $_REQUEST['system_charset']; |
342 | 340 | $GLOBALS['egw_setup']->db->Link_ID->SetCharSet($_REQUEST['system_charset']); |
343 | 341 | } |
344 | - $setup_info = $GLOBALS['egw_setup']->process->pass($setup_info,'new',$_REQUEST['debug'],True); |
|
342 | + $setup_info = $GLOBALS['egw_setup']->process->pass($setup_info, 'new', $_REQUEST['debug'], True); |
|
345 | 343 | $GLOBALS['egw_info']['setup']['currentver']['phpgwapi'] = 'oldversion'; |
346 | 344 | } |
347 | 345 | break; |
@@ -350,24 +348,24 @@ discard block |
||
350 | 348 | // create a backup, before upgrading the tables |
351 | 349 | if ($_POST['backup']) |
352 | 350 | { |
353 | - $db_backup =& CreateObject('phpgwapi.db_backup'); |
|
351 | + $db_backup = & CreateObject('phpgwapi.db_backup'); |
|
354 | 352 | if (is_resource($f = $db_backup->fopen_backup())) |
355 | 353 | { |
356 | - echo '<p align="center">'.lang('backup started, this might take a few minutes ...')."</p>\n".str_repeat(' ',4096); |
|
354 | + echo '<p align="center">'.lang('backup started, this might take a few minutes ...')."</p>\n".str_repeat(' ', 4096); |
|
357 | 355 | $db_backup->backup($f); |
358 | 356 | fclose($f); |
359 | 357 | echo '<p align="center">'.lang('backup finished')."</p>\n"; |
360 | 358 | } |
361 | 359 | else // backup failed ==> dont start the upgrade |
362 | 360 | { |
363 | - $setup_tpl->set_var('submsg',lang('Backup failed')); |
|
364 | - $setup_tpl->set_var('tableshave','<b>'.$f.'</b>'); |
|
365 | - $setup_tpl->set_var('subaction',''); |
|
361 | + $setup_tpl->set_var('submsg', lang('Backup failed')); |
|
362 | + $setup_tpl->set_var('tableshave', '<b>'.$f.'</b>'); |
|
363 | + $setup_tpl->set_var('subaction', ''); |
|
366 | 364 | } |
367 | 365 | } |
368 | 366 | if (!@$_POST['backup'] || !is_string($f)) |
369 | 367 | { |
370 | - $setup_info = $GLOBALS['egw_setup']->process->pass($setup_info,'upgrade',$_REQUEST['debug']); |
|
368 | + $setup_info = $GLOBALS['egw_setup']->process->pass($setup_info, 'upgrade', $_REQUEST['debug']); |
|
371 | 369 | $GLOBALS['egw_info']['setup']['currentver']['phpgwapi'] = 'oldversion'; |
372 | 370 | } |
373 | 371 | break; |
@@ -377,93 +375,93 @@ discard block |
||
377 | 375 | { |
378 | 376 | echo "<pre>".$e->getMessage()."</pre>\n"; |
379 | 377 | } |
380 | - $setup_tpl->set_var('re-check_my_installation',lang('Re-Check My Installation')); |
|
381 | - $setup_tpl->set_var('system_charset',$GLOBALS['egw']->system_charset); |
|
382 | - $setup_tpl->parse('V_db_stage_6_post','B_db_stage_6_post'); |
|
383 | - $db_filled_block = $db_filled_block . $setup_tpl->get_var('V_db_stage_6_post'); |
|
384 | - $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
|
378 | + $setup_tpl->set_var('re-check_my_installation', lang('Re-Check My Installation')); |
|
379 | + $setup_tpl->set_var('system_charset', $GLOBALS['egw']->system_charset); |
|
380 | + $setup_tpl->parse('V_db_stage_6_post', 'B_db_stage_6_post'); |
|
381 | + $db_filled_block = $db_filled_block.$setup_tpl->get_var('V_db_stage_6_post'); |
|
382 | + $setup_tpl->set_var('V_db_filled_block', $db_filled_block); |
|
385 | 383 | break; |
386 | 384 | case 10: |
387 | - $setup_tpl->set_var('tablescurrent',lang('Your eGroupWare API is current')); |
|
388 | - $setup_tpl->set_var('uninstall_all_applications',lang('Uninstall all applications')); |
|
389 | - $setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data')); |
|
390 | - $setup_tpl->set_var('deletetables',lang('Uninstall all applications')); |
|
391 | - $setup_tpl->parse('V_db_stage_10','B_db_stage_10'); |
|
385 | + $setup_tpl->set_var('tablescurrent', lang('Your eGroupWare API is current')); |
|
386 | + $setup_tpl->set_var('uninstall_all_applications', lang('Uninstall all applications')); |
|
387 | + $setup_tpl->set_var('dropwarn', lang('Your tables will be dropped and you will lose data')); |
|
388 | + $setup_tpl->set_var('deletetables', lang('Uninstall all applications')); |
|
389 | + $setup_tpl->parse('V_db_stage_10', 'B_db_stage_10'); |
|
392 | 390 | $db_filled_block = $setup_tpl->get_var('V_db_stage_10'); |
393 | - $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
|
391 | + $setup_tpl->set_var('V_db_filled_block', $db_filled_block); |
|
394 | 392 | break; |
395 | 393 | default: |
396 | - $setup_tpl->set_var('dbnotexist',lang('Your database does not exist')); |
|
397 | - $setup_tpl->parse('V_db_stage_default','B_db_stage_default'); |
|
394 | + $setup_tpl->set_var('dbnotexist', lang('Your database does not exist')); |
|
395 | + $setup_tpl->parse('V_db_stage_default', 'B_db_stage_default'); |
|
398 | 396 | $db_filled_block = $setup_tpl->get_var('V_db_stage_default'); |
399 | - $setup_tpl->set_var('V_db_filled_block',$db_filled_block); |
|
397 | + $setup_tpl->set_var('V_db_filled_block', $db_filled_block); |
|
400 | 398 | break; |
401 | 399 | } |
402 | 400 | |
403 | 401 | // Config Section |
404 | -$setup_tpl->set_var('config_step_text',lang('Step %1 - Configuration', ++$num)); |
|
402 | +$setup_tpl->set_var('config_step_text', lang('Step %1 - Configuration', ++$num)); |
|
405 | 403 | $GLOBALS['egw_info']['setup']['stage']['config'] = $GLOBALS['egw_setup']->detection->check_config(); |
406 | 404 | |
407 | 405 | // begin DEBUG code |
408 | 406 | //$GLOBALS['egw_info']['setup']['stage']['config'] = 10; |
409 | 407 | // end DEBUG code |
410 | 408 | |
411 | -$setup_tpl->set_var('config_status_img',$incomplete); |
|
412 | -$setup_tpl->set_var('config_status_alt',lang('not completed')); |
|
413 | -switch($GLOBALS['egw_info']['setup']['stage']['config']) |
|
409 | +$setup_tpl->set_var('config_status_img', $incomplete); |
|
410 | +$setup_tpl->set_var('config_status_alt', lang('not completed')); |
|
411 | +switch ($GLOBALS['egw_info']['setup']['stage']['config']) |
|
414 | 412 | { |
415 | 413 | case 1: // AFAIK this dont happen any more, as we have setup_process::save_minimal_config() now -- RalfBecker |
416 | 414 | $btn_config_now = $GLOBALS['egw_setup']->html->make_frm_btn_simple( |
417 | 415 | lang('Please configure eGroupWare for your environment'), |
418 | - 'post','config.php', |
|
419 | - 'submit',lang('Configure Now'), |
|
416 | + 'post', 'config.php', |
|
417 | + 'submit', lang('Configure Now'), |
|
420 | 418 | ''); |
421 | - $setup_tpl->set_var('config_table_data',$btn_config_now); |
|
419 | + $setup_tpl->set_var('config_table_data', $btn_config_now); |
|
422 | 420 | break; |
423 | 421 | case 10: |
424 | - $setup_tpl->set_var('config_status_img',$completed); |
|
425 | - $setup_tpl->set_var('config_status_alt',lang('completed')); |
|
422 | + $setup_tpl->set_var('config_status_img', $completed); |
|
423 | + $setup_tpl->set_var('config_status_alt', lang('completed')); |
|
426 | 424 | $config_msg = lang('Configuration completed'); |
427 | 425 | case 2: |
428 | 426 | if ($GLOBALS['egw_info']['setup']['config_errors']) |
429 | 427 | { |
430 | - $config_msg = implode('<br />',$GLOBALS['egw_info']['setup']['config_errors']); |
|
428 | + $config_msg = implode('<br />', $GLOBALS['egw_info']['setup']['config_errors']); |
|
431 | 429 | } |
432 | 430 | $btn_edit_config = $GLOBALS['egw_setup']->html->make_frm_btn_simple( |
433 | 431 | $config_msg, |
434 | - 'post','config.php', |
|
435 | - 'submit',lang('Edit Current Configuration'), |
|
432 | + 'post', 'config.php', |
|
433 | + 'submit', lang('Edit Current Configuration'), |
|
436 | 434 | '' |
437 | 435 | ); |
438 | - $setup_tpl->set_var('config_table_data',$btn_edit_config); |
|
436 | + $setup_tpl->set_var('config_table_data', $btn_edit_config); |
|
439 | 437 | break; |
440 | 438 | default: |
441 | - $setup_tpl->set_var('config_status_img',$incomplete); |
|
442 | - $setup_tpl->set_var('config_status_alt',lang('not completed')); |
|
443 | - $setup_tpl->set_var('config_table_data',lang('Not ready for this stage yet')); |
|
439 | + $setup_tpl->set_var('config_status_img', $incomplete); |
|
440 | + $setup_tpl->set_var('config_status_alt', lang('not completed')); |
|
441 | + $setup_tpl->set_var('config_table_data', lang('Not ready for this stage yet')); |
|
444 | 442 | break; |
445 | 443 | } |
446 | 444 | // Admin Account Section |
447 | -$setup_tpl->set_var('admin_step_text',lang('Step %1 - Admin Account', ++$num)); |
|
445 | +$setup_tpl->set_var('admin_step_text', lang('Step %1 - Admin Account', ++$num)); |
|
448 | 446 | |
449 | -switch($GLOBALS['egw_info']['setup']['stage']['config']) |
|
447 | +switch ($GLOBALS['egw_info']['setup']['stage']['config']) |
|
450 | 448 | { |
451 | 449 | case 10: |
452 | 450 | // check if there is already a user account (not the anonymous account of sitemgr or a group) |
453 | 451 | $no_accounts = !$GLOBALS['egw_setup']->accounts_exist(); |
454 | - $setup_tpl->set_var('admin_status_img',$no_accounts ? $incomplete : $completed); |
|
455 | - $setup_tpl->set_var('admin_status_alt',$no_accounts ? lang('not completed') : lang('completed')); |
|
456 | - $setup_tpl->set_var('admin_table_data',$GLOBALS['egw_setup']->html->make_frm_btn_simple( |
|
452 | + $setup_tpl->set_var('admin_status_img', $no_accounts ? $incomplete : $completed); |
|
453 | + $setup_tpl->set_var('admin_status_alt', $no_accounts ? lang('not completed') : lang('completed')); |
|
454 | + $setup_tpl->set_var('admin_table_data', $GLOBALS['egw_setup']->html->make_frm_btn_simple( |
|
457 | 455 | $no_accounts ? lang('No accounts existing') : lang('Accounts existing'), |
458 | - 'post','admin_account.php', |
|
459 | - 'submit',lang('Create admin account'), |
|
456 | + 'post', 'admin_account.php', |
|
457 | + 'submit', lang('Create admin account'), |
|
460 | 458 | '' |
461 | 459 | )); |
462 | 460 | break; |
463 | 461 | default: |
464 | - $setup_tpl->set_var('admin_status_img',$incomplete); |
|
465 | - $setup_tpl->set_var('admin_status_alt',lang('not completed')); |
|
466 | - $setup_tpl->set_var('admin_table_data',lang('Not ready for this stage yet')); |
|
462 | + $setup_tpl->set_var('admin_status_img', $incomplete); |
|
463 | + $setup_tpl->set_var('admin_status_alt', lang('not completed')); |
|
464 | + $setup_tpl->set_var('admin_table_data', lang('Not ready for this stage yet')); |
|
467 | 465 | break; |
468 | 466 | } |
469 | 467 | /* |
@@ -514,69 +512,69 @@ discard block |
||
514 | 512 | break; |
515 | 513 | } |
516 | 514 | */ |
517 | -$setup_tpl->set_var('apps_step_text',lang('Step %1 - Advanced Application Management', ++$num)); |
|
515 | +$setup_tpl->set_var('apps_step_text', lang('Step %1 - Advanced Application Management', ++$num)); |
|
518 | 516 | // $GLOBALS['egw_info']['setup']['stage']['apps'] = $GLOBALS['egw_setup']->check_apps(); |
519 | -switch($GLOBALS['egw_info']['setup']['stage']['db']) |
|
517 | +switch ($GLOBALS['egw_info']['setup']['stage']['db']) |
|
520 | 518 | { |
521 | 519 | case 10: |
522 | - $setup_tpl->set_var('apps_status_img',$completed); |
|
523 | - $setup_tpl->set_var('apps_status_alt',lang('completed')); |
|
520 | + $setup_tpl->set_var('apps_status_img', $completed); |
|
521 | + $setup_tpl->set_var('apps_status_alt', lang('completed')); |
|
524 | 522 | // check if we have apps to upgrade or essential apps not installed |
525 | 523 | $to_upgrade = $to_install = array(); |
526 | - foreach($setup_info as $app => $data) |
|
524 | + foreach ($setup_info as $app => $data) |
|
527 | 525 | { |
528 | 526 | if ($data['currentver'] && $data['version'] && $data['version'] != $data['currentver']) |
529 | 527 | { |
530 | 528 | $to_upgrade[] = $app; |
531 | - $setup_tpl->set_var('apps_status_img',$incomplete); |
|
529 | + $setup_tpl->set_var('apps_status_img', $incomplete); |
|
532 | 530 | } |
533 | 531 | } |
534 | 532 | // warn if essential apps are not installed |
535 | - foreach(array('phpgwapi','etemplate','home','admin','preferences','emailadmin') as $app) |
|
533 | + foreach (array('phpgwapi', 'etemplate', 'home', 'admin', 'preferences', 'emailadmin') as $app) |
|
536 | 534 | { |
537 | 535 | if (!isset($setup_info[$app]) || empty($setup_info[$app]['currentver'])) |
538 | 536 | { |
539 | 537 | $to_install[] = $app; |
540 | - $setup_tpl->set_var('apps_status_img',$incomplete); |
|
538 | + $setup_tpl->set_var('apps_status_img', $incomplete); |
|
541 | 539 | } |
542 | 540 | } |
543 | 541 | $msg = ''; |
544 | 542 | if ($to_upgrade || $to_install) |
545 | 543 | { |
546 | - if ($to_upgrade) $msg = '<b>'.lang('The following applications need to be upgraded:').'</b> '.implode(', ',$to_upgrade); |
|
547 | - if ($to_install) $msg .= ($msg?'<br />':'').'<b>'.lang('The following applications are required, but NOT installed:').'</b> '.implode(', ',$to_install); |
|
544 | + if ($to_upgrade) $msg = '<b>'.lang('The following applications need to be upgraded:').'</b> '.implode(', ', $to_upgrade); |
|
545 | + if ($to_install) $msg .= ($msg ? '<br />' : '').'<b>'.lang('The following applications are required, but NOT installed:').'</b> '.implode(', ', $to_install); |
|
548 | 546 | } |
549 | 547 | $btn_manage_apps = $GLOBALS['egw_setup']->html->make_frm_btn_simple( |
550 | 548 | $msg ? $msg : lang('This stage is completed<br />'), |
551 | - 'post','applications.php', |
|
552 | - 'submit',lang('Manage Applications'), |
|
549 | + 'post', 'applications.php', |
|
550 | + 'submit', lang('Manage Applications'), |
|
553 | 551 | ''); |
554 | - $setup_tpl->set_var('apps_table_data',$btn_manage_apps); |
|
552 | + $setup_tpl->set_var('apps_table_data', $btn_manage_apps); |
|
555 | 553 | break; |
556 | 554 | default: |
557 | - $setup_tpl->set_var('apps_status_img',$incomplete); |
|
558 | - $setup_tpl->set_var('apps_status_alt',lang('not completed')); |
|
559 | - $setup_tpl->set_var('apps_table_data',lang('Not ready for this stage yet')); |
|
555 | + $setup_tpl->set_var('apps_status_img', $incomplete); |
|
556 | + $setup_tpl->set_var('apps_status_alt', lang('not completed')); |
|
557 | + $setup_tpl->set_var('apps_table_data', lang('Not ready for this stage yet')); |
|
560 | 558 | break; |
561 | 559 | } |
562 | 560 | // Backup and restore section |
563 | -$setup_tpl->set_var('backup_step_text',lang('Step %1 - DB backup and restore', ++$num)); |
|
561 | +$setup_tpl->set_var('backup_step_text', lang('Step %1 - DB backup and restore', ++$num)); |
|
564 | 562 | if ($GLOBALS['egw_info']['setup']['stage']['db'] == 10 && !$no_backup_dir) |
565 | 563 | { |
566 | - $setup_tpl->set_var('backup_status_img',$completed); |
|
567 | - $setup_tpl->set_var('backup_status_alt',lang('completed')); |
|
568 | - $setup_tpl->set_var('backup_table_data',$GLOBALS['egw_setup']->html->make_frm_btn_simple( |
|
564 | + $setup_tpl->set_var('backup_status_img', $completed); |
|
565 | + $setup_tpl->set_var('backup_status_alt', lang('completed')); |
|
566 | + $setup_tpl->set_var('backup_table_data', $GLOBALS['egw_setup']->html->make_frm_btn_simple( |
|
569 | 567 | ''/*lang('This stage is completed<br />')*/, |
570 | - 'post','db_backup.php', |
|
571 | - 'submit',lang('backup and restore'), |
|
568 | + 'post', 'db_backup.php', |
|
569 | + 'submit', lang('backup and restore'), |
|
572 | 570 | '')); |
573 | 571 | } |
574 | 572 | else |
575 | 573 | { |
576 | - $setup_tpl->set_var('backup_status_img',$incomplete); |
|
577 | - $setup_tpl->set_var('backup_status_alt',lang('not completed')); |
|
578 | - $setup_tpl->set_var('backup_table_data',$no_backup_dir ? $no_backup_dir : lang('Not ready for this stage yet')); |
|
574 | + $setup_tpl->set_var('backup_status_img', $incomplete); |
|
575 | + $setup_tpl->set_var('backup_status_alt', lang('not completed')); |
|
576 | + $setup_tpl->set_var('backup_table_data', $no_backup_dir ? $no_backup_dir : lang('Not ready for this stage yet')); |
|
579 | 577 | } |
580 | 578 | |
581 | -$setup_tpl->pparse('out','T_setup_main'); |
|
579 | +$setup_tpl->pparse('out', 'T_setup_main'); |
|
582 | 580 | $GLOBALS['egw_setup']->html->show_footer(); |
@@ -99,7 +99,7 @@ |
||
99 | 99 | //$action = 'Upgrade'; |
100 | 100 | // end DEBUG code |
101 | 101 | |
102 | -switch(@get_var('action',Array('POST'))) |
|
102 | +switch(@get_var('action',array('POST'))) |
|
103 | 103 | { |
104 | 104 | case 'Uninstall all applications': |
105 | 105 | $subtitle = lang('Deleting Tables'); |
@@ -350,7 +350,7 @@ |
||
350 | 350 | { |
351 | 351 | echo lang('because it depends upon') . ':<br />' . "\n"; |
352 | 352 | list($depapp,$depver) = parsedep($setup_info[$resolve]['depends'],False); |
353 | - $depapp_count = count($depapp); |
|
353 | + $depapp_count = count($depapp); |
|
354 | 354 | for ($i=0; $i<$depapp_count; $i++) |
355 | 355 | { |
356 | 356 | echo '<br />' . $depapp[$i] . ': '; |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | // Does not return unless user is authorized |
32 | 32 | |
33 | 33 | $tpl_root = $GLOBALS['egw_setup']->html->setup_tpl_dir('setup'); |
34 | -$setup_tpl = CreateObject('phpgwapi.Template',$tpl_root); |
|
34 | +$setup_tpl = CreateObject('phpgwapi.Template', $tpl_root); |
|
35 | 35 | $setup_tpl->set_file(array( |
36 | 36 | 'T_head' => 'head.tpl', |
37 | 37 | 'T_footer' => 'footer.tpl', |
@@ -48,36 +48,36 @@ discard block |
||
48 | 48 | egw_csrf::validate($_POST['csrf_token'], __FILE__); |
49 | 49 | } |
50 | 50 | |
51 | -$setup_tpl->set_block('T_login_stage_header','B_multi_domain','V_multi_domain'); |
|
52 | -$setup_tpl->set_block('T_login_stage_header','B_single_domain','V_single_domain'); |
|
53 | -$setup_tpl->set_block('T_setup_main','header','header'); |
|
54 | -$setup_tpl->set_block('T_setup_main','app_header','app_header'); |
|
55 | -$setup_tpl->set_block('T_setup_main','apps','apps'); |
|
56 | -$setup_tpl->set_block('T_setup_main','detail','detail'); |
|
57 | -$setup_tpl->set_block('T_setup_main','table','table'); |
|
58 | -$setup_tpl->set_block('T_setup_main','hook','hook'); |
|
59 | -$setup_tpl->set_block('T_setup_main','dep','dep'); |
|
60 | -$setup_tpl->set_block('T_setup_main','app_footer','app_footer'); |
|
61 | -$setup_tpl->set_block('T_setup_main','submit','submit'); |
|
62 | -$setup_tpl->set_block('T_setup_main','footer','footer'); |
|
63 | - |
|
64 | -$bgcolor = array('#DDDDDD','#EEEEEE'); |
|
65 | - |
|
66 | -function parsedep($depends,$main=True) |
|
51 | +$setup_tpl->set_block('T_login_stage_header', 'B_multi_domain', 'V_multi_domain'); |
|
52 | +$setup_tpl->set_block('T_login_stage_header', 'B_single_domain', 'V_single_domain'); |
|
53 | +$setup_tpl->set_block('T_setup_main', 'header', 'header'); |
|
54 | +$setup_tpl->set_block('T_setup_main', 'app_header', 'app_header'); |
|
55 | +$setup_tpl->set_block('T_setup_main', 'apps', 'apps'); |
|
56 | +$setup_tpl->set_block('T_setup_main', 'detail', 'detail'); |
|
57 | +$setup_tpl->set_block('T_setup_main', 'table', 'table'); |
|
58 | +$setup_tpl->set_block('T_setup_main', 'hook', 'hook'); |
|
59 | +$setup_tpl->set_block('T_setup_main', 'dep', 'dep'); |
|
60 | +$setup_tpl->set_block('T_setup_main', 'app_footer', 'app_footer'); |
|
61 | +$setup_tpl->set_block('T_setup_main', 'submit', 'submit'); |
|
62 | +$setup_tpl->set_block('T_setup_main', 'footer', 'footer'); |
|
63 | + |
|
64 | +$bgcolor = array('#DDDDDD', '#EEEEEE'); |
|
65 | + |
|
66 | +function parsedep($depends, $main = True) |
|
67 | 67 | { |
68 | 68 | $depstring = '('; |
69 | - foreach($depends as $a => $b) |
|
69 | + foreach ($depends as $a => $b) |
|
70 | 70 | { |
71 | - foreach($b as $c => $d) |
|
71 | + foreach ($b as $c => $d) |
|
72 | 72 | { |
73 | 73 | if (is_array($d)) |
74 | 74 | { |
75 | - $depstring .= $c . ': ' .implode(',',$d) . '; '; |
|
75 | + $depstring .= $c.': '.implode(',', $d).'; '; |
|
76 | 76 | $depver[] = $d; |
77 | 77 | } |
78 | 78 | else |
79 | 79 | { |
80 | - $depstring .= $c . ': ' . $d . '; '; |
|
80 | + $depstring .= $c.': '.$d.'; '; |
|
81 | 81 | $depapp[] = $d; |
82 | 82 | } |
83 | 83 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | } |
90 | 90 | else |
91 | 91 | { |
92 | - return array($depapp,$depver); |
|
92 | + return array($depapp, $depver); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
@@ -106,29 +106,29 @@ discard block |
||
106 | 106 | //var_dump($setup_info);exit; |
107 | 107 | @ksort($setup_info); |
108 | 108 | |
109 | -if(@get_var('cancel',Array('POST'))) |
|
109 | +if (@get_var('cancel', Array('POST'))) |
|
110 | 110 | { |
111 | 111 | Header("Location: index.php"); |
112 | 112 | exit; |
113 | 113 | } |
114 | 114 | |
115 | -if(@get_var('submit',Array('POST'))) |
|
115 | +if (@get_var('submit', Array('POST'))) |
|
116 | 116 | { |
117 | - $GLOBALS['egw_setup']->html->show_header(lang('Application Management'),False,'config',$GLOBALS['egw_setup']->ConfigDomain . '(' . $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'] . ')'); |
|
118 | - $setup_tpl->set_var('description',lang('App install/remove/upgrade') . ':'); |
|
119 | - $setup_tpl->pparse('out','header'); |
|
117 | + $GLOBALS['egw_setup']->html->show_header(lang('Application Management'), False, 'config', $GLOBALS['egw_setup']->ConfigDomain.'('.$GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'].')'); |
|
118 | + $setup_tpl->set_var('description', lang('App install/remove/upgrade').':'); |
|
119 | + $setup_tpl->pparse('out', 'header'); |
|
120 | 120 | |
121 | - $appname = get_var('appname',Array('POST')); |
|
122 | - $remove = get_var('remove',Array('POST')); |
|
123 | - $install = get_var('install',Array('POST')); |
|
124 | - $upgrade = get_var('upgrade',Array('POST')); |
|
121 | + $appname = get_var('appname', Array('POST')); |
|
122 | + $remove = get_var('remove', Array('POST')); |
|
123 | + $install = get_var('install', Array('POST')); |
|
124 | + $upgrade = get_var('upgrade', Array('POST')); |
|
125 | 125 | |
126 | - if(!empty($remove) && is_array($remove)) |
|
126 | + if (!empty($remove) && is_array($remove)) |
|
127 | 127 | { |
128 | 128 | $historylog = CreateObject('phpgwapi.historylog'); |
129 | 129 | $historylog->db = $GLOBALS['egw_setup']->db; |
130 | 130 | |
131 | - foreach($remove as $appname => $key) |
|
131 | + foreach ($remove as $appname => $key) |
|
132 | 132 | { |
133 | 133 | $app_title = $setup_info[$appname]['title'] ? $setup_info[$appname]['title'] : $setup_info[$appname]['name']; |
134 | 134 | $terror = array(); |
@@ -136,33 +136,33 @@ discard block |
||
136 | 136 | |
137 | 137 | if ($setup_info[$appname]['tables']) |
138 | 138 | { |
139 | - $GLOBALS['egw_setup']->process->droptables($terror,$DEBUG); |
|
140 | - echo '<br />' . $app_title . ' ' . lang('tables dropped') . '.'; |
|
139 | + $GLOBALS['egw_setup']->process->droptables($terror, $DEBUG); |
|
140 | + echo '<br />'.$app_title.' '.lang('tables dropped').'.'; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | $GLOBALS['egw_setup']->deregister_app($setup_info[$appname]['name']); |
144 | - echo '<br />' . $app_title . ' ' . lang('deregistered') . '.'; |
|
144 | + echo '<br />'.$app_title.' '.lang('deregistered').'.'; |
|
145 | 145 | |
146 | 146 | if ($GLOBALS['egw_setup']->deregister_hooks($setup_info[$appname]['name'])) |
147 | 147 | { |
148 | - echo '<br />' . $app_title . ' ' . lang('hooks deregistered') . '.'; |
|
148 | + echo '<br />'.$app_title.' '.lang('hooks deregistered').'.'; |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | $historylog->appname = $appname; |
152 | 152 | if ($historylog->delete(null)) |
153 | 153 | { |
154 | - echo '<br />' . $app_title . ' ' . lang('Historylog removed') . '.'; |
|
154 | + echo '<br />'.$app_title.' '.lang('Historylog removed').'.'; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | // delete all application categories and ACL |
158 | - $GLOBALS['egw_setup']->db->delete($GLOBALS['egw_setup']->cats_table,array('cat_appname' => $appname),__LINE__,__FILE__); |
|
159 | - $GLOBALS['egw_setup']->db->delete($GLOBALS['egw_setup']->acl_table,array('acl_appname' => $appname),__LINE__,__FILE__); |
|
158 | + $GLOBALS['egw_setup']->db->delete($GLOBALS['egw_setup']->cats_table, array('cat_appname' => $appname), __LINE__, __FILE__); |
|
159 | + $GLOBALS['egw_setup']->db->delete($GLOBALS['egw_setup']->acl_table, array('acl_appname' => $appname), __LINE__, __FILE__); |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
163 | - if(!empty($install) && is_array($install)) |
|
163 | + if (!empty($install) && is_array($install)) |
|
164 | 164 | { |
165 | - foreach($install as $appname => $key) |
|
165 | + foreach ($install as $appname => $key) |
|
166 | 166 | { |
167 | 167 | $app_title = $setup_info[$appname]['title'] ? $setup_info[$appname]['title'] : $setup_info[$appname]['name']; |
168 | 168 | $terror = array(); |
@@ -170,15 +170,15 @@ discard block |
||
170 | 170 | |
171 | 171 | if ($setup_info[$appname]['tables']) |
172 | 172 | { |
173 | - $terror = $GLOBALS['egw_setup']->process->current($terror,$DEBUG); |
|
174 | - $terror = $GLOBALS['egw_setup']->process->default_records($terror,$DEBUG); |
|
175 | - echo '<br />' . $app_title . ' ' |
|
176 | - . lang('tables installed, unless there are errors printed above') . '.'; |
|
173 | + $terror = $GLOBALS['egw_setup']->process->current($terror, $DEBUG); |
|
174 | + $terror = $GLOBALS['egw_setup']->process->default_records($terror, $DEBUG); |
|
175 | + echo '<br />'.$app_title.' ' |
|
176 | + . lang('tables installed, unless there are errors printed above').'.'; |
|
177 | 177 | } |
178 | 178 | else |
179 | 179 | { |
180 | 180 | // check default_records for apps without tables, they might need some initial work too |
181 | - $terror = $GLOBALS['egw_setup']->process->default_records($terror,$DEBUG); |
|
181 | + $terror = $GLOBALS['egw_setup']->process->default_records($terror, $DEBUG); |
|
182 | 182 | if ($GLOBALS['egw_setup']->app_registered($setup_info[$appname]['name'])) |
183 | 183 | { |
184 | 184 | $GLOBALS['egw_setup']->update_app($setup_info[$appname]['name']); |
@@ -187,260 +187,260 @@ discard block |
||
187 | 187 | { |
188 | 188 | $GLOBALS['egw_setup']->register_app($setup_info[$appname]['name']); |
189 | 189 | } |
190 | - echo '<br />' . $app_title . ' ' . lang('registered') . '.'; |
|
190 | + echo '<br />'.$app_title.' '.lang('registered').'.'; |
|
191 | 191 | |
192 | 192 | if ($setup_info[$appname]['hooks']) |
193 | 193 | { |
194 | 194 | $GLOBALS['egw_setup']->register_hooks($setup_info[$appname]['name']); |
195 | - echo '<br />' . $app_title . ' ' . lang('hooks registered') . '.'; |
|
195 | + echo '<br />'.$app_title.' '.lang('hooks registered').'.'; |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
201 | - if(!empty($upgrade) && is_array($upgrade)) |
|
201 | + if (!empty($upgrade) && is_array($upgrade)) |
|
202 | 202 | { |
203 | - foreach($upgrade as $appname => $key) |
|
203 | + foreach ($upgrade as $appname => $key) |
|
204 | 204 | { |
205 | 205 | $app_title = $setup_info[$appname]['title'] ? $setup_info[$appname]['title'] : $setup_info[$appname]['name']; |
206 | 206 | $terror = array(); |
207 | 207 | $terror[$appname] = $setup_info[$appname]; |
208 | 208 | |
209 | - $GLOBALS['egw_setup']->process->upgrade($terror,$DEBUG); |
|
209 | + $GLOBALS['egw_setup']->process->upgrade($terror, $DEBUG); |
|
210 | 210 | if ($setup_info[$appname]['tables']) |
211 | 211 | { |
212 | - echo '<br />' . $app_title . ' ' . lang('tables upgraded') . '.'; |
|
212 | + echo '<br />'.$app_title.' '.lang('tables upgraded').'.'; |
|
213 | 213 | // The process_upgrade() function also handles registration |
214 | 214 | } |
215 | 215 | else |
216 | 216 | { |
217 | - echo '<br />' . $app_title . ' ' . lang('upgraded') . '.'; |
|
217 | + echo '<br />'.$app_title.' '.lang('upgraded').'.'; |
|
218 | 218 | } |
219 | 219 | } |
220 | 220 | } |
221 | 221 | //$setup_tpl->set_var('goback', |
222 | - echo '<br /><a href="applications.php?debug='.$DEBUG.'">' . lang('Go back') . '</a>'; |
|
222 | + echo '<br /><a href="applications.php?debug='.$DEBUG.'">'.lang('Go back').'</a>'; |
|
223 | 223 | //$setup_tpl->pparse('out','submit'); |
224 | - $setup_tpl->pparse('out','footer'); |
|
224 | + $setup_tpl->pparse('out', 'footer'); |
|
225 | 225 | exit; |
226 | 226 | } |
227 | 227 | else |
228 | 228 | { |
229 | - $GLOBALS['egw_setup']->html->show_header(lang('Application Management'),False,'config',$GLOBALS['egw_setup']->ConfigDomain . '(' . $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'] . ')'); |
|
229 | + $GLOBALS['egw_setup']->html->show_header(lang('Application Management'), False, 'config', $GLOBALS['egw_setup']->ConfigDomain.'('.$GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'].')'); |
|
230 | 230 | } |
231 | 231 | |
232 | -if(@get_var('hooks', Array('GET'))) |
|
232 | +if (@get_var('hooks', Array('GET'))) |
|
233 | 233 | { |
234 | 234 | egw_cache::flush(egw_cache::INSTANCE); |
235 | 235 | |
236 | 236 | // Find & register all application hooks |
237 | - foreach($setup_info as $appname => $info) |
|
237 | + foreach ($setup_info as $appname => $info) |
|
238 | 238 | { |
239 | 239 | if ($info['currentver']) $GLOBALS['egw_setup']->register_hooks($appname); |
240 | 240 | } |
241 | - echo lang('All hooks registered') . '<br />'; |
|
241 | + echo lang('All hooks registered').'<br />'; |
|
242 | 242 | } |
243 | -$detail = get_var('detail',Array('GET')); |
|
244 | -$resolve = get_var('resolve',Array('GET')); |
|
245 | -if(@$detail) |
|
243 | +$detail = get_var('detail', Array('GET')); |
|
244 | +$resolve = get_var('resolve', Array('GET')); |
|
245 | +if (@$detail) |
|
246 | 246 | { |
247 | 247 | @ksort($setup_info[$detail]); |
248 | - $setup_tpl->set_var('description',lang('App details') . ':'); |
|
249 | - $setup_tpl->pparse('out','header'); |
|
248 | + $setup_tpl->set_var('description', lang('App details').':'); |
|
249 | + $setup_tpl->pparse('out', 'header'); |
|
250 | 250 | |
251 | - $setup_tpl->set_var('name','application'); |
|
251 | + $setup_tpl->set_var('name', 'application'); |
|
252 | 252 | $setup_tpl->set_var('details', lang($setup_info[$detail]['title'])); |
253 | - $setup_tpl->pparse('out','detail'); |
|
253 | + $setup_tpl->pparse('out', 'detail'); |
|
254 | 254 | |
255 | - foreach($setup_info[$detail] as $key => $val) |
|
255 | + foreach ($setup_info[$detail] as $key => $val) |
|
256 | 256 | { |
257 | - if($key != 'title') |
|
257 | + if ($key != 'title') |
|
258 | 258 | { |
259 | 259 | $i = ($i ? 0 : 1); |
260 | 260 | |
261 | 261 | if ($key == 'tables') |
262 | 262 | { |
263 | 263 | $tblcnt = count($setup_info[$detail][$key]); |
264 | - if(is_array($val)) |
|
264 | + if (is_array($val)) |
|
265 | 265 | { |
266 | - $key = '<a href="sqltoarray.php?appname=' . $detail . '&submit=True&apps=True">' . $key . '(' . $tblcnt . ')</a>' . "\n"; |
|
267 | - $val = implode(',' . "\n",$val); |
|
266 | + $key = '<a href="sqltoarray.php?appname='.$detail.'&submit=True&apps=True">'.$key.'('.$tblcnt.')</a>'."\n"; |
|
267 | + $val = implode(','."\n", $val); |
|
268 | 268 | } |
269 | 269 | } |
270 | - if ($key == 'hooks') { $val = implode(',',$val); } |
|
270 | + if ($key == 'hooks') { $val = implode(',', $val); } |
|
271 | 271 | if ($key == 'depends') { $val = parsedep($val); } |
272 | - if (is_array($val)) { $val = implode(',',$val); } |
|
272 | + if (is_array($val)) { $val = implode(',', $val); } |
|
273 | 273 | |
274 | - $setup_tpl->set_var('bg_color',$bgcolor[$i]); |
|
275 | - $setup_tpl->set_var('name',$key); |
|
276 | - $setup_tpl->set_var('details',$val); |
|
277 | - $setup_tpl->pparse('out','detail'); |
|
274 | + $setup_tpl->set_var('bg_color', $bgcolor[$i]); |
|
275 | + $setup_tpl->set_var('name', $key); |
|
276 | + $setup_tpl->set_var('details', $val); |
|
277 | + $setup_tpl->pparse('out', 'detail'); |
|
278 | 278 | } |
279 | 279 | } |
280 | 280 | |
281 | - echo '<br /><a href="applications.php?debug='.$DEBUG.'">' . lang('Go back') . '</a>'; |
|
282 | - $setup_tpl->pparse('out','footer'); |
|
281 | + echo '<br /><a href="applications.php?debug='.$DEBUG.'">'.lang('Go back').'</a>'; |
|
282 | + $setup_tpl->pparse('out', 'footer'); |
|
283 | 283 | exit; |
284 | 284 | } |
285 | 285 | elseif (@$resolve) |
286 | 286 | { |
287 | - $version = get_var('version',Array('GET')); |
|
288 | - $notables = get_var('notables',Array('GET')); |
|
289 | - $setup_tpl->set_var('description',lang('Problem resolution'). ':'); |
|
290 | - $setup_tpl->pparse('out','header'); |
|
287 | + $version = get_var('version', Array('GET')); |
|
288 | + $notables = get_var('notables', Array('GET')); |
|
289 | + $setup_tpl->set_var('description', lang('Problem resolution').':'); |
|
290 | + $setup_tpl->pparse('out', 'header'); |
|
291 | 291 | $app_title = $setup_info[$resolve]['title'] ? $setup_info[$resolve]['title'] : $setup_info[$resolve]['name']; |
292 | 292 | |
293 | - if(get_var('post',Array('GET'))) |
|
293 | + if (get_var('post', Array('GET'))) |
|
294 | 294 | { |
295 | - echo '"' . $app_title . '" ' . lang('may be broken') . ' '; |
|
295 | + echo '"'.$app_title.'" '.lang('may be broken').' '; |
|
296 | 296 | echo lang('because an application it depends upon was upgraded'); |
297 | 297 | echo '<br />'; |
298 | - echo lang('to a version it does not know about') . '.'; |
|
298 | + echo lang('to a version it does not know about').'.'; |
|
299 | 299 | echo '<br />'; |
300 | - echo lang('However, the application may still work') . '.'; |
|
300 | + echo lang('However, the application may still work').'.'; |
|
301 | 301 | } |
302 | - elseif(get_var('badinstall',Array('GET'))) |
|
302 | + elseif (get_var('badinstall', Array('GET'))) |
|
303 | 303 | { |
304 | - echo '"' . $app_title . '" ' . lang('is broken') . ' '; |
|
305 | - echo lang('because of a failed upgrade or install') . '.'; |
|
304 | + echo '"'.$app_title.'" '.lang('is broken').' '; |
|
305 | + echo lang('because of a failed upgrade or install').'.'; |
|
306 | 306 | echo '<br />'; |
307 | - echo lang('Some or all of its tables are missing') . '.'; |
|
307 | + echo lang('Some or all of its tables are missing').'.'; |
|
308 | 308 | echo '<br />'; |
309 | - echo lang('You should either uninstall and then reinstall it, or attempt manual repairs') . '.'; |
|
309 | + echo lang('You should either uninstall and then reinstall it, or attempt manual repairs').'.'; |
|
310 | 310 | } |
311 | - elseif(get_var('deleted',Array('GET'))) |
|
311 | + elseif (get_var('deleted', Array('GET'))) |
|
312 | 312 | { |
313 | - echo '"' . $app_title . '" ' . lang('is broken') . ' '; |
|
314 | - echo lang('because its sources are missing') . '!'; |
|
313 | + echo '"'.$app_title.'" '.lang('is broken').' '; |
|
314 | + echo lang('because its sources are missing').'!'; |
|
315 | 315 | echo '<br />'; |
316 | - echo lang('However the tables are still in the database') . '.'; |
|
316 | + echo lang('However the tables are still in the database').'.'; |
|
317 | 317 | echo '<br />'; |
318 | - echo lang('You should either install the sources or uninstall it, to get rid of the tables') . '.'; |
|
318 | + echo lang('You should either install the sources or uninstall it, to get rid of the tables').'.'; |
|
319 | 319 | } |
320 | 320 | elseif (!$version) |
321 | 321 | { |
322 | - if($setup_info[$resolve]['enabled']) |
|
322 | + if ($setup_info[$resolve]['enabled']) |
|
323 | 323 | { |
324 | - echo '"' . $app_title . '" ' . lang('is broken') . ' '; |
|
324 | + echo '"'.$app_title.'" '.lang('is broken').' '; |
|
325 | 325 | } |
326 | 326 | else |
327 | 327 | { |
328 | - echo '"' . $app_title . '" ' . lang('is disabled') . ' '; |
|
328 | + echo '"'.$app_title.'" '.lang('is disabled').' '; |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | if (!$notables) |
332 | 332 | { |
333 | - if($setup_info[$resolve]['status'] == 'D') |
|
333 | + if ($setup_info[$resolve]['status'] == 'D') |
|
334 | 334 | { |
335 | - echo lang('because it depends upon') . ':<br />' . "\n"; |
|
336 | - list($depapp,$depver) = parsedep($setup_info[$resolve]['depends'],False); |
|
335 | + echo lang('because it depends upon').':<br />'."\n"; |
|
336 | + list($depapp, $depver) = parsedep($setup_info[$resolve]['depends'], False); |
|
337 | 337 | $depapp_count = count($depapp); |
338 | - for ($i=0; $i<$depapp_count; $i++) |
|
338 | + for ($i = 0; $i < $depapp_count; $i++) |
|
339 | 339 | { |
340 | - echo '<br />' . $depapp[$i] . ': '; |
|
340 | + echo '<br />'.$depapp[$i].': '; |
|
341 | 341 | $list = ''; |
342 | - foreach($depver[$i] as $x => $y) |
|
342 | + foreach ($depver[$i] as $x => $y) |
|
343 | 343 | { |
344 | - $list .= $y . ', '; |
|
344 | + $list .= $y.', '; |
|
345 | 345 | } |
346 | - $list = substr($list,0,-2); |
|
346 | + $list = substr($list, 0, -2); |
|
347 | 347 | echo "$list\n"; |
348 | 348 | } |
349 | - echo '<br /><br />' . lang('The table definition was correct, and the tables were installed') . '.'; |
|
349 | + echo '<br /><br />'.lang('The table definition was correct, and the tables were installed').'.'; |
|
350 | 350 | } |
351 | 351 | else |
352 | 352 | { |
353 | - echo lang('because it was manually disabled') . '.'; |
|
353 | + echo lang('because it was manually disabled').'.'; |
|
354 | 354 | } |
355 | 355 | } |
356 | - elseif($setup_info[$resolve]['enable'] == 2) |
|
356 | + elseif ($setup_info[$resolve]['enable'] == 2) |
|
357 | 357 | { |
358 | - echo lang('because it is not a user application, or access is controlled via acl') . '.'; |
|
358 | + echo lang('because it is not a user application, or access is controlled via acl').'.'; |
|
359 | 359 | } |
360 | - elseif($setup_info[$resolve]['enable'] == 0) |
|
360 | + elseif ($setup_info[$resolve]['enable'] == 0) |
|
361 | 361 | { |
362 | - echo lang('because the enable flag for this app is set to 0, or is undefined') . '.'; |
|
362 | + echo lang('because the enable flag for this app is set to 0, or is undefined').'.'; |
|
363 | 363 | } |
364 | 364 | else |
365 | 365 | { |
366 | - echo lang('because it requires manual table installation, <br />or the table definition was incorrect') . ".\n" |
|
367 | - . lang("Please check for sql scripts within the application's directory") . '.'; |
|
366 | + echo lang('because it requires manual table installation, <br />or the table definition was incorrect').".\n" |
|
367 | + . lang("Please check for sql scripts within the application's directory").'.'; |
|
368 | 368 | } |
369 | - echo '<br />' . lang('However, the application is otherwise installed') . '.'; |
|
369 | + echo '<br />'.lang('However, the application is otherwise installed').'.'; |
|
370 | 370 | } |
371 | 371 | else |
372 | 372 | { |
373 | - echo $app_title . ' ' . lang('has a version mismatch') . ' '; |
|
374 | - echo lang('because of a failed upgrade, or the database is newer than the installed version of this app') . '.'; |
|
373 | + echo $app_title.' '.lang('has a version mismatch').' '; |
|
374 | + echo lang('because of a failed upgrade, or the database is newer than the installed version of this app').'.'; |
|
375 | 375 | echo '<br />'; |
376 | - echo lang('If the application has no defined tables, selecting upgrade should remedy the problem') . '.'; |
|
377 | - echo '<br />' . lang('However, the application is otherwise installed') . '.'; |
|
376 | + echo lang('If the application has no defined tables, selecting upgrade should remedy the problem').'.'; |
|
377 | + echo '<br />'.lang('However, the application is otherwise installed').'.'; |
|
378 | 378 | } |
379 | 379 | |
380 | - echo '<br /><a href="applications.php?debug='.$DEBUG.'">' . lang('Go back') . '</a>'; |
|
381 | - $setup_tpl->pparse('out','footer'); |
|
380 | + echo '<br /><a href="applications.php?debug='.$DEBUG.'">'.lang('Go back').'</a>'; |
|
381 | + $setup_tpl->pparse('out', 'footer'); |
|
382 | 382 | exit; |
383 | 383 | } |
384 | 384 | else |
385 | 385 | { |
386 | - $setup_tpl->set_var('description',lang('Select the desired action(s) from the available choices')); |
|
387 | - $setup_tpl->set_var('action_url','applications.php'); |
|
388 | - $setup_tpl->pparse('out','header'); |
|
389 | - |
|
390 | - $setup_tpl->set_var('appdata',lang('Application Data')); |
|
391 | - $setup_tpl->set_var('actions',lang('Actions')); |
|
392 | - $setup_tpl->set_var('app_info',lang('Application Name and Status Information')); |
|
393 | - $setup_tpl->set_var('app_title',lang('Application Title')); |
|
394 | - $setup_tpl->set_var('app_currentver',lang('Current Version')); |
|
395 | - $setup_tpl->set_var('app_version',lang('Available Version')); |
|
396 | - $setup_tpl->set_var('app_install',lang('Install')); |
|
397 | - $setup_tpl->set_var('app_remove',lang('Remove')); |
|
398 | - $setup_tpl->set_var('app_upgrade',lang('Upgrade')); |
|
399 | - $setup_tpl->set_var('app_resolve',lang('Resolve')); |
|
400 | - $setup_tpl->set_var('check','check.png'); |
|
401 | - $setup_tpl->set_var('install_all',lang('Install All')); |
|
402 | - $setup_tpl->set_var('upgrade_all',lang('Upgrade All')); |
|
403 | - $setup_tpl->set_var('remove_all',lang('Remove All')); |
|
404 | - $setup_tpl->set_var('lang_debug',lang('enable for extra debug-messages')); |
|
405 | - $setup_tpl->set_var('debug','<input type="checkbox" name="debug" value="True"' .($DEBUG ? ' checked="checked"' : '') . ' />'); |
|
406 | - $setup_tpl->set_var('bg_color',$bgcolor[0]); |
|
407 | - |
|
408 | - $setup_tpl->pparse('out','app_header'); |
|
386 | + $setup_tpl->set_var('description', lang('Select the desired action(s) from the available choices')); |
|
387 | + $setup_tpl->set_var('action_url', 'applications.php'); |
|
388 | + $setup_tpl->pparse('out', 'header'); |
|
389 | + |
|
390 | + $setup_tpl->set_var('appdata', lang('Application Data')); |
|
391 | + $setup_tpl->set_var('actions', lang('Actions')); |
|
392 | + $setup_tpl->set_var('app_info', lang('Application Name and Status Information')); |
|
393 | + $setup_tpl->set_var('app_title', lang('Application Title')); |
|
394 | + $setup_tpl->set_var('app_currentver', lang('Current Version')); |
|
395 | + $setup_tpl->set_var('app_version', lang('Available Version')); |
|
396 | + $setup_tpl->set_var('app_install', lang('Install')); |
|
397 | + $setup_tpl->set_var('app_remove', lang('Remove')); |
|
398 | + $setup_tpl->set_var('app_upgrade', lang('Upgrade')); |
|
399 | + $setup_tpl->set_var('app_resolve', lang('Resolve')); |
|
400 | + $setup_tpl->set_var('check', 'check.png'); |
|
401 | + $setup_tpl->set_var('install_all', lang('Install All')); |
|
402 | + $setup_tpl->set_var('upgrade_all', lang('Upgrade All')); |
|
403 | + $setup_tpl->set_var('remove_all', lang('Remove All')); |
|
404 | + $setup_tpl->set_var('lang_debug', lang('enable for extra debug-messages')); |
|
405 | + $setup_tpl->set_var('debug', '<input type="checkbox" name="debug" value="True"'.($DEBUG ? ' checked="checked"' : '').' />'); |
|
406 | + $setup_tpl->set_var('bg_color', $bgcolor[0]); |
|
407 | + |
|
408 | + $setup_tpl->pparse('out', 'app_header'); |
|
409 | 409 | |
410 | 410 | $i = 0; |
411 | - foreach($setup_info as $key => $value) |
|
411 | + foreach ($setup_info as $key => $value) |
|
412 | 412 | { |
413 | - if(@$value['name']) |
|
413 | + if (@$value['name']) |
|
414 | 414 | { |
415 | 415 | $i = ($i ? 0 : 1); |
416 | - $setup_tpl->set_var('apptitle',$value['title']?$value['title']:lang($value['name'])); |
|
417 | - $setup_tpl->set_var('currentver',@$value['currentver']); |
|
418 | - $setup_tpl->set_var('version',$value['version']); |
|
419 | - $setup_tpl->set_var('bg_color',$bgcolor[$i]); |
|
416 | + $setup_tpl->set_var('apptitle', $value['title'] ? $value['title'] : lang($value['name'])); |
|
417 | + $setup_tpl->set_var('currentver', @$value['currentver']); |
|
418 | + $setup_tpl->set_var('version', $value['version']); |
|
419 | + $setup_tpl->set_var('bg_color', $bgcolor[$i]); |
|
420 | 420 | |
421 | - switch($value['status']) |
|
421 | + switch ($value['status']) |
|
422 | 422 | { |
423 | 423 | case 'C': |
424 | - $setup_tpl->set_var('remove',$key == 'phpgwapi' ? ' ' : '<input type="checkbox" name="remove[' . $value['name'] . ']" />'); |
|
425 | - $setup_tpl->set_var('upgrade',' '); |
|
424 | + $setup_tpl->set_var('remove', $key == 'phpgwapi' ? ' ' : '<input type="checkbox" name="remove['.$value['name'].']" />'); |
|
425 | + $setup_tpl->set_var('upgrade', ' '); |
|
426 | 426 | if (!$GLOBALS['egw_setup']->detection->check_app_tables($value['name'])) |
427 | 427 | { |
428 | 428 | // App installed and enabled, but some tables are missing |
429 | - $setup_tpl->set_var('instimg','table.png'); |
|
430 | - $setup_tpl->set_var('bg_color','FFCCAA'); |
|
431 | - $setup_tpl->set_var('instalt',lang('Not Completed')); |
|
432 | - $setup_tpl->set_var('resolution','<a href="applications.php?resolve=' . $value['name'] . '&badinstall=True">' . lang('Potential Problem') . '</a>'); |
|
433 | - $status = lang('Requires reinstall or manual repair') . ' - ' . $value['status']; |
|
429 | + $setup_tpl->set_var('instimg', 'table.png'); |
|
430 | + $setup_tpl->set_var('bg_color', 'FFCCAA'); |
|
431 | + $setup_tpl->set_var('instalt', lang('Not Completed')); |
|
432 | + $setup_tpl->set_var('resolution', '<a href="applications.php?resolve='.$value['name'].'&badinstall=True">'.lang('Potential Problem').'</a>'); |
|
433 | + $status = lang('Requires reinstall or manual repair').' - '.$value['status']; |
|
434 | 434 | } |
435 | 435 | else |
436 | 436 | { |
437 | - $setup_tpl->set_var('instimg','completed.png'); |
|
438 | - $setup_tpl->set_var('instalt',lang('Completed')); |
|
439 | - $setup_tpl->set_var('install',' '); |
|
440 | - if($value['enabled']) |
|
437 | + $setup_tpl->set_var('instimg', 'completed.png'); |
|
438 | + $setup_tpl->set_var('instalt', lang('Completed')); |
|
439 | + $setup_tpl->set_var('install', ' '); |
|
440 | + if ($value['enabled']) |
|
441 | 441 | { |
442 | - $setup_tpl->set_var('resolution',''); |
|
443 | - $status = lang('OK') . ' - ' . $value['status']; |
|
442 | + $setup_tpl->set_var('resolution', ''); |
|
443 | + $status = lang('OK').' - '.$value['status']; |
|
444 | 444 | } |
445 | 445 | else |
446 | 446 | { |
@@ -448,123 +448,123 @@ discard block |
||
448 | 448 | { |
449 | 449 | $notables = '¬ables=True'; |
450 | 450 | } |
451 | - $setup_tpl->set_var('bg_color','CCCCFF'); |
|
451 | + $setup_tpl->set_var('bg_color', 'CCCCFF'); |
|
452 | 452 | $setup_tpl->set_var('resolution', |
453 | - '<a href="applications.php?resolve=' . $value['name'] . $notables . '">' . lang('Possible Reasons') . '</a>' |
|
453 | + '<a href="applications.php?resolve='.$value['name'].$notables.'">'.lang('Possible Reasons').'</a>' |
|
454 | 454 | ); |
455 | - $status = lang('Disabled') . ' - ' . $value['status']; |
|
455 | + $status = lang('Disabled').' - '.$value['status']; |
|
456 | 456 | } |
457 | 457 | } |
458 | 458 | break; |
459 | 459 | case 'U': |
460 | - $setup_tpl->set_var('instimg','incomplete.png'); |
|
461 | - $setup_tpl->set_var('instalt',lang('Not Completed')); |
|
460 | + $setup_tpl->set_var('instimg', 'incomplete.png'); |
|
461 | + $setup_tpl->set_var('instalt', lang('Not Completed')); |
|
462 | 462 | if (!@$value['currentver']) |
463 | 463 | { |
464 | - if ($value['tables'] && $GLOBALS['egw_setup']->detection->check_app_tables($value['name'],True)) |
|
464 | + if ($value['tables'] && $GLOBALS['egw_setup']->detection->check_app_tables($value['name'], True)) |
|
465 | 465 | { |
466 | 466 | // Some tables missing |
467 | - $setup_tpl->set_var('remove',$key == 'phpgwapi' ? ' ' : '<input type="checkbox" name="remove[' . $value['name'] . ']" />'); |
|
468 | - $setup_tpl->set_var('resolution','<a href="applications.php?resolve=' . $value['name'] . '&badinstall=True">' . lang('Potential Problem') . '</a>'); |
|
469 | - $status = lang('Requires reinstall or manual repair') . ' - ' . $value['status']; |
|
467 | + $setup_tpl->set_var('remove', $key == 'phpgwapi' ? ' ' : '<input type="checkbox" name="remove['.$value['name'].']" />'); |
|
468 | + $setup_tpl->set_var('resolution', '<a href="applications.php?resolve='.$value['name'].'&badinstall=True">'.lang('Potential Problem').'</a>'); |
|
469 | + $status = lang('Requires reinstall or manual repair').' - '.$value['status']; |
|
470 | 470 | } |
471 | 471 | else |
472 | 472 | { |
473 | - $setup_tpl->set_var('remove',' '); |
|
474 | - $setup_tpl->set_var('resolution',''); |
|
475 | - $status = lang('Requires upgrade') . ' - ' . $value['status']; |
|
473 | + $setup_tpl->set_var('remove', ' '); |
|
474 | + $setup_tpl->set_var('resolution', ''); |
|
475 | + $status = lang('Requires upgrade').' - '.$value['status']; |
|
476 | 476 | } |
477 | 477 | // show not installed apps without icon |
478 | - $setup_tpl->set_var('instimg','spacer.png'); |
|
479 | - $setup_tpl->set_var('instalt',''); |
|
480 | - $setup_tpl->set_var('bg_color','CCFFCC'); |
|
481 | - $setup_tpl->set_var('install','<input type="checkbox" name="install[' . $value['name'] . ']" />'); |
|
482 | - $setup_tpl->set_var('upgrade',' '); |
|
483 | - $status = lang('Please install') . ' - ' . $value['status']; |
|
478 | + $setup_tpl->set_var('instimg', 'spacer.png'); |
|
479 | + $setup_tpl->set_var('instalt', ''); |
|
480 | + $setup_tpl->set_var('bg_color', 'CCFFCC'); |
|
481 | + $setup_tpl->set_var('install', '<input type="checkbox" name="install['.$value['name'].']" />'); |
|
482 | + $setup_tpl->set_var('upgrade', ' '); |
|
483 | + $status = lang('Please install').' - '.$value['status']; |
|
484 | 484 | } |
485 | 485 | else |
486 | 486 | { |
487 | - $setup_tpl->set_var('bg_color','CCCCFF'); |
|
488 | - $setup_tpl->set_var('install',' '); |
|
487 | + $setup_tpl->set_var('bg_color', 'CCCCFF'); |
|
488 | + $setup_tpl->set_var('install', ' '); |
|
489 | 489 | // TODO display some info about breakage if you mess with this app |
490 | - $setup_tpl->set_var('upgrade','<input type="checkbox" name="upgrade[' . $value['name'] . ']" />'); |
|
491 | - $setup_tpl->set_var('remove',$key == 'phpgwapi' ? ' ' : '<input type="checkbox" name="remove[' . $value['name'] . ']" />'); |
|
492 | - $setup_tpl->set_var('resolution',''); |
|
493 | - $status = lang('Requires upgrade') . ' - ' . $value['status']; |
|
490 | + $setup_tpl->set_var('upgrade', '<input type="checkbox" name="upgrade['.$value['name'].']" />'); |
|
491 | + $setup_tpl->set_var('remove', $key == 'phpgwapi' ? ' ' : '<input type="checkbox" name="remove['.$value['name'].']" />'); |
|
492 | + $setup_tpl->set_var('resolution', ''); |
|
493 | + $status = lang('Requires upgrade').' - '.$value['status']; |
|
494 | 494 | } |
495 | 495 | break; |
496 | 496 | case 'V': |
497 | - $setup_tpl->set_var('instimg','incomplete.png'); |
|
498 | - $setup_tpl->set_var('instalt',lang('Not Completed')); |
|
499 | - $setup_tpl->set_var('install',' '); |
|
500 | - $setup_tpl->set_var('remove',$key == 'phpgwapi' ? ' ' : '<input type="checkbox" name="remove[' . $value['name'] . ']" />'); |
|
497 | + $setup_tpl->set_var('instimg', 'incomplete.png'); |
|
498 | + $setup_tpl->set_var('instalt', lang('Not Completed')); |
|
499 | + $setup_tpl->set_var('install', ' '); |
|
500 | + $setup_tpl->set_var('remove', $key == 'phpgwapi' ? ' ' : '<input type="checkbox" name="remove['.$value['name'].']" />'); |
|
501 | 501 | if ($value['version'] == 'deleted') |
502 | 502 | { |
503 | - $setup_tpl->set_var('bg_color','CCAAAA'); |
|
504 | - $setup_tpl->set_var('upgrade',' '); |
|
505 | - $setup_tpl->set_var('resolution','<a href="applications.php?resolve=' . $value['name'] . '&deleted=True">' . lang('Possible Solutions') . '</a>'); |
|
506 | - $status = lang('Sources deleted/missing') . ' - ' . $value['status']; |
|
503 | + $setup_tpl->set_var('bg_color', 'CCAAAA'); |
|
504 | + $setup_tpl->set_var('upgrade', ' '); |
|
505 | + $setup_tpl->set_var('resolution', '<a href="applications.php?resolve='.$value['name'].'&deleted=True">'.lang('Possible Solutions').'</a>'); |
|
506 | + $status = lang('Sources deleted/missing').' - '.$value['status']; |
|
507 | 507 | } |
508 | 508 | else |
509 | 509 | { |
510 | - $setup_tpl->set_var('upgrade','<input type="checkbox" name="upgrade[' . $value['name'] . ']" />'); |
|
511 | - $setup_tpl->set_var('resolution','<a href="applications.php?resolve=' . $value['name'] . '&version=True">' . lang('Possible Solutions') . '</a>'); |
|
512 | - $status = lang('Version Mismatch') . ' - ' . $value['status']; |
|
510 | + $setup_tpl->set_var('upgrade', '<input type="checkbox" name="upgrade['.$value['name'].']" />'); |
|
511 | + $setup_tpl->set_var('resolution', '<a href="applications.php?resolve='.$value['name'].'&version=True">'.lang('Possible Solutions').'</a>'); |
|
512 | + $status = lang('Version Mismatch').' - '.$value['status']; |
|
513 | 513 | } |
514 | 514 | break; |
515 | 515 | case 'D': |
516 | - $setup_tpl->set_var('bg_color','FFCCCC'); |
|
516 | + $setup_tpl->set_var('bg_color', 'FFCCCC'); |
|
517 | 517 | $depstring = parsedep($value['depends']); |
518 | 518 | $depstring .= ')'; |
519 | - $setup_tpl->set_var('instimg','dep.png'); |
|
520 | - $setup_tpl->set_var('instalt',lang('Dependency Failure')); |
|
521 | - $setup_tpl->set_var('install',' '); |
|
519 | + $setup_tpl->set_var('instimg', 'dep.png'); |
|
520 | + $setup_tpl->set_var('instalt', lang('Dependency Failure')); |
|
521 | + $setup_tpl->set_var('install', ' '); |
|
522 | 522 | if ($values['currentver']) |
523 | 523 | { |
524 | - $setup_tpl->set_var('remove',$key == 'phpgwapi' ? ' ' : '<input type="checkbox" name="remove[' . $value['name'] . ']" />'); |
|
525 | - $setup_tpl->set_var('resolution','<a href="applications.php?resolve=' . $value['name'] . '">' . lang('Possible Solutions') . '</a>'); |
|
524 | + $setup_tpl->set_var('remove', $key == 'phpgwapi' ? ' ' : '<input type="checkbox" name="remove['.$value['name'].']" />'); |
|
525 | + $setup_tpl->set_var('resolution', '<a href="applications.php?resolve='.$value['name'].'">'.lang('Possible Solutions').'</a>'); |
|
526 | 526 | } |
527 | 527 | else |
528 | 528 | { |
529 | - $setup_tpl->set_var('remove',' '); |
|
530 | - $setup_tpl->set_var('resolution',' '); |
|
529 | + $setup_tpl->set_var('remove', ' '); |
|
530 | + $setup_tpl->set_var('resolution', ' '); |
|
531 | 531 | } |
532 | - $setup_tpl->set_var('upgrade',' '); |
|
533 | - $status = lang('Dependency Failure') . ':' . $depstring . $value['status']; |
|
532 | + $setup_tpl->set_var('upgrade', ' '); |
|
533 | + $status = lang('Dependency Failure').':'.$depstring.$value['status']; |
|
534 | 534 | break; |
535 | 535 | case 'P': |
536 | - $setup_tpl->set_var('bg_color','FFCCFF'); |
|
536 | + $setup_tpl->set_var('bg_color', 'FFCCFF'); |
|
537 | 537 | $depstring = parsedep($value['depends']); |
538 | 538 | $depstring .= ')'; |
539 | - $setup_tpl->set_var('instimg','dep.png'); |
|
540 | - $setup_tpl->set_var('instalt',lang('Post-install Dependency Failure')); |
|
541 | - $setup_tpl->set_var('install',' '); |
|
542 | - $setup_tpl->set_var('remove',' '); |
|
543 | - $setup_tpl->set_var('upgrade',' '); |
|
544 | - $setup_tpl->set_var('resolution','<a href="applications.php?resolve=' . $value['name'] . '&post=True">' . lang('Possible Solutions') . '</a>'); |
|
545 | - $status = lang('Post-install Dependency Failure') . ':' . $depstring . $value['status']; |
|
539 | + $setup_tpl->set_var('instimg', 'dep.png'); |
|
540 | + $setup_tpl->set_var('instalt', lang('Post-install Dependency Failure')); |
|
541 | + $setup_tpl->set_var('install', ' '); |
|
542 | + $setup_tpl->set_var('remove', ' '); |
|
543 | + $setup_tpl->set_var('upgrade', ' '); |
|
544 | + $setup_tpl->set_var('resolution', '<a href="applications.php?resolve='.$value['name'].'&post=True">'.lang('Possible Solutions').'</a>'); |
|
545 | + $status = lang('Post-install Dependency Failure').':'.$depstring.$value['status']; |
|
546 | 546 | break; |
547 | 547 | default: |
548 | - $setup_tpl->set_var('instimg','incomplete.png'); |
|
549 | - $setup_tpl->set_var('instalt',lang('Not Completed')); |
|
550 | - $setup_tpl->set_var('install',' '); |
|
551 | - $setup_tpl->set_var('remove',' '); |
|
552 | - $setup_tpl->set_var('upgrade',' '); |
|
553 | - $setup_tpl->set_var('resolution',''); |
|
548 | + $setup_tpl->set_var('instimg', 'incomplete.png'); |
|
549 | + $setup_tpl->set_var('instalt', lang('Not Completed')); |
|
550 | + $setup_tpl->set_var('install', ' '); |
|
551 | + $setup_tpl->set_var('remove', ' '); |
|
552 | + $setup_tpl->set_var('upgrade', ' '); |
|
553 | + $setup_tpl->set_var('resolution', ''); |
|
554 | 554 | $status = ''; |
555 | 555 | break; |
556 | 556 | } |
557 | 557 | //$setup_tpl->set_var('appname',$value['name'] . '-' . $status . ',' . $value['filename']); |
558 | - $setup_tpl->set_var('appinfo',$value['name'] . '-' . $status); |
|
559 | - $setup_tpl->set_var('appname',$value['name']); |
|
558 | + $setup_tpl->set_var('appinfo', $value['name'].'-'.$status); |
|
559 | + $setup_tpl->set_var('appname', $value['name']); |
|
560 | 560 | |
561 | - $setup_tpl->pparse('out','apps',True); |
|
561 | + $setup_tpl->pparse('out', 'apps', True); |
|
562 | 562 | } |
563 | 563 | } |
564 | 564 | |
565 | - $setup_tpl->set_var('submit',lang('Save')); |
|
566 | - $setup_tpl->set_var('cancel',lang('Cancel')); |
|
567 | - $setup_tpl->pparse('out','app_footer'); |
|
568 | - $setup_tpl->pparse('out','footer'); |
|
565 | + $setup_tpl->set_var('submit', lang('Save')); |
|
566 | + $setup_tpl->set_var('cancel', lang('Cancel')); |
|
567 | + $setup_tpl->pparse('out', 'app_footer'); |
|
568 | + $setup_tpl->pparse('out', 'footer'); |
|
569 | 569 | $GLOBALS['egw_setup']->html->show_footer(); |
570 | 570 | } |
@@ -236,7 +236,10 @@ discard block |
||
236 | 236 | // Find & register all application hooks |
237 | 237 | foreach($setup_info as $appname => $info) |
238 | 238 | { |
239 | - if ($info['currentver']) $GLOBALS['egw_setup']->register_hooks($appname); |
|
239 | + if ($info['currentver']) |
|
240 | + { |
|
241 | + $GLOBALS['egw_setup']->register_hooks($appname); |
|
242 | + } |
|
240 | 243 | } |
241 | 244 | echo lang('All hooks registered') . '<br />'; |
242 | 245 | } |
@@ -267,9 +270,15 @@ discard block |
||
267 | 270 | $val = implode(',' . "\n",$val); |
268 | 271 | } |
269 | 272 | } |
270 | - if ($key == 'hooks') { $val = implode(',',$val); } |
|
271 | - if ($key == 'depends') { $val = parsedep($val); } |
|
272 | - if (is_array($val)) { $val = implode(',',$val); } |
|
273 | + if ($key == 'hooks') |
|
274 | + { |
|
275 | +$val = implode(',',$val); } |
|
276 | + if ($key == 'depends') |
|
277 | + { |
|
278 | +$val = parsedep($val); } |
|
279 | + if (is_array($val)) |
|
280 | + { |
|
281 | +$val = implode(',',$val); } |
|
273 | 282 | |
274 | 283 | $setup_tpl->set_var('bg_color',$bgcolor[$i]); |
275 | 284 | $setup_tpl->set_var('name',$key); |
@@ -106,22 +106,22 @@ discard block |
||
106 | 106 | //var_dump($setup_info);exit; |
107 | 107 | @ksort($setup_info); |
108 | 108 | |
109 | -if(@get_var('cancel',Array('POST'))) |
|
109 | +if(@get_var('cancel',array('POST'))) |
|
110 | 110 | { |
111 | 111 | Header("Location: index.php"); |
112 | 112 | exit; |
113 | 113 | } |
114 | 114 | |
115 | -if(@get_var('submit',Array('POST'))) |
|
115 | +if(@get_var('submit',array('POST'))) |
|
116 | 116 | { |
117 | 117 | $GLOBALS['egw_setup']->html->show_header(lang('Application Management'),False,'config',$GLOBALS['egw_setup']->ConfigDomain . '(' . $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'] . ')'); |
118 | 118 | $setup_tpl->set_var('description',lang('App install/remove/upgrade') . ':'); |
119 | 119 | $setup_tpl->pparse('out','header'); |
120 | 120 | |
121 | - $appname = get_var('appname',Array('POST')); |
|
122 | - $remove = get_var('remove',Array('POST')); |
|
123 | - $install = get_var('install',Array('POST')); |
|
124 | - $upgrade = get_var('upgrade',Array('POST')); |
|
121 | + $appname = get_var('appname',array('POST')); |
|
122 | + $remove = get_var('remove',array('POST')); |
|
123 | + $install = get_var('install',array('POST')); |
|
124 | + $upgrade = get_var('upgrade',array('POST')); |
|
125 | 125 | |
126 | 126 | if(!empty($remove) && is_array($remove)) |
127 | 127 | { |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | $GLOBALS['egw_setup']->html->show_header(lang('Application Management'),False,'config',$GLOBALS['egw_setup']->ConfigDomain . '(' . $GLOBALS['egw_domain'][$GLOBALS['egw_setup']->ConfigDomain]['db_type'] . ')'); |
230 | 230 | } |
231 | 231 | |
232 | -if(@get_var('hooks', Array('GET'))) |
|
232 | +if(@get_var('hooks', array('GET'))) |
|
233 | 233 | { |
234 | 234 | egw_cache::flush(egw_cache::INSTANCE); |
235 | 235 | |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | } |
241 | 241 | echo lang('All hooks registered') . '<br />'; |
242 | 242 | } |
243 | -$detail = get_var('detail',Array('GET')); |
|
244 | -$resolve = get_var('resolve',Array('GET')); |
|
243 | +$detail = get_var('detail',array('GET')); |
|
244 | +$resolve = get_var('resolve',array('GET')); |
|
245 | 245 | if(@$detail) |
246 | 246 | { |
247 | 247 | @ksort($setup_info[$detail]); |
@@ -284,13 +284,13 @@ discard block |
||
284 | 284 | } |
285 | 285 | elseif (@$resolve) |
286 | 286 | { |
287 | - $version = get_var('version',Array('GET')); |
|
288 | - $notables = get_var('notables',Array('GET')); |
|
287 | + $version = get_var('version',array('GET')); |
|
288 | + $notables = get_var('notables',array('GET')); |
|
289 | 289 | $setup_tpl->set_var('description',lang('Problem resolution'). ':'); |
290 | 290 | $setup_tpl->pparse('out','header'); |
291 | 291 | $app_title = $setup_info[$resolve]['title'] ? $setup_info[$resolve]['title'] : $setup_info[$resolve]['name']; |
292 | 292 | |
293 | - if(get_var('post',Array('GET'))) |
|
293 | + if(get_var('post',array('GET'))) |
|
294 | 294 | { |
295 | 295 | echo '"' . $app_title . '" ' . lang('may be broken') . ' '; |
296 | 296 | echo lang('because an application it depends upon was upgraded'); |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | echo '<br />'; |
300 | 300 | echo lang('However, the application may still work') . '.'; |
301 | 301 | } |
302 | - elseif(get_var('badinstall',Array('GET'))) |
|
302 | + elseif(get_var('badinstall',array('GET'))) |
|
303 | 303 | { |
304 | 304 | echo '"' . $app_title . '" ' . lang('is broken') . ' '; |
305 | 305 | echo lang('because of a failed upgrade or install') . '.'; |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | echo '<br />'; |
309 | 309 | echo lang('You should either uninstall and then reinstall it, or attempt manual repairs') . '.'; |
310 | 310 | } |
311 | - elseif(get_var('deleted',Array('GET'))) |
|
311 | + elseif(get_var('deleted',array('GET'))) |
|
312 | 312 | { |
313 | 313 | echo '"' . $app_title . '" ' . lang('is broken') . ' '; |
314 | 314 | echo lang('because its sources are missing') . '!'; |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @version $Id$ |
12 | 12 | */ |
13 | 13 | |
14 | -chdir(dirname(__FILE__)); // to enable our relative pathes to work |
|
14 | +chdir(dirname(__FILE__)); // to enable our relative pathes to work |
|
15 | 15 | |
16 | 16 | if (php_sapi_name() !== 'cli') // security precaution: forbit calling as web-page |
17 | 17 | { |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | } |
40 | 40 | $ids = explode(',', $_SERVER['argv'][0]); |
41 | 41 | $change = array(); |
42 | -while($ids) |
|
42 | +while ($ids) |
|
43 | 43 | { |
44 | 44 | $from = (int)array_shift($ids); |
45 | 45 | $to = (int)array_shift($ids); |
@@ -66,24 +66,24 @@ discard block |
||
66 | 66 | |
67 | 67 | chown_grp($path, null, $recursive); |
68 | 68 | |
69 | -function chown_grp($path, array $stat=null, $recursive=false) |
|
69 | +function chown_grp($path, array $stat = null, $recursive = false) |
|
70 | 70 | { |
71 | 71 | global $change; |
72 | 72 | |
73 | 73 | if (is_null($stat) && !($stat = stat($path))) return false; |
74 | 74 | |
75 | - if (isset($change[$stat['uid']]) && !chown($path, $uid=$change[$stat['uid']])) |
|
75 | + if (isset($change[$stat['uid']]) && !chown($path, $uid = $change[$stat['uid']])) |
|
76 | 76 | { |
77 | 77 | echo "Faild to set new owner #$uid for $path\n"; |
78 | 78 | } |
79 | - if (isset($change[-$stat['gid']]) && !chgrp($path, $gid=-$change[-$stat['gid']])) |
|
79 | + if (isset($change[-$stat['gid']]) && !chgrp($path, $gid = -$change[-$stat['gid']])) |
|
80 | 80 | { |
81 | 81 | echo "Faild to set new group #$gid for $path\n"; |
82 | 82 | } |
83 | 83 | |
84 | 84 | if ($recursive && is_dir($path)) |
85 | 85 | { |
86 | - foreach(new DirectoryIterator($path) as $child) |
|
86 | + foreach (new DirectoryIterator($path) as $child) |
|
87 | 87 | { |
88 | 88 | if (!$child->isDot()) |
89 | 89 | chown_grp($child->getPathname(), array( |
@@ -13,10 +13,13 @@ discard block |
||
13 | 13 | |
14 | 14 | chdir(dirname(__FILE__)); // to enable our relative pathes to work |
15 | 15 | |
16 | -if (php_sapi_name() !== 'cli') // security precaution: forbit calling as web-page |
|
16 | +if (php_sapi_name() !== 'cli') |
|
17 | +{ |
|
18 | + // security precaution: forbit calling as web-page |
|
17 | 19 | { |
18 | 20 | die('<h1>setup/doc/chown.php must NOT be called as web-page --> exiting !!!</h1>'); |
19 | 21 | } |
22 | +} |
|
20 | 23 | |
21 | 24 | $recursive = false; |
22 | 25 | |
@@ -70,7 +73,10 @@ discard block |
||
70 | 73 | { |
71 | 74 | global $change; |
72 | 75 | |
73 | - if (is_null($stat) && !($stat = stat($path))) return false; |
|
76 | + if (is_null($stat) && !($stat = stat($path))) |
|
77 | + { |
|
78 | + return false; |
|
79 | + } |
|
74 | 80 | |
75 | 81 | if (isset($change[$stat['uid']]) && !chown($path, $uid=$change[$stat['uid']])) |
76 | 82 | { |
@@ -86,10 +92,12 @@ discard block |
||
86 | 92 | foreach(new DirectoryIterator($path) as $child) |
87 | 93 | { |
88 | 94 | if (!$child->isDot()) |
89 | - chown_grp($child->getPathname(), array( |
|
95 | + { |
|
96 | + chown_grp($child->getPathname(), array( |
|
90 | 97 | 'uid' => $child->getOwner(), |
91 | 98 | 'gid' => $child->getGroup(), |
92 | 99 | ), $recursive); |
100 | + } |
|
93 | 101 | } |
94 | 102 | } |
95 | 103 | } |