Se agregan metodo POST para FILES MANAGER y se corrige code style en varios documentos

This commit is contained in:
Freddy Daniel Rojas Valda
2014-01-30 12:01:54 -04:00
parent dc47a6068e
commit 50abb7ea4c
10 changed files with 258 additions and 38 deletions

View File

@@ -198,10 +198,11 @@ class CaseScheduler
$sTASKS = $sTaskUID; $sTASKS = $sTaskUID;
$sWS_USER = trim( $userName ); $sWS_USER = trim( $userName );
$sWS_PASS = trim( $userPass ); $sWS_PASS = trim( $userPass );
if (\G::is_https()) if (\G::is_https()) {
$http = 'https://'; $http = 'https://';
else } else {
$http = 'http://'; $http = 'http://';
}
$endpoint = $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/wsdl2'; $endpoint = $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/wsdl2';
@$client = new \SoapClient( $endpoint ); @$client = new \SoapClient( $endpoint );
$user = $sWS_USER; $user = $sWS_USER;
@@ -285,7 +286,7 @@ class CaseScheduler
throw (new \Exception( 'task not found for id: '. $aData['TAS_UID'])); throw (new \Exception( 'task not found for id: '. $aData['TAS_UID']));
} }
if ($aData['SCH_NAME']=='') { if ($aData['SCH_NAME']=='') {
throw (new \Exception( 'the Case Scheduler name can`t be empty')); throw (new \Exception( '`sch_name` can`t be empty'));
} }
if ($this->existsName($sProcessUID, $aData['SCH_NAME'])) { if ($this->existsName($sProcessUID, $aData['SCH_NAME'])) {
throw (new \Exception( 'duplicate Case Scheduler name')); throw (new \Exception( 'duplicate Case Scheduler name'));
@@ -342,7 +343,6 @@ class CaseScheduler
$aData['SCH_DAYS_PERFORM_TASK'] = ''; $aData['SCH_DAYS_PERFORM_TASK'] = '';
switch ($sOption) { switch ($sOption) {
case '1': case '1':
// Option 1
$aData['SCH_DAYS_PERFORM_TASK'] = '1'; $aData['SCH_DAYS_PERFORM_TASK'] = '1';
$sValue = $aData['SCH_DAYS_PERFORM_TASK']; $sValue = $aData['SCH_DAYS_PERFORM_TASK'];
switch ($sValue) { switch ($sValue) {
@@ -538,13 +538,13 @@ class CaseScheduler
/** /**
* Update case scheduler for a project * Update case scheduler for a project
* @param string $sProcessUID * @param string $sProcessUID
* @param string $sSchUID
* @param array $aData * @param array $aData
* @param string $userUID * @param string $userUID
* @param string $sSchUID
* *
* @access public * @access public
*/ */
public function updateCaseScheduler($sProcessUID, $sSchUID = '', $aData, $userUID) public function updateCaseScheduler($sProcessUID, $aData, $userUID, $sSchUID = '')
{ {
try { try {
require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes". PATH_SEP . "model" . PATH_SEP . "CaseScheduler.php"); require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes". PATH_SEP . "model" . PATH_SEP . "CaseScheduler.php");
@@ -567,7 +567,7 @@ class CaseScheduler
throw (new \Exception( 'task not found for id: '. $aData['TAS_UID'])); throw (new \Exception( 'task not found for id: '. $aData['TAS_UID']));
} }
if ($aData['SCH_NAME']=='') { if ($aData['SCH_NAME']=='') {
throw (new \Exception( 'the Case Scheduler name can`t be empty')); throw (new \Exception( '`sch_name` can`t be empty'));
} }
if ($this->existsNameUpdate($sSchUID, $aData['SCH_NAME'])) { if ($this->existsNameUpdate($sSchUID, $aData['SCH_NAME'])) {
throw (new \Exception( 'duplicate Case Scheduler name')); throw (new \Exception( 'duplicate Case Scheduler name'));
@@ -624,7 +624,6 @@ class CaseScheduler
$aData['SCH_DAYS_PERFORM_TASK'] = ''; $aData['SCH_DAYS_PERFORM_TASK'] = '';
switch ($sOption) { switch ($sOption) {
case '1': case '1':
// Option 1
$aData['SCH_DAYS_PERFORM_TASK'] = '1'; $aData['SCH_DAYS_PERFORM_TASK'] = '1';
$sValue = $aData['SCH_DAYS_PERFORM_TASK']; $sValue = $aData['SCH_DAYS_PERFORM_TASK'];
switch ($sValue) { switch ($sValue) {
@@ -652,7 +651,7 @@ class CaseScheduler
$weeks = explode("|", $weeks); $weeks = explode("|", $weeks);
foreach ($weeks as $row) { foreach ($weeks as $row) {
if ($row == "1" || $row == "2" || $row == "3" || $row == "4" || $row == "5"|| $row == "6" || $row == "7") { if ($row == "1" || $row == "2" || $row == "3" || $row == "4" || $row == "5"|| $row == "6" || $row == "7") {
$aData['SCH_WEEK_DAYS'] = $aData['SCH_WEEK_DAYS']; $aData['SCH_WEEK_DAYS'] = $aData['SCH_WEEK_DAYS'];
} else { } else {
throw (new \Exception( 'invalid value specified for `sch_week_days`')); throw (new \Exception( 'invalid value specified for `sch_week_days`'));
} }
@@ -694,7 +693,7 @@ class CaseScheduler
throw (new \Exception( '`sch_start_day_opt_2` can`t be null')); throw (new \Exception( '`sch_start_day_opt_2` can`t be null'));
} }
$aData['SCH_START_DAY'] = $nStartDay . '|' . $aData['SCH_START_DAY_OPT_2']; $aData['SCH_START_DAY'] = $nStartDay . '|' . $aData['SCH_START_DAY_OPT_2'];
$optionTwo = $aData['SCH_START_DAY_OPT_2']{0}; $optionTwo = $aData['SCH_START_DAY_OPT_2']{0};
if ($optionTwo == "1" || $optionTwo == "2" || $optionTwo == "3" || $optionTwo == "4" || $optionTwo == "5") { if ($optionTwo == "1" || $optionTwo == "2" || $optionTwo == "3" || $optionTwo == "4" || $optionTwo == "5") {
$aData['SCH_START_DAY_OPT_2'] = $aData['SCH_START_DAY_OPT_2']; $aData['SCH_START_DAY_OPT_2'] = $aData['SCH_START_DAY_OPT_2'];
} else { } else {

View File

@@ -47,11 +47,9 @@ class FilesManager
switch ($sMainDirectory) { switch ($sMainDirectory) {
case 'mailTemplates': case 'mailTemplates':
$sDirectory = PATH_DATA_MAILTEMPLATES . $sProcessUID . PATH_SEP; $sDirectory = PATH_DATA_MAILTEMPLATES . $sProcessUID . PATH_SEP;
$sEditable = false;
break; break;
case 'public': case 'public':
$sDirectory = PATH_DATA_PUBLIC . $sProcessUID . PATH_SEP; $sDirectory = PATH_DATA_PUBLIC . $sProcessUID . PATH_SEP;
$sEditable = true;
break; break;
default: default:
die(); die();
@@ -75,18 +73,143 @@ class FilesManager
} }
} }
foreach ($aFiles as $aFile) { foreach ($aFiles as $aFile) {
$aTheFiles[] = array('name' => $aFile['FILE'], $extention = end(explode(".", $aFile['FILE']));
'type' => "file", if ($extention == 'docx' || $extention == 'doc' || $extention == 'html' || $extention == 'php' || $extention == 'jsp' ||
'path' => $sDirectory.$aFile['FILE'], $extention == 'xlsx' || $extention == 'xls' || $extention == 'js' || $extention == 'css' || $extention == 'txt') {
'editable' => $sEditable); $sEditable = true;
} } else {
$sEditable = false;
}
$aTheFiles[] = array('name' => $aFile['FILE'],
'type' => "file",
'path' => $sDirectory.$aFile['FILE'],
'editable' => $sEditable);
}
return $aTheFiles; return $aTheFiles;
} catch (Exception $e) { } catch (Exception $e) {
throw $e; throw $e;
} }
} }
/**
* Return the Process File Manager
*
* @param string $sProcessUID {@min 32} {@max 32}
* @param string $userUid {@min 32} {@max 32}
* @param array $aData
*
* return array
*
* @access public
*/
public function addProcessFilesManager($sProcessUID, $userUid, $aData)
{
try {
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;
}
}
/**
* Return the Process Files Manager
*
* @param string $sProcessUID {@min 32} {@max 32}
*
* return array
*
* @access public
*/
public function getProcessFilesManagerDownload($sProcessUID)
{
try {
} catch (Exception $e) {
throw $e;
}
}
/**
* Return the Process Files Manager
*
* @param string $sProcessUID {@min 32} {@max 32}
*
* return array
*
* @access public
*/
public function uploadProcessFilesManager($sProcessUID)
{
try {
} catch (Exception $e) {
throw $e;
}
}
/**
* Return the Process Files Manager
*
* @param string $sProcessUID {@min 32} {@max 32}
*
* return array
*
* @access public
*/
public function deleteProcessFilesManager($sProcessUID)
{
try {
} catch (Exception $e) {
throw $e;
}
}
} }

View File

@@ -141,14 +141,14 @@ class ProcessSupervisor
/** /**
* Return available supervisors * Return available supervisors
* @param string $sProcessUID
* @param string $obj_type * @param string $obj_type
* @param string $sProcessUID
* *
* @return array * @return array
* *
* @access public * @access public
*/ */
public function getAvailableProcessSupervisors($sProcessUID = '', $obj_type) public function getAvailableProcessSupervisors($obj_type, $sProcessUID = '')
{ {
try { try {
// Groups // Groups

View File

@@ -168,10 +168,11 @@ class ProjectUser
$sWS_PASS = trim( $oData['password'] ); $sWS_PASS = trim( $oData['password'] );
$sWS_ROUNDROBIN = $oData->WS_ROUNDROBIN; $sWS_ROUNDROBIN = $oData->WS_ROUNDROBIN;
$sWE_USR = $oData->WE_USR; $sWE_USR = $oData->WE_USR;
if (\G::is_https()) if (\G::is_https()) {
$http = 'https://'; $http = 'https://';
else } else {
$http = 'http://'; $http = 'http://';
}
$endpoint = $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/wsdl2'; $endpoint = $http . $_SERVER['HTTP_HOST'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . SYS_SKIN . '/services/wsdl2';
@$client = new \SoapClient( $endpoint ); @$client = new \SoapClient( $endpoint );
$user = $sWS_USER; $user = $sWS_USER;

View File

@@ -981,7 +981,7 @@ class Task
if ( $type != $assType ) { if ( $type != $assType ) {
throw (new \Exception( 'This id: '. $sAssigneeUID .' do not correspond to a registered ' .$assType )); throw (new \Exception( 'This id: '. $sAssigneeUID .' do not correspond to a registered ' .$assType ));
} }
} }
if (! is_null( $oTypeAssigneeG ) && is_null( $oTypeAssigneeU ) ) { if (! is_null( $oTypeAssigneeG ) && is_null( $oTypeAssigneeU ) ) {
$type = "group"; $type = "group";
if ( $type != $assType ) { if ( $type != $assType ) {
@@ -1016,7 +1016,7 @@ class Task
* @access public * @access public
*/ */
public function removeTaskAssignee($sProcessUID, $sTaskUID, $sAssigneeUID) public function removeTaskAssignee($sProcessUID, $sTaskUID, $sAssigneeUID)
{ {
try { try {
$oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID );
if (is_null($oProcess)) { if (is_null($oProcess)) {
@@ -1451,7 +1451,7 @@ class Task
if ( $type != $assType ) { if ( $type != $assType ) {
throw (new \Exception( 'This id: '. $sAssigneeUID .' do not correspond to a registered ' .$assType )); throw (new \Exception( 'This id: '. $sAssigneeUID .' do not correspond to a registered ' .$assType ));
} }
} }
if (! is_null( $oTypeAssigneeG ) && is_null( $oTypeAssigneeU ) ) { if (! is_null( $oTypeAssigneeG ) && is_null( $oTypeAssigneeU ) ) {
$type = "group"; $type = "group";
if ( $type != $assType ) { if ( $type != $assType ) {
@@ -1486,7 +1486,7 @@ class Task
* @access public * @access public
*/ */
public function removeTaskAdhocAssignee($sProcessUID, $sTaskUID, $sAssigneeUID) public function removeTaskAdhocAssignee($sProcessUID, $sTaskUID, $sAssigneeUID)
{ {
try { try {
$oProcess = \ProcessPeer::retrieveByPK( $sProcessUID ); $oProcess = \ProcessPeer::retrieveByPK( $sProcessUID );
if (is_null($oProcess)) { if (is_null($oProcess)) {

View File

@@ -240,5 +240,5 @@ class Assignee extends Api
} }
return $response; return $response;
} }
} }

View File

@@ -88,7 +88,7 @@ class CaseScheduler extends Api
$userUid = $this->getUserId(); $userUid = $this->getUserId();
$request_data = (array)($request_data); $request_data = (array)($request_data);
$caseScheduler = new \BusinessModel\CaseScheduler(); $caseScheduler = new \BusinessModel\CaseScheduler();
$objectData = $caseScheduler->updateCaseScheduler($prjUid, $schUid, $request_data, $userUid); $objectData = $caseScheduler->updateCaseScheduler($prjUid, $request_data, $userUid, $schUid);
//Response //Response
$response = $objectData; $response = $objectData;
} catch (\Exception $e) { } catch (\Exception $e) {
@@ -118,7 +118,7 @@ class CaseScheduler extends Api
} }
class CaseSchedulerStructure class CaseSchedulerStructure
{ {
/** /**
* @var string {@from body} {@min 0} {@max 100} * @var string {@from body} {@min 0} {@max 100}
*/ */
@@ -234,4 +234,3 @@ class CaseSchedulerStructure
public $sch_repeat_every; public $sch_repeat_every;
} }

View File

@@ -21,7 +21,7 @@ class FilesManager extends Api
{ {
try { try {
$filesManager = new \BusinessModel\FilesManager(); $filesManager = new \BusinessModel\FilesManager();
if ($path != '') { if ($path != '') {
if ($path == 'templates') { if ($path == 'templates') {
$path = 'mailTemplates'; $path = 'mailTemplates';
} else { } else {
@@ -30,7 +30,7 @@ class FilesManager extends Api
$arrayData = $filesManager->getProcessFilesManagerPath($prjUid, $path); $arrayData = $filesManager->getProcessFilesManagerPath($prjUid, $path);
} else { } else {
$arrayData = $filesManager->getProcessFilesManager($prjUid); $arrayData = $filesManager->getProcessFilesManager($prjUid);
} }
//Response //Response
$response = $arrayData; $response = $arrayData;
} catch (\Exception $e) { } catch (\Exception $e) {
@@ -40,4 +40,103 @@ class FilesManager extends Api
return $response; return $response;
} }
/**
* @param string $prjUid {@min 32} {@max 32}
* @param string $path {@choice templates,folder,}
*
* @url GET /:prjUid/process-file-manager-download
*/
public function doGetProcessFilesManagerDownload($prjUid, $path = '')
{
try {
$filesManager = new \BusinessModel\FilesManager();
$arrayData = $filesManager->getProcessFilesManagerDownload($prjUid);
//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}
* @param ProcessFilesManagerStructure $request_data
*
* @url POST /:prjUid/process-file-manager
*/
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}
*
* @url POST /:prjUid/process-file-manager-upload
*/
public function doPostProcessFilesManagerUpload($prjUid)
{
try {
$userUid = $this->getUserId();
$filesManager = new \BusinessModel\FilesManager();
$arrayData = $filesManager->uploadProcessFilesManager($prjUid, $userUid);
//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}
*
* @url DELETE /:prjUid/process-file-manager-delete
*/
public function doDeleteProcessFilesManager($prjUid)
{
try {
$filesManager = new \BusinessModel\FilesManager();
$arrayData = $filesManager->deleteProcessFilesManager($prjUid);
//Response
$response = $arrayData;
} catch (\Exception $e) {
//response
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}
return $response;
}
} }
class ProcessFilesManagerStructure
{
/**
* @var string {@from body}
*/
public $file_name;
/**
* @var string {@from body}
*/
public $path;
/**
* @var string {@from body}
*/
public $content;
}

View File

@@ -60,7 +60,7 @@ class ProcessSupervisors extends Api
{ {
try { try {
$supervisor = new \BusinessModel\ProcessSupervisor(); $supervisor = new \BusinessModel\ProcessSupervisor();
$arrayData = $supervisor->getAvailableProcessSupervisors($prjUid, $obj_type); $arrayData = $supervisor->getAvailableProcessSupervisors($obj_type, $prjUid);
//Response //Response
$response = $arrayData; $response = $arrayData;
} catch (\Exception $e) { } catch (\Exception $e) {
@@ -174,7 +174,6 @@ class ProcessSupervisors extends Api
* @url GET /:prjUid/process-supervisor/available-input-documents * @url GET /:prjUid/process-supervisor/available-input-documents
*/ */
public function doGetAvailableProcessSupervisorInputDocument($prjUid) public function doGetAvailableProcessSupervisorInputDocument($prjUid)
{ {
try { try {
$supervisor = new \BusinessModel\ProcessSupervisor(); $supervisor = new \BusinessModel\ProcessSupervisor();
@@ -312,3 +311,4 @@ class ProcessSupervisors extends Api
return $response; return $response;
} }
} }

View File

@@ -89,22 +89,21 @@ class ProjectUsers extends Api
} }
return $response; return $response;
} }
} }
class wsUserCanStartTaskStructure class wsUserCanStartTaskStructure
{ /** {
/**
* @var string {@from body} {@min 32} {@max 32} * @var string {@from body} {@min 32} {@max 32}
*/ */
public $act_uid; public $act_uid;
/** /**
* @var string {@from body} * @var string {@from body}
*/ */
public $username; public $username;
/** /**
* @var string {@from body} * @var string {@from body}
*/ */
public $password; public $password;
} }