2014-01-28 16:31:20 -04:00
|
|
|
<?php
|
|
|
|
|
namespace Services\Api\ProcessMaker\Project;
|
|
|
|
|
|
|
|
|
|
use \ProcessMaker\Services\Api;
|
|
|
|
|
use \Luracast\Restler\RestException;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Project\ProjectUsers Api Controller
|
|
|
|
|
*
|
|
|
|
|
* @protected
|
|
|
|
|
*/
|
|
|
|
|
class FilesManager extends Api
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* @param string $prjUid {@min 32} {@max 32}
|
2014-01-31 13:09:16 -04:00
|
|
|
* @param string $path
|
2014-01-28 16:31:20 -04:00
|
|
|
*
|
2014-02-20 12:27:28 -04:00
|
|
|
* @url GET /:prjUid/file-manager
|
2014-01-28 16:31:20 -04:00
|
|
|
*/
|
|
|
|
|
public function doGetProcessFilesManager($prjUid, $path = '')
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$filesManager = new \BusinessModel\FilesManager();
|
2014-01-30 12:01:54 -04:00
|
|
|
if ($path != '') {
|
2014-01-28 16:31:20 -04:00
|
|
|
$arrayData = $filesManager->getProcessFilesManagerPath($prjUid, $path);
|
|
|
|
|
} else {
|
|
|
|
|
$arrayData = $filesManager->getProcessFilesManager($prjUid);
|
2014-01-30 12:01:54 -04:00
|
|
|
}
|
2014-01-28 16:31:20 -04:00
|
|
|
//Response
|
|
|
|
|
$response = $arrayData;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
//response
|
|
|
|
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
return $response;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-30 12:01:54 -04:00
|
|
|
/**
|
|
|
|
|
* @param string $prjUid {@min 32} {@max 32}
|
|
|
|
|
* @param ProcessFilesManagerStructure $request_data
|
|
|
|
|
*
|
2014-02-20 12:27:28 -04:00
|
|
|
* @url POST /:prjUid/file-manager
|
2014-01-30 12:01:54 -04:00
|
|
|
*/
|
|
|
|
|
public function doPostProcessFilesManager($prjUid, ProcessFilesManagerStructure $request_data)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$userUid = $this->getUserId();
|
|
|
|
|
$request_data = (array)($request_data);
|
|
|
|
|
$filesManager = new \BusinessModel\FilesManager();
|
|
|
|
|
$arrayData = $filesManager->addProcessFilesManager($prjUid, $userUid, $request_data);
|
|
|
|
|
//Response
|
|
|
|
|
$response = $arrayData;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
//response
|
|
|
|
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
return $response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $prjUid {@min 32} {@max 32}
|
2014-02-24 16:54:55 -04:00
|
|
|
* @param string $prfUid {@min 32} {@max 32}
|
2014-01-30 12:01:54 -04:00
|
|
|
*
|
2014-02-24 16:54:55 -04:00
|
|
|
* @url POST /:prjUid/file-manager/:prfUid/upload
|
2014-01-30 12:01:54 -04:00
|
|
|
*/
|
2014-02-24 16:54:55 -04:00
|
|
|
public function doPostProcessFilesManagerUpload($prjUid, $prfUid)
|
2014-01-30 12:01:54 -04:00
|
|
|
{
|
|
|
|
|
try {
|
2014-02-18 16:13:57 -04:00
|
|
|
$filesManager = new \BusinessModel\FilesManager();
|
2014-02-26 12:22:22 -04:00
|
|
|
$sData = $filesManager->uploadProcessFilesManager($prjUid, $prfUid);
|
|
|
|
|
//Response
|
|
|
|
|
$response = $sData;
|
2014-01-30 12:01:54 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
//response
|
|
|
|
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-30 14:53:30 -04:00
|
|
|
/**
|
|
|
|
|
* @param string $prjUid {@min 32} {@max 32}
|
2014-02-26 12:22:22 -04:00
|
|
|
* @param ProcessFilesManagerStructure $request_data
|
|
|
|
|
* @param string $prfUid {@min 32} {@max 32}
|
2014-01-30 14:53:30 -04:00
|
|
|
*
|
2014-02-26 12:22:22 -04:00
|
|
|
* @url PUT /:prjUid/file-manager/:prfUid
|
2014-01-30 14:53:30 -04:00
|
|
|
*/
|
2014-02-26 12:22:22 -04:00
|
|
|
public function doPutProcessFilesManager($prjUid, ProcessFilesManagerStructure $request_data, $prfUid)
|
2014-01-30 14:53:30 -04:00
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$userUid = $this->getUserId();
|
|
|
|
|
$request_data = (array)($request_data);
|
|
|
|
|
$filesManager = new \BusinessModel\FilesManager();
|
2014-02-26 12:22:22 -04:00
|
|
|
$arrayData = $filesManager->updateProcessFilesManager($prjUid, $userUid, $request_data, $prfUid);
|
2014-01-30 14:53:30 -04:00
|
|
|
//Response
|
|
|
|
|
$response = $arrayData;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
//response
|
|
|
|
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
return $response;
|
|
|
|
|
}
|
2014-02-11 17:03:25 -04:00
|
|
|
|
2014-01-30 12:01:54 -04:00
|
|
|
/**
|
|
|
|
|
* @param string $prjUid {@min 32} {@max 32}
|
2014-02-26 12:22:22 -04:00
|
|
|
* @param string $prfUid {@min 32} {@max 32}
|
2014-01-30 12:01:54 -04:00
|
|
|
*
|
2014-02-26 12:22:22 -04:00
|
|
|
* @url DELETE /:prjUid/file-manager/:prfUid
|
2014-01-30 12:01:54 -04:00
|
|
|
*/
|
2014-02-26 12:22:22 -04:00
|
|
|
public function doDeleteProcessFilesManager($prjUid, $prfUid)
|
2014-01-30 12:01:54 -04:00
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$filesManager = new \BusinessModel\FilesManager();
|
2014-02-26 12:22:22 -04:00
|
|
|
$filesManager->deleteProcessFilesManager($prjUid, $prfUid);
|
2014-01-30 12:01:54 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
//response
|
|
|
|
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-02-11 17:03:25 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $prjUid {@min 32} {@max 32}
|
2014-02-25 12:43:18 -04:00
|
|
|
* @param string $prfUid {@min 32} {@max 32}
|
2014-02-11 17:03:25 -04:00
|
|
|
*
|
2014-02-25 12:43:18 -04:00
|
|
|
* @url GET /:prjUid/file-manager/:prfUid/download
|
2014-02-11 17:03:25 -04:00
|
|
|
*/
|
2014-02-25 12:43:18 -04:00
|
|
|
public function doGetProcessFilesManagerDownload($prjUid, $prfUid)
|
2014-02-11 17:03:25 -04:00
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$filesManager = new \BusinessModel\FilesManager();
|
2014-02-25 12:43:18 -04:00
|
|
|
$filesManager->downloadProcessFilesManager($prjUid, $prfUid);
|
2014-02-11 17:03:25 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
//response
|
|
|
|
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-05 16:02:35 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $prjUid {@min 32} {@max 32}
|
|
|
|
|
* @param string $path
|
|
|
|
|
*
|
|
|
|
|
* @url DELETE /:prjUid/file-manager/folder
|
|
|
|
|
*/
|
|
|
|
|
public function doDeleteFolderProcessFilesManager($prjUid, $path)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$filesManager = new \BusinessModel\FilesManager();
|
|
|
|
|
$filesManager->deleteFolderProcessFilesManager($prjUid, $path);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
//response
|
|
|
|
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-01-28 16:31:20 -04:00
|
|
|
}
|
2014-01-30 12:01:54 -04:00
|
|
|
|
|
|
|
|
class ProcessFilesManagerStructure
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* @var string {@from body}
|
|
|
|
|
*/
|
2014-02-20 12:27:28 -04:00
|
|
|
public $prf_filename;
|
2014-01-30 12:01:54 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var string {@from body}
|
|
|
|
|
*/
|
2014-02-20 12:27:28 -04:00
|
|
|
public $prf_path;
|
2014-02-26 16:22:23 -04:00
|
|
|
|
2014-02-25 09:50:33 -04:00
|
|
|
/**
|
|
|
|
|
* @var string {@from body}
|
|
|
|
|
*/
|
2014-02-20 12:27:28 -04:00
|
|
|
public $prf_content;
|
2014-01-31 13:09:16 -04:00
|
|
|
}
|
|
|
|
|
|