BUG 0000 Feature: Sharepoint Triggers

Included new library to Trigger wizard that wraps common function to work with documents in sharepoint
This commit is contained in:
Hugo Loza
2011-07-04 17:09:56 -04:00
parent 80728423c4
commit e3a0aa7a86
2 changed files with 22 additions and 38 deletions

View File

@@ -51,19 +51,10 @@ class soapNtlm {
* @return unknown * @return unknown
*/ */
public function stream_open($path, $mode, $options, $opened_path) { public function stream_open($path, $mode, $options, $opened_path) {
echo "[NTLMStream::stream_open] $path , mode=$mode \n"; //echo "[NTLMStream::stream_open] $path , mode=$mode <br>";
//G::pr($options);
$authPath=explode("|", urldecode($path));
G::pr($authPath);
$path=$authPath[0];
G::pr($path);
$authO=explode(":",$authPath[1]);
G::pr($authO);
$this->path = $path; $this->path = $path;
$this->user=$authO[0];
$this->password=$authO[1];
$this->mode = $mode; $this->mode = $mode;
$this->options = $options; $this->options = $options;
$this->opened_path = $opened_path; $this->opened_path = $opened_path;
@@ -78,7 +69,7 @@ class soapNtlm {
* *
*/ */
public function stream_close() { public function stream_close() {
echo "[NTLMStream::stream_close] \n"; //echo "[NTLMStream::stream_close] <br>";
curl_close($this->ch); curl_close($this->ch);
} }
@@ -89,7 +80,7 @@ class soapNtlm {
* @return content from pos to count * @return content from pos to count
*/ */
public function stream_read($count) { public function stream_read($count) {
echo "[NTLMStream::stream_read] $count \n"; //echo "[NTLMStream::stream_read] $count <br>";
if (strlen($this->buffer) == 0) { if (strlen($this->buffer) == 0) {
return false; return false;
} }
@@ -108,7 +99,7 @@ class soapNtlm {
* @return content from pos to count * @return content from pos to count
*/ */
public function stream_write($data) { public function stream_write($data) {
echo "[NTLMStream::stream_write] \n"; //echo "[NTLMStream::stream_write] <br>";
if (strlen($this->buffer) == 0) { if (strlen($this->buffer) == 0) {
return false; return false;
} }
@@ -120,13 +111,13 @@ class soapNtlm {
* @return true if eof else false * @return true if eof else false
*/ */
public function stream_eof() { public function stream_eof() {
echo "[NTLMStream::stream_eof] "; //echo "[NTLMStream::stream_eof] ";
if ($this->pos > strlen($this->buffer)) { if ($this->pos > strlen($this->buffer)) {
echo "true \n"; //echo "true <br>";
return true; return true;
} }
echo "false \n"; //echo "false <br>";
return false; return false;
} }
@@ -134,7 +125,7 @@ class soapNtlm {
* @return int the position of the current read pointer * @return int the position of the current read pointer
*/ */
public function stream_tell() { public function stream_tell() {
echo "[NTLMStream::stream_tell] \n"; //echo "[NTLMStream::stream_tell] <br>";
return $this->pos; return $this->pos;
} }
@@ -142,7 +133,7 @@ class soapNtlm {
* Flush stream data * Flush stream data
*/ */
public function stream_flush() { public function stream_flush() {
echo "[NTLMStream::stream_flush] \n"; //echo "[NTLMStream::stream_flush] <br>";
$this->buffer = null; $this->buffer = null;
$this->pos = null; $this->pos = null;
} }
@@ -153,7 +144,7 @@ class soapNtlm {
* @return array stat information * @return array stat information
*/ */
public function stream_stat() { public function stream_stat() {
echo "[NTLMStream::stream_stat] \n"; //echo "[NTLMStream::stream_stat] <br>";
$this->createBuffer($this->path); $this->createBuffer($this->path);
$stat = array( $stat = array(
@@ -169,16 +160,9 @@ class soapNtlm {
* @return array stat information * @return array stat information
*/ */
public function url_stat($path, $flags) { public function url_stat($path, $flags) {
echo "[NTLMStream::url_stat] -> $path \n"; //G::pr($this->options);
$authPath=explode("|", urldecode($path)); //echo "[NTLMStream::url_stat] -> $path <br>";
G::pr($authPath); $this->createBuffer($path);
$path=$authPath[0];
G::pr($path);
$authO=explode(":",$authPath[1]);
G::pr($authO);
$this->user=$authO[0];
$this->password=$authO[1];
$this->createBuffer($this->path);
$stat = array( $stat = array(
'size' => strlen($this->buffer), 'size' => strlen($this->buffer),
); );
@@ -196,16 +180,16 @@ class soapNtlm {
return; return;
} }
echo "[NTLMStream::createBuffer] create buffer from : $path \n"; //echo "[NTLMStream::createBuffer] create buffer from : $path <br>";
$this->ch = curl_init($this->path); $this->ch = curl_init($this->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->user . ':' . $this->password); curl_setopt($this->ch, CURLOPT_USERPWD, $this->options['auth']);
G::pr($this->ch);
echo $this->buffer = curl_exec($this->ch); echo $this->buffer = curl_exec($this->ch);
echo "[NTLMStream::createBuffer] buffer size : " . strlen($this->buffer) . "bytes\n"; //echo "[NTLMStream::createBuffer] buffer size : " . strlen($this->buffer) . "bytes<br>";
$this->pos = 0; $this->pos = 0;
} }
@@ -213,8 +197,8 @@ G::pr($this->ch);
class NTLMSoapClient extends SoapClient { class NTLMSoapClient extends SoapClient {
function __doRequest($request, $location, $action, $version) {
function __doRequest($request, $location, $action, $version) {
$headers = array( $headers = array(
'Method: POST', 'Method: POST',
'Connection: Keep-Alive', 'Connection: Keep-Alive',
@@ -233,7 +217,7 @@ 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->user . ':' . $this->password); curl_setopt($ch, CURLOPT_USERPWD, $this->options['auth']);
$response = curl_exec($ch); $response = curl_exec($ch);
return $response; return $response;

View File

@@ -19,7 +19,7 @@
/** /**
* Sharepoint Triggers that allow ProcessMaker to perform common DWS actions * Sharepoint Triggers that allow ProcessMaker to perform common DWS actions
* @class pmTrSharepoint * @class pmTrSharepoint
* @name Sharepoint DWS Triggers * @name Sharepoint DWS Triggers v. 0.1
* @icon /images/triggers/sharepoint.gif * @icon /images/triggers/sharepoint.gif
* @className class.pmTrSharepoint.pmFunctions.php * @className class.pmTrSharepoint.pmFunctions.php
*/ */
@@ -43,7 +43,7 @@
* *
*/ */
function createDWS($sharepointServer, $auth, $name="", $users="", $title="", $documents="", $result="") { function createDWS($sharepointServer, $auth, $name="", $users="", $title="", $documents="", $result="") {
print "Trigger: createDWS"; //print "Trigger: createDWS";
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);
$beforeResult = $pmTrSharepoint->createDWS($name, $users, $title, $documents); $beforeResult = $pmTrSharepoint->createDWS($name, $users, $title, $documents);