function PROPFIND(&$options, &$files, $arParams = array())
{
global $by, $order, $USER;
$io = self::GetIo();
if (!function_exists("__sort_array_folder_and_file"))
{
function __sort_array_folder_and_file($res1, $res2)
{
global $by, $order;
InitSorting();
if (empty($by))
{
$by = "NAME"; $order = "ASC";
}
$by = mb_strtoupper($by);
$order = mb_strtoupper($order);
if ($res1["~TYPE"] == "FOLDER" && $res2["~TYPE"] == "FILE")
return -1;
elseif ($res1["~TYPE"] == "FILE" && $res2["~TYPE"] == "FOLDER")
return 1;
else
{
$by = (is_set($res1, $by) ? $by : "NAME");
$ord = $order;
if ($by == "TIMESTAMP_X")
$ord = ($order == "ASC" ? "DESC" : "ASC");
if ($ord == "ASC")
return ($res1[$by] < $res2[$by] ? -1 : 1);
else
return ($res1[$by] < $res2[$by] ? 1 : -1);
}
}
}
$this->IsDir($options);
$files['files'] = array();
$arResult = array("NAV_RESULT" => false, "RESULT" => array());
if (empty($options["FILTER"]))
{
if ($this->arParams["not_found"] === true)
{
return false;
}
elseif($this->arParams["is_dir"] != true)
{
//$files["files"]["E".$res["ID"]] = $this->_get_fileinfo($this->arParams["item_id"]);
$files["files"]["E"] = $this->_get_fileinfo($this->arParams["item_id"]);
}
else
{
$files["files"]["section"] = $this->_get_fileinfo($this->arParams["item_id"]);
if (
!empty($this->arParams["item_id"])
&& $this->arParams["item_id"] != "/"
)
$arResult["SECTION"] = array("ID" => $this->arParams["item_id"], "NAME" => $this->arParams["item_id"]);
//$path = $this->_slashify($io->CombinePath($this->real_path_full, $this->arParams["item_id"]));
$path = CWebDavBase::CleanRelativePathString($this->arParams["item_id"], $this->real_path_full);
if($path === false)
{
return false;
}
$path = $this->_slashify($path);
if (!empty($options["depth"]))
{
$dir = $io->GetDirectory($path);
if ($dir->IsExists())
{
$this->arParams["item_id"] = $this->_slashify(str_replace("//", "/", $this->arParams["item_id"]));
$tzOffset = CTimeZone::GetOffset();
$arChildren = $dir->GetChildren();
foreach($arChildren as $node)
{
$filename = $node->GetName();
$filePath = $io->CombinePath($this->arParams["item_id"], $filename);
$res = array(
"~TYPE" => "FOLDER",
"TYPE" => "S",
"ID" => $filePath,
"NAME" => $filename,
"TIMESTAMP_X" => $node->GetModificationTime() + $tzOffset,
"PERMISSION" => $this->permission,
"PATH" => $filePath,
"REAL_PATH" => $path.$filename,
"FILE_SIZE" => 0
);
if ($this->MetaNames($res))
{
if (! $node->IsDirectory())
{
$ext = mb_strtolower(strrchr($filename, '.'));
if (in_array($ext, $this->arFileForbiddenExtentions["READ"]))
continue;
$res["~TYPE"] = "FILE";
$res["TYPE"] = "E";
$res["LOCK_STATUS"] = "green";
$res["EXTENTION"] = $ext;
$res["FILE_SIZE"] = $node->GetFileSize();
$res["FILE_ARRAY"] = array(
"TIMESTAMP_X" => $res["TIMESTAMP_X"],
"MODULE_ID" => "webdav",
"HEIGHT" => 0,
"WIDTH" => 0,
"FILE_SIZE" => $res["FILE_SIZE"],
"CONTENT_TYPE" => ($node->IsReadable() ? $this->_mimetype($path.$filename) : 'application/x-non-readable'),
"SUBDIR" => $io->CombinePath("/", $this->real_path, $this->arParams["item_id"]),
"FILE_NAME" => $filename,
"ORIGINAL_NAME" => $filename,
"DESCRIPTION" => ""
);
}
$res["PROPS"] = $this->_get_props($filePath);
$res["LOCK_STATUS"] = 'green';
if (is_array($res['PROPS']['LOCK']))
{
$userLogin = $GLOBALS['USER']->GetLogin();
$now = time();
foreach($res['PROPS']['LOCK'] as $arLock)
{
if (
$arLock['exclusivelock'] == 1
&& $arLock['expires'] >= $now
&& $arLock['created'] <= $now
)
{
$res['LOCK_STATUS'] = (($userLogin == $arLock['owner']) ? 'yellow' : 'red');
$rsUser = CUser::GetByLogin($arLock['owner']);
$arUser = $rsUser->GetNext();
$res['LOCKED_USER_NAME'] = '('.$arUser['LOGIN'].')';
if ($arUser['NAME'] <> '' && $arUser['LAST_NAME'] <> '')
$res['LOCKED_USER_NAME'] .= ' '.$arUser['NAME'].' '.$arUser['LAST_NAME'];
break;
}
}
}
$res['SHOW'] = $this->_getShowParams($res);
$arResult["RESULT"][($res["TYPE"] == "FOLDER" ? "S" : "E").$filename] = $res;
$files['files'][] = $this->_get_fileinfo($this->arParams["item_id"].$filename);
}
}
}
}
}
}
else // search
{
$arSearchResults = array();
if (
IsModuleInstalled('search')
&& CModule::IncludeModule('search')
)
{
$arSearchParams = array(
"MODULE_ID" => "main",
"URL" => $this->base_url.'%'
);
if (
isset($options["FILTER"]["content"])
&& $options["FILTER"]["content"] <> ''
)
{
$arSearchParams += array(
"QUERY" => $options["FILTER"]["content"]
);
}
$obSearch = new CSearch;
$obSearch->Search($arSearchParams);
if ($obSearch->errorno != 0)
{
$arResult["ERROR_MESSAGE"] = $obSearch->error;
}
else
{
while($arSearchResultItem = $obSearch->GetNext())
{
$arSearchResults[] = $arSearchResultItem['ITEM_ID'];
}
}
$tzOffset = CTimeZone::GetOffset();
foreach ($arSearchResults as $sSearchItem)
{
$dataInSearchItem = explode("|", $sSearchItem);
$file = array_pop($dataInSearchItem);
$filename = GetFileName($file);
$sFullFileName = $io->CombinePath($_SERVER['DOCUMENT_ROOT'], $file);
if (mb_strpos($sFullFileName, $this->real_path_full) === 0)
{
$filePath = CWebDavBase::ConvertPathToRelative($sFullFileName, $this->real_path_full);
}
$filePath = CWebDavBase::CleanRelativePathString($filePath, $this->real_path_full);
if($filePath === false)
{
return false;
}
/*$sFullFileName = $io->CombinePath($_SERVER['DOCUMENT_ROOT'], $file);
$filename = array_pop(explode("/", $file));
$path = implode("/", array_slice(explode("/", $sFullFileName), 0 , -1)) . "/";
$filePath = $io->CombinePath($path, $filename);*/
$oFile = $io->GetFile($filePath);
$res = array(
"ID" => $file,
"NAME" => $filename,
"TIMESTAMP_X" => $oFile->GetModificationTime() + $tzOffset,
"PERMISSION" => $this->permission,
"PATH" => mb_substr($file, mb_strlen($this->real_path)),
"REAL_PATH" => $filePath,
"FILE_SIZE" => 0
);
$res['SHOW'] = $this->_getShowParams($res);
if ($this->MetaNames($res))
{
$res["PROPS"] = $this->_get_props(mb_substr($file, mb_strlen($this->real_path)));
if (!isset($res["PROPS"]["UNDELETEBX:"]))
{
if ($oFile->IsExists())
{
$ext = mb_strtolower(strrchr($filename, '.'));
if (in_array($ext, $this->arFileForbiddenExtentions["READ"]))
continue;
$fileSize = $oFile->GetFileSize();
$res["~TYPE"] = "FILE";
$res["TYPE"] = "E";
$res["LOCK_STATUS"] = "green";
$res["EXTENTION"] = $ext;
$res["FILE_SIZE"] = $fileSize;
$res["FILE_ARRAY"] = array(
"TIMESTAMP_X" => $res["TIMESTAMP_X"],
"MODULE_ID" => "webdav",
"HEIGHT" => 0,
"WIDTH" => 0,
"FILE_SIZE" => $fileSize,
"CONTENT_TYPE" => ($oFile->IsReadable() ? $this->_mimetype($filePath) : 'application/x-non-readable'),
"SUBDIR" => implode("/", array_slice(explode("/", $file), 0 , -1)),
"FILE_NAME" => $filename,
"ORIGINAL_NAME" => $filename,
"DESCRIPTION" => "");
}
$arResult["RESULT"][($res["TYPE"] == "FOLDER" ? "S" : "E").$filename] = $res;
}
}
}
}
}
if ($arParams["return"] == "nav_result" || $arParams["return"] == "array")
{
uasort($arResult["RESULT"], "__sort_array_folder_and_file");
$arResult["NAV_RESULT"] = new CDBResult();
$arResult["NAV_RESULT"]->InitFromArray($arResult["RESULT"]);
$arResult["NAV_RESULT"] = new CDBResultWebDAVFiles($arResult["NAV_RESULT"]);
return $arResult;
}
return true;
}