Se agrega metodo DELETE para FILES MANAGER. Se agregan validaciones en PROJECT USERS. se agrega la clase USER.
This commit is contained in:
@@ -95,14 +95,14 @@ class FilesManager
|
||||
* Return the Process File Manager
|
||||
*
|
||||
* @param string $sProcessUID {@min 32} {@max 32}
|
||||
* @param string $userUid {@min 32} {@max 32}
|
||||
* @param string $userUID {@min 32} {@max 32}
|
||||
* @param array $aData
|
||||
*
|
||||
* return array
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function addProcessFilesManager($sProcessUID, $userUid, $aData)
|
||||
public function addProcessFilesManager($sProcessUID, $userUID, $aData)
|
||||
{
|
||||
try {
|
||||
if ($aData['path'] == 'templates/' || $aData['path'] == 'folder/') {
|
||||
@@ -133,7 +133,7 @@ class FilesManager
|
||||
$sDate = date( 'Y-m-d H:i' );
|
||||
$oProcessFiles->setPrfUid( $sPkProcessFiles );
|
||||
$oProcessFiles->setProUid( $sProcessUID );
|
||||
$oProcessFiles->setUsrUid( $userUid );
|
||||
$oProcessFiles->setUsrUid( $userUID );
|
||||
$oProcessFiles->setPrfUpdateUsrUid( '' );
|
||||
$oProcessFiles->setPrfPath( $sDirectory );
|
||||
$oProcessFiles->setPrfType( 'file' );
|
||||
@@ -176,7 +176,6 @@ class FilesManager
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the Process Files Manager
|
||||
*
|
||||
@@ -195,20 +194,23 @@ class FilesManager
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Process Files Manager
|
||||
* Get data of unique ids of a file
|
||||
*
|
||||
* @param string $sProcessUID {@min 32} {@max 32}
|
||||
* @param string $userUid {@min 32} {@max 32}
|
||||
* @param array $aData
|
||||
* @param string $path
|
||||
*
|
||||
* return array
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function updateProcessFilesManager($sProcessUID, $userUid, $aData)
|
||||
public function getFileManagerUid($path)
|
||||
{
|
||||
try {
|
||||
} catch (Exception $e) {
|
||||
$criteria = new \Criteria("workflow");
|
||||
$criteria->addSelectColumn(\ProcessFilesPeer::PRF_UID);
|
||||
$criteria->add(\ProcessFilesPeer::PRF_PATH, $path, \Criteria::EQUAL);
|
||||
$rsCriteria = \ProcessFilesPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
$rsCriteria->next();
|
||||
return $rsCriteria->getRow();
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
@@ -217,18 +219,95 @@ class FilesManager
|
||||
* Return the Process Files Manager
|
||||
*
|
||||
* @param string $sProcessUID {@min 32} {@max 32}
|
||||
* @param string $path
|
||||
* @param string $userUID {@min 32} {@max 32}
|
||||
* @param array $aData
|
||||
*
|
||||
* return array
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function deleteProcessFilesManager($sProcessUID)
|
||||
public function updateProcessFilesManager($sProcessUID, $userUID, $aData, $path)
|
||||
{
|
||||
try {
|
||||
$arrayTaskUid = $this->getFileManagerUid($path);
|
||||
if ($aData['path'] == 'templates/' || $aData['path'] == 'folder/') {
|
||||
switch ($aData['path']) {
|
||||
case 'templates/':
|
||||
$sDirectory = PATH_DATA_MAILTEMPLATES . $sProcessUID . PATH_SEP . $aData['file_name'];
|
||||
$sEditable = false;
|
||||
break;
|
||||
case 'folder/':
|
||||
$sDirectory = PATH_DATA_PUBLIC . $sProcessUID . PATH_SEP . $aData['file_name'];
|
||||
break;
|
||||
default:
|
||||
$sDirectory = PATH_DATA_MAILTEMPLATES . $sProcessUID . PATH_SEP . $aData['file_name'];
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
throw (new \Exception( 'invalid value specified for `prf_path`. Expecting `templates/` or `folder/`'));
|
||||
}
|
||||
$extention = end(explode(".", $aData['file_name']));
|
||||
if ($extention == 'docx' || $extention == 'doc' || $extention == 'html' || $extention == 'php' || $extention == 'jsp' ||
|
||||
$extention == 'xlsx' || $extention == 'xls' || $extention == 'js' || $extention == 'css' || $extention == 'txt') {
|
||||
$sEditable = true;
|
||||
} else {
|
||||
$sEditable = false;
|
||||
}
|
||||
$sPkProcessFiles = \G::generateUniqueID();
|
||||
$oProcessFiles = new \ProcessFiles();
|
||||
$sDate = date( 'Y-m-d H:i' );
|
||||
$oProcessFiles->setPrfUid( $sPkProcessFiles );
|
||||
$oProcessFiles->setProUid( $sProcessUID );
|
||||
$oProcessFiles->setUsrUid( $userUID );
|
||||
$oProcessFiles->setPrfUpdateUsrUid( '' );
|
||||
$oProcessFiles->setPrfPath( $sDirectory );
|
||||
$oProcessFiles->setPrfType( 'file' );
|
||||
$oProcessFiles->setPrfEditable( $sEditable );
|
||||
$oProcessFiles->setPrfCreateDate( $sDate );
|
||||
$oProcessFiles->save();
|
||||
$fp = fopen($sDirectory, 'w');
|
||||
$content = $aData['content'];
|
||||
fwrite($fp, $content);
|
||||
fclose($fp);
|
||||
$oProcessFile = array('prf_uid' => $oProcessFiles->getPrfUid(),
|
||||
'pro_uid' => $oProcessFiles->getProUid(),
|
||||
'usr_uid' => $oProcessFiles->getUsrUid(),
|
||||
'prf_update_usr_uid' => $oProcessFiles->getPrfUpdateUsrUid(),
|
||||
'prf_path' => $oProcessFiles->getPrfPath(),
|
||||
'prf_type' => $oProcessFiles->getPrfType(),
|
||||
'prf_editable' => $oProcessFiles->getPrfEditable(),
|
||||
'prf_create_date' => $oProcessFiles->getPrfCreateDate(),
|
||||
'prf_update_date' => $oProcessFiles->getPrfUpdateDate());
|
||||
return $oProcessFile;
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $sProcessUID {@min 32} {@max 32}
|
||||
* @param string $path
|
||||
*
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function deleteProcessFilesManager($sProcessUID, $path)
|
||||
{
|
||||
try {
|
||||
$sPath = explode("/", $path);
|
||||
$sfile = end(explode("/",$path));
|
||||
$main = implode(array_slice($sPath, -3, 1));
|
||||
$carpeta = '';
|
||||
$oProcessMap = new \processMap(new \DBConnection());
|
||||
$oProcessMap->deleteFile($sProcessUID,
|
||||
$main,
|
||||
$carpeta,
|
||||
$sfile);
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,10 @@ class ProjectUser
|
||||
public function getProjectUsers($sProcessUID)
|
||||
{
|
||||
try {
|
||||
$oProcess = \ProcessPeer::retrieveByPK( $sProcessUID );
|
||||
if (is_null($oProcess)) {
|
||||
throw (new \Exception( 'This id for `prj_uid`: '. $sProcessUID .' do not correspond to a registered process'));
|
||||
}
|
||||
$aUsers = array();
|
||||
$sDelimiter = \DBAdapter::getStringDelimiter();
|
||||
$oCriteria = new \Criteria('workflow');
|
||||
@@ -98,6 +102,10 @@ class ProjectUser
|
||||
public function getProjectStartingTasks($sProcessUID)
|
||||
{
|
||||
try {
|
||||
$oProcess = \ProcessPeer::retrieveByPK( $sProcessUID );
|
||||
if (is_null($oProcess)) {
|
||||
throw (new \Exception( 'This id for `prj_uid`: '. $sProcessUID .' do not correspond to a registered process'));
|
||||
}
|
||||
$aUsers = array();
|
||||
$sDelimiter = \DBAdapter::getStringDelimiter();
|
||||
$oCriteria = new \Criteria('workflow');
|
||||
@@ -157,6 +165,14 @@ class ProjectUser
|
||||
public function getProjectStartingTaskUsers($sProcessUID, $sUserUID)
|
||||
{
|
||||
try {
|
||||
$oProcess = \ProcessPeer::retrieveByPK( $sProcessUID );
|
||||
if (is_null($oProcess)) {
|
||||
throw (new \Exception( 'This id for `prj_uid`: '. $sProcessUID .' do not correspond to a registered process'));
|
||||
}
|
||||
$oUser = \UsersPeer::retrieveByPK($sUserUID);
|
||||
if (is_null($oUser)) {
|
||||
throw (new \Exception( 'This id for `usr_uid`: '. $userUid .' do not correspond to a registered user'));
|
||||
}
|
||||
$aUsers = array();
|
||||
\G::LoadClass( 'case' );
|
||||
$oCase = new \Cases();
|
||||
@@ -189,6 +205,10 @@ class ProjectUser
|
||||
public function postProjectWsUserCanStartTask($sProcessUID, $oData)
|
||||
{
|
||||
try {
|
||||
$oProcess = \ProcessPeer::retrieveByPK( $sProcessUID );
|
||||
if (is_null($oProcess)) {
|
||||
throw (new \Exception( 'This id for `prj_uid`: '. $sProcessUID .' do not correspond to a registered process'));
|
||||
}
|
||||
/**
|
||||
* process_webEntryValidate
|
||||
* validates if the username and password are valid data and if the user assigned
|
||||
@@ -261,7 +281,7 @@ class ProjectUser
|
||||
$oCriteria->add( \UsersPeer::USR_USERNAME, $sWS_USER );
|
||||
$userIsAssigned = \GroupUserPeer::doCount( $oCriteria );
|
||||
if (! ($userIsAssigned >= 1)) {
|
||||
throw (new \Exception( "The User `" . $sWS_USER . "` doesn't have the activity `" . $sTASKS . "` assigned"));
|
||||
throw (new \Exception( "The `usr_uid` `" . $sWS_USER . "` doesn't have the activity `tas_uid` `" . $sTASKS . "` assigned"));
|
||||
}
|
||||
}
|
||||
$oDataset = \TaskUserPeer::doSelectRS($oCriteria);
|
||||
|
||||
504
workflow/engine/src/BusinessModel/User.php
Normal file
504
workflow/engine/src/BusinessModel/User.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -13,7 +13,7 @@ class FilesManager extends Api
|
||||
{
|
||||
/**
|
||||
* @param string $prjUid {@min 32} {@max 32}
|
||||
* @param string $path {@choice templates,folder,}
|
||||
* @param string $path
|
||||
*
|
||||
* @url GET /:prjUid/process-file-manager
|
||||
*/
|
||||
@@ -42,7 +42,7 @@ class FilesManager extends Api
|
||||
|
||||
/**
|
||||
* @param string $prjUid {@min 32} {@max 32}
|
||||
* @param string $path {@choice templates,folder,}
|
||||
* @param string $path
|
||||
*
|
||||
* @url GET /:prjUid/process-file-manager-download
|
||||
*/
|
||||
@@ -105,17 +105,18 @@ class FilesManager extends Api
|
||||
|
||||
/**
|
||||
* @param string $prjUid {@min 32} {@max 32}
|
||||
* @param ProcessFilesManagerStructure $request_data
|
||||
* @param string $path
|
||||
* @param ProcessFilesManagerStructure1 $request_data
|
||||
*
|
||||
* @url PUT /:prjUid/process-file-manager-upload
|
||||
* @url PUT /:prjUid/process-file-manager1
|
||||
*/
|
||||
public function doPutProcessFilesManagerUpload($prjUid, ProcessFilesManagerStructure $request_data)
|
||||
public function doPutProcessFilesManager($prjUid, ProcessFilesManagerStructure1 $request_data, $path)
|
||||
{
|
||||
try {
|
||||
$userUid = $this->getUserId();
|
||||
$request_data = (array)($request_data);
|
||||
$filesManager = new \BusinessModel\FilesManager();
|
||||
$arrayData = $filesManager->updateProcessFilesManager($prjUid, $userUid, $request_data);
|
||||
$arrayData = $filesManager->updateProcessFilesManager($prjUid, $userUid, $request_data, $path);
|
||||
//Response
|
||||
$response = $arrayData;
|
||||
} catch (\Exception $e) {
|
||||
@@ -126,14 +127,15 @@ class FilesManager extends Api
|
||||
}
|
||||
/**
|
||||
* @param string $prjUid {@min 32} {@max 32}
|
||||
* @param string $path
|
||||
*
|
||||
* @url DELETE /:prjUid/process-file-manager-delete
|
||||
* @url DELETE /:prjUid/process-file-manager
|
||||
*/
|
||||
public function doDeleteProcessFilesManager($prjUid)
|
||||
public function doDeleteProcessFilesManager($prjUid, $path)
|
||||
{
|
||||
try {
|
||||
$filesManager = new \BusinessModel\FilesManager();
|
||||
$arrayData = $filesManager->deleteProcessFilesManager($prjUid);
|
||||
$arrayData = $filesManager->deleteProcessFilesManager($prjUid, $path);
|
||||
//Response
|
||||
$response = $arrayData;
|
||||
} catch (\Exception $e) {
|
||||
@@ -156,6 +158,19 @@ class ProcessFilesManagerStructure
|
||||
*/
|
||||
public $path;
|
||||
|
||||
/**
|
||||
* @var string {@from body}
|
||||
*/
|
||||
public $content;
|
||||
}
|
||||
|
||||
class ProcessFilesManagerStructure1
|
||||
{
|
||||
/**
|
||||
* @var string {@from body}
|
||||
*/
|
||||
public $file_name;
|
||||
|
||||
/**
|
||||
* @var string {@from body}
|
||||
*/
|
||||
|
||||
@@ -12,15 +12,15 @@ use \Luracast\Restler\RestException;
|
||||
class ProjectUsers extends Api
|
||||
{
|
||||
/**
|
||||
* @param string $prjUid {@min 32} {@max 32}
|
||||
* @param string $prj_uid {@min 32} {@max 32}
|
||||
*
|
||||
* @url GET /:prjUid/users
|
||||
* @url GET /:prj_uid/users
|
||||
*/
|
||||
public function doGetProjectUsers($prjUid)
|
||||
public function doGetProjectUsers($prj_uid)
|
||||
{
|
||||
try {
|
||||
$users = new \BusinessModel\ProjectUser();
|
||||
$arrayData = $users->getProjectUsers($prjUid);
|
||||
$arrayData = $users->getProjectUsers($prj_uid);
|
||||
//Response
|
||||
$response = $arrayData;
|
||||
} catch (\Exception $e) {
|
||||
@@ -51,15 +51,15 @@ class ProjectUsers extends Api
|
||||
|
||||
/**
|
||||
* @param string $prjUid {@min 32} {@max 32}
|
||||
* @param string $usrUid {@min 32} {@max 32}
|
||||
* @param string $usr_uid {@min 32} {@max 32}
|
||||
*
|
||||
* @url GET /:prjUid/user/:usrUid/starting-tasks
|
||||
* @url GET /:prjUid/user/:usr_uid/starting-tasks
|
||||
*/
|
||||
public function doGetProjectStartingTaskUsers($prjUid, $usrUid)
|
||||
public function doGetProjectStartingTaskUsers($prjUid, $usr_uid)
|
||||
{
|
||||
try {
|
||||
$startingTasks = new \BusinessModel\ProjectUser();
|
||||
$arrayData = $startingTasks->getProjectStartingTaskUsers($prjUid, $usrUid);
|
||||
$arrayData = $startingTasks->getProjectStartingTaskUsers($prjUid, $usr_uid);
|
||||
//Response
|
||||
$response = $arrayData;
|
||||
} catch (\Exception $e) {
|
||||
|
||||
113
workflow/engine/src/Services/Api/ProcessMaker/User.php
Normal file
113
workflow/engine/src/Services/Api/ProcessMaker/User.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
namespace Services\Api\ProcessMaker;
|
||||
|
||||
use \ProcessMaker\Services\Api;
|
||||
use \Luracast\Restler\RestException;
|
||||
|
||||
/**
|
||||
* User Api Controller
|
||||
*
|
||||
* @protected
|
||||
*/
|
||||
class User extends Api
|
||||
{
|
||||
/**
|
||||
* @url GET
|
||||
*/
|
||||
public function index($filter = '', $start = null, $limit = null)
|
||||
{
|
||||
try {
|
||||
$user = new \BusinessModel\User();
|
||||
$response = $user->getUsers($filter, null, null, $start, $limit);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url GET /:usr_uid
|
||||
*
|
||||
* @param string $usr_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function doGet($usr_uid)
|
||||
{
|
||||
try {
|
||||
$user = new \BusinessModel\User();
|
||||
$response = $user->getUser($usr_uid);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url POST
|
||||
*
|
||||
* @param array $request_data
|
||||
* @param string $grp_title {@from body}{@required true}
|
||||
* @param string $grp_status {@from body}{@choice ACTIVE,INACTIVE}{@required true}
|
||||
*
|
||||
* @status 201
|
||||
*/
|
||||
public function doPost(
|
||||
$request_data,
|
||||
$grp_title = "",
|
||||
$grp_status = "ACTIVE"
|
||||
) {
|
||||
try {
|
||||
$group = new \BusinessModel\Group();
|
||||
$group->setFormatFieldNameInUppercase(false);
|
||||
|
||||
$arrayData = $group->create($request_data);
|
||||
|
||||
$response = $arrayData;
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url PUT /:grp_uid
|
||||
*
|
||||
* @param string $grp_uid {@min 32}{@max 32}
|
||||
* @param array $request_data
|
||||
* @param string $grp_title {@from body}
|
||||
* @param string $grp_status {@from body}{@choice ACTIVE,INACTIVE}
|
||||
*/
|
||||
public function doPut(
|
||||
$grp_uid,
|
||||
$request_data,
|
||||
$grp_title = "",
|
||||
$grp_status = "ACTIVE"
|
||||
) {
|
||||
try {
|
||||
$group = new \BusinessModel\Group();
|
||||
$group->setFormatFieldNameInUppercase(false);
|
||||
|
||||
$arrayData = $group->update($grp_uid, $request_data);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url DELETE /:grp_uid
|
||||
*
|
||||
* @param string $grp_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function doDelete($grp_uid)
|
||||
{
|
||||
try {
|
||||
$group = new \BusinessModel\Group();
|
||||
$group->setFormatFieldNameInUppercase(false);
|
||||
|
||||
$group->delete($grp_uid);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,3 +42,8 @@ debug = 1
|
||||
[alias: groups]
|
||||
group = "Services\Api\ProcessMaker\Group"
|
||||
|
||||
[alias: user]
|
||||
user = "Services\Api\ProcessMaker\User"
|
||||
|
||||
[alias: users]
|
||||
user = "Services\Api\ProcessMaker\User"
|
||||
|
||||
Reference in New Issue
Block a user