This commit is contained in:
Julio Cesar Laura Avendaño
2019-08-30 14:50:11 -04:00
parent d0450f32a8
commit 6fac85df76

View File

@@ -1,7 +1,9 @@
<?php <?php
namespace ProcessMaker\BusinessModel; namespace ProcessMaker\BusinessModel;
use Criteria;
use ProcessMaker\Core\System; use ProcessMaker\Core\System;
use ResultSet;
use WebEntryPeer; use WebEntryPeer;
class WebEntry class WebEntry
@@ -962,31 +964,35 @@ class WebEntry
* Check the existence of a file of type web entry, returns true if it exists * 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. * and false otherwise. Verification is done by the field WE_DATA and PRO_UID.
* The PRO_UID key and the file path are required. * The PRO_UID key and the file path are required.
* @param type $proUid *
* @param type $filePath * @param string $proUid
* @return boolean * @param string $filePath
*
* @return bool
*/ */
public static function isWebEntry($proUid, $filePath) public static function isWebEntry($proUid, $filePath)
{ {
// Validate if path file is valid
$fileName = basename($filePath); $fileName = basename($filePath);
if (empty($proUid) || empty($fileName)) { if (empty($proUid) || empty($fileName)) {
return false; return false;
} }
// Transform the sent filename to a valid web entry filename
$fileName = trim($fileName); $fileName = trim($fileName);
$postfix = "Post.php"; $fileName = str_replace(['Post.php', 'Info.php'], '.php', $fileName);
$n = strlen($postfix);
$string = substr($fileName, 0, -$n); // Search in DB the filename
if ($string . $postfix === $fileName) { $criteria = new Criteria("workflow");
$fileName = $string . ".php"; $criteria->addSelectColumn(WebEntryPeer::WE_DATA);
} $criteria->add(WebEntryPeer::PRO_UID, $proUid, Criteria::EQUAL);
$criteria = new \Criteria("workflow"); $criteria->add(WebEntryPeer::WE_DATA, $fileName, Criteria::EQUAL);
$criteria->addSelectColumn(\WebEntryPeer::WE_DATA); $resultSet = WebEntryPeer::doSelectRS($criteria);
$criteria->add(\WebEntryPeer::PRO_UID, $proUid, \Criteria::EQUAL); $resultSet->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$criteria->add(\WebEntryPeer::WE_DATA, $fileName, \Criteria::EQUAL);
$resultSet = \WebEntryPeer::doSelectRS($criteria);
$resultSet->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$resultSet->next(); $resultSet->next();
$row = $resultSet->getRow(); $row = $resultSet->getRow();
// Web entry file exists?
return isset($row["WE_DATA"]); return isset($row["WE_DATA"]);
} }