|
|
@@ -3736,7 +3736,7 @@ jQuery(document).ready(function(){
|
|
|
$files = $uploader->getFilesFromFolder($mainFolder, false, true);
|
|
|
$localPath = $uploader->getLocalPath();
|
|
|
$folderWeb = $uploader->getFolderWeb();
|
|
|
- $jsonFiles = $this->convertFileListToJson($files, $folderWeb, $localPath, $mainFolder);
|
|
|
+ $jsonFiles = $this->convertFileListToJson($files, $folderWeb, $localPath, $mainFolder, $record->ID);
|
|
|
echo json_encode($jsonFiles);
|
|
|
exit;
|
|
|
}
|
|
|
@@ -3810,12 +3810,12 @@ jQuery(document).ready(function(){
|
|
|
$files = $uploader->getFilesFromFolder($mainFolder, false, true);
|
|
|
$localPath = $uploader->getLocalPath();
|
|
|
$folderWeb = $uploader->getFolderWeb();
|
|
|
- $jsonFiles = $this->convertFileListToJson($files, $folderWeb, $localPath, $mainFolder);
|
|
|
+ $jsonFiles = $this->convertFileListToJson($files, $folderWeb, $localPath, $mainFolder, $record->ID);
|
|
|
echo json_encode($jsonFiles);
|
|
|
exit;
|
|
|
}
|
|
|
|
|
|
- public function convertFileListToJson($files, $folderWeb, $localPath, $mainFolder) {
|
|
|
+ public function convertFileListToJson($files, $folderWeb, $localPath, $mainFolder, $recordID) {
|
|
|
sort($files);
|
|
|
$jsonFiles = array();
|
|
|
foreach ($files as $vFilePath) {
|
|
|
@@ -3832,7 +3832,7 @@ jQuery(document).ready(function(){
|
|
|
}
|
|
|
$file->type = '';
|
|
|
$file->created = date("Y-m-d H:i:s", filectime($vFilePath));
|
|
|
- $file->web = str_replace($localPath, $folderWeb, $vFilePath);
|
|
|
+ $file->web = "PLIKI/{$this->_zasobID}/{$recordID}/{$file->name}";
|
|
|
$jsonFiles[] = $file;
|
|
|
}
|
|
|
return $jsonFiles;
|
|
|
@@ -3900,6 +3900,13 @@ jQuery(document).ready(function(){
|
|
|
exit;
|
|
|
}
|
|
|
|
|
|
+ if (!$this->_acl->canWriteRecord($record) && !$this->_acl->hasPermSuperWrite()) {
|
|
|
+ echo '<div class="alert alert-error">';
|
|
|
+ echo "Brak dostępu do rekordu";// TODO: more info - reason
|
|
|
+ echo '</div>';
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
$tblName = $this->_acl->getName();
|
|
|
$confTblName = "{$tblName}_COLUMN";
|
|
|
Lib::loadClass('FoldersConfig');
|
|
|
@@ -3937,7 +3944,7 @@ jQuery(document).ready(function(){
|
|
|
}
|
|
|
$localPath = $uploader->getLocalPath();
|
|
|
$folderWeb = $uploader->getFolderWeb();
|
|
|
- $jsonFiles = $this->convertFileListToJson($files, $folderWeb, $localPath, $mainFolder);
|
|
|
+ $jsonFiles = $this->convertFileListToJson($files, $folderWeb, $localPath, $mainFolder, $record->ID);
|
|
|
if($DBG){ echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">jsonFiles (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($jsonFiles);echo'</pre>'; }
|
|
|
|
|
|
$folderSkanyConf = FoldersConfig::getAll('SCANS_COLUMN');
|
|
|
@@ -4797,4 +4804,74 @@ jQuery(document).ready(function(){
|
|
|
return $response;
|
|
|
}
|
|
|
|
|
|
+ // TODO: check read access
|
|
|
+ public function sendFileContent($id, $fileName) {
|
|
|
+ $DBG = ('1' == V::get('DBG', '', $_REQUEST));
|
|
|
+
|
|
|
+ $dbID = $this->_acl->getDB();
|
|
|
+ $db = DB::getDB($dbID);
|
|
|
+ if (!$db) {
|
|
|
+ throw new Exception('No DB', 406);
|
|
|
+ }
|
|
|
+
|
|
|
+ $record = $this->_dataSource->getItem($id);
|
|
|
+ if (!$record) {
|
|
|
+ throw new Exception("No item ID({$rowID})", 404);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!$this->_acl->canReadRecord($record)) {
|
|
|
+ throw new Exception("Brak dostępu do rekordu", 406);
|
|
|
+ }
|
|
|
+
|
|
|
+ $tblName = $this->_acl->getName();
|
|
|
+ $confTblName = "{$tblName}_COLUMN";
|
|
|
+ Lib::loadClass('FoldersConfig');
|
|
|
+ $folderConfAll = FoldersConfig::getRawData();
|
|
|
+ if (!FoldersConfig::hasConfig($confTblName)) {
|
|
|
+ throw new Exception("Brak danych konfiguracyjnych", 404);
|
|
|
+ }
|
|
|
+
|
|
|
+ $folderConf = FoldersConfig::getAll($confTblName);
|
|
|
+ if($DBG){ echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">$folderConf (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($folderConf);echo'</pre>'; }
|
|
|
+
|
|
|
+ Lib::loadClass('FileUploader');
|
|
|
+ $uploader = new FileUploader($confTblName, $record);
|
|
|
+ $errMsg = '';
|
|
|
+ if (!$uploader->setConfig($folderConf, $errMsg)) {
|
|
|
+ throw new Exception("Błąd danych konfiguracyjnych ({$tblName})\n". $errMsg, 404);
|
|
|
+ }
|
|
|
+ $uploader->findFolder();
|
|
|
+ if($DBG){ echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">uploader (F.' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($uploader);echo'</pre>'; }
|
|
|
+
|
|
|
+ $mainFolder = $uploader->getDestFolder();
|
|
|
+ if($DBG){ echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">mainFolder (F.' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($mainFolder);echo'</pre>'; }
|
|
|
+
|
|
|
+ $localPath = $uploader->getLocalPath();
|
|
|
+ $filePath = "{$localPath}/{$mainFolder}/{$fileName}";
|
|
|
+ if (!file_exists($filePath)) {
|
|
|
+ throw new Exception("Plik nie istnieje", 404);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (function_exists('http_send_file')) {
|
|
|
+ http_send_file($filePath);
|
|
|
+ } else {
|
|
|
+ header('Content-Description: File Transfer');
|
|
|
+ header('Content-Type: application/octet-stream');
|
|
|
+ header('Content-Disposition: attachment; filename='.basename($filePath));
|
|
|
+ header('Content-Transfer-Encoding: binary');
|
|
|
+ header('Expires: 0');
|
|
|
+ header('Cache-Control: must-revalidate');
|
|
|
+ header('Pragma: public');
|
|
|
+ header('Content-Length: ' . filesize($filePath));
|
|
|
+
|
|
|
+ set_time_limit(0);
|
|
|
+ $file = @fopen($filePath, "rb");
|
|
|
+ while (!feof($file)) {
|
|
|
+ print(@fread($file, 1024*8));
|
|
|
+ ob_flush();
|
|
|
+ flush();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|