From 089f0fedc2c8ba02e36b5f87e5c5c0d45f978c30 Mon Sep 17 00:00:00 2001 From: Julio Cesar Laura Date: Mon, 8 Jul 2013 13:10:57 -0400 Subject: [PATCH 1/2] BUG 11086 Los datos introducidos despues de una fila vacia son ingnorados IMPROVEMENT --- workflow/engine/controllers/pmTablesProxy.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/workflow/engine/controllers/pmTablesProxy.php b/workflow/engine/controllers/pmTablesProxy.php index ccee469de..1e660e3cb 100755 --- a/workflow/engine/controllers/pmTablesProxy.php +++ b/workflow/engine/controllers/pmTablesProxy.php @@ -423,13 +423,17 @@ class pmTablesProxy extends HttpProxyController $primaryKeys = $additionalTables->getPrimaryKeys(); - foreach ($result['rows'] as $i => $row) { - $primaryKeysValues = array (); - foreach ($primaryKeys as $key) { - $primaryKeysValues[] = isset( $row[$key['FLD_NAME']] ) ? $row[$key['FLD_NAME']] : ''; - } + if (is_array($result['rows'])) { + foreach ($result['rows'] as $i => $row) { + $primaryKeysValues = array (); + foreach ($primaryKeys as $key) { + $primaryKeysValues[] = isset( $row[$key['FLD_NAME']] ) ? $row[$key['FLD_NAME']] : ''; + } - $result['rows'][$i]['__index__'] = G::encrypt( implode( ',', $primaryKeysValues ), 'pmtable' ); + $result['rows'][$i]['__index__'] = G::encrypt( implode( ',', $primaryKeysValues ), 'pmtable' ); + } + } else { + $result['rows'] = array(); } return $result; From 848647f72c674b4d07aec361cd917c0eb5710480 Mon Sep 17 00:00:00 2001 From: Julio Cesar Laura Date: Tue, 9 Jul 2013 15:59:25 -0400 Subject: [PATCH 2/2] Changing file encoding for class.pmAlfrescoFunctions.php --- .../triggers/class.pmAlfrescoFunctions.php | 726 +++++++++--------- 1 file changed, 363 insertions(+), 363 deletions(-) diff --git a/workflow/engine/classes/triggers/class.pmAlfrescoFunctions.php b/workflow/engine/classes/triggers/class.pmAlfrescoFunctions.php index abf399874..9317b79e5 100755 --- a/workflow/engine/classes/triggers/class.pmAlfrescoFunctions.php +++ b/workflow/engine/classes/triggers/class.pmAlfrescoFunctions.php @@ -1,363 +1,363 @@ -getResponse()); - return $domapi_res; -} - -/** - * @method - * - * Checkin document/file - * - * @name Checkin - * @label Checkin document/file - * - * @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco - * @param string | $docUid | Document Uid - * @param string | $comments | Comments - * @param string | $user | Valid Admin username to connect to Alfresco server - * @param string | $pwd | Valid Admin password to connect to Alfresco server - * - * @return string | $result | Response | - * - */ - -function checkIn($alfrescoServerUrl, $docUid, $comments, $user = "", $pwd = "") -{ - $alfresco_url = "$alfrescoServerUrl/s/cmis/pwc/i/$docUid?checkin=true&checkinComment=$comments"; - $xmlData = array(); - $xmlData = ''; - - $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; - } -} - -/** - * @method - * - * Checkout document/file - * - * @name Checkout - * @label Checkout document/file - * - * @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco - * @param string | $docUid | Document Uid - * @param string | $user | Valid Admin username to connect to Alfresco server - * @param string | $pwd | Valid Admin password to connect to Alfresco server - * - * @return string | $result | Response | - * - */ -// Validation done -function checkOut($alfrescoServerUrl, $docUid, $user = "", $pwd = "") -{ - $alfresco_url = "$alfrescoServerUrl/s/cmis/checkedout"; - $xmlData = array(); - $xmlData = '' . '' . '' . '' . '' . 'workspace://SpacesStore/' . $docUid . '' . '' . '' . '' . ''; - - $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; - } -} - -/** - * @method - * - * Create a folder in Alfresco Repository - * - * @name createFolder - * @label Create a folder in Alfresco Repository - * - * @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco - * @param string | $parentFolder | Parent Folder Name - * @param string | $folderName | Name of the Folder to be created - * @param string | $user | Valid Admin username to connect to Alfresco server - * @param string | $pwd | Valid Admin password to connect to Alfresco server - * - * @return string | $result | Response | - * - */ -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"; - $xmlData = array(); - $xmlData = '' . '' . '' . $name[0] . '' . '' . '' . 'cmis:folder' . '' . '' . ''; - $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]; - - if ($folderName != null) { - createFolder($alfrescoServerUrl, $parentFolder, $folderName, $user, $pwd); - } - if ($alfrescoMessage === 'Created') { - return "The Folder has been Created"; - } else { - return $alfrescoMessage; - } -} - -/** - * @method - * - * Delete an object(Folder/File) from Alfresco Repository - * - * @name deleteObject - * @label Delete an object(Folder/File) from Alfresco Repository - * - * @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco - * @param string | $objetcId | Id of the Object(Folder/File) to be deleted - * @param string | $user | Valid Admin username to connect to Alfresco server - * @param string | $pwd | Valid Admin password to connect to Alfresco server - * - * @return object | $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"); - - $alfresco_res = G::json_decode($alfresco_exec->getResponse()); - - return $alfresco_res; -} - -/** - * @method - * - * Download Document/File from Alfresco Repository - * - * @name downloadDoc - * @label Download Document/File from Alfresco Repository - * - * @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco - * @param string | $pathFile | File Source - * @param string | $pathFolder | Folder Name - * @param string | $user | Valid Admin username to connect to Alfresco server - * @param string | $pwd | Valid Admin password to connect to Alfresco server - * @param string | $mainFolder | The main folder in alfreco to save the files - * - * @return string | $result | Response | - * - */ -function downloadDoc($alfrescoServerUrl, $pathFile, $pathFolder, $user, $pwd, $mainFolder = 'Sites') -{ - if (!(G::verifyPath($pathFolder))) { - $result = new stdclass(); - $result->error = G::Loadtranslation('ID_FILE_PLUGIN_NOT_EXISTS', SYS_LANG, array('pluginFile' => $pathFolder)); - return $result; - } - - $dataPathFile = pathinfo($pathFile); - $nameFile = $dataPathFile['basename']; - - $alfresco_url = "$alfrescoServerUrl" . PATH_SEP . "s" . PATH_SEP . "cmis" . PATH_SEP . "p" . PATH_SEP . $mainFolder . PATH_SEP . "$pathFile"; - $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); - - if (!isset($xmlObject->content)) { - $result = new stdclass(); - $result->error = G::Loadtranslation('ID_FILE_PLUGIN_NOT_EXISTS', SYS_LANG, array('pluginFile' => $nameFile)); - return $result; - } - - $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 .= '/'; - } - - $fp = fopen($pathFolder . $nameFile, "w+"); - fwrite($fp, $content); - fclose($fp); - return true; -} - -/** - * @method - * - * Get a list of Checkedout Document/File from Alfresco Repository - * - * @name getCheckedoutFiles - * @label Get a list of Checkedout Document/File from Alfresco Repository - * - * @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco - * @param string | $user | Valid Admin username to connect to Alfresco server - * @param string | $pwd | Valid Admin password to connect to Alfresco server - * - * @return object | $result | Response | - * - */ -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); - - return $alfresco_res; -} - -/** - * @method - * - * Get Children of the given folder - * - * @name getFolderChildren - * @label Get Children of the given folder - * - * @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco - * @param string | $folderId | FolderId of the Folder whose children is to be listed - * @param string | $user | Valid Admin username to connect to Alfresco server - * @param string | $pwd | Valid Admin password to connect to Alfresco server - * - * @return object | $result | Response | - * - */ -function getFolderChildren($alfrescoServerUrl, $folderId, $user, $pwd) -{ - $getChildrenUrl = "$alfrescoServerUrl/service/api/node/workspace/SpacesStore/$folderId/children"; - $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); - - return $aXmlArray; -} - -/** - * @method - * - * Uplaod file/document in Alfresco Repository - * - * @name uploadDoc - * @label Uplaod file/document in Alfresco Repository - * - * @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco - * @param string | $fileSource | File Source - * @param string | $title | File Title - * @param string | $description | Description about File - * @param string | $docType | Type of document to be Uploaded - * @param string | $user | Valid Admin username to connect to Alfresco server - * @param string | $pwd | Valid Admin password to connect to Alfresco server - * @param string | $path | Path of document to be Uploaded - * @param string | $mainFolder | The main folder in alfreco to save the files - * - * @return object | $result | Response | - * - */ -function uploadDoc($alfrescoServerUrl, $fileSource, $title, $description, $docType, $user, $pwd, $path = '', $mainFolder= 'Sites') -{ - if (!(file_exists($fileSource))) { - $result = new stdclass(); - $result->error = G::Loadtranslation('ID_FILE_PLUGIN_NOT_EXISTS', SYS_LANG, array('pluginFile' => $fileSource)); - return $result; - } - $filep = fopen($fileSource, "r"); - $fileLength = filesize($fileSource); - $fileContent = fread($filep, $fileLength); - $fileContent = base64_encode($fileContent); - - if ($path != '') { - createFolder($alfrescoServerUrl, $mainFolder, $path, $user, $pwd); - $path = $path . PATH_SEP; - } - - $alfresco_url = "$alfrescoServerUrl/s/cmis/p/$mainFolder/" . $path . "children"; - $xmlData = array(); - $xmlData = '' . $title . '' . $description . '' . $fileContent . 'cmis:document'; - - $alfresco_exec = RestClient::post($alfresco_url, $xmlData, $user, $pwd, "application/atom+xml"); - $response = $alfresco_exec->getHeaders(); - switch ($response['code']) { - case '201': - //Created - $sXmlArray = $alfresco_exec->getResponse(); - $sXmlArray = trim($sXmlArray); - $xXmlArray = simplexml_load_string($sXmlArray); - $aXmlArray = @G::json_decode(@G::json_encode($xXmlArray), 1); - break; - case '409': - //file exists - $aXmlArray = 'There is already a file with the same name: ' . $title; - break; - default: - $aXmlArray = $response['message']; - break; - } - return $aXmlArray; -} +getResponse()); + return $domapi_res; +} + +/** + * @method + * + * Checkin document/file + * + * @name Checkin + * @label Checkin document/file + * + * @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco + * @param string | $docUid | Document Uid + * @param string | $comments | Comments + * @param string | $user | Valid Admin username to connect to Alfresco server + * @param string | $pwd | Valid Admin password to connect to Alfresco server + * + * @return string | $result | Response | + * + */ + +function checkIn($alfrescoServerUrl, $docUid, $comments, $user = "", $pwd = "") +{ + $alfresco_url = "$alfrescoServerUrl/s/cmis/pwc/i/$docUid?checkin=true&checkinComment=$comments"; + $xmlData = array(); + $xmlData = ''; + + $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; + } +} + +/** + * @method + * + * Checkout document/file + * + * @name Checkout + * @label Checkout document/file + * + * @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco + * @param string | $docUid | Document Uid + * @param string | $user | Valid Admin username to connect to Alfresco server + * @param string | $pwd | Valid Admin password to connect to Alfresco server + * + * @return string | $result | Response | + * + */ +// Validation done +function checkOut($alfrescoServerUrl, $docUid, $user = "", $pwd = "") +{ + $alfresco_url = "$alfrescoServerUrl/s/cmis/checkedout"; + $xmlData = array(); + $xmlData = '' . '' . '' . '' . '' . 'workspace://SpacesStore/' . $docUid . '' . '' . '' . '' . ''; + + $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; + } +} + +/** + * @method + * + * Create a folder in Alfresco Repository + * + * @name createFolder + * @label Create a folder in Alfresco Repository + * + * @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco + * @param string | $parentFolder | Parent Folder Name + * @param string | $folderName | Name of the Folder to be created + * @param string | $user | Valid Admin username to connect to Alfresco server + * @param string | $pwd | Valid Admin password to connect to Alfresco server + * + * @return string | $result | Response | + * + */ +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"; + $xmlData = array(); + $xmlData = '' . '' . '' . $name[0] . '' . '' . '' . 'cmis:folder' . '' . '' . ''; + $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]; + + if ($folderName != null) { + createFolder($alfrescoServerUrl, $parentFolder, $folderName, $user, $pwd); + } + if ($alfrescoMessage === 'Created') { + return "The Folder has been Created"; + } else { + return $alfrescoMessage; + } +} + +/** + * @method + * + * Delete an object(Folder/File) from Alfresco Repository + * + * @name deleteObject + * @label Delete an object(Folder/File) from Alfresco Repository + * + * @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco + * @param string | $objetcId | Id of the Object(Folder/File) to be deleted + * @param string | $user | Valid Admin username to connect to Alfresco server + * @param string | $pwd | Valid Admin password to connect to Alfresco server + * + * @return object | $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"); + + $alfresco_res = G::json_decode($alfresco_exec->getResponse()); + + return $alfresco_res; +} + +/** + * @method + * + * Download Document/File from Alfresco Repository + * + * @name downloadDoc + * @label Download Document/File from Alfresco Repository + * + * @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco + * @param string | $pathFile | File Source + * @param string | $pathFolder | Folder Name + * @param string | $user | Valid Admin username to connect to Alfresco server + * @param string | $pwd | Valid Admin password to connect to Alfresco server + * @param string | $mainFolder | The main folder in alfreco to save the files + * + * @return string | $result | Response | + * + */ +function downloadDoc($alfrescoServerUrl, $pathFile, $pathFolder, $user, $pwd, $mainFolder = 'Sites') +{ + if (!(G::verifyPath($pathFolder))) { + $result = new stdclass(); + $result->error = G::Loadtranslation('ID_FILE_PLUGIN_NOT_EXISTS', SYS_LANG, array('pluginFile' => $pathFolder)); + return $result; + } + + $dataPathFile = pathinfo($pathFile); + $nameFile = $dataPathFile['basename']; + + $alfresco_url = "$alfrescoServerUrl" . PATH_SEP . "s" . PATH_SEP . "cmis" . PATH_SEP . "p" . PATH_SEP . $mainFolder . PATH_SEP . "$pathFile"; + $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); + + if (!isset($xmlObject->content)) { + $result = new stdclass(); + $result->error = G::Loadtranslation('ID_FILE_PLUGIN_NOT_EXISTS', SYS_LANG, array('pluginFile' => $nameFile)); + return $result; + } + + $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 .= '/'; + } + + $fp = fopen($pathFolder . $nameFile, "w+"); + fwrite($fp, $content); + fclose($fp); + return true; +} + +/** + * @method + * + * Get a list of Checkedout Document/File from Alfresco Repository + * + * @name getCheckedoutFiles + * @label Get a list of Checkedout Document/File from Alfresco Repository + * + * @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco + * @param string | $user | Valid Admin username to connect to Alfresco server + * @param string | $pwd | Valid Admin password to connect to Alfresco server + * + * @return object | $result | Response | + * + */ +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); + + return $alfresco_res; +} + +/** + * @method + * + * Get Children of the given folder + * + * @name getFolderChildren + * @label Get Children of the given folder + * + * @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco + * @param string | $folderId | FolderId of the Folder whose children is to be listed + * @param string | $user | Valid Admin username to connect to Alfresco server + * @param string | $pwd | Valid Admin password to connect to Alfresco server + * + * @return object | $result | Response | + * + */ +function getFolderChildren($alfrescoServerUrl, $folderId, $user, $pwd) +{ + $getChildrenUrl = "$alfrescoServerUrl/service/api/node/workspace/SpacesStore/$folderId/children"; + $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); + + return $aXmlArray; +} + +/** + * @method + * + * Uplaod file/document in Alfresco Repository + * + * @name uploadDoc + * @label Uplaod file/document in Alfresco Repository + * + * @param string | $alfrescoServerUrl | Server name and port where Alfresco exists | http://localhost:8080/alfresco + * @param string | $fileSource | File Source + * @param string | $title | File Title + * @param string | $description | Description about File + * @param string | $docType | Type of document to be Uploaded + * @param string | $user | Valid Admin username to connect to Alfresco server + * @param string | $pwd | Valid Admin password to connect to Alfresco server + * @param string | $path | Path of document to be Uploaded + * @param string | $mainFolder | The main folder in alfreco to save the files + * + * @return object | $result | Response | + * + */ +function uploadDoc($alfrescoServerUrl, $fileSource, $title, $description, $docType, $user, $pwd, $path = '', $mainFolder= 'Sites') +{ + if (!(file_exists($fileSource))) { + $result = new stdclass(); + $result->error = G::Loadtranslation('ID_FILE_PLUGIN_NOT_EXISTS', SYS_LANG, array('pluginFile' => $fileSource)); + return $result; + } + $filep = fopen($fileSource, "r"); + $fileLength = filesize($fileSource); + $fileContent = fread($filep, $fileLength); + $fileContent = base64_encode($fileContent); + + if ($path != '') { + createFolder($alfrescoServerUrl, $mainFolder, $path, $user, $pwd); + $path = $path . PATH_SEP; + } + + $alfresco_url = "$alfrescoServerUrl/s/cmis/p/$mainFolder/" . $path . "children"; + $xmlData = array(); + $xmlData = '' . $title . '' . $description . '' . $fileContent . 'cmis:document'; + + $alfresco_exec = RestClient::post($alfresco_url, $xmlData, $user, $pwd, "application/atom+xml"); + $response = $alfresco_exec->getHeaders(); + switch ($response['code']) { + case '201': + //Created + $sXmlArray = $alfresco_exec->getResponse(); + $sXmlArray = trim($sXmlArray); + $xXmlArray = simplexml_load_string($sXmlArray); + $aXmlArray = @G::json_decode(@G::json_encode($xXmlArray), 1); + break; + case '409': + //file exists + $aXmlArray = 'There is already a file with the same name: ' . $title; + break; + default: + $aXmlArray = $response['message']; + break; + } + return $aXmlArray; +}