BUG 0000 Adjustment for the standardization of code. CODE_STYLE

This commit is contained in:
Hector Cortez
2013-03-05 09:12:44 -04:00
parent 782300f92c
commit 3fe55aa94f
4 changed files with 400 additions and 384 deletions

View File

@@ -23,7 +23,6 @@
* @icon /images/triggers/alfrescoIcon.png
* @className class.pmTrAlfresco.pmFunctions.php
*/
/**
* @method
*
@@ -41,14 +40,16 @@
*
*/
G::LoadSystem('restClient');
// Validation left
function cancelCheckout($alfrescoServerUrl, $docUid, $user="", $pwd="") {
//require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrAlfresco.php');
$alfresco_url = "$alfrescoServerUrl/s/cmis/pwc/s/workspace:SpacesStore/i/$docUid";
$domapi_exec = RestClient::delete($alfresco_url,$user,$pwd,"application/atom+xml;type=entry");
//$alfrescoMessage = $domapi_exec['header'];
$domapi_res = G::json_decode($domapi_exec->getResponse());
return $domapi_res;
function cancelCheckout($alfrescoServerUrl, $docUid, $user = "", $pwd = "")
{
//require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrAlfresco.php');
$alfresco_url = "$alfrescoServerUrl/s/cmis/pwc/s/workspace:SpacesStore/i/$docUid";
$domapi_exec = RestClient::delete($alfresco_url, $user, $pwd, "application/atom+xml;type=entry");
//$alfrescoMessage = $domapi_exec['header'];
$domapi_res = G::json_decode($domapi_exec->getResponse());
return $domapi_res;
}
/**
@@ -69,22 +70,23 @@ return $domapi_res;
*
*/
// Validation done
function checkIn($alfrescoServerUrl, $docUid, $comments, $user="", $pwd="") {
$alfresco_url = "$alfrescoServerUrl/s/cmis/pwc/i/$docUid?checkin=true&checkinComment=$comments";
$xmlData = array();
$xmlData = '<?xml version="1.0" encoding="utf-8"?><entry xmlns="http://www.w3.org/2005/Atom"/>';
function checkIn($alfrescoServerUrl, $docUid, $comments, $user = "", $pwd = "")
{
$alfresco_url = "$alfrescoServerUrl/s/cmis/pwc/i/$docUid?checkin=true&checkinComment=$comments";
$xmlData = array();
$xmlData = '<?xml version="1.0" encoding="utf-8"?><entry xmlns="http://www.w3.org/2005/Atom"/>';
$alfresco_exec = RestClient::put($alfresco_url,$xmlData,$user,$pwd,"application/atom+xml");
$alfrescoMessage = $alfresco_exec->getResponseMessage();
if($alfrescoMessage === 'OK' )
return "The Document has been Checkedin";
elseif ($alfrescoMessage === 'Internal Server Error')
$alfresco_exec = RestClient::put($alfresco_url, $xmlData, $user, $pwd, "application/atom+xml");
$alfrescoMessage = $alfresco_exec->getResponseMessage();
if ($alfrescoMessage === 'OK') {
return "The Document has been Checkedin";
} elseif ($alfrescoMessage === 'Internal Server Error') {
return "Please enter a Valid Document Id";
else
return $alfrescoMessage;
} else {
return $alfrescoMessage;
}
}
/**
* @method
*
@@ -102,19 +104,21 @@ return $alfrescoMessage;
*
*/
// Validation done
function checkOut($alfrescoServerUrl, $docUid, $user="", $pwd="") {
$alfresco_url = "$alfrescoServerUrl/s/cmis/checkedout";
$xmlData = array();
$xmlData = '<?xml version="1.0" encoding="utf-8"?>'.'<entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/">'.'<cmisra:object>'.'<cmis:properties>'.'<cmis:propertyId propertyDefinitionId="cmis:objectId">'.'<cmis:value>workspace://SpacesStore/'.$docUid.'</cmis:value>'.'</cmis:propertyId>'.'</cmis:properties>'.'</cmisra:object>'.'</entry>';
function checkOut($alfrescoServerUrl, $docUid, $user = "", $pwd = "")
{
$alfresco_url = "$alfrescoServerUrl/s/cmis/checkedout";
$xmlData = array();
$xmlData = '<?xml version="1.0" encoding="utf-8"?>' . '<entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/">' . '<cmisra:object>' . '<cmis:properties>' . '<cmis:propertyId propertyDefinitionId="cmis:objectId">' . '<cmis:value>workspace://SpacesStore/' . $docUid . '</cmis:value>' . '</cmis:propertyId>' . '</cmis:properties>' . '</cmisra:object>' . '</entry>';
$alfresco_exec = RestClient::post($alfresco_url,$xmlData,$user,$pwd,"application/atom+xml;type=entry");
$alfrescoMessage = $alfresco_exec->getResponseMessage();
if($alfrescoMessage === 'Created' )
return "The Document has been Checkedout";
elseif ($alfrescoMessage === 'Conflict')
$alfresco_exec = RestClient::post($alfresco_url, $xmlData, $user, $pwd, "application/atom+xml;type=entry");
$alfrescoMessage = $alfresco_exec->getResponseMessage();
if ($alfrescoMessage === 'Created') {
return "The Document has been Checkedout";
} elseif ($alfrescoMessage === 'Conflict') {
return "The Document you are trying to checkout has already been Checkedout";
else
return $alfrescoMessage;
} else {
return $alfrescoMessage;
}
}
/**
@@ -134,22 +138,23 @@ return $alfrescoMessage;
* @return string | $result | Response
*
*/
function createFolder($alfrescoServerUrl, $parentFolder, $folderName, $user, $pwd) {
function createFolder($alfrescoServerUrl, $parentFolder, $folderName, $user, $pwd)
{
$name = explode("/", $folderName);
$init = substr($parentFolder,0,1);
$parentFolder = ($init == "/")? substr($parentFolder, 1)."/": $parentFolder."/";
$alfresco_url = "$alfrescoServerUrl/s/cmis/p/".$parentFolder."children";
$init = substr($parentFolder, 0, 1);
$parentFolder = ($init == "/") ? substr($parentFolder, 1) . "/" : $parentFolder . "/";
$alfresco_url = "$alfrescoServerUrl/s/cmis/p/" . $parentFolder . "children";
$xmlData = array();
$xmlData = '<?xml version="1.0" encoding="utf-8"?>'.'<entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/">'.'<title>'.$name[0].'</title>'.'<cmisra:object>'.'<cmis:properties>'.'<cmis:propertyId propertyDefinitionId="cmis:objectTypeId"><cmis:value>cmis:folder</cmis:value></cmis:propertyId>'.'</cmis:properties>'.'</cmisra:object>'.'</entry>';
$alfresco_exec = RestClient::post($alfresco_url,$xmlData,$user,$pwd,"application/atom+xml");
$xmlData = '<?xml version="1.0" encoding="utf-8"?>' . '<entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/">' . '<title>' . $name[0] . '</title>' . '<cmisra:object>' . '<cmis:properties>' . '<cmis:propertyId propertyDefinitionId="cmis:objectTypeId"><cmis:value>cmis:folder</cmis:value></cmis:propertyId>' . '</cmis:properties>' . '</cmisra:object>' . '</entry>';
$alfresco_exec = RestClient::post($alfresco_url, $xmlData, $user, $pwd, "application/atom+xml");
$alfrescoMessage = $alfresco_exec->getResponseMessage();
$folderName = substr(strstr($folderName, "/"),1);
$parentFolder = $parentFolder."".$name[0];
$folderName = substr(strstr($folderName, "/"), 1);
$parentFolder = $parentFolder . "" . $name[0];
if ($folderName != null) {
createFolder($alfrescoServerUrl, $parentFolder, $folderName, $user, $pwd);
}
if($alfrescoMessage === 'Created') {
if ($alfrescoMessage === 'Created') {
return "The Folder has been Created";
} else {
return $alfrescoMessage;
@@ -172,9 +177,10 @@ function createFolder($alfrescoServerUrl, $parentFolder, $folderName, $user, $pw
* @return string | $result | Response
*
*/
function deleteObject($alfrescoServerUrl, $objetcId, $user, $pwd) {
$alfresco_url = "$alfrescoServerUrl/s/cmis/s/workspace:SpacesStore/i/$objetcId";
$alfresco_exec = RestClient::delete($alfresco_url,$user,$pwd,"application/atom+xml");
function deleteObject($alfrescoServerUrl, $objetcId, $user, $pwd)
{
$alfresco_url = "$alfrescoServerUrl/s/cmis/s/workspace:SpacesStore/i/$objetcId";
$alfresco_exec = RestClient::delete($alfresco_url, $user, $pwd, "application/atom+xml");
$alfresco_res = G::json_decode($alfresco_exec->getResponse());
echo($alfresco_res);
@@ -198,10 +204,11 @@ function deleteObject($alfrescoServerUrl, $objetcId, $user, $pwd) {
* @return string | $result | Response
*
*/
function downloadDoc($alfrescoServerUrl, $pathFile , $pathFolder, $user, $pwd) {
function downloadDoc($alfrescoServerUrl, $pathFile, $pathFolder, $user, $pwd)
{
if (!(G::verifyPath($pathFolder))) {
G::SendTemporalMessage('ID_FILE_PLUGIN_NOT_EXISTS', 'error', 'labels', null, null, array('pluginFile' => $pathFolder));
G::header('Location: '.$_SERVER['HTTP_REFERER']);
G::header('Location: ' . $_SERVER['HTTP_REFERER']);
die;
}
@@ -209,22 +216,22 @@ function downloadDoc($alfrescoServerUrl, $pathFile , $pathFolder, $user, $pwd) {
$nameFile = $dataPathFile['basename'];
$alfresco_url = "$alfrescoServerUrl" . PATH_SEP . "s" . PATH_SEP . "cmis" . PATH_SEP . "p" . PATH_SEP . "Sites" . PATH_SEP . "$pathFile";
$alfresco_exec = RestClient::get($alfresco_url,$user,$pwd,'application/atom+xml');
$alfresco_exec = RestClient::get($alfresco_url, $user, $pwd, 'application/atom+xml');
$sXmlArray = $alfresco_exec->getResponse();
$sXmlArray = eregi_replace("[\n|\r|\n\r]", '', $sXmlArray);
$xmlObject = simplexml_load_string((string)$sXmlArray);
$xmlObject = simplexml_load_string((string) $sXmlArray);
if (!isset($xmlObject->content)) {
G::SendTemporalMessage('ID_FILE_PLUGIN_NOT_EXISTS', 'error', 'labels', null, null, array('pluginFile' => $nameFile . ' in Alfresco'));
G::header('Location: '.$_SERVER['HTTP_REFERER']);
G::header('Location: ' . $_SERVER['HTTP_REFERER']);
die;
}
$linkContent = (string)$xmlObject->content->attributes()->src;
$alfresco_exec = RestClient::get($linkContent,$user,$pwd,'application/atom+xml');
$linkContent = (string) $xmlObject->content->attributes()->src;
$alfresco_exec = RestClient::get($linkContent, $user, $pwd, 'application/atom+xml');
$sXmlArray = $alfresco_exec->getResponse();
$content = eregi_replace("[\n|\r|\n\r]", '', $sXmlArray);
if ('/' != substr($pathFolder, -1)) {
$pathFolder .= '/';
}
@@ -250,16 +257,17 @@ function downloadDoc($alfrescoServerUrl, $pathFile , $pathFolder, $user, $pwd) {
* @return string | $result | Response
*
*/
function getCheckedoutFiles($alfrescoServerUrl, $user, $pwd) {
$getChildrenUrl = "$alfrescoServerUrl/s/cmis/checkedout";
function getCheckedoutFiles($alfrescoServerUrl, $user, $pwd)
{
$getChildrenUrl = "$alfrescoServerUrl/s/cmis/checkedout";
$domapi_exec = RestClient::get($getChildrenUrl,$user,$pwd,'application/atom+xml');
$sXmlArray = G::json_decode($domapi_exec->getResponse());
$sXmlArray = trim($sXmlArray);
$xXmlArray = simplexml_load_string($sXmlArray);
$aXmlArray = @G::json_decode(@G::json_encode($xXmlArray),1);
$domapi_exec = RestClient::get($getChildrenUrl, $user, $pwd, 'application/atom+xml');
$sXmlArray = G::json_decode($domapi_exec->getResponse());
$sXmlArray = trim($sXmlArray);
$xXmlArray = simplexml_load_string($sXmlArray);
$aXmlArray = @G::json_decode(@G::json_encode($xXmlArray), 1);
return $alfresco_res;
return $alfresco_res;
}
/**
@@ -278,13 +286,14 @@ function getCheckedoutFiles($alfrescoServerUrl, $user, $pwd) {
* @return string | $result | Response
*
*/
function getFolderChildren($alfrescoServerUrl, $folderId, $user, $pwd) {
function getFolderChildren($alfrescoServerUrl, $folderId, $user, $pwd)
{
$getChildrenUrl = "$alfrescoServerUrl/service/api/node/workspace/SpacesStore/$folderId/children";
$alfresco_exec = RestClient::get($getChildrenUrl,$user,$pwd);
$alfresco_exec = RestClient::get($getChildrenUrl, $user, $pwd);
$sXmlArray = $alfresco_exec->getResponse();
$sXmlArray = trim($sXmlArray);
$xXmlArray = simplexml_load_string($sXmlArray);
$aXmlArray = @G::json_decode(@G::json_encode($xXmlArray),1);
$aXmlArray = @G::json_decode(@G::json_encode($xXmlArray), 1);
return $aXmlArray;
}
@@ -309,18 +318,18 @@ function getFolderChildren($alfrescoServerUrl, $folderId, $user, $pwd) {
* @return string | $result | Response
*
*/
function uploadDoc($alfrescoServerUrl, $fileSource, $title, $description, $docType, $user, $pwd, $path = '') {
if (!(file_exists($fileSource)))
{
function uploadDoc($alfrescoServerUrl, $fileSource, $title, $description, $docType, $user, $pwd, $path = '')
{
if (!(file_exists($fileSource))) {
G::SendTemporalMessage('ID_FILE_PLUGIN_NOT_EXISTS', 'error', 'labels', null, null, array('pluginFile' => $fileSource));
G::header('Location: '.$_SERVER['HTTP_REFERER']);
G::header('Location: ' . $_SERVER['HTTP_REFERER']);
die;
}
$filep = fopen($fileSource,"r");
$fileLength = filesize($fileSource);
$fileContent = fread($filep,$fileLength);
$fileContent = base64_encode($fileContent);
$filep = fopen($fileSource, "r");
$fileLength = filesize($fileSource);
$fileContent = fread($filep, $fileLength);
$fileContent = base64_encode($fileContent);
if ($path != '') {
createFolder($alfrescoServerUrl, 'Sites', $path, $user, $pwd);
$path = $path . PATH_SEP;
@@ -328,13 +337,14 @@ function uploadDoc($alfrescoServerUrl, $fileSource, $title, $description, $docTy
$alfresco_url = "$alfrescoServerUrl/s/cmis/p/Sites/" . $path . "children";
$xmlData = array();
$xmlData = '<?xml version="1.0" encoding="utf-8"?><entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/"><title>'.$title.'</title><summary>'.$description.'</summary><content type="application/'.$docType.'">'.$fileContent.'</content><cmisra:object><cmis:properties><cmis:propertyId propertyDefinitionId="cmis:objectTypeId"><cmis:value>cmis:document</cmis:value></cmis:propertyId></cmis:properties></cmisra:object></entry>';
$xmlData = '<?xml version="1.0" encoding="utf-8"?><entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/"><title>' . $title . '</title><summary>' . $description . '</summary><content type="application/' . $docType . '">' . $fileContent . '</content><cmisra:object><cmis:properties><cmis:propertyId propertyDefinitionId="cmis:objectTypeId"><cmis:value>cmis:document</cmis:value></cmis:propertyId></cmis:properties></cmisra:object></entry>';
$alfresco_exec = RestClient::post($alfresco_url,$xmlData,$user,$pwd,"application/atom+xml");
$sXmlArray = $alfresco_exec->getResponse();
$sXmlArray = trim($sXmlArray);
$xXmlArray = simplexml_load_string($sXmlArray);
$aXmlArray = @G::json_decode(@G::json_encode($xXmlArray),1);
$alfresco_exec = RestClient::post($alfresco_url, $xmlData, $user, $pwd, "application/atom+xml");
$sXmlArray = $alfresco_exec->getResponse();
$sXmlArray = trim($sXmlArray);
$xXmlArray = simplexml_load_string($sXmlArray);
$aXmlArray = @G::json_decode(@G::json_encode($xXmlArray), 1);
return $aXmlArray;
}
}

View File

@@ -1,4 +1,5 @@
<?php
/**
* cases_SaveDocument.php
*
@@ -22,144 +23,137 @@
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
*/
try {
$docUid=$_POST['form']['DOC_UID'];
$appDocUid=$_POST['form']['APP_DOC_UID'];
$docVersion=$_POST['form']['docVersion'];
$actionType=$_POST['form']['actionType'];
$appId=$_GET['appId'];
$docType=isset($_GET['docType'])?$_GET['docType']:"";
try {
$docUid = $_POST['form']['DOC_UID'];
$appDocUid = $_POST['form']['APP_DOC_UID'];
$docVersion = $_POST['form']['docVersion'];
$actionType = $_POST['form']['actionType'];
$appId = $_GET['appId'];
$docType = isset($_GET['docType']) ? $_GET['docType'] : "";
//save info
require_once ( "classes/model/AppDocument.php" );
require_once ("classes/model/AppDocument.php");
require_once ('classes/model/AppFolder.php');
require_once ('classes/model/InputDocument.php');
$oInputDocument = new InputDocument();
if($_GET['UID']!=-1){
$aID = $oInputDocument->load($_GET['UID']);
}else{
$oFolder=new AppFolder();
$folderStructure=$oFolder->getFolderStructure(isset($_GET['folderId'])?$_GET['folderId']:"/");
$aID=array('INP_DOC_DESTINATION_PATH'=>$folderStructure['PATH']);
if ($_GET['UID'] != -1) {
$aID = $oInputDocument->load($_GET['UID']);
} else {
$oFolder = new AppFolder();
$folderStructure = $oFolder->getFolderStructure(isset($_GET['folderId']) ? $_GET['folderId'] : "/");
$aID = array('INP_DOC_DESTINATION_PATH' => $folderStructure['PATH']);
}
$oAppDocument = new AppDocument();
//Get the Custom Folder ID (create if necessary)
$oFolder=new AppFolder();
if($_GET['UID']!=-1){
//krumo("jhl");
$folderId=$oFolder->createFromPath($aID['INP_DOC_DESTINATION_PATH'],$appId);
//Tags
$fileTags=$oFolder->parseTags($aID['INP_DOC_TAGS'],$appId);
}else{
$folderId=isset($_GET['folderId'])?$_GET['folderId']:"/";
$fileTags="EXTERNAL";
//Get the Custom Folder ID (create if necessary)
$oFolder = new AppFolder();
if ($_GET['UID'] != -1) {
//krumo("jhl");
$folderId = $oFolder->createFromPath($aID['INP_DOC_DESTINATION_PATH'], $appId);
//Tags
$fileTags = $oFolder->parseTags($aID['INP_DOC_TAGS'], $appId);
} else {
$folderId = isset($_GET['folderId']) ? $_GET['folderId'] : "/";
$fileTags = "EXTERNAL";
}
switch($actionType){
case "R": //replace
$aFields = array('APP_DOC_UID' => $appDocUid,
'APP_UID' => $appId,
'DOC_VERSION' => $docVersion,
'DEL_INDEX' => 1,
'USR_UID' => $_SESSION['USER_LOGGED'],
'DOC_UID' => $docUid,
'APP_DOC_TYPE' => $_POST['form']['APP_DOC_TYPE'],
'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'),
'APP_DOC_COMMENT' => isset($_POST['form']['APP_DOC_COMMENT']) ? $_POST['form']['APP_DOC_COMMENT'] : '',
'APP_DOC_TITLE' => '',
'APP_DOC_FILENAME' => isset($_FILES['form']['name']['APP_DOC_FILENAME']) ? $_FILES['form']['name']['APP_DOC_FILENAME'] : '',
'FOLDER_UID' => $folderId,
'APP_DOC_TAGS' => $fileTags);
switch ($actionType) {
case "R": //replace
$aFields = array('APP_DOC_UID' => $appDocUid,
'APP_UID' => $appId,
'DOC_VERSION' => $docVersion,
'DEL_INDEX' => 1,
'USR_UID' => $_SESSION['USER_LOGGED'],
'DOC_UID' => $docUid,
'APP_DOC_TYPE' => $_POST['form']['APP_DOC_TYPE'],
'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'),
'APP_DOC_COMMENT' => isset($_POST['form']['APP_DOC_COMMENT']) ? $_POST['form']['APP_DOC_COMMENT'] : '',
'APP_DOC_TITLE' => '',
'APP_DOC_FILENAME' => isset($_FILES['form']['name']['APP_DOC_FILENAME']) ? $_FILES['form']['name']['APP_DOC_FILENAME'] : '',
'FOLDER_UID' => $folderId,
'APP_DOC_TAGS' => $fileTags);
$oAppDocument->update($aFields);
break;
break;
case "NV": //New Version
$aFields = array('APP_DOC_UID' => $appDocUid,
'APP_UID' => $appId,
'DEL_INDEX' => 1,
'USR_UID' => $_SESSION['USER_LOGGED'],
'DOC_UID' => $docUid,
'APP_DOC_TYPE' => $_POST['form']['APP_DOC_TYPE'],
'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'),
'APP_DOC_COMMENT' => isset($_POST['form']['APP_DOC_COMMENT']) ? $_POST['form']['APP_DOC_COMMENT'] : '',
'APP_DOC_TITLE' => '',
'APP_DOC_FILENAME' => isset($_FILES['form']['name']['APP_DOC_FILENAME']) ? $_FILES['form']['name']['APP_DOC_FILENAME'] : '',
'FOLDER_UID' => $folderId,
'APP_DOC_TAGS' => $fileTags);
$aFields = array('APP_DOC_UID' => $appDocUid,
'APP_UID' => $appId,
'DEL_INDEX' => 1,
'USR_UID' => $_SESSION['USER_LOGGED'],
'DOC_UID' => $docUid,
'APP_DOC_TYPE' => $_POST['form']['APP_DOC_TYPE'],
'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'),
'APP_DOC_COMMENT' => isset($_POST['form']['APP_DOC_COMMENT']) ? $_POST['form']['APP_DOC_COMMENT'] : '',
'APP_DOC_TITLE' => '',
'APP_DOC_FILENAME' => isset($_FILES['form']['name']['APP_DOC_FILENAME']) ? $_FILES['form']['name']['APP_DOC_FILENAME'] : '',
'FOLDER_UID' => $folderId,
'APP_DOC_TAGS' => $fileTags);
$oAppDocument->create($aFields);
break;
default: //New
$aFields = array('APP_UID' => $appId,
'DEL_INDEX' => isset($_SESSION['INDEX'])?$_SESSION['INDEX']:1,
'USR_UID' => $_SESSION['USER_LOGGED'],
'DOC_UID' => $docUid,
'APP_DOC_TYPE' => $_POST['form']['APP_DOC_TYPE'],
'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'),
'APP_DOC_COMMENT' => isset($_POST['form']['APP_DOC_COMMENT']) ? $_POST['form']['APP_DOC_COMMENT'] : '',
'APP_DOC_TITLE' => '',
'APP_DOC_FILENAME' => isset($_FILES['form']['name']['APP_DOC_FILENAME']) ? $_FILES['form']['name']['APP_DOC_FILENAME'] : '',
'FOLDER_UID' => $folderId,
'APP_DOC_TAGS' => $fileTags);
break;
default: //New
$aFields = array('APP_UID' => $appId,
'DEL_INDEX' => isset($_SESSION['INDEX']) ? $_SESSION['INDEX'] : 1,
'USR_UID' => $_SESSION['USER_LOGGED'],
'DOC_UID' => $docUid,
'APP_DOC_TYPE' => $_POST['form']['APP_DOC_TYPE'],
'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'),
'APP_DOC_COMMENT' => isset($_POST['form']['APP_DOC_COMMENT']) ? $_POST['form']['APP_DOC_COMMENT'] : '',
'APP_DOC_TITLE' => '',
'APP_DOC_FILENAME' => isset($_FILES['form']['name']['APP_DOC_FILENAME']) ? $_FILES['form']['name']['APP_DOC_FILENAME'] : '',
'FOLDER_UID' => $folderId,
'APP_DOC_TAGS' => $fileTags);
$oAppDocument->create($aFields);
break;
break;
}
$sAppDocUid = $oAppDocument->getAppDocUid();
$iDocVersion = $oAppDocument->getDocVersion();
$info = pathinfo( $oAppDocument->getAppDocFilename() );
$info = pathinfo($oAppDocument->getAppDocFilename());
$ext = (isset($info['extension']) ? $info['extension'] : '');
//save the file
if (!empty($_FILES['form'])) {
if ($_FILES['form']['error']['APP_DOC_FILENAME'] == 0) {
$sPathName = PATH_DOCUMENT . $appId . PATH_SEP;
$sFileName = $sAppDocUid . "_".$iDocVersion. '.' . $ext;
G::uploadFile($_FILES['form']['tmp_name']['APP_DOC_FILENAME'], $sPathName, $sFileName );
if (!empty($_FILES['form'])) {
if ($_FILES['form']['error']['APP_DOC_FILENAME'] == 0) {
$sPathName = PATH_DOCUMENT . $appId . PATH_SEP;
$sFileName = $sAppDocUid . "_" . $iDocVersion . '.' . $ext;
G::uploadFile($_FILES['form']['tmp_name']['APP_DOC_FILENAME'], $sPathName, $sFileName);
//Plugin Hook PM_UPLOAD_DOCUMENT for upload document
$oPluginRegistry =& PMPluginRegistry::getSingleton();
if ( $oPluginRegistry->existsTrigger ( PM_UPLOAD_DOCUMENT ) && class_exists ('uploadDocumentData' ) ) {
$oData['APP_UID'] = $appId;
$documentData = new uploadDocumentData (
$appId,
$_SESSION['USER_LOGGED'],
$sPathName . $sFileName,
$aFields['APP_DOC_FILENAME'],
$sAppDocUid
);
//Plugin Hook PM_UPLOAD_DOCUMENT for upload document
$oPluginRegistry = & PMPluginRegistry::getSingleton();
if ($oPluginRegistry->existsTrigger(PM_UPLOAD_DOCUMENT) && class_exists('uploadDocumentData')) {
$oPluginRegistry->executeTriggers ( PM_UPLOAD_DOCUMENT , $documentData );
unlink ( $sPathName . $sFileName );
$oData['APP_UID'] = $appId;
$documentData = new uploadDocumentData(
$appId,
$_SESSION['USER_LOGGED'],
$sPathName . $sFileName,
$aFields['APP_DOC_FILENAME'],
$sAppDocUid
);
$oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData);
unlink($sPathName . $sFileName);
}
//end plugin
}
//end plugin
}
}
G::header('location: appFolderList');
die;
} catch ( Exception $e ) {
G::header('location: appFolderList');
die;
} catch (Exception $e) {
/* Render Error page */
$aMessage['MESSAGE'] = $e->getMessage();
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage );
G::RenderPage( 'publish' );
}
$aMessage['MESSAGE'] = $e->getMessage();
$G_PUBLISH = new Publisher;
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $aMessage);
G::RenderPage('publish');
}