BUG 6984 Fix Bug in Web entries in output documents & other PmFunction.
This commit is contained in:
@@ -393,11 +393,16 @@ function WSLogin($user, $pass, $endpoint='') {
|
|||||||
|
|
||||||
if($result->status_code == 0) {
|
if($result->status_code == 0) {
|
||||||
if($endpoint != '') {
|
if($endpoint != '') {
|
||||||
$_SESSION['WS_END_POINT'] = $endpoint;
|
if(isset($_SESSION['WS_SESSION_ID']))
|
||||||
|
$_SESSION['WS_END_POINT'] = $endpoint;
|
||||||
}
|
}
|
||||||
return $_SESSION['WS_SESSION_ID'] = $result->message;
|
if(isset($_SESSION['WS_SESSION_ID']))
|
||||||
|
return $_SESSION['WS_SESSION_ID'] = $result->message;
|
||||||
|
else
|
||||||
|
return $result->message;
|
||||||
} else {
|
} else {
|
||||||
unset($_SESSION['WS_SESSION_ID']);
|
if(isset($_SESSION['WS_SESSION_ID']))
|
||||||
|
unset($_SESSION['WS_SESSION_ID']);
|
||||||
$wp = (trim($pass) != "")?'YES':'NO';
|
$wp = (trim($pass) != "")?'YES':'NO';
|
||||||
throw new Exception("WSAccess denied! for user $user with password $wp");
|
throw new Exception("WSAccess denied! for user $user with password $wp");
|
||||||
}
|
}
|
||||||
@@ -1084,99 +1089,114 @@ function PMFUserList() #its test was successfull
|
|||||||
* @return none | $none | None | None
|
* @return none | $none | None | None
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function PMFGenerateOutputDocument($outputID) {
|
function PMFGenerateOutputDocument($outputID, $sApplication = null, $index = null, $sUserLogged = null) {
|
||||||
|
|
||||||
|
|
||||||
|
if(!$sApplication){
|
||||||
|
$sApplication = $_SESSION['APPLICATION'];
|
||||||
|
}
|
||||||
|
if(!$index){
|
||||||
|
$index = $_SESSION['INDEX'];
|
||||||
|
}
|
||||||
|
if(!$sUserLogged){
|
||||||
|
$sUserLogged = $_SESSION['USER_LOGGED'];
|
||||||
|
}
|
||||||
|
|
||||||
|
G::LoadClass('case');
|
||||||
$oCase = new Cases();
|
$oCase = new Cases();
|
||||||
$oCase->thisIsTheCurrentUser($_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], '', 'cases_List');
|
$oCase->thisIsTheCurrentUser($sApplication, $index, $sUserLogged, '', 'cases_List');
|
||||||
|
|
||||||
|
|
||||||
|
// require_once 'classes/model/OutputDocument.php';
|
||||||
$oOutputDocument = new OutputDocument();
|
$oOutputDocument = new OutputDocument();
|
||||||
$aOD = $oOutputDocument->load($outputID);
|
$aOD = $oOutputDocument->load($outputID);
|
||||||
$Fields = $oCase->loadCase( $_SESSION['APPLICATION'] );
|
$Fields = $oCase->loadCase( $sApplication );
|
||||||
// The $_GET['UID'] variable is used when a process executes.
|
// The $_GET['UID'] variable is used when a process executes.
|
||||||
// $_GET['UID']=($aOD['OUT_DOC_VERSIONING'])?$_GET['UID']:$aOD['OUT_DOC_UID'];
|
// $_GET['UID']=($aOD['OUT_DOC_VERSIONING'])?$_GET['UID']:$aOD['OUT_DOC_UID'];
|
||||||
$sUID = ($aOD['OUT_DOC_VERSIONING'])?$_GET['UID']:$aOD['OUT_DOC_UID'];
|
$sUID = ($aOD['OUT_DOC_VERSIONING'])?$_GET['UID']:$aOD['OUT_DOC_UID'];
|
||||||
$sFilename = preg_replace('[^A-Za-z0-9_]', '_', G::replaceDataField($aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA']));
|
$sFilename = preg_replace('[^A-Za-z0-9_]', '_', G::replaceDataField($aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA']));
|
||||||
require_once 'classes/model/AppFolder.php';
|
require_once 'classes/model/AppFolder.php';
|
||||||
require_once 'classes/model/AppDocument.php';
|
require_once 'classes/model/AppDocument.php';
|
||||||
|
|
||||||
//Get the Custom Folder ID (create if necessary)
|
//Get the Custom Folder ID (create if necessary)
|
||||||
$oFolder=new AppFolder();
|
$oFolder=new AppFolder();
|
||||||
//$aOD['OUT_DOC_DESTINATION_PATH'] = ($aOD['OUT_DOC_DESTINATION_PATH']=='')?PATH_DOCUMENT . $_SESSION['APPLICATION'] . PATH_SEP . 'outdocs'. PATH_SEP:$aOD['OUT_DOC_DESTINATION_PATH'];
|
//$aOD['OUT_DOC_DESTINATION_PATH'] = ($aOD['OUT_DOC_DESTINATION_PATH']=='')?PATH_DOCUMENT . $_SESSION['APPLICATION'] . PATH_SEP . 'outdocs'. PATH_SEP:$aOD['OUT_DOC_DESTINATION_PATH'];
|
||||||
$folderId=$oFolder->createFromPath($aOD['OUT_DOC_DESTINATION_PATH']);
|
$folderId=$oFolder->createFromPath($aOD['OUT_DOC_DESTINATION_PATH'], $sApplication);
|
||||||
//Tags
|
//Tags
|
||||||
$fileTags=$oFolder->parseTags($aOD['OUT_DOC_TAGS']);
|
$fileTags=$oFolder->parseTags($aOD['OUT_DOC_TAGS'], $sApplication);
|
||||||
|
|
||||||
//Get last Document Version and apply versioning if is enabled
|
//Get last Document Version and apply versioning if is enabled
|
||||||
|
|
||||||
$oAppDocument= new AppDocument();
|
$oAppDocument= new AppDocument();
|
||||||
$lastDocVersion=$oAppDocument->getLastDocVersion($sUID, $_SESSION['APPLICATION']);
|
$lastDocVersion=$oAppDocument->getLastDocVersion($sUID, $sApplication);
|
||||||
|
|
||||||
$oCriteria = new Criteria('workflow');
|
$oCriteria = new Criteria('workflow');
|
||||||
$oCriteria->add(AppDocumentPeer::APP_UID, $_SESSION['APPLICATION']);
|
$oCriteria->add(AppDocumentPeer::APP_UID, $sApplication);
|
||||||
//$oCriteria->add(AppDocumentPeer::DEL_INDEX, $_SESSION['INDEX']);
|
//$oCriteria->add(AppDocumentPeer::DEL_INDEX, $index);
|
||||||
$oCriteria->add(AppDocumentPeer::DOC_UID, $sUID);
|
$oCriteria->add(AppDocumentPeer::DOC_UID, $sUID);
|
||||||
$oCriteria->add(AppDocumentPeer::DOC_VERSION, $lastDocVersion);
|
$oCriteria->add(AppDocumentPeer::DOC_VERSION, $lastDocVersion);
|
||||||
$oCriteria->add(AppDocumentPeer::APP_DOC_TYPE, 'OUTPUT');
|
$oCriteria->add(AppDocumentPeer::APP_DOC_TYPE, 'OUTPUT');
|
||||||
$oDataset = AppDocumentPeer::doSelectRS($oCriteria);
|
$oDataset = AppDocumentPeer::doSelectRS($oCriteria);
|
||||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||||
$oDataset->next();
|
$oDataset->next();
|
||||||
|
|
||||||
if(($aOD['OUT_DOC_VERSIONING'])&&($lastDocVersion!=0)){//Create new Version of current output
|
if(($aOD['OUT_DOC_VERSIONING'])&&($lastDocVersion!=0)){//Create new Version of current output
|
||||||
$lastDocVersion++;
|
$lastDocVersion++;
|
||||||
if ($aRow = $oDataset->getRow()) {
|
if ($aRow = $oDataset->getRow()) {
|
||||||
$aFields = array('APP_DOC_UID' => $aRow['APP_DOC_UID'],
|
$aFields = array('APP_DOC_UID' => $aRow['APP_DOC_UID'],
|
||||||
'APP_UID' => $_SESSION['APPLICATION'],
|
'APP_UID' => $sApplication,
|
||||||
'DEL_INDEX' => $_SESSION['INDEX'],
|
'DEL_INDEX' => $index,
|
||||||
'DOC_UID' => $outputID,
|
'DOC_UID' => $outputID,
|
||||||
'DOC_VERSION' => $lastDocVersion+1,
|
'DOC_VERSION' => $lastDocVersion+1,
|
||||||
'USR_UID' => $_SESSION['USER_LOGGED'],
|
'USR_UID' => $sUserLogged,
|
||||||
'APP_DOC_TYPE' => 'OUTPUT',
|
'APP_DOC_TYPE' => 'OUTPUT',
|
||||||
'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'),
|
'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'),
|
||||||
'APP_DOC_FILENAME' => $sFilename,
|
'APP_DOC_FILENAME' => $sFilename,
|
||||||
'FOLDER_UID' => $folderId,
|
'FOLDER_UID' => $folderId,
|
||||||
'APP_DOC_TAGS' => $fileTags);
|
'APP_DOC_TAGS' => $fileTags);
|
||||||
$oAppDocument = new AppDocument();
|
$oAppDocument = new AppDocument();
|
||||||
$oAppDocument->create($aFields);
|
$oAppDocument->create($aFields);
|
||||||
$sDocUID = $aRow['APP_DOC_UID'];
|
$sDocUID = $aRow['APP_DOC_UID'];
|
||||||
}
|
}
|
||||||
}else{//No versioning so Update a current Output or Create new if no exist
|
}else{//No versioning so Update a current Output or Create new if no exist
|
||||||
if ($aRow = $oDataset->getRow()) { //Update
|
if ($aRow = $oDataset->getRow()) { //Update
|
||||||
$aFields = array('APP_DOC_UID' => $aRow['APP_DOC_UID'],
|
$aFields = array('APP_DOC_UID' => $aRow['APP_DOC_UID'],
|
||||||
'APP_UID' => $_SESSION['APPLICATION'],
|
'APP_UID' => $sApplication,
|
||||||
'DEL_INDEX' => $_SESSION['INDEX'],
|
'DEL_INDEX' => $index,
|
||||||
'DOC_UID' => $outputID,
|
'DOC_UID' => $outputID,
|
||||||
'DOC_VERSION' => $lastDocVersion,
|
'DOC_VERSION' => $lastDocVersion,
|
||||||
'USR_UID' => $_SESSION['USER_LOGGED'],
|
'USR_UID' => $sUserLogged,
|
||||||
'APP_DOC_TYPE' => 'OUTPUT',
|
'APP_DOC_TYPE' => 'OUTPUT',
|
||||||
'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'),
|
'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'),
|
||||||
'APP_DOC_FILENAME' => $sFilename,
|
'APP_DOC_FILENAME' => $sFilename,
|
||||||
'FOLDER_UID' => $folderId,
|
'FOLDER_UID' => $folderId,
|
||||||
'APP_DOC_TAGS' => $fileTags);
|
'APP_DOC_TAGS' => $fileTags);
|
||||||
$oAppDocument = new AppDocument();
|
$oAppDocument = new AppDocument();
|
||||||
$oAppDocument->update($aFields);
|
$oAppDocument->update($aFields);
|
||||||
$sDocUID = $aRow['APP_DOC_UID'];
|
$sDocUID = $aRow['APP_DOC_UID'];
|
||||||
}else{
|
}else{
|
||||||
//we are creating the appdocument row
|
//we are creating the appdocument row
|
||||||
//create
|
//create
|
||||||
if($lastDocVersion==0) $lastDocVersion++;
|
if($lastDocVersion==0) $lastDocVersion++;
|
||||||
$aFields = array('APP_UID' => $_SESSION['APPLICATION'],
|
$aFields = array('APP_UID' => $sApplication,
|
||||||
'DEL_INDEX' => $_SESSION['INDEX'],
|
'DEL_INDEX' => $index,
|
||||||
'DOC_UID' => $outputID,
|
'DOC_UID' => $outputID,
|
||||||
'DOC_VERSION' => $lastDocVersion,
|
'DOC_VERSION' => $lastDocVersion,
|
||||||
'USR_UID' => $_SESSION['USER_LOGGED'],
|
'USR_UID' => $sUserLogged,
|
||||||
'APP_DOC_TYPE' => 'OUTPUT',
|
'APP_DOC_TYPE' => 'OUTPUT',
|
||||||
'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'),
|
'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'),
|
||||||
'APP_DOC_FILENAME' => $sFilename,
|
'APP_DOC_FILENAME' => $sFilename,
|
||||||
'FOLDER_UID' => $folderId,
|
'FOLDER_UID' => $folderId,
|
||||||
'APP_DOC_TAGS' => $fileTags);
|
'APP_DOC_TAGS' => $fileTags);
|
||||||
$oAppDocument = new AppDocument();
|
$oAppDocument = new AppDocument();
|
||||||
$aFields['APP_DOC_UID']=$sDocUID = $oAppDocument->create($aFields);
|
$aFields['APP_DOC_UID']=$sDocUID = $oAppDocument->create($aFields);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sFilename = $aFields['APP_DOC_UID']. "_".$lastDocVersion;
|
$sFilename = $aFields['APP_DOC_UID']. "_".$lastDocVersion;
|
||||||
|
|
||||||
$pathOutput = PATH_DOCUMENT . $_SESSION['APPLICATION'] . PATH_SEP . 'outdocs'. PATH_SEP ;//G::pr($sFilename);die;
|
$pathOutput = PATH_DOCUMENT . $sApplication . PATH_SEP . 'outdocs'. PATH_SEP ;//G::pr($sFilename);die;
|
||||||
G::mk_dir ( $pathOutput );
|
G::mk_dir ( $pathOutput );
|
||||||
|
|
||||||
$aProperties = array();
|
$aProperties = array();
|
||||||
|
|
||||||
if(!isset($aOD['OUT_DOC_MEDIA']))
|
if(!isset($aOD['OUT_DOC_MEDIA']))
|
||||||
@@ -1195,6 +1215,7 @@ function PMFGenerateOutputDocument($outputID) {
|
|||||||
$oOutputDocument->generate( $outputID, $Fields['APP_DATA'], $pathOutput, $sFilename, $aOD['OUT_DOC_TEMPLATE'], (boolean)$aOD['OUT_DOC_LANDSCAPE'], $aOD['OUT_DOC_GENERATE'] );
|
$oOutputDocument->generate( $outputID, $Fields['APP_DATA'], $pathOutput, $sFilename, $aOD['OUT_DOC_TEMPLATE'], (boolean)$aOD['OUT_DOC_LANDSCAPE'], $aOD['OUT_DOC_GENERATE'] );
|
||||||
|
|
||||||
//Plugin Hook PM_UPLOAD_DOCUMENT for upload document
|
//Plugin Hook PM_UPLOAD_DOCUMENT for upload document
|
||||||
|
// G::LoadClass('plugin');
|
||||||
$oPluginRegistry =& PMPluginRegistry::getSingleton();
|
$oPluginRegistry =& PMPluginRegistry::getSingleton();
|
||||||
if ( $oPluginRegistry->existsTrigger ( PM_UPLOAD_DOCUMENT ) && class_exists ('uploadDocumentData' ) ) {
|
if ( $oPluginRegistry->existsTrigger ( PM_UPLOAD_DOCUMENT ) && class_exists ('uploadDocumentData' ) ) {
|
||||||
$triggerDetail=$oPluginRegistry->getTriggerInfo( PM_UPLOAD_DOCUMENT );
|
$triggerDetail=$oPluginRegistry->getTriggerInfo( PM_UPLOAD_DOCUMENT );
|
||||||
@@ -1203,15 +1224,15 @@ function PMFGenerateOutputDocument($outputID) {
|
|||||||
$oAppDocument1 = new AppDocument();
|
$oAppDocument1 = new AppDocument();
|
||||||
$oAppDocument1->update($aFields);
|
$oAppDocument1->update($aFields);
|
||||||
|
|
||||||
$sPathName = PATH_DOCUMENT . $_SESSION['APPLICATION'] . PATH_SEP;
|
$sPathName = PATH_DOCUMENT . $sApplication . PATH_SEP;
|
||||||
|
|
||||||
$oData['APP_UID'] = $_SESSION['APPLICATION'];
|
$oData['APP_UID'] = $sApplication;
|
||||||
$oData['ATTACHMENT_FOLDER'] = true;
|
$oData['ATTACHMENT_FOLDER'] = true;
|
||||||
switch($aOD['OUT_DOC_GENERATE']){
|
switch($aOD['OUT_DOC_GENERATE']){
|
||||||
case "BOTH":
|
case "BOTH":
|
||||||
$documentData = new uploadDocumentData (
|
$documentData = new uploadDocumentData (
|
||||||
$_SESSION['APPLICATION'],
|
$sApplication,
|
||||||
$_SESSION['USER_LOGGED'],
|
$sUserLogged,
|
||||||
$pathOutput . $sFilename . '.pdf',
|
$pathOutput . $sFilename . '.pdf',
|
||||||
$sFilename. '.pdf',
|
$sFilename. '.pdf',
|
||||||
$sDocUID,
|
$sDocUID,
|
||||||
@@ -1228,8 +1249,8 @@ function PMFGenerateOutputDocument($outputID) {
|
|||||||
|
|
||||||
|
|
||||||
$documentData = new uploadDocumentData (
|
$documentData = new uploadDocumentData (
|
||||||
$_SESSION['APPLICATION'],
|
$sApplication,
|
||||||
$_SESSION['USER_LOGGED'],
|
$sUserLogged,
|
||||||
$pathOutput . $sFilename . '.doc',
|
$pathOutput . $sFilename . '.doc',
|
||||||
$sFilename. '.doc',
|
$sFilename. '.doc',
|
||||||
$sDocUID,
|
$sDocUID,
|
||||||
@@ -1246,8 +1267,8 @@ function PMFGenerateOutputDocument($outputID) {
|
|||||||
break;
|
break;
|
||||||
case "PDF":
|
case "PDF":
|
||||||
$documentData = new uploadDocumentData (
|
$documentData = new uploadDocumentData (
|
||||||
$_SESSION['APPLICATION'],
|
$sApplication,
|
||||||
$_SESSION['USER_LOGGED'],
|
$sUserLogged,
|
||||||
$pathOutput . $sFilename . '.pdf',
|
$pathOutput . $sFilename . '.pdf',
|
||||||
$sFilename. '.pdf',
|
$sFilename. '.pdf',
|
||||||
$sDocUID,
|
$sDocUID,
|
||||||
@@ -1264,8 +1285,8 @@ function PMFGenerateOutputDocument($outputID) {
|
|||||||
break;
|
break;
|
||||||
case "DOC":
|
case "DOC":
|
||||||
$documentData = new uploadDocumentData (
|
$documentData = new uploadDocumentData (
|
||||||
$_SESSION['APPLICATION'],
|
$sApplication,
|
||||||
$_SESSION['USER_LOGGED'],
|
$sUserLogged,
|
||||||
$pathOutput . $sFilename . '.doc',
|
$pathOutput . $sFilename . '.doc',
|
||||||
$sFilename. '.doc',
|
$sFilename. '.doc',
|
||||||
$sDocUID,
|
$sDocUID,
|
||||||
@@ -1283,7 +1304,7 @@ function PMFGenerateOutputDocument($outputID) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @method
|
* @method
|
||||||
*
|
*
|
||||||
@@ -1431,10 +1452,13 @@ function PMFSendVariables($caseId, $variables) {
|
|||||||
* @return int | $result | Result of Derivate case | Returns 1 if new case was derivated (routed) successfully; otherwise, returns 0 if an error occurred.
|
* @return int | $result | Result of Derivate case | Returns 1 if new case was derivated (routed) successfully; otherwise, returns 0 if an error occurred.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function PMFDerivateCase($caseId, $delIndex, $bExecuteTriggersBeforeAssignment = false) {
|
function PMFDerivateCase($caseId, $delIndex, $bExecuteTriggersBeforeAssignment = false, $sUserLogged = null) {
|
||||||
|
if(!$sUserLogged) {
|
||||||
|
$sUserLogged = $_SESSION['USER_LOGGED'];
|
||||||
|
}
|
||||||
G::LoadClass('wsBase');
|
G::LoadClass('wsBase');
|
||||||
$ws = new wsBase ();
|
$ws = new wsBase ();
|
||||||
$result = $ws->derivateCase($_SESSION['USER_LOGGED'], $caseId, $delIndex, $bExecuteTriggersBeforeAssignment);//var_dump($result);die;
|
$result = $ws->derivateCase($sUserLogged, $caseId, $delIndex, $bExecuteTriggersBeforeAssignment);//var_dump($result);die;
|
||||||
if (isset($result->status_code)) {
|
if (isset($result->status_code)) {
|
||||||
return $result->status_code;
|
return $result->status_code;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user