Skip to content

Commit cf5cae5

Browse files
authored
Merge pull request #146 from thybag/develop
Dev->Master
2 parents 5732be7 + 0dd10cc commit cf5cae5

File tree

6 files changed

+22
-18
lines changed

6 files changed

+22
-18
lines changed

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"name": "thybag/php-sharepoint-lists-api",
3-
"version": "0.6.4",
43
"type": "library",
54
"description": "A simple PHP API to make working with SharePoint lists easy.",
65
"homepage": "https://github.com/thybag/PHP-SharePoint-Lists-API",

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The **PHP SharePoint Lists API** is designed to make working with SharePoint Lis
44

55
Using the PHP SharePoint Lists API, you can easily create, read, edit and delete from SharePoint list. The API also has support for querying list metadata and the list of lists.
66

7-
Known to work with: SharePoint 2007 and SharePoint online (experimental).
7+
Known to work with: SharePoint 2007, SharePoint 2013 and SharePoint online (experimental).
88

99
### Usage Instructions
1010

src/Thybag/Auth/SharePointOnlineAuth.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public function __doRequest($request, $location, $action, $version, $one_way = f
2222
// Set base headers
2323
$headers = array();
2424
$headers[] = "Content-Type: text/xml;";
25+
$headers[] = "SOAPAction: \"{$action}\"";
2526

2627
$curl = curl_init($location);
2728

@@ -39,13 +40,6 @@ public function __doRequest($request, $location, $action, $version, $one_way = f
3940
curl_setopt($curl, CURLOPT_VERBOSE,FALSE);
4041
curl_setopt($curl, CURLOPT_HEADER, FALSE);
4142

42-
// SharePoint Online requires the SOAPAction header set for ADD/EDIT and DELETE Operations.
43-
// Failure to have this will result in a "Security Validation exception"
44-
// @see http://weblogs.asp.net/jan/archive/2009/05/25/quot-the-security-validation-for-this-page-is-invalid-quot-when-calling-the-sharepoint-web-services.aspx
45-
if( strpos($request, 'UpdateListItems') !== FALSE ) {
46-
$headers[] = 'SOAPAction: "http://schemas.microsoft.com/sharepoint/soap/UpdateListItems"';
47-
}
48-
4943
// Add headers
5044
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
5145

src/Thybag/Auth/SoapClientAuth.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ public function __doRequest($request, $location, $action, $version, $one_way = 0
9292
);
9393

9494
$this->__last_request_headers = $headers;
95+
$location = $this->sanitizeUrl($location);
96+
9597
$ch = curl_init($location);
9698
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
9799

@@ -109,8 +111,6 @@ public function __doRequest($request, $location, $action, $version, $one_way = 0
109111
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
110112

111113
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
112-
curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
113-
curl_setopt($ch, CURLOPT_CERTINFO, TRUE);
114114

115115
$response = curl_exec($ch);
116116

@@ -131,4 +131,14 @@ public function __doRequest($request, $location, $action, $version, $one_way = 0
131131
}
132132
}
133133
}
134+
135+
/**
136+
* Sanitize URL to request to Sharepoint
137+
*
138+
* @param string $url
139+
* @return type string
140+
*/
141+
protected function sanitizeUrl($url) {
142+
return str_replace(" ", "%20", $url);
143+
}
134144
}

src/Thybag/Service/QueryObjectService.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,21 +216,21 @@ public function get ($options = NULL) {
216216
*
217217
* @param $rel Relation AND/OR etc
218218
* @param $col column to test
219-
* @param $test comparison type (=,!+,<,>)
219+
* @param $test comparison type (=,!+,<,>,like)
220220
* @param $value value to test with
221221
* @return Ref to self
222222
* @throws \Exception Thrown if $test is unrecognized
223223
*/
224224
private function addQueryLine ($rel, $col, $test, $value) {
225225
// Check tests are usable
226-
if (!in_array($test, array('!=', '>=', '<=', '<', '>', '='))) {
227-
throw new \Exception('Unrecognized query parameter. Please use <,>,=,>=,<= or !=');
226+
if (!in_array($test, array('!=', '>=', '<=', '<', '>', '=', 'like'))) {
227+
throw new \Exception('Unrecognized query parameter. Please use <,>,=,>=,<=, != or like');
228228
}
229229

230230
// Make sure $rel is lower-case
231231
$rel = strtolower($rel);
232232

233-
$test = str_replace(array('!=', '>=', '<=', '<', '>', '='), array('Neq', 'Geq', 'Leq', 'Lt', 'Gt', 'Eq'), $test);
233+
$test = str_replace(array('!=', '>=', '<=', '<', '>', '=', 'like'), array('Neq', 'Geq', 'Leq', 'Lt', 'Gt', 'Eq', 'Contains'), $test);
234234

235235
// Create caml
236236
$caml = $this->where_caml;
@@ -291,4 +291,4 @@ public function getOptionCAML () {
291291

292292
return $xml;
293293
}
294-
}
294+
}

src/Thybag/SharePointAPI.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,8 @@ public function CRUD ($list_name) {
772772
private function getArrayFromElementsByTagName ($rawXml, $tag, $namespace = NULL) {
773773
// Get DOM instance and load XML
774774
$dom = new \DOMDocument();
775-
$dom->loadXML($rawXml);
775+
776+
$dom->loadXML($rawXml, (LIBXML_VERSION >= 20900) ? LIBXML_PARSEHUGE : null);
776777

777778
// Is namespace set?
778779
if (!is_null($namespace)) {
@@ -1096,7 +1097,7 @@ public function getFieldVersions ($list, $id, $field) {
10961097

10971098
// Load XML in to DOM document and grab all Fields
10981099
$dom = new \DOMDocument();
1099-
$dom->loadXML($rawxml);
1100+
$dom->loadXML($rawxml, (LIBXML_VERSION >= 20900) ? LIBXML_PARSEHUGE : null);
11001101
$nodes = $dom->getElementsByTagName("Version");
11011102

11021103
// Parse results

0 commit comments

Comments
 (0)