2013-12-13 16:36:03 -04:00
|
|
|
<?php
|
2014-04-02 16:51:28 -04:00
|
|
|
namespace ProcessMaker\BusinessModel;
|
2013-12-13 16:36:03 -04:00
|
|
|
|
|
|
|
|
use \G;
|
|
|
|
|
|
|
|
|
|
class OutputDocument
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Return output documents of a project
|
|
|
|
|
* @param string $sProcessUID
|
|
|
|
|
* @return array
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*/
|
|
|
|
|
public function getOutputDocuments($sProcessUID = '')
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$sDelimiter = \DBAdapter::getStringDelimiter();
|
|
|
|
|
$oCriteria = new \Criteria('workflow');
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_UID);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_TYPE);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::PRO_UID);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_REPORT_GENERATOR);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_LANDSCAPE);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_MEDIA);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_LEFT_MARGIN);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_RIGHT_MARGIN);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_TOP_MARGIN);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_BOTTOM_MARGIN);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_GENERATE);
|
2014-01-25 06:36:45 -04:00
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_TYPE);
|
2013-12-13 16:36:03 -04:00
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_CURRENT_REVISION);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_FIELD_MAPPING);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_VERSIONING);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_DESTINATION_PATH);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_TAGS);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_PDF_SECURITY_ENABLED);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_PDF_SECURITY_OPEN_PASSWORD);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_PDF_SECURITY_OWNER_PASSWORD);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_PDF_SECURITY_PERMISSIONS);
|
2015-03-06 13:23:13 -04:00
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_OPEN_TYPE);
|
2016-12-01 09:32:35 -05:00
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_TITLE);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_DESCRIPTION);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_FILENAME);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_TEMPLATE);
|
2013-12-13 16:36:03 -04:00
|
|
|
$oCriteria->add(\OutputDocumentPeer::PRO_UID, $sProcessUID);
|
|
|
|
|
$oDataset = \OutputDocumentPeer::doSelectRS($oCriteria);
|
|
|
|
|
$oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
$oDataset->next();
|
|
|
|
|
$outputDocArray = array();
|
|
|
|
|
while ($aRow = $oDataset->getRow()) {
|
|
|
|
|
if (($aRow['OUT_DOC_TITLE'] == null) || ($aRow['OUT_DOC_TITLE'] == "")) {
|
|
|
|
|
// There is no transaltion for this Document name, try to get/regenerate the label
|
|
|
|
|
$outputDocument = new \OutputDocument();
|
|
|
|
|
$outputDocumentObj = $outputDocument->load($aRow['OUT_DOC_UID']);
|
|
|
|
|
$aRow['OUT_DOC_TITLE'] = $outputDocumentObj['OUT_DOC_TITLE'];
|
|
|
|
|
$aRow['OUT_DOC_DESCRIPTION'] = $outputDocumentObj['OUT_DOC_DESCRIPTION'];
|
|
|
|
|
} else {
|
|
|
|
|
$outputDocArray[] = array('out_doc_uid' => $aRow['OUT_DOC_UID'],
|
|
|
|
|
'out_doc_title' => $aRow['OUT_DOC_TITLE'],
|
|
|
|
|
'out_doc_description' => $aRow['OUT_DOC_DESCRIPTION'],
|
|
|
|
|
'out_doc_filename' => $aRow['OUT_DOC_FILENAME'],
|
2014-05-15 13:13:45 -04:00
|
|
|
'out_doc_template' => $aRow['OUT_DOC_TEMPLATE'],
|
2013-12-16 14:32:38 -04:00
|
|
|
'out_doc_report_generator' => $aRow['OUT_DOC_REPORT_GENERATOR'],
|
|
|
|
|
'out_doc_landscape' => $aRow['OUT_DOC_LANDSCAPE'],
|
|
|
|
|
'out_doc_media' => $aRow['OUT_DOC_MEDIA'],
|
|
|
|
|
'out_doc_left_margin' => $aRow['OUT_DOC_LEFT_MARGIN'],
|
|
|
|
|
'out_doc_right_margin' => $aRow['OUT_DOC_RIGHT_MARGIN'],
|
|
|
|
|
'out_doc_top_margin' => $aRow['OUT_DOC_TOP_MARGIN'],
|
|
|
|
|
'out_doc_bottom_margin' => $aRow['OUT_DOC_BOTTOM_MARGIN'],
|
|
|
|
|
'out_doc_generate' => $aRow['OUT_DOC_GENERATE'],
|
|
|
|
|
'out_doc_type' => $aRow['OUT_DOC_TYPE'],
|
|
|
|
|
'out_doc_current_revision' => $aRow['OUT_DOC_CURRENT_REVISION'],
|
|
|
|
|
'out_doc_field_mapping' => $aRow['OUT_DOC_FIELD_MAPPING'],
|
|
|
|
|
'out_doc_versioning' => $aRow['OUT_DOC_VERSIONING'],
|
|
|
|
|
'out_doc_destination_path' => $aRow['OUT_DOC_DESTINATION_PATH'],
|
|
|
|
|
'out_doc_tags' => $aRow['OUT_DOC_TAGS'],
|
|
|
|
|
'out_doc_pdf_security_enabled' => $aRow['OUT_DOC_PDF_SECURITY_ENABLED'],
|
2015-03-06 13:23:13 -04:00
|
|
|
'out_doc_pdf_security_permissions' => $aRow['OUT_DOC_PDF_SECURITY_PERMISSIONS'],
|
|
|
|
|
"out_doc_open_type" => $aRow["OUT_DOC_OPEN_TYPE"]);
|
2013-12-13 16:36:03 -04:00
|
|
|
}
|
|
|
|
|
$oDataset->next();
|
|
|
|
|
}
|
|
|
|
|
return $outputDocArray;
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return a single output document of a project
|
|
|
|
|
* @param string $sProcessUID
|
2014-01-15 14:54:27 -04:00
|
|
|
* @param string $sOutputDocumentUID
|
2013-12-13 16:36:03 -04:00
|
|
|
* @return array
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*/
|
|
|
|
|
public function getOutputDocument($sProcessUID = '', $sOutputDocumentUID = '')
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$sDelimiter = \DBAdapter::getStringDelimiter();
|
|
|
|
|
$oCriteria = new \Criteria('workflow');
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_UID);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_TYPE);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::PRO_UID);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_REPORT_GENERATOR);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_LANDSCAPE);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_MEDIA);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_LEFT_MARGIN);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_RIGHT_MARGIN);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_TOP_MARGIN);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_BOTTOM_MARGIN);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_GENERATE);
|
2014-01-25 06:36:45 -04:00
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_TYPE);
|
2013-12-13 16:36:03 -04:00
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_CURRENT_REVISION);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_FIELD_MAPPING);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_VERSIONING);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_DESTINATION_PATH);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_TAGS);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_PDF_SECURITY_ENABLED);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_PDF_SECURITY_OPEN_PASSWORD);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_PDF_SECURITY_OWNER_PASSWORD);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_PDF_SECURITY_PERMISSIONS);
|
2015-03-06 13:23:13 -04:00
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_OPEN_TYPE);
|
2016-12-01 09:32:35 -05:00
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_TITLE);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_DESCRIPTION);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_FILENAME);
|
|
|
|
|
$oCriteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_TEMPLATE);
|
2013-12-13 16:36:03 -04:00
|
|
|
$oCriteria->add(\OutputDocumentPeer::OUT_DOC_UID, $sOutputDocumentUID);
|
|
|
|
|
$oCriteria->add(\OutputDocumentPeer::PRO_UID, $sProcessUID);
|
|
|
|
|
$oDataset = \OutputDocumentPeer::doSelectRS($oCriteria);
|
|
|
|
|
$oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
$oDataset->next();
|
|
|
|
|
$outputDocArray = array();
|
|
|
|
|
while ($aRow = $oDataset->getRow()) {
|
|
|
|
|
if (($aRow['OUT_DOC_TITLE'] == null) || ($aRow['OUT_DOC_TITLE'] == "")) {
|
|
|
|
|
// There is no transaltion for this Document name, try to get/regenerate the label
|
|
|
|
|
$outputDocument = new \OutputDocument();
|
|
|
|
|
$outputDocumentObj = $outputDocument->load($aRow['OUT_DOC_UID']);
|
|
|
|
|
$aRow['OUT_DOC_TITLE'] = $outputDocumentObj['OUT_DOC_TITLE'];
|
|
|
|
|
$aRow['OUT_DOC_DESCRIPTION'] = $outputDocumentObj['OUT_DOC_DESCRIPTION'];
|
|
|
|
|
} else {
|
2014-01-06 11:39:35 -04:00
|
|
|
$outputDocArray = array('out_doc_uid' => $aRow['OUT_DOC_UID'],
|
2013-12-13 16:36:03 -04:00
|
|
|
'out_doc_title' => $aRow['OUT_DOC_TITLE'],
|
|
|
|
|
'out_doc_description' => $aRow['OUT_DOC_DESCRIPTION'],
|
|
|
|
|
'out_doc_filename' => $aRow['OUT_DOC_FILENAME'],
|
2014-05-15 13:13:45 -04:00
|
|
|
'out_doc_template' => $aRow['OUT_DOC_TEMPLATE'],
|
2013-12-16 14:32:38 -04:00
|
|
|
'out_doc_report_generator' => $aRow['OUT_DOC_REPORT_GENERATOR'],
|
|
|
|
|
'out_doc_landscape' => $aRow['OUT_DOC_LANDSCAPE'],
|
|
|
|
|
'out_doc_media' => $aRow['OUT_DOC_MEDIA'],
|
|
|
|
|
'out_doc_left_margin' => $aRow['OUT_DOC_LEFT_MARGIN'],
|
|
|
|
|
'out_doc_right_margin' => $aRow['OUT_DOC_RIGHT_MARGIN'],
|
|
|
|
|
'out_doc_top_margin' => $aRow['OUT_DOC_TOP_MARGIN'],
|
|
|
|
|
'out_doc_bottom_margin' => $aRow['OUT_DOC_BOTTOM_MARGIN'],
|
|
|
|
|
'out_doc_generate' => $aRow['OUT_DOC_GENERATE'],
|
|
|
|
|
'out_doc_type' => $aRow['OUT_DOC_TYPE'],
|
|
|
|
|
'out_doc_current_revision' => $aRow['OUT_DOC_CURRENT_REVISION'],
|
|
|
|
|
'out_doc_field_mapping' => $aRow['OUT_DOC_FIELD_MAPPING'],
|
|
|
|
|
'out_doc_versioning' => $aRow['OUT_DOC_VERSIONING'],
|
|
|
|
|
'out_doc_destination_path' => $aRow['OUT_DOC_DESTINATION_PATH'],
|
|
|
|
|
'out_doc_tags' => $aRow['OUT_DOC_TAGS'],
|
|
|
|
|
'out_doc_pdf_security_enabled' => $aRow['OUT_DOC_PDF_SECURITY_ENABLED'],
|
2015-03-06 13:23:13 -04:00
|
|
|
'out_doc_pdf_security_permissions' => $aRow['OUT_DOC_PDF_SECURITY_PERMISSIONS'],
|
|
|
|
|
"out_doc_open_type" => $aRow["OUT_DOC_OPEN_TYPE"]);
|
2013-12-13 16:36:03 -04:00
|
|
|
}
|
|
|
|
|
$oDataset->next();
|
|
|
|
|
}
|
|
|
|
|
return $outputDocArray;
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new output document for a project
|
|
|
|
|
* @param string $sProcessUID
|
2014-04-30 13:00:01 -04:00
|
|
|
* @param array $outputDocumentData
|
2013-12-13 16:36:03 -04:00
|
|
|
* @return array
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*/
|
2014-04-30 13:00:01 -04:00
|
|
|
public function addOutputDocument($sProcessUID, $outputDocumentData)
|
2014-01-25 06:36:45 -04:00
|
|
|
{
|
2014-04-30 13:00:01 -04:00
|
|
|
$pemission = $outputDocumentData['out_doc_pdf_security_permissions'];
|
2014-01-15 14:54:27 -04:00
|
|
|
$pemission = explode("|", $pemission);
|
|
|
|
|
foreach ($pemission as $row) {
|
2014-01-16 09:35:11 -04:00
|
|
|
if ($row == "print" || $row == "modify" || $row == "copy" || $row == "forms" || $row == "") {
|
2014-04-30 13:00:01 -04:00
|
|
|
$outputDocumentData['out_doc_pdf_security_permissions'] = $outputDocumentData['out_doc_pdf_security_permissions'];
|
2014-01-15 14:54:27 -04:00
|
|
|
} else {
|
2014-05-22 09:12:35 -04:00
|
|
|
throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('out_doc_pdf_security_permissions')));
|
2014-01-15 14:54:27 -04:00
|
|
|
}
|
|
|
|
|
}
|
2013-12-13 16:36:03 -04:00
|
|
|
try {
|
2014-04-02 16:51:28 -04:00
|
|
|
require_once(PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "OutputDocument.php");
|
2014-04-30 13:00:01 -04:00
|
|
|
$outputDocumentData = array_change_key_case($outputDocumentData, CASE_UPPER);
|
|
|
|
|
$outputDocumentData['PRO_UID'] = $sProcessUID;
|
2013-12-13 16:36:03 -04:00
|
|
|
//Verify data
|
2014-05-15 13:13:45 -04:00
|
|
|
Validator::proUid($sProcessUID, '$pro_uid');
|
2014-04-30 13:00:01 -04:00
|
|
|
if ($outputDocumentData["OUT_DOC_TITLE"]=="") {
|
2014-05-22 09:12:35 -04:00
|
|
|
throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('out_doc_title')));
|
2014-01-22 15:57:12 -04:00
|
|
|
}
|
2014-04-30 13:00:01 -04:00
|
|
|
if (isset($outputDocumentData["OUT_DOC_TITLE"]) && $this->existsTitle($sProcessUID, $outputDocumentData["OUT_DOC_TITLE"])) {
|
2013-12-13 16:36:03 -04:00
|
|
|
throw (new \Exception(\G::LoadTranslation("ID_OUTPUT_NOT_SAVE")));
|
|
|
|
|
}
|
|
|
|
|
$oOutputDocument = new \OutputDocument();
|
2014-04-30 13:00:01 -04:00
|
|
|
if (isset( $outputDocumentData['OUT_DOC_TITLE'] ) && $outputDocumentData['OUT_DOC_TITLE'] != '') {
|
|
|
|
|
if (isset( $outputDocumentData['OUT_DOC_PDF_SECURITY_ENABLED'] ) && $outputDocumentData['OUT_DOC_PDF_SECURITY_ENABLED'] == "0") {
|
|
|
|
|
$outputDocumentData['OUT_DOC_PDF_SECURITY_OPEN_PASSWORD'] = "";
|
|
|
|
|
$outputDocumentData['OUT_DOC_PDF_SECURITY_OWNER_PASSWORD'] = "";
|
|
|
|
|
$outputDocumentData['OUT_DOC_PDF_SECURITY_PERMISSIONS'] = "";
|
2013-12-13 16:36:03 -04:00
|
|
|
}
|
|
|
|
|
}
|
2014-04-30 13:00:01 -04:00
|
|
|
if (isset($outputDocumentData['OUT_DOC_CURRENT_REVISION'])) {
|
|
|
|
|
$oOutputDocument->setOutDocCurrentRevision($outputDocumentData['OUT_DOC_CURRENT_REVISION']);
|
2014-04-29 15:57:44 -04:00
|
|
|
} else {
|
|
|
|
|
$oOutputDocument->setOutDocCurrentRevision(0);
|
|
|
|
|
}
|
2014-04-30 13:00:01 -04:00
|
|
|
if (isset($outputDocumentData['OUT_DOC_FIELD_MAPPING'])) {
|
|
|
|
|
$oOutputDocument->setOutDocFieldMapping($outputDocumentData['OUT_DOC_FIELD_MAPPING']);
|
2014-04-29 15:57:44 -04:00
|
|
|
} else {
|
|
|
|
|
$oOutputDocument->setOutDocFieldMapping(null);
|
|
|
|
|
}
|
2014-04-30 13:00:01 -04:00
|
|
|
$outDocUid = $oOutputDocument->create($outputDocumentData);
|
|
|
|
|
$outputDocumentData = array_change_key_case($outputDocumentData, CASE_LOWER);
|
|
|
|
|
$this->updateOutputDocument($sProcessUID, $outputDocumentData, 1, $outDocUid);
|
2013-12-13 16:36:03 -04:00
|
|
|
//Return
|
2014-04-30 13:00:01 -04:00
|
|
|
unset($outputDocumentData["PRO_UID"]);
|
|
|
|
|
$outputDocumentData = array_change_key_case($outputDocumentData, CASE_LOWER);
|
|
|
|
|
$outputDocumentData["out_doc_uid"] = $outDocUid;
|
|
|
|
|
return $outputDocumentData;
|
2013-12-13 16:36:03 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update a output document for a project
|
|
|
|
|
* @param string $sProcessUID
|
2014-04-30 13:00:01 -04:00
|
|
|
* @param array $outputDocumentData
|
2014-01-29 13:09:08 -04:00
|
|
|
* @param string $sOutputDocumentUID
|
2014-03-28 10:13:26 -04:00
|
|
|
* @param int $sFlag
|
2013-12-13 16:36:03 -04:00
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*/
|
2014-04-30 13:00:01 -04:00
|
|
|
public function updateOutputDocument($sProcessUID, $outputDocumentData, $sFlag, $sOutputDocumentUID = '')
|
2014-01-15 14:54:27 -04:00
|
|
|
{
|
|
|
|
|
$oConnection = \Propel::getConnection(\OutputDocumentPeer::DATABASE_NAME);
|
2014-04-30 13:00:01 -04:00
|
|
|
$pemission = $outputDocumentData['out_doc_pdf_security_permissions'];
|
2014-01-15 14:54:27 -04:00
|
|
|
$pemission = explode("|", $pemission);
|
|
|
|
|
foreach ($pemission as $row) {
|
2014-01-16 09:35:11 -04:00
|
|
|
if ($row == "print" || $row == "modify" || $row == "copy" || $row == "forms" || $row == "") {
|
2014-04-30 13:00:01 -04:00
|
|
|
$outputDocumentData['out_doc_pdf_security_permissions'] = $outputDocumentData['out_doc_pdf_security_permissions'];
|
2014-01-15 14:54:27 -04:00
|
|
|
} else {
|
2014-05-22 09:12:35 -04:00
|
|
|
throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_FOR", array('out_doc_pdf_security_permissions')));
|
2014-01-15 14:54:27 -04:00
|
|
|
}
|
|
|
|
|
}
|
2013-12-13 16:36:03 -04:00
|
|
|
try {
|
|
|
|
|
$oOutputDocument = \OutputDocumentPeer::retrieveByPK($sOutputDocumentUID);
|
|
|
|
|
if (!is_null($oOutputDocument)) {
|
2015-09-30 18:52:19 -04:00
|
|
|
if (isset( $outputDocumentData['out_doc_pdf_security_open_password'] ) && $outputDocumentData['out_doc_pdf_security_open_password'] != "") {
|
|
|
|
|
$outputDocumentData['out_doc_pdf_security_open_password'] = \G::encrypt( $outputDocumentData['out_doc_pdf_security_open_password'], $sOutputDocumentUID);
|
|
|
|
|
$outputDocumentData['out_doc_pdf_security_owner_password'] = \G::encrypt( $outputDocumentData['out_doc_pdf_security_owner_password'], $sOutputDocumentUID);
|
|
|
|
|
}else{
|
|
|
|
|
unset($outputDocumentData['out_doc_pdf_security_open_password']);
|
|
|
|
|
unset($outputDocumentData['out_doc_pdf_security_owner_password']);
|
|
|
|
|
}
|
|
|
|
|
$outputDocumentData = array_change_key_case($outputDocumentData, CASE_UPPER);
|
2014-04-30 13:00:01 -04:00
|
|
|
$oOutputDocument->fromArray($outputDocumentData, \BasePeer::TYPE_FIELDNAME);
|
2013-12-13 16:36:03 -04:00
|
|
|
if ($oOutputDocument->validate()) {
|
|
|
|
|
$oConnection->begin();
|
2014-04-30 13:00:01 -04:00
|
|
|
if (isset($outputDocumentData['OUT_DOC_TITLE'])) {
|
|
|
|
|
$uid = $this->titleExists($sProcessUID, $outputDocumentData["OUT_DOC_TITLE"]);
|
2014-04-15 14:43:29 -04:00
|
|
|
if ($uid != '') {
|
2014-04-22 11:11:03 -04:00
|
|
|
if ($uid != $sOutputDocumentUID && $sFlag == 0) {
|
2014-04-15 14:43:29 -04:00
|
|
|
throw (new \Exception(\G::LoadTranslation("ID_OUTPUT_NOT_SAVE")));
|
|
|
|
|
}
|
2014-03-27 16:48:23 -04:00
|
|
|
}
|
2016-12-01 09:32:35 -05:00
|
|
|
$oOutputDocument->setOutDocTitleContent($outputDocumentData['OUT_DOC_TITLE']);
|
2013-12-13 16:36:03 -04:00
|
|
|
}
|
2014-04-30 13:00:01 -04:00
|
|
|
if (isset($outputDocumentData['OUT_DOC_DESCRIPTION'])) {
|
2016-12-01 09:32:35 -05:00
|
|
|
$oOutputDocument->setOutDocDescriptionContent($outputDocumentData['OUT_DOC_DESCRIPTION']);
|
2013-12-13 16:36:03 -04:00
|
|
|
}
|
2014-04-30 13:00:01 -04:00
|
|
|
if (isset($outputDocumentData['OUT_DOC_FILENAME'])) {
|
2016-12-01 09:32:35 -05:00
|
|
|
$oOutputDocument->setOutDocFilenameContent($outputDocumentData['OUT_DOC_FILENAME']);
|
2013-12-13 16:36:03 -04:00
|
|
|
}
|
2014-05-15 13:13:45 -04:00
|
|
|
if (isset($outputDocumentData['OUT_DOC_TEMPLATE'])) {
|
2015-04-10 13:01:56 -04:00
|
|
|
$outputDocumentData['OUT_DOC_TEMPLATE'] = stripslashes($outputDocumentData['OUT_DOC_TEMPLATE']);
|
|
|
|
|
$outputDocumentData['OUT_DOC_TEMPLATE'] = str_replace("@amp@", "&", $outputDocumentData['OUT_DOC_TEMPLATE']);
|
2014-05-15 13:13:45 -04:00
|
|
|
$oOutputDocument->setOutDocTemplate($outputDocumentData['OUT_DOC_TEMPLATE']);
|
2016-12-01 09:32:35 -05:00
|
|
|
$oOutputDocument->setOutDocTemplateContent($outputDocumentData['OUT_DOC_TEMPLATE']);
|
2014-05-15 13:13:45 -04:00
|
|
|
}
|
2014-04-29 15:57:44 -04:00
|
|
|
$oOutputDocument->save();
|
2013-12-13 16:36:03 -04:00
|
|
|
$oConnection->commit();
|
|
|
|
|
} else {
|
|
|
|
|
$sMessage = '';
|
|
|
|
|
$aValidationFailures = $oOutputDocument->getValidationFailures();
|
|
|
|
|
foreach ($aValidationFailures as $oValidationFailure) {
|
|
|
|
|
$sMessage .= $oValidationFailure->getMessage();
|
|
|
|
|
}
|
2014-05-22 09:12:35 -04:00
|
|
|
throw (new \Exception(\G::LoadTranslation("ID_REGISTRY_CANNOT_BE_UPDATED") . $sMessage));
|
2013-12-13 16:36:03 -04:00
|
|
|
}
|
|
|
|
|
} else {
|
2014-05-22 09:12:35 -04:00
|
|
|
throw new \Exception(\G::LoadTranslation("ID_ROW_DOES_NOT_EXIST"));
|
2013-12-13 16:36:03 -04:00
|
|
|
}
|
|
|
|
|
} catch (\Exception $e) {
|
2014-04-29 15:57:44 -04:00
|
|
|
throw $e;
|
2013-12-13 16:36:03 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delete a output document of a project
|
|
|
|
|
*
|
|
|
|
|
* @param string $sProcessUID
|
|
|
|
|
* @param string $sOutputDocumentUID
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
*/
|
|
|
|
|
public function deleteOutputDocument($sProcessUID, $sOutputDocumentUID)
|
2014-01-25 06:36:45 -04:00
|
|
|
{
|
2013-12-13 16:36:03 -04:00
|
|
|
try {
|
2017-02-14 21:24:08 +00:00
|
|
|
|
2014-07-01 11:33:37 -04:00
|
|
|
$this->throwExceptionIfItsAssignedInOtherObjects($sOutputDocumentUID, "outputDocumentUid");
|
2017-02-14 21:24:08 +00:00
|
|
|
|
2014-01-25 06:36:45 -04:00
|
|
|
$oOutputDocument = new \OutputDocument();
|
|
|
|
|
$fields = $oOutputDocument->load( $sOutputDocumentUID );
|
2013-12-13 16:36:03 -04:00
|
|
|
$oOutputDocument->remove( $sOutputDocumentUID );
|
|
|
|
|
$oStep = new \Step();
|
|
|
|
|
$oStep->removeStep( 'OUTPUT_DOCUMENT', $sOutputDocumentUID );
|
|
|
|
|
$oOP = new \ObjectPermission();
|
|
|
|
|
$oOP->removeByObject( 'OUTPUT', $sOutputDocumentUID );
|
|
|
|
|
//refresh dbarray with the last change in outputDocument
|
2017-08-04 16:21:06 -04:00
|
|
|
$oMap = new \ProcessMap();
|
2013-12-13 16:36:03 -04:00
|
|
|
$oCriteria = $oMap->getOutputDocumentsCriteria( $fields['PRO_UID'] );
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-01-21 12:14:14 -04:00
|
|
|
* Checks if the title exists in the OutputDocuments of Process
|
2013-12-13 16:36:03 -04:00
|
|
|
*
|
|
|
|
|
* @param string $processUid Unique id of Process
|
|
|
|
|
* @param string $title Title
|
|
|
|
|
*
|
2014-01-21 12:14:14 -04:00
|
|
|
* return bool Return true if the title exists in the OutputDocuments of Process, false otherwise
|
2013-12-13 16:36:03 -04:00
|
|
|
*/
|
|
|
|
|
public function existsTitle($processUid, $title)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$criteria = new \Criteria("workflow");
|
|
|
|
|
$criteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_UID);
|
2016-12-01 09:32:35 -05:00
|
|
|
$criteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_TITLE);
|
2013-12-13 16:36:03 -04:00
|
|
|
$criteria->add(\OutputDocumentPeer::PRO_UID, $processUid, \Criteria::EQUAL);
|
2016-12-01 09:32:35 -05:00
|
|
|
$criteria->add(\OutputDocumentPeer::OUT_DOC_TITLE, $title, \Criteria::EQUAL);
|
2014-01-25 06:36:45 -04:00
|
|
|
$rsCriteria = \OutputDocumentPeer::doSelectRS($criteria);
|
2013-12-13 16:36:03 -04:00
|
|
|
if ($rsCriteria->next()) {
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-04-15 14:43:29 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks if the title exists in the OutputDocuments of Process
|
|
|
|
|
*
|
|
|
|
|
* @param string $processUid Unique id of Process
|
|
|
|
|
* @param string $title Title
|
|
|
|
|
*
|
|
|
|
|
*/
|
2014-04-16 09:57:12 -04:00
|
|
|
public function titleExists($processUid, $title)
|
2014-04-15 14:43:29 -04:00
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$aResp = '';
|
|
|
|
|
$criteria = new \Criteria("workflow");
|
|
|
|
|
$criteria->addSelectColumn(\OutputDocumentPeer::OUT_DOC_UID);
|
|
|
|
|
$criteria->add(\OutputDocumentPeer::PRO_UID, $processUid, \Criteria::EQUAL);
|
2016-12-01 09:32:35 -05:00
|
|
|
$criteria->add(\OutputDocumentPeer::OUT_DOC_TITLE, $title, \Criteria::EQUAL);
|
2014-04-15 14:43:29 -04:00
|
|
|
$rsCriteria = \OutputDocumentPeer::doSelectRS($criteria);
|
|
|
|
|
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
$rsCriteria->next();
|
|
|
|
|
while ($aRow = $rsCriteria->getRow()) {
|
|
|
|
|
$aResp = $aRow['OUT_DOC_UID'];
|
|
|
|
|
$rsCriteria->next();
|
|
|
|
|
}
|
|
|
|
|
return $aResp;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-07-01 11:30:44 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Verify if the OutputDocument it's assigned in other objects
|
|
|
|
|
*
|
|
|
|
|
* @param string $outputDocumentUid Unique id of OutputDocument
|
|
|
|
|
*
|
|
|
|
|
* return array Return array (true if it's assigned or false otherwise and data)
|
|
|
|
|
*/
|
|
|
|
|
public function itsAssignedInOtherObjects($outputDocumentUid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$flagAssigned = false;
|
|
|
|
|
$arrayData = array();
|
|
|
|
|
//Step
|
|
|
|
|
$criteria = new \Criteria("workflow");
|
|
|
|
|
|
|
|
|
|
$criteria->addSelectColumn(\StepPeer::STEP_UID);
|
|
|
|
|
$criteria->add(\StepPeer::STEP_TYPE_OBJ, "OUTPUT_DOCUMENT", \Criteria::EQUAL);
|
|
|
|
|
$criteria->add(\StepPeer::STEP_UID_OBJ, $outputDocumentUid, \Criteria::EQUAL);
|
|
|
|
|
|
|
|
|
|
$rsCriteria = \StepPeer::doSelectRS($criteria);
|
|
|
|
|
|
|
|
|
|
if ($rsCriteria->next()) {
|
|
|
|
|
$flagAssigned = true;
|
|
|
|
|
$arrayData[] = \G::LoadTranslation("ID_STEPS");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//StepSupervisor
|
|
|
|
|
$criteria = new \Criteria("workflow");
|
|
|
|
|
|
|
|
|
|
$criteria->addSelectColumn(\StepSupervisorPeer::STEP_UID);
|
|
|
|
|
$criteria->add(\StepSupervisorPeer::STEP_TYPE_OBJ, "OUTPUT_DOCUMENT", \Criteria::EQUAL);
|
|
|
|
|
$criteria->add(\StepSupervisorPeer::STEP_UID_OBJ, $outputDocumentUid, \Criteria::EQUAL);
|
|
|
|
|
|
|
|
|
|
$rsCriteria = \StepSupervisorPeer::doSelectRS($criteria);
|
|
|
|
|
|
|
|
|
|
if ($rsCriteria->next()) {
|
|
|
|
|
$flagAssigned = true;
|
|
|
|
|
$arrayData[] = \G::LoadTranslation("ID_CASES_MENU_ADMIN");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//ObjectPermission
|
|
|
|
|
$criteria = new \Criteria("workflow");
|
|
|
|
|
|
|
|
|
|
$criteria->addSelectColumn(\ObjectPermissionPeer::OP_UID);
|
|
|
|
|
$criteria->add(\ObjectPermissionPeer::OP_OBJ_TYPE, "OUTPUT", \Criteria::EQUAL);
|
|
|
|
|
$criteria->add(\ObjectPermissionPeer::OP_OBJ_UID, $outputDocumentUid, \Criteria::EQUAL);
|
|
|
|
|
|
|
|
|
|
$rsCriteria = \ObjectPermissionPeer::doSelectRS($criteria);
|
|
|
|
|
|
|
|
|
|
if ($rsCriteria->next()) {
|
|
|
|
|
$flagAssigned = true;
|
|
|
|
|
$arrayData[] = \G::LoadTranslation("ID_PROCESS_PERMISSIONS");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Return
|
|
|
|
|
return array($flagAssigned, $arrayData);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Verify if the OutputDocument it's assigned in other objects
|
|
|
|
|
*
|
|
|
|
|
* @param string $outputDocumentUid Unique id of OutputDocument
|
|
|
|
|
* @param string $fieldNameForException Field name for the exception
|
|
|
|
|
*
|
|
|
|
|
* return void Throw exception if the OutputDocument it's assigned in other objects
|
|
|
|
|
*/
|
|
|
|
|
public function throwExceptionIfItsAssignedInOtherObjects($outputDocumentUid, $fieldNameForException)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
list($flagAssigned, $arrayData) = $this->itsAssignedInOtherObjects($outputDocumentUid);
|
|
|
|
|
|
|
|
|
|
if ($flagAssigned) {
|
|
|
|
|
throw new \Exception(\G::LoadTranslation("ID_OUTPUT_DOCUMENT_ITS_ASSIGNED", array($fieldNameForException, $outputDocumentUid, implode(", ", $arrayData))));
|
|
|
|
|
}
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-12-13 16:36:03 -04:00
|
|
|
}
|
|
|
|
|
|