This commit is contained in:
Roly Rudy Gutierrez Pinto
2017-03-09 18:24:34 -04:00
parent 80d49fc7e5
commit 06a232ed39
8 changed files with 243 additions and 21 deletions

View File

@@ -148,7 +148,7 @@ class FilesManager
*
* @access public
*/
public function addProcessFilesManager($sProcessUID, $userUID, $aData)
public function addProcessFilesManager($sProcessUID, $userUID, $aData, $isImport = false)
{
try {
$aData['prf_path'] = rtrim($aData['prf_path'], '/') . '/';
@@ -190,7 +190,7 @@ class FilesManager
if ($extention == '.exe') {
throw new \Exception(\G::LoadTranslation('ID_FILE_UPLOAD_INCORRECT_EXTENSION'));
}
if (\Bootstrap::getDisablePhpUploadExecution() === 1 && $extention === '.php') {
if (\Bootstrap::getDisablePhpUploadExecution() === 1 && $extention === '.php' && !$isImport) {
$message = \G::LoadTranslation('THE_UPLOAD_OF_PHP_FILES_WAS_DISABLED');
\Bootstrap::registerMonologPhpUploadExecution('phpUpload', 550, $message, $aData['prf_filename']);
throw new \Exception($message);
@@ -708,7 +708,7 @@ class FilesManager
*
* return void
*/
public function processFilesUpgrade($projectUid = "")
public function processFilesUpgrade($projectUid = "", $isImport = false)
{
try {
//Set variables
@@ -778,7 +778,7 @@ class FilesManager
"prf_content" => ""
);
$arrayData = $this->addProcessFilesManager($row["PRJ_UID"], "00000000000000000000000000000001", $arrayData);
$arrayData = $this->addProcessFilesManager($row["PRJ_UID"], "00000000000000000000000000000001", $arrayData, $isImport);
rename($dir . PATH_SEP . $file . ".tmp", $dir . PATH_SEP . $file);
}

View File

@@ -571,7 +571,7 @@ class WebEntry
*
* return array Return data of the new Web Entry created
*/
public function create($processUid, $userUidCreator, array $arrayData)
public function create($processUid, $userUidCreator, array $arrayData, $validate = true)
{
try {
//Verify data
@@ -590,7 +590,9 @@ class WebEntry
//Verify data
$process->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
$this->throwExceptionIfDataIsInvalid("", $processUid, $arrayData);
if ($validate === true) {
$this->throwExceptionIfDataIsInvalid("", $processUid, $arrayData);
}
//Create
$cnn = \Propel::getConnection("workflow");
@@ -946,5 +948,90 @@ class WebEntry
throw $e;
}
}
/**
* Check the existence of a file of type web entry, returns true if it exists
* and false otherwise. Verification is done by the field WE_DATA and PRO_UID.
* The PRO_UID key and the file path are required.
* @param type $proUid
* @param type $filePath
* @return boolean
*/
public static function isWebEntry($proUid, $filePath)
{
$fileName = basename($filePath);
if (empty($proUid) || empty($fileName)) {
return false;
}
$fileName = trim($fileName);
$postfix = "Post.php";
$n = strlen($postfix);
$string = substr($fileName, 0, -$n);
if ($string . $postfix === $fileName) {
$fileName = $string . ".php";
}
$criteria = new \Criteria("workflow");
$criteria->addSelectColumn(\WebEntryPeer::WE_DATA);
$criteria->add(\WebEntryPeer::PRO_UID, $proUid, \Criteria::EQUAL);
$criteria->add(\WebEntryPeer::WE_DATA, $fileName, \Criteria::EQUAL);
$resultSet = \WebEntryPeer::doSelectRS($criteria);
$resultSet->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$resultSet->next();
$row = $resultSet->getRow();
return isset($row["WE_DATA"]);
}
/**
* Fill the WEB_ENTRY table for the classic processes.
* @param type $data
*/
public function createClassic($data)
{
$cnn = \Propel::getConnection("workflow");
$criteria = new \Criteria("workflow");
$criteria->add(\WebEntryPeer::PRO_UID, $data["PRO_UID"], \Criteria::EQUAL);
$criteria->add(\WebEntryPeer::WE_DATA, $data["WE_DATA"], \Criteria::EQUAL);
$result = \WebEntryPeer::doSelect($criteria, $cnn);
if (isset($result[0])) {
$webEntry = $result[0];
$webEntry->fromArray($data, \BasePeer::TYPE_FIELDNAME);
} else {
$webEntry = new \WebEntry();
$webEntry->fromArray($data, \BasePeer::TYPE_FIELDNAME);
$webEntry->setWeUid(\ProcessMaker\Util\Common::generateUID());
$webEntry->setWeCreateDate("now");
$webEntry->setWeMethod("WS");
$webEntry->setWeInputDocumentAccess(1);
}
$webEntry->setWeUpdateDate("now");
if ($webEntry->validate()) {
$cnn->begin();
$result = $webEntry->save();
$cnn->commit();
}
}
/**
* Removes a record from the WEB_ENTRY table for the classic processes.
* The PRO_UID key and the file path are required.
* @param type $proUid
* @param type $filePath
* @return boolean
*/
public function deleteClassic($proUid, $filePath)
{
$fileName = basename($filePath);
if (empty($proUid) || empty($fileName)) {
return false;
}
$criteria = new \Criteria("workflow");
$criteria->add(\WebEntryPeer::PRO_UID, $proUid, \Criteria::EQUAL);
$criteria->add(\WebEntryPeer::WE_DATA, $fileName, \Criteria::EQUAL);
$result = \WebEntryPeer::doDelete($criteria);
return $result;
}
}