BUG 7195 error in cron.php coused by sharepoint triggers
Fixed and at same time fixed some other issues in sharepoint triggers
This commit is contained in:
@@ -41,6 +41,16 @@ class soapNtlm {
|
|||||||
private $buffer;
|
private $buffer;
|
||||||
private $pos;
|
private $pos;
|
||||||
|
|
||||||
|
public function getuser()
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getpassword()
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open the stream
|
* Open the stream
|
||||||
*
|
*
|
||||||
@@ -181,12 +191,12 @@ class soapNtlm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//echo "[NTLMStream::createBuffer] create buffer from : $path <br>";
|
//echo "[NTLMStream::createBuffer] create buffer from : $path <br>";
|
||||||
$this->ch = curl_init($this->path);
|
$this->ch = curl_init($path);
|
||||||
curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
curl_setopt($this->ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
|
curl_setopt($this->ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
|
||||||
curl_setopt($this->ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
|
curl_setopt($this->ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
|
||||||
curl_setopt($this->ch, CURLOPT_USERPWD, $this->options['auth']);
|
//curl_setopt($this->ch, CURLOPT_USERPWD, $this->options['auth']); // Hugo's code
|
||||||
|
curl_setopt($this->ch, CURLOPT_USERPWD, $this->getuser().':'.$this->getpassword());// Ankit's code
|
||||||
echo $this->buffer = curl_exec($this->ch);
|
echo $this->buffer = curl_exec($this->ch);
|
||||||
|
|
||||||
//echo "[NTLMStream::createBuffer] buffer size : " . strlen($this->buffer) . "bytes<br>";
|
//echo "[NTLMStream::createBuffer] buffer size : " . strlen($this->buffer) . "bytes<br>";
|
||||||
@@ -217,7 +227,8 @@ class NTLMSoapClient extends SoapClient {
|
|||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
|
||||||
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
|
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
|
||||||
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
|
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
|
||||||
curl_setopt($ch, CURLOPT_USERPWD, $this->options['auth']);
|
//curl_setopt($ch, CURLOPT_USERPWD, $this->options['auth']); //Hugo's Code
|
||||||
|
curl_setopt($ch, CURLOPT_USERPWD, $this->user.':'.$this->password); //Ankit's Code
|
||||||
$response = curl_exec($ch);
|
$response = curl_exec($ch);
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
@@ -230,21 +241,36 @@ class NTLMSoapClient extends SoapClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class PMServiceNTLMSoapClient extends NTLMSoapClient {
|
class PMServiceNTLMSoapClient extends NTLMSoapClient {
|
||||||
|
|
||||||
protected $user;
|
protected $user;
|
||||||
protected $password;
|
protected $password;
|
||||||
|
|
||||||
function setAuth($auth){
|
function setAuthClient($auth){
|
||||||
$authInfo=explode(":",$auth);
|
$authInfo=explode(":",$auth);
|
||||||
$this->user=$authInfo[0];
|
$this->user=$authInfo[0];
|
||||||
$this->password=$authInfo[1];
|
$this->password=$authInfo[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class PMServiceProviderNTLMStream extends soapNtlm {
|
class PMServiceProviderNTLMStream extends soapNtlm {
|
||||||
|
|
||||||
protected $user;
|
protected static $user ;
|
||||||
protected $password;
|
protected static $password;
|
||||||
|
|
||||||
|
|
||||||
|
public function getuser()
|
||||||
|
{
|
||||||
|
return self::$user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getpassword()
|
||||||
|
{
|
||||||
|
return self::$password;
|
||||||
|
}
|
||||||
|
|
||||||
|
static function setAuthStream($auth){
|
||||||
|
$authInfo=explode(":",$auth);
|
||||||
|
self::$user=$authInfo[0];
|
||||||
|
self::$password=$authInfo[1];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -164,7 +164,7 @@ function getDWSData($sharepointServer, $auth, $newFileName, $dwsname, $lastUpdat
|
|||||||
$pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth);
|
$pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth);
|
||||||
$resultDWSData = $pmTrSharepoint->getDWSData($newFileName, $dwsname, $lastUpdate);
|
$resultDWSData = $pmTrSharepoint->getDWSData($newFileName, $dwsname, $lastUpdate);
|
||||||
if($resultDWSData)
|
if($resultDWSData)
|
||||||
return $newResult;
|
return $resultDWSData;
|
||||||
else
|
else
|
||||||
return "There was some error while getting the DWS Data";
|
return "There was some error while getting the DWS Data";
|
||||||
}
|
}
|
||||||
@@ -191,15 +191,15 @@ function getDWSMetaData($sharepointServer, $auth, $newFileName, $dwsname, $id) {
|
|||||||
require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrSharepoint.php');
|
require_once(PATH_CORE. 'classes' . PATH_SEP.'triggers' . PATH_SEP . 'class.pmTrSharepoint.php');
|
||||||
$pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth);
|
$pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth);
|
||||||
$result = $pmTrSharepoint->getDWSMetaData($newFileName, $dwsname, $id);
|
$result = $pmTrSharepoint->getDWSMetaData($newFileName, $dwsname, $id);
|
||||||
$newResult = $result->GetDwsMetaDataResult;
|
//$newResult = $result->GetDwsMetaDataResult;
|
||||||
if(isset($newResult))
|
if(isset($result))
|
||||||
{
|
{
|
||||||
return "Document workspace Meta-data found";
|
return $result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return "Document workspace Meta-data not found";
|
return "Document workspace Meta-data not found";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ class wscaller {
|
|||||||
private $soapObj;
|
private $soapObj;
|
||||||
private $client;
|
private $client;
|
||||||
private $auth;
|
private $auth;
|
||||||
|
private $clientStream;
|
||||||
|
|
||||||
function setAuthUser($auth) {
|
function setAuthUser($auth) {
|
||||||
//print "<br>- auth Setup";
|
//print "<br>- auth Setup";
|
||||||
@@ -29,9 +30,13 @@ class wscaller {
|
|||||||
// we unregister the current HTTP wrapper
|
// we unregister the current HTTP wrapper
|
||||||
stream_wrapper_unregister('http');
|
stream_wrapper_unregister('http');
|
||||||
// we register the new HTTP wrapper
|
// we register the new HTTP wrapper
|
||||||
|
//$client = new PMServiceProviderNTLMStream($this->auth);
|
||||||
|
PMServiceProviderNTLMStream::setAuthStream($this->auth);
|
||||||
stream_wrapper_register('http', 'PMServiceProviderNTLMStream') or die("Failed to register protocol");
|
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);
|
// $this->client = new PMServiceNTLMSoapClient($this->wsdlurl, array('trace' => 1, 'auth' => $this->auth));// Hugo's code
|
||||||
|
$this->client = new PMServiceNTLMSoapClient($this->wsdlurl, array('trace' => 1)); // Ankit's Code
|
||||||
|
$this->client->setAuthClient($this->auth);
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
echo $e;
|
echo $e;
|
||||||
@@ -78,7 +83,7 @@ class FieldInformationCollection {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class pmTrSharepointClass extends PMPlugin {
|
class pmTrSharepointClass{
|
||||||
|
|
||||||
function __construct($server, $auth) {
|
function __construct($server, $auth) {
|
||||||
set_include_path(
|
set_include_path(
|
||||||
@@ -124,15 +129,13 @@ class pmTrSharepointClass extends PMPlugin {
|
|||||||
$url = $this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL";
|
$url = $this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL";
|
||||||
$this->dwsObj->setwsdlurl($url);
|
$this->dwsObj->setwsdlurl($url);
|
||||||
|
|
||||||
if ($this->dwsObj->loadSOAPClient()) {
|
$this->dwsObj->loadSOAPClient();
|
||||||
$paramArray = null;
|
$paramArray = null;
|
||||||
$methodName = 'DeleteDws';
|
$methodName = 'DeleteDws';
|
||||||
$result = $this->dwsObj->callWsMethod($methodName, $paramArray = null);
|
$result = $this->dwsObj->callWsMethod($methodName, $paramArray = null);
|
||||||
var_dump($result);
|
var_dump($result);
|
||||||
return $result;
|
return $result;
|
||||||
} else {
|
|
||||||
return "Please Enter a proper Dws";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createFolderDWS($dwsname, $dwsFolderName) {
|
function createFolderDWS($dwsname, $dwsFolderName) {
|
||||||
@@ -208,7 +211,8 @@ class pmTrSharepointClass extends PMPlugin {
|
|||||||
|
|
||||||
function uploadDocumentDWS($dwsname, $folderName, $sourceUrl, $filename) {
|
function uploadDocumentDWS($dwsname, $folderName, $sourceUrl, $filename) {
|
||||||
//print "<br>- Method createDWS";
|
//print "<br>- Method createDWS";
|
||||||
$this->dwsObj->setwsdlurl($this->server . $dwsName . "/_vti_bin/Copy.asmx?WSDL");
|
$url = $this->server ."/". $dwsname . "/_vti_bin/Copy.asmx?WSDL";
|
||||||
|
$this->dwsObj->setwsdlurl($url);
|
||||||
$this->dwsObj->loadSOAPClient();
|
$this->dwsObj->loadSOAPClient();
|
||||||
|
|
||||||
$destUrlObj = new DestinationUrlCollection();
|
$destUrlObj = new DestinationUrlCollection();
|
||||||
@@ -228,7 +232,7 @@ class pmTrSharepointClass extends PMPlugin {
|
|||||||
$filep = fopen($imgfile, "r");
|
$filep = fopen($imgfile, "r");
|
||||||
$fileLength = filesize($imgfile);
|
$fileLength = filesize($imgfile);
|
||||||
$content = fread($filep, $fileLength);
|
$content = fread($filep, $fileLength);
|
||||||
$content = base64_encode($content);
|
//$content = base64_encode($content);
|
||||||
|
|
||||||
$paramArray = array('SourceUrl' => $imgfile, 'DestinationUrls' => $destUrlObj, 'Fields' => $fieldInfoCollObj, 'Stream' => $content);
|
$paramArray = array('SourceUrl' => $imgfile, 'DestinationUrls' => $destUrlObj, 'Fields' => $fieldInfoCollObj, 'Stream' => $content);
|
||||||
$methodName = 'CopyIntoItems';
|
$methodName = 'CopyIntoItems';
|
||||||
@@ -255,8 +259,15 @@ class pmTrSharepointClass extends PMPlugin {
|
|||||||
$methodName = 'GetDwsMetaData';
|
$methodName = 'GetDwsMetaData';
|
||||||
|
|
||||||
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
|
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
|
||||||
var_dump($result);
|
$sResult = $result->GetDwsMetaDataResult;
|
||||||
return $result;
|
$errorReturn = strpos($sResult, "Error");
|
||||||
|
if(isset($sResult) && !$errorReturn)
|
||||||
|
{
|
||||||
|
$serializeResult = serialize($sResult); // serializing the Array for Returning.
|
||||||
|
var_dump($serializeResult);
|
||||||
|
return $serializeResult;
|
||||||
|
}
|
||||||
|
else return $sResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDWSDocumentVersions($newFileName, $dwsname) {
|
function getDWSDocumentVersions($newFileName, $dwsname) {
|
||||||
@@ -291,7 +302,19 @@ class pmTrSharepointClass extends PMPlugin {
|
|||||||
$sResult = $result->DeleteVersionResult->any;
|
$sResult = $result->DeleteVersionResult->any;
|
||||||
$xmlNew = simplexml_load_string($sResult); // used to parse string to xml
|
$xmlNew = simplexml_load_string($sResult); // used to parse string to xml
|
||||||
$xmlArray = @json_decode(@json_encode($xmlNew), 1); // used to convert Objects to array
|
$xmlArray = @json_decode(@json_encode($xmlNew), 1); // used to convert Objects to array
|
||||||
$version[] = $xmlArray['result']['@attributes']['version'];
|
$versionCount = count($xmlArray['result']);
|
||||||
|
|
||||||
|
if($versionCount>1)
|
||||||
|
{
|
||||||
|
for($i=0;$i<$versionCount;$i++)
|
||||||
|
{
|
||||||
|
$version[] = $xmlArray['result'][$i]['@attributes']['version'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$version[] = $xmlArray['result']['@attributes']['version'];
|
||||||
|
}
|
||||||
|
|
||||||
$serializeResult = serialize($version); // serializing the Array for Returning.
|
$serializeResult = serialize($version); // serializing the Array for Returning.
|
||||||
var_dump($serializeResult);
|
var_dump($serializeResult);
|
||||||
return $serializeResult;
|
return $serializeResult;
|
||||||
@@ -376,14 +399,15 @@ class pmTrSharepointClass extends PMPlugin {
|
|||||||
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
|
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
|
||||||
$newResult = $result->Stream;
|
$newResult = $result->Stream;
|
||||||
|
|
||||||
$latestResult = base64_decode($newResult);
|
//$latestResult = base64_decode($newResult);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In the Below line of code, we are coping the files at our local Directory using the php file methods.
|
* In the Below line of code, we are coping the files at our local Directory using the php file methods.
|
||||||
* */
|
* */
|
||||||
$imgfile = $fileLocation . "/" . $fileName;
|
$imgfile = $fileLocation . "/" . $fileName;
|
||||||
$filep = fopen($imgfile, 'w');
|
$filep = fopen($imgfile, 'w');
|
||||||
$content = fwrite($filep, $latestResult);
|
//$content = fwrite($filep, $latestResult);
|
||||||
|
$content = fwrite($filep, $newResult);
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -400,6 +424,10 @@ class pmTrSharepointClass extends PMPlugin {
|
|||||||
$actualResult = substr($newResult, $newResultPos);
|
$actualResult = substr($newResult, $newResultPos);
|
||||||
return $actualResult;
|
return $actualResult;
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
$actualResult = substr($newResult,$urlStartPos);
|
||||||
|
return $actualResult;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user