public static function GetFileList($DOCUMENT_ID) { $err_mess = (CAllWorkflow::err_mess())."<br>Function: GetFileList<br>Line: "; global $DB; $DOCUMENT_ID = intval($DOCUMENT_ID); $strSql = " SELECT F.*, D.SITE_ID, ".$DB->DateToCharFunction("F.TIMESTAMP_X")." TIMESTAMP_X, concat('(',U.LOGIN,') ',ifnull(U.NAME,''),' ',ifnull(U.LAST_NAME,'')) USER_NAME FROM b_workflow_document D INNER JOIN b_workflow_file F ON (F.DOCUMENT_ID = D.ID) LEFT JOIN b_user U ON (U.ID = F.MODIFIED_BY) WHERE D.ID = ".$DOCUMENT_ID." ORDER BY F.TIMESTAMP_X desc "; $z = $DB->Query($strSql, false, $err_mess.__LINE__); return $z; }
function GetFileList($DOCUMENT_ID) { $err_mess = CAllWorkflow::err_mess() . "<br>Function: GetFileList<br>Line: "; global $DB; $DOCUMENT_ID = intval($DOCUMENT_ID); $strSql = "\n\t\t\tSELECT\n\t\t\t\tF.*, D.SITE_ID,\n\t\t\t\t" . $DB->DateToCharFunction("F.TIMESTAMP_X") . " TIMESTAMP_X,\n\t\t\t\tconcat('(',U.LOGIN,') ',ifnull(U.NAME,''),' ',ifnull(U.LAST_NAME,'')) USER_NAME\n\t\t\tFROM\n\t\t\t\tb_workflow_document D\n\t\t\t\tINNER JOIN b_workflow_file F ON (F.DOCUMENT_ID = D.ID)\n\t\t\t\tLEFT JOIN b_user U ON (U.ID = F.MODIFIED_BY)\n\t\t\tWHERE\n\t\t\t\tD.ID = " . $DOCUMENT_ID . "\n\t\t\tORDER BY\n\t\t\t\tF.TIMESTAMP_X desc\n\t\t"; $z = $DB->Query($strSql, false, $err_mess . __LINE__); return $z; }
public static function GetFileContent($did, $fname, $wf_path = "", $site = false) { $err_mess = CAllWorkflow::err_mess() . "<br>Function: GetFileContent<br>Line: "; global $DB, $APPLICATION, $USER; $did = intval($did); // check if executable if ($USER->IsAdmin() || CBXVirtualIoFileSystem::ValidatePathString($fname) && !HasScriptExtension($fname)) { if ($did > 0) { // check if it is associated wtih document $z = CWorkflow::GetFileByID($did, $fname); // found one if ($zr = $z->Fetch()) { // get it's contents $path = CWorkflow::GetTempDir() . $zr["TEMP_FILENAME"]; if (file_exists($path)) { return $APPLICATION->GetFileContent($path); } } else { // lookup in database $strSql = "SELECT FILENAME, SITE_ID FROM b_workflow_document WHERE ID='{$did}'"; $y = $DB->Query($strSql, false, $err_mess . __LINE__); // found if ($yr = $y->Fetch()) { // get it's directory $path = GetDirPath($yr["FILENAME"]); // absolute path $pathto = Rel2Abs($path, $fname); $DOC_ROOT = CSite::GetSiteDocRoot($yr["SITE_ID"]); $path = $DOC_ROOT . $pathto; // give it another try $u = CWorkflow::GetFileByID($did, $pathto); // found if ($ur = $u->Fetch()) { // get it's contents $path = CWorkflow::GetTempDir() . $ur["TEMP_FILENAME"]; if (file_exists($path)) { return $APPLICATION->GetFileContent($path); } } elseif (file_exists($path)) { // get it's contents if ($USER->CanDoFileOperation('fm_view_file', array($yr["SITE_ID"], $pathto))) { return $APPLICATION->GetFileContent($path); } } } } } $DOC_ROOT = CSite::GetSiteDocRoot($site); // new one if (strlen($wf_path) > 0) { $pathto = Rel2Abs($wf_path, $fname); $path = $DOC_ROOT . $pathto; if (file_exists($path)) { // get it's contents if ($USER->CanDoFileOperation('fm_view_file', array($site, $pathto))) { $src = $APPLICATION->GetFileContent($path); return $src; } } } // still failed to find // get path $path = $DOC_ROOT . $fname; if (file_exists($path)) { // get it's contents if ($USER->CanDoFileOperation('fm_view_file', array($site, $fname))) { return $APPLICATION->GetFileContent($path); } } } else { return GetMessage("FLOW_ACCESS_DENIED_PHP_VIEW"); } }