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:
Hugo Loza
2011-07-13 18:36:37 -04:00
parent cbb4f0f5ea
commit f3ee768f1a
3 changed files with 84 additions and 30 deletions

View File

@@ -41,6 +41,16 @@ class soapNtlm {
private $buffer;
private $pos;
public function getuser()
{
return "";
}
public function getpassword()
{
return "";
}
/**
* Open the stream
*
@@ -181,12 +191,12 @@ class soapNtlm {
}
//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_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
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 "[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_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
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);
return $response;
@@ -230,21 +241,36 @@ class NTLMSoapClient extends SoapClient {
}
class PMServiceNTLMSoapClient extends NTLMSoapClient {
protected $user;
protected $password;
function setAuth($auth){
function setAuthClient($auth){
$authInfo=explode(":",$auth);
$this->user=$authInfo[0];
$this->password=$authInfo[1];
}
}
class PMServiceProviderNTLMStream extends soapNtlm {
protected $user;
protected $password;
protected static $user ;
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];
}
}

View File

@@ -164,7 +164,7 @@ function getDWSData($sharepointServer, $auth, $newFileName, $dwsname, $lastUpdat
$pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth);
$resultDWSData = $pmTrSharepoint->getDWSData($newFileName, $dwsname, $lastUpdate);
if($resultDWSData)
return $newResult;
return $resultDWSData;
else
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');
$pmTrSharepoint = new pmTrSharepointClass($sharepointServer, $auth);
$result = $pmTrSharepoint->getDWSMetaData($newFileName, $dwsname, $id);
$newResult = $result->GetDwsMetaDataResult;
if(isset($newResult))
//$newResult = $result->GetDwsMetaDataResult;
if(isset($result))
{
return "Document workspace Meta-data found";
return $result;
}
else
{
return "Document workspace Meta-data not found";
}
{
return "Document workspace Meta-data not found";
}
}

View File

@@ -12,6 +12,7 @@ class wscaller {
private $soapObj;
private $client;
private $auth;
private $clientStream;
function setAuthUser($auth) {
//print "<br>- auth Setup";
@@ -29,9 +30,13 @@ class wscaller {
// we unregister the current HTTP wrapper
stream_wrapper_unregister('http');
// 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");
$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;
} catch (Exception $e) {
echo $e;
@@ -78,7 +83,7 @@ class FieldInformationCollection {
}
class pmTrSharepointClass extends PMPlugin {
class pmTrSharepointClass{
function __construct($server, $auth) {
set_include_path(
@@ -124,15 +129,13 @@ class pmTrSharepointClass extends PMPlugin {
$url = $this->server . "/" . $dwsname . "/_vti_bin/Dws.asmx?WSDL";
$this->dwsObj->setwsdlurl($url);
if ($this->dwsObj->loadSOAPClient()) {
$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) {
@@ -208,7 +211,8 @@ class pmTrSharepointClass extends PMPlugin {
function uploadDocumentDWS($dwsname, $folderName, $sourceUrl, $filename) {
//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();
$destUrlObj = new DestinationUrlCollection();
@@ -228,7 +232,7 @@ class pmTrSharepointClass extends PMPlugin {
$filep = fopen($imgfile, "r");
$fileLength = filesize($imgfile);
$content = fread($filep, $fileLength);
$content = base64_encode($content);
//$content = base64_encode($content);
$paramArray = array('SourceUrl' => $imgfile, 'DestinationUrls' => $destUrlObj, 'Fields' => $fieldInfoCollObj, 'Stream' => $content);
$methodName = 'CopyIntoItems';
@@ -255,8 +259,15 @@ class pmTrSharepointClass extends PMPlugin {
$methodName = 'GetDwsMetaData';
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
var_dump($result);
return $result;
$sResult = $result->GetDwsMetaDataResult;
$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) {
@@ -291,7 +302,19 @@ class pmTrSharepointClass extends PMPlugin {
$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'];
$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.
var_dump($serializeResult);
return $serializeResult;
@@ -376,14 +399,15 @@ class pmTrSharepointClass extends PMPlugin {
$result = $this->dwsObj->callWsMethod($methodName, $paramArray);
$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.
* */
$imgfile = $fileLocation . "/" . $fileName;
$filep = fopen($imgfile, 'w');
$content = fwrite($filep, $latestResult);
//$content = fwrite($filep, $latestResult);
$content = fwrite($filep, $newResult);
return $content;
}
@@ -400,6 +424,10 @@ class pmTrSharepointClass extends PMPlugin {
$actualResult = substr($newResult, $newResultPos);
return $actualResult;
}
else{
$actualResult = substr($newResult,$urlStartPos);
return $actualResult;
}
}
}