[VD:LocalFileSystem] add volume option statOwner

`statOwner`
:Include file owner name or id into stat results. This option only uses
the LocalFileSystem volume driver.
:Data type -  bool
:Default value - false
This commit is contained in:
nao-pon
2015-06-18 17:55:49 +09:00
parent 5579b7210e
commit 785542d076
@@ -305,6 +305,13 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
* @author Dmitry (dio) Levashov
**/
protected function _stat($path) {
static $names = array();
static $statOwner = null;
if (is_null($statOwner)) {
$statOwner = (!empty($this->options['statOwner']));
}
$stat = array();
if (!file_exists($path)) {
@@ -320,6 +327,7 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
return $stat;
}
$uid = 0;
if ($path != $this->root && is_link($path)) {
if (($target = $this->readlink($path)) == false
|| $target == $path) {
@@ -335,8 +343,21 @@ class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
$lstat = lstat($path);
$size = sprintf('%u', $lstat['size']);
} else {
if ($statOwner) {
$fstat = stat($path);
$uid = $fstat['uid'];
}
$size = sprintf('%u', @filesize($path));
}
if ($statOwner && $uid) {
if (isset($names[$uid])) {
$stat['owner'] = $names[$uid];
} else if (is_callable('posix_getpwuid')) {
$stat['owner'] = $names[$uid] = posix_getpwuid($uid)['name'];
} else {
$stat['owner'] = $names[$uid] = $uid;
}
}
$dir = is_dir($path);