Merged in darojas/processmaker (pull request #126)
Se agregan validaciones para CASE SCHEDULER y se corrige code style en OUTPUTDOCUMENTS
This commit is contained in:
@@ -189,42 +189,72 @@ class CaseScheduler
|
|||||||
* @param string $userPass Password
|
* @param string $userPass Password
|
||||||
* @param string $sProcessUID Process
|
* @param string $sProcessUID Process
|
||||||
*
|
*
|
||||||
* return message if the authentication fail
|
* return message
|
||||||
*/
|
*/
|
||||||
public function getUser($userName, $userPass, $sProcessUID)
|
public function getUser($userName, $userPass, $sProcessUID, $sTaskUID)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (\G::is_https()) {
|
$sPRO_UID = $sProcessUID;
|
||||||
|
$sTASKS = $sTaskUID;
|
||||||
|
$sWS_USER = trim( $userName );
|
||||||
|
$sWS_PASS = trim( $userPass );
|
||||||
|
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 = $userName;
|
$user = $sWS_USER;
|
||||||
$pass = $userPass;
|
$pass = $sWS_PASS;
|
||||||
$params = array ('userid' => $user,'password' => $pass);
|
$params = array ('userid' => $user,'password' => $pass);
|
||||||
$result = $client->__SoapCall( 'login', array ($params) );
|
$result = $client->__SoapCall('login', array ($params));
|
||||||
if ($result->status_code == 0) {
|
$fields['status_code'] = $result->status_code;
|
||||||
if (! class_exists( 'Users' )) {
|
$fields['message'] = 'ProcessMaker WebService version: ' . $result->version . "\n" . $result->message;
|
||||||
require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes". PATH_SEP . "model" . PATH_SEP . "UsersPeer.php");
|
$fields['version'] = $result->version;
|
||||||
}
|
$fields['time_stamp'] = $result->timestamp;
|
||||||
$oCriteria = new \Criteria( 'workflow' );
|
$messageCode = 1;
|
||||||
$oCriteria->addSelectColumn( 'USR_UID' );
|
\G::LoadClass( 'Task' );
|
||||||
$oCriteria->add( \UsersPeer::USR_USERNAME, $sWS_USER );
|
\G::LoadClass( 'User' );
|
||||||
$resultSet = \UsersPeer::doSelectRS( $oCriteria );
|
\G::LoadClass( 'TaskUser' );
|
||||||
$resultSet->next();
|
\G::LoadClass( 'Groupwf' );
|
||||||
$user_id = $resultSet->getRow();
|
if (! class_exists( 'GroupUser' )) {
|
||||||
$result->message = $user_id[0];
|
\G::LoadClass( 'GroupUser' );
|
||||||
\G::LoadClass( 'case' );
|
|
||||||
$caseInstance = new \Cases();
|
|
||||||
if (! $caseInstance->canStartCase( $result->message, $sProcessUID )) {
|
|
||||||
$result->status_code = - 1000;
|
|
||||||
$result->message = \G::LoadTranslation( 'ID_USER_CASES_NOT_START' );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$message = $result->message;
|
if ($result->status_code == 0) {
|
||||||
return $message;
|
$oCriteria = new \Criteria( 'workflow' );
|
||||||
|
$oCriteria->addSelectColumn( \UsersPeer::USR_UID );
|
||||||
|
$oCriteria->addSelectColumn( \TaskUserPeer::USR_UID );
|
||||||
|
$oCriteria->addSelectColumn( \TaskUserPeer::TAS_UID );
|
||||||
|
$oCriteria->addSelectColumn( \UsersPeer::USR_USERNAME );
|
||||||
|
$oCriteria->addSelectColumn( \UsersPeer::USR_FIRSTNAME );
|
||||||
|
$oCriteria->addSelectColumn( \UsersPeer::USR_LASTNAME );
|
||||||
|
$oCriteria->addJoin( \TaskUserPeer::USR_UID, \UsersPeer::USR_UID, \Criteria::LEFT_JOIN );
|
||||||
|
$oCriteria->add( \TaskUserPeer::TAS_UID, $sTASKS );
|
||||||
|
$oCriteria->add( \UsersPeer::USR_USERNAME, $sWS_USER );
|
||||||
|
$userIsAssigned = \TaskUserPeer::doCount( $oCriteria );
|
||||||
|
if ($userIsAssigned < 1) {
|
||||||
|
$oCriteria = new \Criteria( 'workflow' );
|
||||||
|
$oCriteria->addSelectColumn( \UsersPeer::USR_UID );
|
||||||
|
$oCriteria->addJoin( \UsersPeer::USR_UID, \GroupUserPeer::USR_UID, \Criteria::LEFT_JOIN );
|
||||||
|
$oCriteria->addJoin( \GroupUserPeer::GRP_UID, \TaskUserPeer::USR_UID, \Criteria::LEFT_JOIN );
|
||||||
|
$oCriteria->add( \TaskUserPeer::TAS_UID, $sTASKS );
|
||||||
|
$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"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$oDataset = \TaskUserPeer::doSelectRS($oCriteria);
|
||||||
|
$oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||||
|
$oDataset->next();
|
||||||
|
while ($aRow = $oDataset->getRow()) {
|
||||||
|
$messageCode = $aRow['USR_UID'];
|
||||||
|
$oDataset->next();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw (new \Exception( $result->message));
|
||||||
|
}
|
||||||
|
return $messageCode;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
@@ -254,11 +284,15 @@ class CaseScheduler
|
|||||||
if (empty($arrayTaskUid)) {
|
if (empty($arrayTaskUid)) {
|
||||||
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']=='') {
|
||||||
|
throw (new \Exception( 'the Case Scheduler 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'));
|
||||||
}
|
}
|
||||||
$mUser = $this->getUser($aData['SCH_DEL_USER_NAME'], $aData['SCH_DEL_USER_PASS'], $sProcessUID);
|
$mUser = $this->getUser($aData['SCH_DEL_USER_NAME'], $aData['SCH_DEL_USER_PASS'], $sProcessUID, $aData['TAS_UID']);
|
||||||
if (!empty($mUser)) {
|
$oUser = \UsersPeer::retrieveByPK( $mUser );
|
||||||
|
if (is_null($oUser)) {
|
||||||
throw (new \Exception($mUser));
|
throw (new \Exception($mUser));
|
||||||
}
|
}
|
||||||
$aData['SCH_DEL_USER_PASS'] = md5( $aData['SCH_DEL_USER_PASS']);
|
$aData['SCH_DEL_USER_PASS'] = md5( $aData['SCH_DEL_USER_PASS']);
|
||||||
@@ -284,6 +318,11 @@ class CaseScheduler
|
|||||||
throw (new \Exception( '`sch_start_date` can`t be null'));
|
throw (new \Exception( '`sch_start_date` can`t be null'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($sOption == '2') {
|
||||||
|
$aData['SCH_EVERY_DAYS'] = 1;
|
||||||
|
} else {
|
||||||
|
$aData['SCH_EVERY_DAYS'] = 0;
|
||||||
|
}
|
||||||
$oCaseScheduler = new \CaseScheduler();
|
$oCaseScheduler = new \CaseScheduler();
|
||||||
$aData['SCH_UID'] = \G::generateUniqueID();
|
$aData['SCH_UID'] = \G::generateUniqueID();
|
||||||
$aData['PRO_UID'] = $sProcessUID;
|
$aData['PRO_UID'] = $sProcessUID;
|
||||||
@@ -373,6 +412,24 @@ 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};
|
||||||
|
if ($optionTwo == "1" || $optionTwo == "2" || $optionTwo == "3" || $optionTwo == "4" || $optionTwo == "5") {
|
||||||
|
$aData['SCH_START_DAY_OPT_2'] = $aData['SCH_START_DAY_OPT_2'];
|
||||||
|
} else {
|
||||||
|
throw (new \Exception( 'invalid value specified for `sch_start_day_opt_2`'));
|
||||||
|
}
|
||||||
|
$pipelineTwo = $aData['SCH_START_DAY_OPT_2']{1};
|
||||||
|
if ($pipelineTwo == "|") {
|
||||||
|
$aData['SCH_START_DAY_OPT_2'] = $aData['SCH_START_DAY_OPT_2'];
|
||||||
|
} else {
|
||||||
|
throw (new \Exception( 'invalid value specified for `sch_start_day_opt_2`'));
|
||||||
|
}
|
||||||
|
$dayTwo = $aData['SCH_START_DAY_OPT_2']{2};
|
||||||
|
if ($dayTwo == "1" || $dayTwo == "2" || $dayTwo == "3" || $dayTwo == "4" || $dayTwo == "5" || $dayTwo == "6" || $dayTwo == "7") {
|
||||||
|
$aData['SCH_START_DAY_OPT_2'] = $aData['SCH_START_DAY_OPT_2'];
|
||||||
|
} else {
|
||||||
|
throw (new \Exception( 'invalid value specified for `sch_start_day_opt_2`'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($nStartDay == "") {
|
if ($nStartDay == "") {
|
||||||
throw (new \Exception( '`sch_start_day` can`t be null'));
|
throw (new \Exception( '`sch_start_day` can`t be null'));
|
||||||
@@ -383,6 +440,14 @@ class CaseScheduler
|
|||||||
}
|
}
|
||||||
if (! empty( $aData['SCH_MONTHS'] )) {
|
if (! empty( $aData['SCH_MONTHS'] )) {
|
||||||
$aMonths = $aData['SCH_MONTHS'];
|
$aMonths = $aData['SCH_MONTHS'];
|
||||||
|
$aMonths = explode("|", $aMonths);
|
||||||
|
foreach ($aMonths as $row) {
|
||||||
|
if ($row == "1" || $row == "2" || $row == "3" || $row == "4" || $row == "5"|| $row == "6" || $row == "7"|| $row == "8" || $row == "9" || $row == "10"|| $row == "11" || $row == "12") {
|
||||||
|
$aData['SCH_MONTHS'] = $aData['SCH_MONTHS'];
|
||||||
|
} else {
|
||||||
|
throw (new \Exception( 'invalid value specified for `sch_months`'));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$sMonths = $aData['SCH_MONTHS'];
|
$sMonths = $aData['SCH_MONTHS'];
|
||||||
$sStartDay = $aData['SCH_START_DAY'];
|
$sStartDay = $aData['SCH_START_DAY'];
|
||||||
@@ -501,11 +566,15 @@ class CaseScheduler
|
|||||||
if (empty($arrayTaskUid)) {
|
if (empty($arrayTaskUid)) {
|
||||||
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']=='') {
|
||||||
|
throw (new \Exception( 'the Case Scheduler 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'));
|
||||||
}
|
}
|
||||||
$mUser = $this->getUser($aData['SCH_DEL_USER_NAME'], $aData['SCH_DEL_USER_PASS'], $sProcessUID);
|
$mUser = $this->getUser($aData['SCH_DEL_USER_NAME'], $aData['SCH_DEL_USER_PASS'], $sProcessUID, $aData['TAS_UID']);
|
||||||
if (!empty($mUser)) {
|
$oUser = \UsersPeer::retrieveByPK( $mUser );
|
||||||
|
if (is_null($oUser)) {
|
||||||
throw (new \Exception($mUser));
|
throw (new \Exception($mUser));
|
||||||
}
|
}
|
||||||
$aData['SCH_DEL_USER_PASS'] = md5( $aData['SCH_DEL_USER_PASS']);
|
$aData['SCH_DEL_USER_PASS'] = md5( $aData['SCH_DEL_USER_PASS']);
|
||||||
@@ -531,6 +600,11 @@ class CaseScheduler
|
|||||||
throw (new \Exception( '`sch_start_date` can`t be null'));
|
throw (new \Exception( '`sch_start_date` can`t be null'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($sOption == '2') {
|
||||||
|
$aData['SCH_EVERY_DAYS'] = 1;
|
||||||
|
} else {
|
||||||
|
$aData['SCH_EVERY_DAYS'] = 0;
|
||||||
|
}
|
||||||
$oCaseScheduler = new \CaseScheduler();
|
$oCaseScheduler = new \CaseScheduler();
|
||||||
$aData['SCH_UID'] = $sSchUID;
|
$aData['SCH_UID'] = $sSchUID;
|
||||||
$aData['PRO_UID'] = $sProcessUID;
|
$aData['PRO_UID'] = $sProcessUID;
|
||||||
@@ -620,6 +694,24 @@ 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};
|
||||||
|
if ($optionTwo == "1" || $optionTwo == "2" || $optionTwo == "3" || $optionTwo == "4" || $optionTwo == "5") {
|
||||||
|
$aData['SCH_START_DAY_OPT_2'] = $aData['SCH_START_DAY_OPT_2'];
|
||||||
|
} else {
|
||||||
|
throw (new \Exception( 'invalid value specified for `sch_start_day_opt_2`'));
|
||||||
|
}
|
||||||
|
$pipelineTwo = $aData['SCH_START_DAY_OPT_2']{1};
|
||||||
|
if ($pipelineTwo == "|") {
|
||||||
|
$aData['SCH_START_DAY_OPT_2'] = $aData['SCH_START_DAY_OPT_2'];
|
||||||
|
} else {
|
||||||
|
throw (new \Exception( 'invalid value specified for `sch_start_day_opt_2`'));
|
||||||
|
}
|
||||||
|
$dayTwo = $aData['SCH_START_DAY_OPT_2']{2};
|
||||||
|
if ($dayTwo == "1" || $dayTwo == "2" || $dayTwo == "3" || $dayTwo == "4" || $dayTwo == "5" || $dayTwo == "6" || $dayTwo == "7") {
|
||||||
|
$aData['SCH_START_DAY_OPT_2'] = $aData['SCH_START_DAY_OPT_2'];
|
||||||
|
} else {
|
||||||
|
throw (new \Exception( 'invalid value specified for `sch_start_day_opt_2`'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($nStartDay == "") {
|
if ($nStartDay == "") {
|
||||||
throw (new \Exception( '`sch_start_day` can`t be null'));
|
throw (new \Exception( '`sch_start_day` can`t be null'));
|
||||||
@@ -630,6 +722,14 @@ class CaseScheduler
|
|||||||
}
|
}
|
||||||
if (! empty( $aData['SCH_MONTHS'] )) {
|
if (! empty( $aData['SCH_MONTHS'] )) {
|
||||||
$aMonths = $aData['SCH_MONTHS'];
|
$aMonths = $aData['SCH_MONTHS'];
|
||||||
|
$aMonths = explode("|", $aMonths);
|
||||||
|
foreach ($aMonths as $row) {
|
||||||
|
if ($row == "1" || $row == "2" || $row == "3" || $row == "4" || $row == "5"|| $row == "6" || $row == "7"|| $row == "8" || $row == "9" || $row == "10"|| $row == "11" || $row == "12") {
|
||||||
|
$aData['SCH_MONTHS'] = $aData['SCH_MONTHS'];
|
||||||
|
} else {
|
||||||
|
throw (new \Exception( 'invalid value specified for `sch_months`'));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$sMonths = $aData['SCH_MONTHS'];
|
$sMonths = $aData['SCH_MONTHS'];
|
||||||
$sStartDay = $aData['SCH_START_DAY'];
|
$sStartDay = $aData['SCH_START_DAY'];
|
||||||
|
|||||||
@@ -281,12 +281,12 @@ class OutputDocument
|
|||||||
/**
|
/**
|
||||||
* Update a output document for a project
|
* Update a output document for a project
|
||||||
* @param string $sProcessUID
|
* @param string $sProcessUID
|
||||||
* @param string $sOutputDocumentUID
|
|
||||||
* @param array $aData
|
* @param array $aData
|
||||||
|
* @param string $sOutputDocumentUID
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
public function updateOutputDocument($sProcessUID, $sOutputDocumentUID = '', $aData)
|
public function updateOutputDocument($sProcessUID, $aData, $sOutputDocumentUID = '')
|
||||||
{
|
{
|
||||||
$oConnection = \Propel::getConnection(\OutputDocumentPeer::DATABASE_NAME);
|
$oConnection = \Propel::getConnection(\OutputDocumentPeer::DATABASE_NAME);
|
||||||
$pemission = $aData['out_doc_pdf_security_permissions'];
|
$pemission = $aData['out_doc_pdf_security_permissions'];
|
||||||
|
|||||||
@@ -215,11 +215,11 @@ class CaseSchedulerStructure
|
|||||||
public $sch_start_day_opt_1;
|
public $sch_start_day_opt_1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string {@from body}
|
* @var string {@from body} {@max 3}
|
||||||
*/
|
*/
|
||||||
public $sch_start_day_opt_2;
|
public $sch_start_day_opt_2;
|
||||||
/**
|
/**
|
||||||
* @var string {@from body} {@min 0} {@max 24}
|
* @var string {@from body} {@min 0} {@max 32}
|
||||||
*/
|
*/
|
||||||
public $sch_months;
|
public $sch_months;
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ class OutputDocuments extends Api
|
|||||||
try {
|
try {
|
||||||
$request_data = (array)($request_data);
|
$request_data = (array)($request_data);
|
||||||
$outputDocument = new \BusinessModel\OutputDocument();
|
$outputDocument = new \BusinessModel\OutputDocument();
|
||||||
$arrayData = $outputDocument->updateOutputDocument($prjUid, $outputDocumentUid, $request_data);
|
$arrayData = $outputDocument->updateOutputDocument($prjUid, $request_data, $outputDocumentUid);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
//response
|
//response
|
||||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||||
|
|||||||
Reference in New Issue
Block a user