diff --git a/workflow/engine/classes/triggers/class.pmSharepointFunctions.php b/workflow/engine/classes/triggers/class.pmSharepointFunctions.php new file mode 100644 index 000000000..10d4c4841 --- /dev/null +++ b/workflow/engine/classes/triggers/class.pmSharepointFunctions.php @@ -0,0 +1,372 @@ +createDWS($name, $users, $title, $documents); + return $beforeResult; +} + +/** + * @method + * + * Delete a DWS in Sharepoint server + * + * @name deleteDWS + * @label Delete a DWS in Sharepoint server + * + * @param string | $sharepointServer | Server name and port whre DWS wsdl exists, including protocol | http://server:port/_vti_bin/Dws.asmx?WSDL + * @param string | $auth | Valid Auth string to connect to server | user:password + * @param string | $dwsname | Name of DWS to be deleted + * + * @return string | $result | Response + * + */ +function deleteDWS($sharepointServer, $auth, $dwsname) { + require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); + $pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth); + $beforeResult = $pmTrSharepoint->deleteDWS($dwsname); + $newResult = $beforeResult->DeleteDwsResult; + if($newResult == '') + return "Successfully deleted the DWS"; + else + return "Error in deleting the DWS"; + +} + +/** + * @method + * + * Create a folder in a DWS + * + * @name createFolderDWS + * @label Create a folder in a DWS + * + * @param string | $sharepointServer | Server name and port whre DWS wsdl exists, including protocol | http://server:port/_vti_bin/Dws.asmx?WSDL + * @param string | $auth | Valid Auth string to connect to server | user:password + * @param string | $dwsname | Name of DWS + * @param string | $dwsFolderName | Name of DWS folder + * + * @return string | $result | Response + * + */ +function createFolderDWS($sharepointServer, $auth, $dwsname, $dwsFolderName) { + require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); + $pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth); + $result = $pmTrSharepoint->createFolderDWS($dwsname,$dwsFolderName); + var_dump($result); + $newResult = $result->CreateFolderResult; + var_dump($newResult); + if(isset($newResult)) + { + if($newResult == '') + return "Folder is created"; + else + return "Folder could not be created"; + } +} + + +/** + * @method + * + * Delete a DWS folder + * + * @name deleteFolderDWS + * @label Delete a DWS folder + * + * @param string | $sharepointServer | Server name and port whre DWS wsdl exists, including protocol | http://server:port/_vti_bin/Dws.asmx?WSDL + * @param string | $auth | Valid Auth string to connect to server | user:password + * @param string | $dwsname | Name of DWS + * @param string | $delDwsFolderName | Name of DWS folder to be deleted + * + * @return string | $result | Response + * + */ + +function deleteFolderDWS($sharepointServer, $auth, $dwsname, $folderName) { + require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); + $pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth); + $result = $pmTrSharepoint->deleteFolderDWS($dwsname, $folderName); + $newResult = $result->DeleteFolderResult; + if(isset($newResult)) + { + if($newResult == '') + return "Folder is deleted"; + else + return "Folder could not be deleted"; + } +} + + +/** + * @method + * + * Get DWS data + * + * @name getDWSData + * @label Get DWS data + * + * @param string | $sharepointServer | Server name and port whre DWS wsdl exists, including protocol | http://server:port/_vti_bin/Dws.asmx?WSDL + * @param string | $auth | Valid Auth string to connect to server | user:password + * @param string | $newFileName | File Name + * @param string | $dwsname | Name of DWS + * @param string | $lastUpdate | LastUpdate + * + * @return string | $result | Response + * + */ +function getDWSData($sharepointServer, $auth, $newFileName, $dwsname, $lastUpdate) { + require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); + $pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth); + $resultDWSData = $pmTrSharepoint->getDWSData($newFileName, $dwsname, $lastUpdate); +if($resultDWSData) + return $newResult; + else + return "There was some error while getting the DWS Data"; +} + +/** + * @method + * + * Get DWS meta data + * + * @name getDWSMetaData + * @label Get DWS meta data + * + * @param string | $sharepointServer | Server name and port whre DWS wsdl exists, including protocol | http://server:port/_vti_bin/Dws.asmx?WSDL + * @param string | $auth | Valid Auth string to connect to server | user:password + * @param string | $newFileName | File Name + * @param string | $dwsname | Name of DWS + * @param string | $id | ID + * + * + * @return string | $result | Response + * + */ +function getDWSMetaData($sharepointServer, $auth, $newFileName, $dwsname, $id) { + require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); + $pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth); + $result = $pmTrSharepoint->getDWSMetaData($newFileName, $dwsname, $id); + $newResult = $result->GetDwsMetaDataResult; + if(isset($newResult)) + { + return "Document workspace Meta-data found"; + } + else + { + return "Document workspace Meta-data not found"; + } + +} + + +/** + * @method + * + * Copy/Upload Documents to DWS folder + * + * @name uploadDocumentDWS + * @label Copy/Upload Documents to DWS folder + * + * @param string | $sharepointServer | Server name and port whre DWS wsdl exists, including protocol | http://server:port/_vti_bin/Dws.asmx?WSDL + * @param string | $auth | Valid Auth string to connect to server | user:password + * @param string | $dwsname | DWS name in which you want to Upload the Folder + * @param string | $folderName | Folder Name, dont provide folder name in case upload is in "Shared Directory" + * @param string | $sourceUrl | Absolute path of the file to upload + * @param string | $filename | Name of the File to Upload + * + * @return string | $result | Response + * + */ +function uploadDocumentDWS($sharepointServer, $auth, $dwsname, $folderName, $sourceUrl, $filename) { + require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); + $pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth); + $beforeResult = $pmTrSharepoint->uploadDocumentDWS($dwsname, $folderName, $sourceUrl, $filename); + + return $beforeResult; +} + +/** + * @method + * + * Download documents from DWS folder + * + * @name downloadDocumentDWS + * @label Download DWS Documents + * + * @param string | $sharepointServer | Server name and port whre DWS wsdl exists, including protocol | http://server:port/_vti_bin/Dws.asmx?WSDL + * @param string | $auth | Valid Auth string to connect to server | user:password + * @param string | $dwsname | Name of DWS + * @param string | $fileName | File to be downloaded + * @param string | $fileLocation | Location to be downloaded into + * + * @return string | $result | Response + * + */ +function downloadDocumentDWS($sharepointServer, $auth, $dwsname, $fileName, $fileLocation) { + require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); + $pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth); + $result = $pmTrSharepoint->downloadDocumentDWS($dwsname, $fileName, $fileLocation); + if(isset($result)) + return "Document downloaded"; + else + return "Document cannot be downloaded"; +} + + +/** + * @method + * + * Get DWS Folder items + * + * @name getDWSFolderItems + * @label Get DWS Folder items + * + * @param string | $sharepointServer | Server name and port whre DWS wsdl exists, including protocol | http://server:port/_vti_bin/Dws.asmx?WSDL + * @param string | $auth | Valid Auth string to connect to server | user:password + * @param string | $dwsname | Name of the DWS + * @param string | $strFolderUrl | Folder URL + * + * @return string | $result | Response + * + */ +function getDWSFolderItems($sharepointServer, $auth,$dwsname, $strFolderUrl) { + require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); + $pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth); + $result = $pmTrSharepoint->getDWSFolderItems($dwsname, $strFolderUrl); + if(isset($result)) + return $result; + else + return "Folder does not exists"; +} + +/** + * @method + * + * Get DWS Document Versions + * + * @name getDWSDocumentVersions + * @label Get DWS Document Versions + * + * @param string | $sharepointServer | Server name and port whre DWS wsdl exists, including protocol | http://server:port/_vti_bin/Dws.asmx?WSDL + * @param string | $auth | Valid Auth string to connect to server | user:password + * @param string | $newFileName | Name of New File + * @param string | $dwsname | Name of DWS + * + * @return string | $result | Response + * + */ +function getDWSDocumentVersions($sharepointServer, $auth, $newFileName, $dwsname) { + require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); + $pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth); + $result = $pmTrSharepoint->getDWSDocumentVersions($newFileName, $dwsname); + if(isset($result->GetVersionsResult)) + { + /* + * Code to get the Document's Version/s + */ + $xml = $result->GetVersionsResult->any;// in Result we get string in Xml format + $xmlNew = simplexml_load_string($xml);// used to parse string to xml + $xmlArray = @json_decode(@json_encode($xmlNew),1);// used to convert Objects to array + $resultCount = count($xmlArray['result']); + for($i=0;$i<$resultCount;$i++) + { + $version[] =$xmlArray['result'][$i]['@attributes']['version']; + } + $serializeResult = serialize($version);// serializing the Array for Returning. + return $serializeResult; + } + else + return "No version found"; +} +/** + * @method + * + * Delete DWS Document Version + * + * @name deleteDWSDocumentVersion + * @label Delete DWS Document Version + * + * @param string | $sharepointServer | Server name and port whre DWS wsdl exists, including protocol | http://server:port/_vti_bin/Dws.asmx?WSDL + * @param string | $auth | Valid Auth string to connect to server | user:password + * @param string | $newFileName | Name of the file + * @param string | $dwsname | Name of DWS + * @param string | $versionNum | Version No. + * + * @return string | $result | Response + * + */ +function deleteDWSDocumentVersion($sharepointServer, $auth, $newFileName, $dwsname, $versionNum) { + require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); + $pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth); + $result = $pmTrSharepoint->deleteDWSDocVersion($newFileName, $dwsname, $versionNum); + return $result; +} + + +/** + * @method + * + * Delete all DWS Document Versions + * + * @name deleteDWSAllDocumentVersion + * @label Delete all DWS Document Versions + * + * @param string | $sharepointServer | Server name and port whre DWS wsdl exists, including protocol | http://server:port/_vti_bin/Dws.asmx?WSDL + * @param string | $auth | Valid Auth string to connect to server | user:password + * @param string | $newFileName | Name of File + * @param string | $dwsname | Name of DWS + * + * @return string | $result | Response + * + */ +function deleteDWSAllDocumentVersion($sharepointServer, $auth, $newFileName, $dwsname) { + require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrSharepoint.php'); + $pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth); + $result = $pmTrSharepoint->deleteAllDWSDocVersion($newFileName, $dwsname); + return $result; +} \ No newline at end of file diff --git a/workflow/engine/classes/triggers/class.pmTrSharepoint.php b/workflow/engine/classes/triggers/class.pmTrSharepoint.php new file mode 100644 index 000000000..77849f2c9 --- /dev/null +++ b/workflow/engine/classes/triggers/class.pmTrSharepoint.php @@ -0,0 +1,405 @@ +- auth Setup"; + $this->auth = $auth; + } + + function setwsdlurl($wsdl) { + //print "
- wsdl Setup"; + $this->wsdlurl = $wsdl; + //var_dump($wsdl); + } + + function loadSOAPClient() { + try { + // we unregister the current HTTP wrapper + stream_wrapper_unregister('http'); + // we register the new HTTP wrapper + stream_wrapper_register('http', 'PMServiceProviderNTLMStream') or die("Failed to register protocol"); + $this->client = new PMServiceNTLMSoapClient($this->wsdlurl, array('trace' => 1, 'auth' => $this->auth)); + $this->client->setAuth($this->auth); + return true; + } catch (Exception $e) { + echo $e; + exit; + } + } + + function callWsMethod($methodName, $paramArray) { + + try { + if ($methodName == 'DeleteDws' || $methodName == 'GetListCollection') { + $strResult = ""; + $strResult = $this->client->$methodName($paramArray = ""); + return $strResult; + } else { + $strResult = ""; + $strResult = $this->client->$methodName($paramArray); + return $strResult; + } + } catch (SoapFault $fault) { + echo 'Fault code: ' . $fault->faultcode; + echo 'Fault string: ' . $fault->faultstring; + } + stream_wrapper_restore('http'); + } + +} + +class DestinationUrlCollection { + + public $string; + +} + +; + +class FieldInformation { + +} + +class FieldInformationCollection { + + public $FieldInformation; + +} + +class pmTrSharepointClass extends PMPlugin { + + function __construct($server, $auth) { + set_include_path( + PATH_PLUGINS . 'pmTrSharepoint' . PATH_SEPARATOR . + get_include_path() + ); + $this->server = $server; + $this->auth = $auth; + $this->dwsObj = new wscaller(); + $this->dwsObj->setAuthUser($this->auth); + } + + function createDWS($name, $users, $title, $documents) { + //print "
- Method createDWS"; + $this->dwsObj->setwsdlurl($this->server . "/_vti_bin/Dws.asmx?WSDL"); + + $this->dwsObj->loadSOAPClient(); + + $paramArray = array('name' => '', 'users' => '', 'title' => $name, 'documents' => ''); + + $methodName = 'CreateDws'; + + $result = $this->dwsObj->callWsMethod($methodName, $paramArray); + $xml = $result->CreateDwsResult; // in Result we get string in Xml format + $xmlNew = simplexml_load_string($xml); // used to parse string to xml + $xmlArray = @json_decode(@json_encode($xmlNew), 1); // used to convert Objects to array + $dwsUrl = $xmlArray['Url']; + return "Dws with following Url is created:$dwsUrl"; + + /* $newResult = $result->CreateDwsResult; + $needleStart=''; + $urlStartPos = strpos($newResult, $needleStart); + $urlStart = $urlStartPos + 5; + $needleEnd=''; + $urlEndPos = strpos($newResult, $needleEnd); + $length = $urlEndPos - $urlStart; + $result = substr($newResult, $urlStart, $length); + return $result; */ + } + + function deleteDWS($dwsname) { + //print "
- Method createDWS"; + $url = $this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL"; + $this->dwsObj->setwsdlurl($url); + + if ($this->dwsObj->loadSOAPClient()) { + $paramArray = null; + $methodName = 'DeleteDws'; + $result = $this->dwsObj->callWsMethod($methodName, $paramArray = null); + var_dump($result); + return $result; + } else { + return "Please Enter a proper Dws"; + } + } + + function createFolderDWS($dwsname, $dwsFolderName) { + //print "
- Method createDWS"; + $this->dwsObj->setwsdlurl($this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL"); + + $this->dwsObj->loadSOAPClient(); + + $url = "Shared Documents/$dwsFolderName"; + $paramArray = array('url' => $url); + + # $paramArray = array('name' => '', 'users' => '', 'title' => $name, 'documents' => ''); + + $methodName = 'CreateFolder'; + + $result = $this->dwsObj->callWsMethod($methodName, $paramArray); + var_dump($result); + return $result; + } + + function deleteFolderDWS($dwsname, $folderName) { + //print "
- Method createDWS"; + $this->dwsObj->setwsdlurl($this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL"); + + $this->dwsObj->loadSOAPClient(); + + $url = "Shared Documents/$folderName"; + $paramArray = array('url' => $url); + + # $paramArray = array('name' => '', 'users' => '', 'title' => $name, 'documents' => ''); + + $methodName = 'DeleteFolder'; + + $result = $this->dwsObj->callWsMethod($methodName, $paramArray); + var_dump($result); + return $result; + } + + function findDWSdoc($dwsname, $guid) { + //print "
- Method createDWS"; + $this->dwsObj->setwsdlurl($this->server . $dwsName . "/_vti_bin/Dws.asmx?WSDL"); + + $this->dwsObj->loadSOAPClient(); + + $paramArray = array('id' => '$guid'); + + $methodName = 'FindDwsDoc'; + + $result = $this->dwsObj->callWsMethod($methodName, $paramArray); + var_dump($result); + } + + function getDWSData($newFileName, $dwsname, $lastUpdate) { + //print "
- Method getDWSData
"; + $url = $this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL"; + $this->dwsObj->setwsdlurl($url); + if ($this->dwsObj->loadSOAPClient()) { + $doc = "Shared Documents"; + $paramArray = array('document' => '', 'lastUpdate' => ''); + $methodName = 'GetDwsData'; + $result = $this->dwsObj->callWsMethod($methodName, $paramArray); + var_dump($result); + $sResult = $result->GetDwsDataResult; + /* $xmlNew = simplexml_load_string($sResult);// used to parse string to xml + $xmlArray = @json_decode(@json_encode($xmlNew),1);// used to convert Objects to array */ + $serializeResult = serialize($sResult); // serializing the Array for Returning. + var_dump($serializeResult); + return $serializeResult; + } else { + return "The enter the Correct Dws Name"; + } + } + + function uploadDocumentDWS($dwsname, $folderName, $sourceUrl, $filename) { + //print "
- Method createDWS"; + $this->dwsObj->setwsdlurl($this->server . $dwsName . "/_vti_bin/Copy.asmx?WSDL"); + $this->dwsObj->loadSOAPClient(); + + $destUrlObj = new DestinationUrlCollection(); + if ($folderName != '') { + $destUrl = $this->server . "/$dwsname/Shared%20Documents/$folderName/$filename"; + } else { + $destUrl = $this->server . "/$dwsname/Shared%20Documents/$filename"; + } + $destUrlObj->string = $destUrl; + + $fieldInfoObj = new FieldInformation(); + + $fieldInfoCollObj = new FieldInformationCollection(); + $fieldInfoCollObj->FieldInformation = $fieldInfoObj; + + $imgfile = $sourceUrl . "/" . $filename; + $filep = fopen($imgfile, "r"); + $fileLength = filesize($imgfile); + $content = fread($filep, $fileLength); + $content = base64_encode($content); + + $paramArray = array('SourceUrl' => $imgfile, 'DestinationUrls' => $destUrlObj, 'Fields' => $fieldInfoCollObj, 'Stream' => $content); + $methodName = 'CopyIntoItems'; + $result = $this->dwsObj->callWsMethod($methodName, $paramArray); + var_dump($result); + $newResult = $result->Results->CopyResult->ErrorCode; + if ($newResult == 'Success') { + return "The document has been uploaded Successfully"; + } else { + return "Could not Upload the Document due to some Error"; + } + } + + function getDWSMetaData($newFileName, $dwsname, $id) { + //print "
- Method createDWS"; + $url = $this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL"; + $this->dwsObj->setwsdlurl($url); + + $this->dwsObj->loadSOAPClient(); + + $doc = "Shared Documents/$newFileName"; + $paramArray = array('document' => $doc, 'id' => '', 'minimal' => False); + + $methodName = 'GetDwsMetaData'; + + $result = $this->dwsObj->callWsMethod($methodName, $paramArray); + var_dump($result); + return $result; + } + + function getDWSDocumentVersions($newFileName, $dwsname) { + //print "
- Method createDWS"; + $this->dwsObj->setwsdlurl($this->server . "/" . $dwsname . "/_vti_bin/Versions.asmx?WSDL"); + + $this->dwsObj->loadSOAPClient(); + + $doc = "Shared Documents/$newFileName"; + $paramArray = array('fileName' => $doc); + + $methodName = 'GetVersions'; + + $result = $this->dwsObj->callWsMethod($methodName, $paramArray); + var_dump($result); + return $result; + } + + function deleteDWSDocVersion($newFileName, $dwsname, $versionNum) { + //print "
- Method createDWS"; + $this->dwsObj->setwsdlurl($this->server . "/" . $dwsname . "/_vti_bin/Versions.asmx?WSDL"); + + $this->dwsObj->loadSOAPClient(); + + $doc = "Shared Documents/$newFileName"; + $paramArray = array('fileName' => $doc, 'fileVersion' => $versionNum); + + $methodName = 'DeleteVersion'; + + $result = $this->dwsObj->callWsMethod($methodName, $paramArray); + if ($result) { + $sResult = $result->DeleteVersionResult->any; + $xmlNew = simplexml_load_string($sResult); // used to parse string to xml + $xmlArray = @json_decode(@json_encode($xmlNew), 1); // used to convert Objects to array + $version[] = $xmlArray['result']['@attributes']['version']; + $serializeResult = serialize($version); // serializing the Array for Returning. + var_dump($serializeResult); + return $serializeResult; + } else { + return"The given Version could not be deleted."; + } + } + + function deleteAllDWSDocVersion($newFileName, $dwsname) { + //print "
- Method createDWS"; + $this->dwsObj->setwsdlurl($this->server . "/" . $dwsname . "/_vti_bin/Versions.asmx?WSDL"); + + $this->dwsObj->loadSOAPClient(); + + $doc = "Shared Documents/$newFileName"; + $paramArray = array('fileName' => $doc); + + $methodName = 'DeleteAllVersions'; + + $result = $this->dwsObj->callWsMethod($methodName, $paramArray); + if ($result) { + $xml = $result->DeleteAllVersionsResult->any; // in Result we get string in Xml format + $xmlNew = simplexml_load_string($xml); // used to parse string to xml + $xmlArray = @json_decode(@json_encode($xmlNew), 1); // used to convert Objects to array + $latestVersion = $xmlArray['result']['@attributes']['version']; + return "All Versions are Deleted, except the latest i.e $latestVersion"; + } else { + return "The Version/ File name/ Dws Name is incorrect"; + } + } + + function getDWSFolderItems($dwsname, $strFolderUrl) { + $pmTrSharepointClassObj = new pmTrSharepointClass(); + //print "
- Method getDWSFolderItems"; + $url = $this->server . "/" . $dwsname . "/_vti_bin/SiteData.asmx?WSDL"; + $this->dwsObj->setwsdlurl($this->server . "/" . $dwsname . "/_vti_bin/SiteData.asmx?WSDL"); + + $this->dwsObj->loadSOAPClient(); + + #$doc = "Shared Documents/$newFileName"; + $paramArray = array('strFolderUrl' => $strFolderUrl); + + $methodName = 'EnumerateFolder'; + + $result = $this->dwsObj->callWsMethod($methodName, $paramArray); + //$newResult = $result->vUrls->_sFPUrl->Url; + if (isset($result->vUrls->_sFPUrl->Url)) { + $returnContent = $pmTrSharepointClassObj->getFolderUrlContent($result->vUrls->_sFPUrl->Url); + $serializeResult = serialize($returnContent); + return $serializeResult; + } else if (isset($result->vUrls->_sFPUrl)) { + $itemCount = count($result->vUrls->_sFPUrl); + for ($i = 0; $i < $itemCount; $i++) { + $aObjects = $result->vUrls->_sFPUrl[$i]->IsFolder; + //$booleanStatus = $aObjects[$i]->IsFolder; + if ($aObjects) { + $listArr = $result->vUrls->_sFPUrl[$i]->Url; + $returnContent[] = $pmTrSharepointClassObj->getFolderUrlContent($listArr) . "(Is a Folder)"; + } else { + $listArr = $result->vUrls->_sFPUrl[$i]->Url; + $returnContent[] = $pmTrSharepointClassObj->getFolderUrlContent($listArr) . "(Is a File)"; + } + } + $serializeResult = serialize($returnContent); + return $serializeResult; + } + return "There is some error"; + } + + function downloadDocumentDWS($dwsname, $fileName, $fileLocation) { + //print "
- Method createDWS"; + $url = $this->server . "/" . $dwsname . "/_vti_bin/Copy.asmx?WSDL"; + $this->dwsObj->setwsdlurl($url); + + $this->dwsObj->loadSOAPClient(); + + $CompleteUrl = $this->server . "/" . $dwsname . "/Shared Documents/" . $fileName; + $paramArray = array('Url' => $CompleteUrl); + + $methodName = 'GetItem'; + + $result = $this->dwsObj->callWsMethod($methodName, $paramArray); + $newResult = $result->Stream; + + $latestResult = base64_decode($newResult); + + /** + * In the Below line of code, we are coping the files at our local Directory using the php file methods. + * */ + $imgfile = $fileLocation . "/" . $fileName; + $filep = fopen($imgfile, 'w'); + $content = fwrite($filep, $latestResult); + return $content; + } + + function getFolderUrlContent($newResult) { + $needleStart = '/'; + $needleCount = substr_count($newResult, $needleStart); + + $urlStartPos = strpos($newResult, $needleStart); + $urlStartPos++; + + if ($needleCount == '2') { + $newResultPos = strpos($newResult, $needleStart, $urlStartPos); + $newResultPos++; + $actualResult = substr($newResult, $newResultPos); + return $actualResult; + } + } + +} \ No newline at end of file diff --git a/workflow/public_html/images/triggers/sharepoint.gif b/workflow/public_html/images/triggers/sharepoint.gif new file mode 100644 index 000000000..d32159193 Binary files /dev/null and b/workflow/public_html/images/triggers/sharepoint.gif differ