Commit cb3fe52b4e20c215331660ed7dcee909de66d2e6

Authored by conradverm
1 parent 116b9085

KTS-2298

"KTAPI and Webservice should use correct php open tags"
Fixed.

Reviewed By: Kevin Fourie

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7096 c91229c3-7414-0410-bfa2-8a42b809f60b
ktwsapi/php/examples/ktws_eg_add_document.php
1   -<?
  1 +<?php
2 2 /**
3 3 * Copyright (c) 2007, The Jam Warehouse Software (Pty) Ltd.
4 4 *
5 5 * All rights reserved.
6 6 *
7   - * Redistribution and use in source and binary forms, with or without
  7 + * Redistribution and use in source and binary forms, with or without
8 8 * modification, are permitted provided that the following conditions are met:
9 9 *
10 10 * i) Redistributions of source code must retain the above copyright notice,
... ... @@ -12,8 +12,8 @@
12 12 * ii) Redistributions in binary form must reproduce the above copyright
13 13 * notice, this list of conditions and the following disclaimer in the
14 14 * documentation and/or other materials provided with the distribution.
15   - * iii) Neither the name of the The Jam Warehouse Software (Pty) Ltd nor the
16   - * names of its contributors may be used to endorse or promote products
  15 + * iii) Neither the name of the The Jam Warehouse Software (Pty) Ltd nor the
  16 + * names of its contributors may be used to endorse or promote products
17 17 * derived from this software without specific prior written permission.
18 18 *
19 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
... ... @@ -49,5 +49,5 @@ $root = $ktapi-&gt;get_root_folder();
49 49 $root->add_document('c:/temp/test.doc');
50 50  
51 51 $ktapi->logout();
52   -
  52 +
53 53 ?>
... ...
ktwsapi/php/examples/ktws_eg_anonymous.php
1   -<?
  1 +<?php
2 2 /**
3 3 * Copyright (c) 2007, The Jam Warehouse Software (Pty) Ltd.
4 4 *
5 5 * All rights reserved.
6 6 *
7   - * Redistribution and use in source and binary forms, with or without
  7 + * Redistribution and use in source and binary forms, with or without
8 8 * modification, are permitted provided that the following conditions are met:
9 9 *
10 10 * i) Redistributions of source code must retain the above copyright notice,
... ... @@ -12,8 +12,8 @@
12 12 * ii) Redistributions in binary form must reproduce the above copyright
13 13 * notice, this list of conditions and the following disclaimer in the
14 14 * documentation and/or other materials provided with the distribution.
15   - * iii) Neither the name of the The Jam Warehouse Software (Pty) Ltd nor the
16   - * names of its contributors may be used to endorse or promote products
  15 + * iii) Neither the name of the The Jam Warehouse Software (Pty) Ltd nor the
  16 + * names of its contributors may be used to endorse or promote products
17 17 * derived from this software without specific prior written permission.
18 18 *
19 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
... ... @@ -52,5 +52,5 @@ $root=$ktapi-&gt;get_root_folder();
52 52  
53 53  
54 54 $ktapi->logout();
55   -
  55 +
56 56 ?>
... ...
ktwsapi/php/examples/ktws_eg_checkin.php
1   -<?
  1 +<?php
2 2 /**
3 3 * Copyright (c) 2007, The Jam Warehouse Software (Pty) Ltd.
4 4 *
5 5 * All rights reserved.
6 6 *
7   - * Redistribution and use in source and binary forms, with or without
  7 + * Redistribution and use in source and binary forms, with or without
8 8 * modification, are permitted provided that the following conditions are met:
9 9 *
10 10 * i) Redistributions of source code must retain the above copyright notice,
... ... @@ -12,8 +12,8 @@
12 12 * ii) Redistributions in binary form must reproduce the above copyright
13 13 * notice, this list of conditions and the following disclaimer in the
14 14 * documentation and/or other materials provided with the distribution.
15   - * iii) Neither the name of the The Jam Warehouse Software (Pty) Ltd nor the
16   - * names of its contributors may be used to endorse or promote products
  15 + * iii) Neither the name of the The Jam Warehouse Software (Pty) Ltd nor the
  16 + * names of its contributors may be used to endorse or promote products
17 17 * derived from this software without specific prior written permission.
18 18 *
19 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
... ... @@ -75,5 +75,5 @@ if (PEAR::isError($result))
75 75 }
76 76  
77 77 $ktapi->logout();
78   -
  78 +
79 79 ?>
... ...
ktwsapi/php/examples/ktws_eg_create_folder.php
1   -<?
  1 +<?php
2 2 /**
3 3 * Copyright (c) 2007, The Jam Warehouse Software (Pty) Ltd.
4 4 *
5 5 * All rights reserved.
6 6 *
7   - * Redistribution and use in source and binary forms, with or without
  7 + * Redistribution and use in source and binary forms, with or without
8 8 * modification, are permitted provided that the following conditions are met:
9 9 *
10 10 * i) Redistributions of source code must retain the above copyright notice,
... ... @@ -12,8 +12,8 @@
12 12 * ii) Redistributions in binary form must reproduce the above copyright
13 13 * notice, this list of conditions and the following disclaimer in the
14 14 * documentation and/or other materials provided with the distribution.
15   - * iii) Neither the name of the The Jam Warehouse Software (Pty) Ltd nor the
16   - * names of its contributors may be used to endorse or promote products
  15 + * iii) Neither the name of the The Jam Warehouse Software (Pty) Ltd nor the
  16 + * names of its contributors may be used to endorse or promote products
17 17 * derived from this software without specific prior written permission.
18 18 *
19 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
... ...
ktwsapi/php/examples/ktws_eg_doc_info.php
1   -<?
  1 +<?php
2 2 /**
3 3 * Copyright (c) 2007, The Jam Warehouse Software (Pty) Ltd.
4 4 *
5 5 * All rights reserved.
6 6 *
7   - * Redistribution and use in source and binary forms, with or without
  7 + * Redistribution and use in source and binary forms, with or without
8 8 * modification, are permitted provided that the following conditions are met:
9 9 *
10 10 * i) Redistributions of source code must retain the above copyright notice,
... ... @@ -12,8 +12,8 @@
12 12 * ii) Redistributions in binary form must reproduce the above copyright
13 13 * notice, this list of conditions and the following disclaimer in the
14 14 * documentation and/or other materials provided with the distribution.
15   - * iii) Neither the name of the The Jam Warehouse Software (Pty) Ltd nor the
16   - * names of its contributors may be used to endorse or promote products
  15 + * iii) Neither the name of the The Jam Warehouse Software (Pty) Ltd nor the
  16 + * names of its contributors may be used to endorse or promote products
17 17 * derived from this software without specific prior written permission.
18 18 *
19 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
... ...
ktwsapi/php/examples/ktws_eg_folder_listing.php
1   -<?
  1 +<?php
2 2 /**
3 3 * Copyright (c) 2007, The Jam Warehouse Software (Pty) Ltd.
4 4 *
5 5 * All rights reserved.
6 6 *
7   - * Redistribution and use in source and binary forms, with or without
  7 + * Redistribution and use in source and binary forms, with or without
8 8 * modification, are permitted provided that the following conditions are met:
9 9 *
10 10 * i) Redistributions of source code must retain the above copyright notice,
... ... @@ -12,8 +12,8 @@
12 12 * ii) Redistributions in binary form must reproduce the above copyright
13 13 * notice, this list of conditions and the following disclaimer in the
14 14 * documentation and/or other materials provided with the distribution.
15   - * iii) Neither the name of the The Jam Warehouse Software (Pty) Ltd nor the
16   - * names of its contributors may be used to endorse or promote products
  15 + * iii) Neither the name of the The Jam Warehouse Software (Pty) Ltd nor the
  16 + * names of its contributors may be used to endorse or promote products
17 17 * derived from this software without specific prior written permission.
18 18 *
19 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
... ... @@ -67,7 +67,7 @@ foreach($listing as $folderitem)
67 67 $title = $folderitem->title;
68 68 $item_type = $folderitem->item_type;
69 69 $mime_display = $folderitem->mime_display;
70   -
  70 +
71 71 print "$title $item_type $mime_display\n";
72 72 }
73 73  
... ...
ktwsapi/php/ktwsapi.inc.php
1   -<?
  1 +<?php
2 2 /**
3 3 * Copyright (c) 2007, The Jam Warehouse Software (Pty) Ltd.
4 4 *
5 5 * All rights reserved.
6 6 *
7   - * Redistribution and use in source and binary forms, with or without
  7 + * Redistribution and use in source and binary forms, with or without
8 8 * modification, are permitted provided that the following conditions are met:
9 9 *
10 10 * i) Redistributions of source code must retain the above copyright notice,
... ... @@ -12,8 +12,8 @@
12 12 * ii) Redistributions in binary form must reproduce the above copyright
13 13 * notice, this list of conditions and the following disclaimer in the
14 14 * documentation and/or other materials provided with the distribution.
15   - * iii) Neither the name of the The Jam Warehouse Software (Pty) Ltd nor the
16   - * names of its contributors may be used to endorse or promote products
  15 + * iii) Neither the name of the The Jam Warehouse Software (Pty) Ltd nor the
  16 + * names of its contributors may be used to endorse or promote products
17 17 * derived from this software without specific prior written permission.
18 18 *
19 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
... ... @@ -49,9 +49,9 @@ define(&#39;KTWSAPI_ERR_SESSION_NOT_STARTED&#39;,&#39;An active session has not been started
49 49 class KTWSAPI_FolderItem
50 50 {
51 51 var $ktapi;
52   -
  52 +
53 53 var $parent_id;
54   -
  54 +
55 55 /**
56 56 * Upload a file to KT. Returns a temp filename on the server.
57 57 *
... ... @@ -66,73 +66,73 @@ class KTWSAPI_FolderItem
66 66 {
67 67 return new PEAR_Error('CURL library not included.');
68 68 }
69   -
  69 +
70 70 if (!is_file($filename) || !is_readable($filename))
71 71 {
72   - return new PEAR_Error('Could not access file to upload.');
  72 + return new PEAR_Error('Could not access file to upload.');
73 73 }
74   -
  74 +
75 75 if (is_null($document_id))
76 76 {
77 77 $uploadname="upload_document";
78 78 }
79   - else
  79 + else
80 80 {
81 81 $uploadname="upload_$document_id";
82   -
  82 +
83 83 }
84   -
  84 +
85 85 $session_id = $this->ktapi->session;
86   -
  86 +
87 87 $ch = curl_init();
88   - $fp = fopen ($filename, 'r');
  88 + $fp = fopen ($filename, 'r');
89 89 curl_setopt($ch, CURLOPT_URL, KTUploadURL);
90 90 curl_setopt($ch, CURLOPT_POST, 1);
91   -
  91 +
92 92 $post_fields = array(
93 93 'session_id'=>$session_id,
94 94 'action'=>$action,
95 95 'document_id'=>$document_id,
96 96 $uploadname=>'@' . $filename
97   -
  97 +
98 98 );
99   -
  99 +
100 100 $str = serialize($post_fields);
101   -
  101 +
102 102 curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
103   - curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  103 + curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
104 104 $response = curl_exec ($ch);
105 105 curl_close ($ch);
106   -
  106 +
107 107 if ($response == '')
108 108 {
109 109 return new PEAR_Error('No response from server.');
110 110 }
111   -
  111 +
112 112 $fields=explode('&',$response);
113 113 $status_code=-1;
114 114 $msg='*not set*';
115 115 $upload_status='';
116   -
  116 +
117 117  
118 118 foreach($fields as $field)
119 119 {
120 120 list($fieldname, $value) = explode('=', $field);
121   -
  121 +
122 122 $$fieldname = $value;
123 123 }
124   -
  124 +
125 125 if ($status_code == 0)
126 126 {
127 127 $upload_status= unserialize(urldecode($upload_status));
128   -
  128 +
129 129 if ($upload_status[$uploadname]['size'] == filesize($filename))
130 130 {
131 131 return $upload_status[$uploadname]['tmp_name'];
132 132 }
133 133 }
134 134 return new PEAR_Error('Could not upload file.');
135   -
  135 +
136 136 }
137 137  
138 138 /**
... ... @@ -146,27 +146,27 @@ class KTWSAPI_FolderItem
146 146 function _download_file($url, $localpath, $filename)
147 147 {
148 148 $localfilename = $localpath . '/' . $filename;
149   -
  149 +
150 150 $fp = fopen($localfilename,'wb');
151 151 if ($fp == null)
152 152 {
153 153 return new PEAR_Error('Could not create local file');
154 154 }
155   -
  155 +
156 156 $ch = curl_init();
157   -
  157 +
158 158 curl_setopt($ch, CURLOPT_FILE, $fp);
159 159 curl_setopt($ch, CURLOPT_HEADER, 0);
160   - curl_setopt($ch, CURLOPT_URL, $url);
161   -
  160 + curl_setopt($ch, CURLOPT_URL, $url);
  161 +
162 162 $response = curl_exec($ch);
163 163 curl_close($ch);
164   -
  164 +
165 165 fclose($fp);
166   -
167   - return $response;
  166 +
  167 + return $response;
168 168 }
169   -
  169 +
170 170 /**
171 171 * Returns a reference to the parent folder.
172 172 *
... ... @@ -177,7 +177,7 @@ class KTWSAPI_FolderItem
177 177 $parent = &KTAPI::get_folder_by_id($this->parent_id);
178 178 return $parent;
179 179 }
180   -
  180 +
181 181 }
182 182  
183 183 class KTWSAPI_Folder extends KTWSAPI_FolderItem
... ... @@ -185,7 +185,7 @@ class KTWSAPI_Folder extends KTWSAPI_FolderItem
185 185 var $folder_name;
186 186 var $full_path;
187 187 var $folder_id;
188   -
  188 +
189 189 /**
190 190 * Constructor
191 191 *
... ... @@ -199,9 +199,9 @@ class KTWSAPI_Folder extends KTWSAPI_FolderItem
199 199 $this->folder_id = $kt_folder_detail->id+0;
200 200 $this->folder_name = $kt_folder_detail->folder_name;
201 201 $this->parent_id = $kt_folder_detail->parent_id+0;
202   - $this->full_path = $kt_folder_detail->full_path;
  202 + $this->full_path = $kt_folder_detail->full_path;
203 203 }
204   -
  204 +
205 205 /**
206 206 * Returns a reference to a KTWSAPI_Folder
207 207 *
... ... @@ -214,22 +214,22 @@ class KTWSAPI_Folder extends KTWSAPI_FolderItem
214 214 assert(!is_null($ktapi));
215 215 assert(is_a($ktapi, 'KTWSAPI'));
216 216 assert(is_numeric($folderid));
217   -
  217 +
218 218 $folderid += 0;
219   -
  219 +
220 220 $kt_folder_detail = $ktapi->soapclient->get_folder_detail($ktapi->session, $folderid);
221 221 if (SOAP_Client::isError($kt_folder_detail))
222 222 {
223 223 return $kt_folder_detail;
224 224 }
225   -
  225 +
226 226 if ($kt_folder_detail->status_code != 0)
227 227 {
228 228 return new PEAR_Error($kt_folder_detail->message);
229 229 }
230   -
231   - $folder = & new KTWSAPI_Folder($ktapi, $kt_folder_detail);
232   -
  230 +
  231 + $folder = & new KTWSAPI_Folder($ktapi, $kt_folder_detail);
  232 +
233 233 return $folder;
234 234 }
235 235  
... ... @@ -242,7 +242,7 @@ class KTWSAPI_Folder extends KTWSAPI_FolderItem
242 242 {
243 243 return $this->parent_id;
244 244 }
245   -
  245 +
246 246 /**
247 247 * Returns the folder name.
248 248 *
... ... @@ -251,8 +251,8 @@ class KTWSAPI_Folder extends KTWSAPI_FolderItem
251 251 function get_folder_name()
252 252 {
253 253 return $this->folder_name;
254   - }
255   -
  254 + }
  255 +
256 256 /**
257 257 * Returns the current folder id.
258 258 *
... ... @@ -261,7 +261,7 @@ class KTWSAPI_Folder extends KTWSAPI_FolderItem
261 261 function get_folderid()
262 262 {
263 263 return $this->folder_id;
264   - }
  264 + }
265 265  
266 266 /**
267 267 * Returns the foldre based on foldername.
... ... @@ -280,23 +280,23 @@ class KTWSAPI_Folder extends KTWSAPI_FolderItem
280 280 {
281 281 $path = substr($path,12);
282 282 }
283   -
  283 +
284 284 $kt_folder_detail = $this->ktapi->soapclient->get_folder_detail_by_name($this->ktapi->session, $path);
285   -
  285 +
286 286 if (SOAP_Client::isError($kt_folder_detail))
287 287 {
288 288 return $kt_folder_detail;
289 289 }
290   -
  290 +
291 291 if ($kt_folder_detail->status_code != 0)
292 292 {
293 293 return new PEAR_Error($kt_folder_detail->message);
294 294 }
295   -
296   - $folder= & new KTWSAPI_Folder($this->ktapi, $kt_folder_detail);
297   - return $folder;
  295 +
  296 + $folder= & new KTWSAPI_Folder($this->ktapi, $kt_folder_detail);
  297 + return $folder;
298 298 }
299   -
  299 +
300 300 /**
301 301 * Returns the full folder path.
302 302 *
... ... @@ -305,8 +305,8 @@ class KTWSAPI_Folder extends KTWSAPI_FolderItem
305 305 function get_full_path()
306 306 {
307 307 return $this->full_path;
308   - }
309   -
  308 + }
  309 +
310 310 /**
311 311 * Returns the contents of a folder.
312 312 *
... ... @@ -321,15 +321,15 @@ class KTWSAPI_Folder extends KTWSAPI_FolderItem
321 321 {
322 322 return $kt_folder_contents;
323 323 }
324   -
  324 +
325 325 if ($kt_folder_contents->status_code != 0)
326 326 {
327 327 return new PEAR_Error($kt_folder_contents->message);
328 328 }
329   -
330   - return $kt_folder_contents->items;
  329 +
  330 + return $kt_folder_contents->items;
331 331 }
332   -
  332 +
333 333 /**
334 334 * Returns a document based on title.
335 335 *
... ... @@ -338,7 +338,7 @@ class KTWSAPI_Folder extends KTWSAPI_FolderItem
338 338 */
339 339 function &get_document_by_name($title)
340 340 {
341   - $path = $this->full_path . '/' . $title;
  341 + $path = $this->full_path . '/' . $title;
342 342 if (substr($path,0,13) == '/Root Folder/')
343 343 {
344 344 $path = substr($path,13);
... ... @@ -347,21 +347,21 @@ class KTWSAPI_Folder extends KTWSAPI_FolderItem
347 347 {
348 348 $path = substr($path,12);
349 349 }
350   -
  350 +
351 351 $kt_document_detail = $this->ktapi->soapclient->get_document_detail_by_name($this->ktapi->session, $path, 'T');
352   -
  352 +
353 353 if (SOAP_Client::isError($kt_document_detail))
354 354 {
355 355 return $kt_document_detail;
356 356 }
357   -
  357 +
358 358 if ($kt_document_detail->status_code != 0)
359 359 {
360 360 return new PEAR_Error($kt_document_detail->message);
361 361 }
362   -
  362 +
363 363 $document = & new KTWSAPI_Document($this->ktapi, $kt_document_detail);
364   -
  364 +
365 365 return $document;
366 366 }
367 367  
... ... @@ -373,7 +373,7 @@ class KTWSAPI_Folder extends KTWSAPI_FolderItem
373 373 */
374 374 function &get_document_by_filename($filename)
375 375 {
376   - $path = $this->full_path . '/' . $filename;
  376 + $path = $this->full_path . '/' . $filename;
377 377 if (substr($path,0,13) == '/Root Folder/')
378 378 {
379 379 $path = substr($path,13);
... ... @@ -382,24 +382,24 @@ class KTWSAPI_Folder extends KTWSAPI_FolderItem
382 382 {
383 383 $path = substr($path,12);
384 384 }
385   -
  385 +
386 386 $kt_document_detail = $this->ktapi->soapclient->get_document_detail_by_name($this->ktapi->session, $path, 'F');
387   -
  387 +
388 388 if (SOAP_Client::isError($kt_document_detail))
389 389 {
390 390 return $kt_document_detail;
391 391 }
392   -
  392 +
393 393 if ($kt_document_detail->status_code != 0)
394 394 {
395 395 return new PEAR_Error($kt_document_detail->message);
396 396 }
397   -
  397 +
398 398 $document = & new KTWSAPI_Document($this->ktapi, $kt_document_detail);
399 399 return $document;
400 400 }
401   -
402   -
  401 +
  402 +
403 403 /**
404 404 * Adds a sub folder.
405 405 *
... ... @@ -413,17 +413,17 @@ class KTWSAPI_Folder extends KTWSAPI_FolderItem
413 413 {
414 414 return $kt_folder_detail;
415 415 }
416   -
  416 +
417 417 if ($kt_folder_detail->status_code != 0)
418 418 {
419 419 return new PEAR_Error($kt_folder_detail->message);
420 420 }
421   -
  421 +
422 422 $folder = &new KTWSAPI_Folder($this->ktapi, $kt_folder_detail);
423   -
  423 +
424 424 return $folder;
425 425 }
426   -
  426 +
427 427 /**
428 428 * Deletes the current folder.
429 429 *
... ... @@ -438,15 +438,15 @@ class KTWSAPI_Folder extends KTWSAPI_FolderItem
438 438 {
439 439 return $kt_response;
440 440 }
441   -
  441 +
442 442 if ($kt_response->status_code != 0)
443 443 {
444 444 return new PEAR_Error($kt_response->message);
445 445 }
446   -
  446 +
447 447 return true;
448 448 }
449   -
  449 +
450 450 /**
451 451 * Renames the current folder.
452 452 *
... ... @@ -460,15 +460,15 @@ class KTWSAPI_Folder extends KTWSAPI_FolderItem
460 460 {
461 461 return $kt_response;
462 462 }
463   -
  463 +
464 464 if ($kt_response->status_code != 0)
465 465 {
466 466 return new PEAR_Error($kt_response->message);
467 467 }
468   -
  468 +
469 469 return true;
470 470 }
471   -
  471 +
472 472 /**
473 473 * Moves a folder to another location.
474 474 *
... ... @@ -480,18 +480,18 @@ class KTWSAPI_Folder extends KTWSAPI_FolderItem
480 480 {
481 481 assert(!is_null($ktwsapi_target_folder));
482 482 assert(is_a($ktwsapi_target_folder,'KTWSAPI_Folder'));
483   -
  483 +
484 484 $kt_response = $this->ktapi->soapclient->move_folder($this->ktapi->session, $this->folder_id,$ktwsapi_target_folder->get_folderid());
485 485 if (SOAP_Client::isError($kt_response))
486 486 {
487 487 return $kt_response;
488 488 }
489   -
  489 +
490 490 if ($kt_response->status_code != 0)
491 491 {
492 492 return new PEAR_Error($kt_response->message);
493 493 }
494   -
  494 +
495 495 return true;
496 496 }
497 497  
... ... @@ -506,23 +506,23 @@ class KTWSAPI_Folder extends KTWSAPI_FolderItem
506 506 {
507 507 assert(!is_null($ktwsapi_target_folder));
508 508 assert(is_a($ktwsapi_target_folder,'KTWSAPI_Folder'));
509   -
  509 +
510 510 $targetid=$ktwsapi_target_folder->get_folderid();
511   -
  511 +
512 512 $kt_response = $this->ktapi->soapclient->copy_folder($this->ktapi->session, $this->folder_id,$targetid, $reason);
513 513 if (SOAP_Client::isError($kt_response))
514 514 {
515 515 return $kt_response;
516 516 }
517   -
  517 +
518 518 if ($kt_response->status_code != 0)
519 519 {
520 520 return new PEAR_Error($kt_response->message);
521 521 }
522   -
  522 +
523 523 return true;
524   - }
525   -
  524 + }
  525 +
526 526 /**
527 527 * Adds a document to the current folder.
528 528 *
... ... @@ -535,15 +535,15 @@ class KTWSAPI_Folder extends KTWSAPI_FolderItem
535 535 {
536 536 if (empty($title))
537 537 {
538   - $title=basename($filename);
539   - }
540   - $basename=basename($filename);
541   -
  538 + $title=basename($filename);
  539 + }
  540 + $basename=basename($filename);
  541 +
542 542 if (empty($documenttype))
543 543 {
544 544 $documenttype='Default';
545 545 }
546   -
  546 +
547 547 // First step - upload file
548 548 $tempfilename = $this->_upload_file($filename,'A');
549 549 if (PEAR::isError($tempfilename))
... ... @@ -562,13 +562,13 @@ class KTWSAPI_Folder extends KTWSAPI_FolderItem
562 562 {
563 563 return new PEAR_Error($kt_document_detail->message);
564 564 }
565   -
  565 +
566 566 $document = & new KTWSAPI_Document($this->ktapi, $kt_document_detail);
567 567 return $document;
568 568 }
569 569 }
570 570  
571   -class KTWSAPI_Document extends KTWSAPI_FolderItem
  571 +class KTWSAPI_Document extends KTWSAPI_FolderItem
572 572 {
573 573 var $document_id;
574 574 var $title;
... ... @@ -583,7 +583,7 @@ class KTWSAPI_Document extends KTWSAPI_FolderItem
583 583 var $workflow_state;
584 584 var $checkout_by;
585 585 var $full_path;
586   -
  586 +
587 587 /**
588 588 * Constructor
589 589 *
... ... @@ -609,7 +609,7 @@ class KTWSAPI_Document extends KTWSAPI_FolderItem
609 609 $this->checkout_by = $kt_document_detail->checkout_by;
610 610 $this->full_path = $kt_document_detail->full_path;
611 611 }
612   -
  612 +
613 613 /**
614 614 * Returns a reference to a document.
615 615 *
... ... @@ -618,12 +618,12 @@ class KTWSAPI_Document extends KTWSAPI_FolderItem
618 618 * @param boolean $loadinfo
619 619 * @return KTWSAPI_Document
620 620 */
621   - function &get(&$ktapi, $documentid, $loadinfo=true)
  621 + function &get(&$ktapi, $documentid, $loadinfo=true)
622 622 {
623 623 assert(!is_null($ktapi));
624 624 assert(is_a($ktapi, 'KTWSAPI'));
625 625 assert(is_numeric($documentid));
626   -
  626 +
627 627 if ($loadinfo)
628 628 {
629 629 $kt_document_detail = $ktapi->soapclient->get_document_detail($ktapi->session, $documentid);
... ... @@ -635,19 +635,19 @@ class KTWSAPI_Document extends KTWSAPI_FolderItem
635 635 if ($kt_document_detail->status_code != 0)
636 636 {
637 637 return new PEAR_Error($kt_document_detail->message);
638   - }
  638 + }
639 639 }
640   - else
  640 + else
641 641 {
642 642 $kt_document_detail = array(
643   - 'document_id'=>$documentid,
  643 + 'document_id'=>$documentid,
644 644 );
645 645 }
646   -
647   - $document=& new KTWSAPI_Document($ktapi, $kt_document_detail);
648   - return $document;
  646 +
  647 + $document=& new KTWSAPI_Document($ktapi, $kt_document_detail);
  648 + return $document;
649 649 }
650   -
  650 +
651 651 /**
652 652 * Checks in a document.
653 653 *
... ... @@ -658,14 +658,14 @@ class KTWSAPI_Document extends KTWSAPI_FolderItem
658 658 */
659 659 function checkin($filename, $reason, $major_update )
660 660 {
661   - $basename=basename($filename);
662   -
  661 + $basename=basename($filename);
  662 +
663 663 $tempfilename = $this->_upload_file($filename,'C', $this->document_id);
664 664 if (PEAR::isError($tempfilename))
665 665 {
666 666 return new PEAR_Error($tempfilename->message);
667 667 }
668   -
  668 +
669 669 $kt_response = $this->ktapi->soapclient->checkin_document($this->ktapi->session, $this->document_id, $basename, $reason, $tempfilename, $major_update );
670 670 if (SOAP_Client::isError($kt_response))
671 671 {
... ... @@ -676,10 +676,10 @@ class KTWSAPI_Document extends KTWSAPI_FolderItem
676 676 {
677 677 return new PEAR_Error($kt_response->message);
678 678 }
679   -
680   - return true;
  679 +
  680 + return true;
681 681 }
682   -
  682 +
683 683 /**
684 684 * Checks out a document.
685 685 *
... ... @@ -688,12 +688,12 @@ class KTWSAPI_Document extends KTWSAPI_FolderItem
688 688 * @return true
689 689 */
690 690 function checkout($reason, $localpath=null)
691   - {
  691 + {
692 692 if (is_null($localpath))
693 693 {
694 694 $localpath = $this->ktapi->get_download_path();
695 695 }
696   -
  696 +
697 697 if (!is_dir($localpath))
698 698 {
699 699 return new PEAR_Error('local path does not exist');
... ... @@ -702,7 +702,7 @@ class KTWSAPI_Document extends KTWSAPI_FolderItem
702 702 {
703 703 return new PEAR_Error('local path is not writable');
704 704 }
705   -
  705 +
706 706 $kt_response = $this->ktapi->soapclient->checkout_document($this->ktapi->session, $this->document_id, $reason);
707 707 if (SOAP_Client::isError($kt_response))
708 708 {
... ... @@ -713,18 +713,18 @@ class KTWSAPI_Document extends KTWSAPI_FolderItem
713 713 {
714 714 return new PEAR_Error($kt_response->message);
715 715 }
716   -
  716 +
717 717 $url = $kt_response->message;
718   -
  718 +
719 719 $response = $this->_download_file($url, $localpath, $this->filename);
720 720 if (PEAR::isError($response))
721 721 {
722 722 return new PEAR_Error($kt_response->message);
723   - }
724   -
725   - return true;
  723 + }
  724 +
  725 + return true;
726 726 }
727   -
  727 +
728 728 /**
729 729 * Undo a document checkout
730 730 *
... ... @@ -743,7 +743,7 @@ class KTWSAPI_Document extends KTWSAPI_FolderItem
743 743 {
744 744 return new PEAR_Error($kt_response->message);
745 745 }
746   -
  746 +
747 747 return true;
748 748 }
749 749  
... ... @@ -755,12 +755,12 @@ class KTWSAPI_Document extends KTWSAPI_FolderItem
755 755 * @return true
756 756 */
757 757 function download($version=null, $localpath=null)
758   - {
  758 + {
759 759 if (is_null($localpath))
760 760 {
761 761 $localpath = $this->ktapi->get_download_path();
762 762 }
763   -
  763 +
764 764 if (!is_dir($localpath))
765 765 {
766 766 return new PEAR_Error('local path does not exist');
... ... @@ -769,7 +769,7 @@ class KTWSAPI_Document extends KTWSAPI_FolderItem
769 769 {
770 770 return new PEAR_Error('local path is not writable');
771 771 }
772   -
  772 +
773 773 $kt_response = $this->ktapi->soapclient->download_document($this->ktapi->session, $this->document_id);
774 774 if (SOAP_Client::isError($kt_response))
775 775 {
... ... @@ -780,18 +780,18 @@ class KTWSAPI_Document extends KTWSAPI_FolderItem
780 780 {
781 781 return new PEAR_Error($kt_response->message);
782 782 }
783   -
  783 +
784 784 $url = $kt_response->message;
785   -
  785 +
786 786 $response = $this->_download_file($url, $localpath, $this->filename);
787 787 if (PEAR::isError($response))
788 788 {
789 789 return new PEAR_Error($kt_response->message);
790   - }
791   -
792   - return true;
  790 + }
  791 +
  792 + return true;
793 793 }
794   -
  794 +
795 795 /**
796 796 * Deletes the current document.
797 797 *
... ... @@ -810,17 +810,17 @@ class KTWSAPI_Document extends KTWSAPI_FolderItem
810 810 {
811 811 return new PEAR_Error($kt_response->message);
812 812 }
813   -
  813 +
814 814 return true;
815   - }
816   -
  815 + }
  816 +
817 817 /**
818 818 * Changes the owner of the document.
819 819 *
820 820 * @param string $username
821 821 * @param string $reason
822 822 * @return true
823   - */
  823 + */
824 824 function change_owner($username, $reason)
825 825 {
826 826 $kt_response = $this->ktapi->soapclient->change_document_owner($this->ktapi->session, $this->document_id, $username, $reason);
... ... @@ -833,18 +833,18 @@ class KTWSAPI_Document extends KTWSAPI_FolderItem
833 833 {
834 834 return new PEAR_Error($kt_response->message);
835 835 }
836   -
  836 +
837 837 return true;
838   - }
839   -
  838 + }
  839 +
840 840 /**
841 841 * Copies the document to the specified folder.
842 842 *
843   - * @param KTWSAPI_Folder $folder
  843 + * @param KTWSAPI_Folder $folder
844 844 * @param string $reason
845 845 * @param string $newtitle
846 846 * @param string $newfilename
847   - */
  847 + */
848 848 function copy(&$folder,$reason,$newtitle='',$newfilename='')
849 849 {
850 850 assert(is_a($folder,'KTWSAPI_Folder'));
... ... @@ -861,10 +861,10 @@ class KTWSAPI_Document extends KTWSAPI_FolderItem
861 861 {
862 862 return new PEAR_Error($kt_response->message);
863 863 }
864   -
  864 +
865 865 return true;
866 866 }
867   -
  867 +
868 868 /**
869 869 * Moves the current folder to the specified folder.
870 870 *
... ... @@ -878,7 +878,7 @@ class KTWSAPI_Document extends KTWSAPI_FolderItem
878 878 {
879 879 assert(is_a($folder,'KTWSAPI_Folder'));
880 880 assert(!is_null($folder));
881   -
  881 +
882 882 $folder_id = $folder->folderid;
883 883 $kt_response = $this->ktapi->soapclient->move_document($this->ktapi->session, $this->document_id, $folder_id, $reason, $newtitle, $newfilename);
884 884 if (SOAP_Client::isError($kt_response))
... ... @@ -890,7 +890,7 @@ class KTWSAPI_Document extends KTWSAPI_FolderItem
890 890 {
891 891 return new PEAR_Error($kt_response->message);
892 892 }
893   -
  893 +
894 894 return true;
895 895 }
896 896  
... ... @@ -912,10 +912,10 @@ class KTWSAPI_Document extends KTWSAPI_FolderItem
912 912 {
913 913 return new PEAR_Error($kt_response->message);
914 914 }
915   -
  915 +
916 916 return true;
917 917 }
918   -
  918 +
919 919 /**
920 920 * Renames the title of the current document.
921 921 *
... ... @@ -934,10 +934,10 @@ class KTWSAPI_Document extends KTWSAPI_FolderItem
934 934 {
935 935 return new PEAR_Error($kt_response->message);
936 936 }
937   -
  937 +
938 938 return true;
939 939 }
940   -
  940 +
941 941 /**
942 942 * Renames the filename of the current document.
943 943 *
... ... @@ -956,10 +956,10 @@ class KTWSAPI_Document extends KTWSAPI_FolderItem
956 956 {
957 957 return new PEAR_Error($kt_response->message);
958 958 }
959   -
  959 +
960 960 return true;
961 961 }
962   -
  962 +
963 963 /**
964 964 * Starts a workflow on the current document.
965 965 *
... ... @@ -978,7 +978,7 @@ class KTWSAPI_Document extends KTWSAPI_FolderItem
978 978 {
979 979 return new PEAR_Error($kt_response->message);
980 980 }
981   -
  981 +
982 982 return true;
983 983 }
984 984  
... ... @@ -986,7 +986,7 @@ class KTWSAPI_Document extends KTWSAPI_FolderItem
986 986 * Removes the workflow process from the current document.
987 987 *
988 988 * @return true
989   - */
  989 + */
990 990 function delete_workflow()
991 991 {
992 992 $kt_response = $this->ktapi->soapclient->delete_document_workflow($this->ktapi->session, $this->document_id);
... ... @@ -999,10 +999,10 @@ class KTWSAPI_Document extends KTWSAPI_FolderItem
999 999 {
1000 1000 return new PEAR_Error($kt_response->message);
1001 1001 }
1002   -
  1002 +
1003 1003 return true;
1004 1004 }
1005   -
  1005 +
1006 1006 /**
1007 1007 * Performs a transition on the current document.
1008 1008 *
... ... @@ -1022,10 +1022,10 @@ class KTWSAPI_Document extends KTWSAPI_FolderItem
1022 1022 {
1023 1023 return new PEAR_Error($kt_response->message);
1024 1024 }
1025   -
  1025 +
1026 1026 return true;
1027 1027 }
1028   -
  1028 +
1029 1029 /**
1030 1030 * Returns metadata on the document.
1031 1031 *
... ... @@ -1043,7 +1043,7 @@ class KTWSAPI_Document extends KTWSAPI_FolderItem
1043 1043 {
1044 1044 return new PEAR_Error($kt_metadata_response->message);
1045 1045 }
1046   -
  1046 +
1047 1047 return $kt_metadata_response;
1048 1048 }
1049 1049  
... ... @@ -1065,10 +1065,10 @@ class KTWSAPI_Document extends KTWSAPI_FolderItem
1065 1065 {
1066 1066 return new PEAR_Error($kt_response->message);
1067 1067 }
1068   -
  1068 +
1069 1069 return true;
1070   - }
1071   -
  1070 + }
  1071 +
1072 1072 /**
1073 1073 * Returns the transaction history on the current document.
1074 1074 *
... ... @@ -1086,10 +1086,10 @@ class KTWSAPI_Document extends KTWSAPI_FolderItem
1086 1086 {
1087 1087 return new PEAR_Error($kt_document_transaction_history_response->message);
1088 1088 }
1089   -
  1089 +
1090 1090 return $kt_document_transaction_history_response->history;
1091 1091 }
1092   -
  1092 +
1093 1093 /**
1094 1094 * Returns the version history on the current document.
1095 1095 *
... ... @@ -1107,9 +1107,9 @@ class KTWSAPI_Document extends KTWSAPI_FolderItem
1107 1107 {
1108 1108 return new PEAR_Error($kt_document_version_history_response->message);
1109 1109 }
1110   -
  1110 +
1111 1111 return $kt_document_version_history_response->history;
1112   - }
  1112 + }
1113 1113 }
1114 1114  
1115 1115 class KTWSAPI
... ... @@ -1124,7 +1124,7 @@ class KTWSAPI
1124 1124 var $timeout;
1125 1125 var $session;
1126 1126 var $download_path;
1127   -
  1127 +
1128 1128 /**
1129 1129 * Constructor
1130 1130 *
... ... @@ -1138,9 +1138,9 @@ class KTWSAPI
1138 1138 $this->timeout = $timeout;
1139 1139 $this->soapclient = $this->wsdl->getProxy();
1140 1140 $this->soapclient->setOpt('timeout', $this->timeout);
1141   - $this->download_path = 'c:/temp';
  1141 + $this->download_path = 'c:/temp';
1142 1142 }
1143   -
  1143 +
1144 1144 /**
1145 1145 * This returns the default location where documents are downloaded in download() and checkout().
1146 1146 *
... ... @@ -1150,7 +1150,7 @@ class KTWSAPI
1150 1150 {
1151 1151 return $this->download_path;
1152 1152 }
1153   -
  1153 +
1154 1154 /**
1155 1155 * Allows the default location for downloaded documents to be changed.
1156 1156 *
... ... @@ -1163,15 +1163,15 @@ class KTWSAPI
1163 1163 {
1164 1164 return new PEAR_Error('local path is not writable');
1165 1165 }
1166   -
  1166 +
1167 1167 if (!is_writable($download_path))
1168 1168 {
1169 1169 return new PEAR_Error('local path is not writable');
1170   - }
  1170 + }
1171 1171 $this->download_path = $download_path;
1172 1172 return true;
1173 1173 }
1174   -
  1174 +
1175 1175 /**
1176 1176 * Starts an anonymous session.
1177 1177 *
... ... @@ -1182,7 +1182,7 @@ class KTWSAPI
1182 1182 {
1183 1183 return $this->start_session('anonymous','',$ip);
1184 1184 }
1185   -
  1185 +
1186 1186 /**
1187 1187 * Starts a user session.
1188 1188 *
... ... @@ -1202,19 +1202,19 @@ class KTWSAPI
1202 1202 {
1203 1203 return $kt_response;
1204 1204 }
1205   -
  1205 +
1206 1206 if ($kt_response->status_code == 0)
1207 1207 {
1208 1208 $this->session = $kt_response->message;
1209 1209 }
1210   - else
  1210 + else
1211 1211 {
1212 1212 return new PEAR_Error($kt_response->message);
1213   - }
1214   -
  1213 + }
  1214 +
1215 1215 return $this->session;
1216 1216 }
1217   -
  1217 +
1218 1218 /**
1219 1219 * Sets an active session.
1220 1220 *
... ... @@ -1227,12 +1227,12 @@ class KTWSAPI
1227 1227 if (!is_null($this->session))
1228 1228 {
1229 1229 return new PEAR_Error(KTWSAPI_ERR_SESSION_IN_USE);
1230   - }
  1230 + }
1231 1231 $this->session = $session;
1232   -
  1232 +
1233 1233 return $session;
1234 1234 }
1235   -
  1235 +
1236 1236 /**
1237 1237 * Closes an active session.
1238 1238 *
... ... @@ -1243,10 +1243,10 @@ class KTWSAPI
1243 1243 if (is_null($this->session))
1244 1244 {
1245 1245 return new PEAR_Error(KTWSAPI_ERR_SESSION_NOT_STARTED);
1246   - }
1247   -
  1246 + }
  1247 +
1248 1248 $kt_response = $this->soapclient->logout($this->session);
1249   -
  1249 +
1250 1250 if ($kt_response->status_code != 0)
1251 1251 {
1252 1252 return new PEAR_Error($kt_response->message);
... ... @@ -1255,7 +1255,7 @@ class KTWSAPI
1255 1255  
1256 1256 return true;
1257 1257 }
1258   -
  1258 +
1259 1259 /**
1260 1260 * Returns a reference to the root folder.
1261 1261 *
... ... @@ -1265,22 +1265,22 @@ class KTWSAPI
1265 1265 {
1266 1266 return $this->get_folder_by_id(1);
1267 1267 }
1268   -
  1268 +
1269 1269 /**
1270 1270 * Returns a reference to a folder based on id.
1271 1271 *
1272 1272 * @return KTWSAPI_Folder
1273   - */
  1273 + */
1274 1274 function &get_folder_by_id($folderid)
1275 1275 {
1276 1276 if (is_null($this->session))
1277 1277 {
1278   - return new PEAR_Error('A session is not active');
  1278 + return new PEAR_Error('A session is not active');
1279 1279 }
1280   -
  1280 +
1281 1281 return KTWSAPI_Folder::get($this, $folderid);
1282   - }
1283   -
  1282 + }
  1283 +
1284 1284 /**
1285 1285 * Returns a reference to a document based on id.
1286 1286 *
... ... @@ -1291,11 +1291,11 @@ class KTWSAPI
1291 1291 {
1292 1292 if (is_null($this->session))
1293 1293 {
1294   - return new PEAR_Error('A session is not active');
  1294 + return new PEAR_Error('A session is not active');
1295 1295 }
1296   -
  1296 +
1297 1297 return KTWSAPI_Document::get($this, $documentid);
1298   - }
  1298 + }
1299 1299 }
1300 1300  
1301 1301 ?>
... ...
ktwsapi/php/ktwsapi_cfg.inc.php
1   -<?
  1 +<?php
2 2 /**
3 3 * Copyright (c) 2007, The Jam Warehouse Software (Pty) Ltd.
4 4 *
5 5 * All rights reserved.
6 6 *
7   - * Redistribution and use in source and binary forms, with or without
  7 + * Redistribution and use in source and binary forms, with or without
8 8 * modification, are permitted provided that the following conditions are met:
9 9 *
10 10 * i) Redistributions of source code must retain the above copyright notice,
... ... @@ -12,8 +12,8 @@
12 12 * ii) Redistributions in binary form must reproduce the above copyright
13 13 * notice, this list of conditions and the following disclaimer in the
14 14 * documentation and/or other materials provided with the distribution.
15   - * iii) Neither the name of the The Jam Warehouse Software (Pty) Ltd nor the
16   - * names of its contributors may be used to endorse or promote products
  15 + * iii) Neither the name of the The Jam Warehouse Software (Pty) Ltd nor the
  16 + * names of its contributors may be used to endorse or promote products
17 17 * derived from this software without specific prior written permission.
18 18 *
19 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
... ... @@ -30,19 +30,19 @@
30 30 */
31 31  
32 32 /*
33   - * This is the basic configuration for the KnowledgeTree WebService object model
  33 + * This is the basic configuration for the KnowledgeTree WebService object model
34 34 */
35 35  
36 36 // Path to PEAR libraries
37 37  
38   -define('KT_PEAR_DIR', 'c:/kt/kt.trunk/thirdparty/pear');
  38 +define('KT_PEAR_DIR', '/knowledgetree/ktdms.trunk/thirdparty/pear');
39 39  
40 40 // URL to KnowledgeTree installation
41 41 // This must be configured by the administrator installing this component.
42 42  
43   -define('KTWebServiceURL', 'http://ktdms.trunk');
  43 +define('KTWebServiceURL', 'http://localhost:80');
44 44  
45   -define('KTWebService_WSDL', KTWebServiceURL . '/ktwebservice/?wsdl');
  45 +define('KTWebService_WSDL', KTWebServiceURL . '/ktwebservice/index.php?wsdl');
46 46 define('KTUploadURL', KTWebServiceURL . '/ktwebservice/upload.php');
47 47  
48 48 ?>
... ...