Commit a453bbfc130cdc02935c597a222ab7759b0edba7

Authored by kevin_fourie
1 parent 97c2e57f

Merged in from DEV trunk...

"KTS-1973"
"Webservice error when calling get_folder_contents fom VB.NET"
Updated. Added typecast to integer for content listing. Removed the 'return true' for procedures.

Reviewed By: Kevin Fourie

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/STABLE/trunk@6611 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 8 additions and 67 deletions
ktapi/ktapi.inc.php
1 <? 1 <?
2 -  
3 /** 2 /**
4 * 3 *
5 * Implements a cleaner wrapper API for KnowledgeTree. 4 * Implements a cleaner wrapper API for KnowledgeTree.
@@ -314,7 +313,6 @@ class KTAPI_Session @@ -314,7 +313,6 @@ class KTAPI_Session
314 $this->user = null; 313 $this->user = null;
315 $this->session = ''; 314 $this->session = '';
316 $this->sessionid = -1; 315 $this->sessionid = -1;
317 - return true;  
318 } 316 }
319 317
320 } 318 }
@@ -655,6 +653,7 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -655,6 +653,7 @@ class KTAPI_Folder extends KTAPI_FolderItem
655 $num_items = count($contents); 653 $num_items = count($contents);
656 for($i=0;$i<$num_items;$i++) 654 for($i=0;$i<$num_items;$i++)
657 { 655 {
  656 + $contents[$i]['id'] = (int) $contents[$i]['id'];
658 if ($contents[$i]['item_type'] == 'D') 657 if ($contents[$i]['item_type'] == 'D')
659 { 658 {
660 $contents[$i]['items'] = array(); 659 $contents[$i]['items'] = array();
@@ -766,7 +765,6 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -766,7 +765,6 @@ class KTAPI_Folder extends KTAPI_FolderItem
766 * This deletes the current folder. 765 * This deletes the current folder.
767 * 766 *
768 * @param string $reason 767 * @param string $reason
769 - * @return true  
770 */ 768 */
771 function delete($reason) 769 function delete($reason)
772 { 770 {
@@ -790,15 +788,12 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -790,15 +788,12 @@ class KTAPI_Folder extends KTAPI_FolderItem
790 return new PEAR_Error(KTAPI_ERROR_INTERNAL_ERROR); 788 return new PEAR_Error(KTAPI_ERROR_INTERNAL_ERROR);
791 } 789 }
792 DBUtil::commit(); 790 DBUtil::commit();
793 -  
794 - return true;  
795 } 791 }
796 792
797 /** 793 /**
798 * This renames the folder 794 * This renames the folder
799 * 795 *
800 * @param string $newname 796 * @param string $newname
801 - * @return true  
802 */ 797 */
803 function rename($newname) 798 function rename($newname)
804 { 799 {
@@ -817,8 +812,6 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -817,8 +812,6 @@ class KTAPI_Folder extends KTAPI_FolderItem
817 return new PEAR_Error(KTAPI_ERROR_INTERNAL_ERROR); 812 return new PEAR_Error(KTAPI_ERROR_INTERNAL_ERROR);
818 } 813 }
819 DBUtil::commit(); 814 DBUtil::commit();
820 -  
821 - return true;  
822 } 815 }
823 816
824 /** 817 /**
@@ -826,7 +819,6 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -826,7 +819,6 @@ class KTAPI_Folder extends KTAPI_FolderItem
826 * 819 *
827 * @param KTAPI_Folder $ktapi_target_folder 820 * @param KTAPI_Folder $ktapi_target_folder
828 * @param string $reason 821 * @param string $reason
829 - * @return true  
830 */ 822 */
831 function move($ktapi_target_folder, $reason='') 823 function move($ktapi_target_folder, $reason='')
832 { 824 {
@@ -852,8 +844,6 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -852,8 +844,6 @@ class KTAPI_Folder extends KTAPI_FolderItem
852 return new PEAR_Error(KTAPI_ERROR_INTERNAL_ERROR); 844 return new PEAR_Error(KTAPI_ERROR_INTERNAL_ERROR);
853 } 845 }
854 DBUtil::commit(); 846 DBUtil::commit();
855 -  
856 - return true;  
857 } 847 }
858 848
859 /** 849 /**
@@ -861,7 +851,6 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -861,7 +851,6 @@ class KTAPI_Folder extends KTAPI_FolderItem
861 * 851 *
862 * @param KTAPI_Folder $ktapi_target_folder 852 * @param KTAPI_Folder $ktapi_target_folder
863 * @param string $reason 853 * @param string $reason
864 - * @return true  
865 */ 854 */
866 function copy($ktapi_target_folder, $reason='') 855 function copy($ktapi_target_folder, $reason='')
867 { 856 {
@@ -888,8 +877,6 @@ class KTAPI_Folder extends KTAPI_FolderItem @@ -888,8 +877,6 @@ class KTAPI_Folder extends KTAPI_FolderItem
888 return new PEAR_Error(KTAPI_ERROR_INTERNAL_ERROR); 877 return new PEAR_Error(KTAPI_ERROR_INTERNAL_ERROR);
889 } 878 }
890 DBUtil::commit(); 879 DBUtil::commit();
891 -  
892 - return true;  
893 } 880 }
894 881
895 /** 882 /**
@@ -1000,7 +987,6 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1000,7 +987,6 @@ class KTAPI_Document extends KTAPI_FolderItem
1000 * @param string $reason 987 * @param string $reason
1001 * @param string $tempfilename 988 * @param string $tempfilename
1002 * @param bool $major_update 989 * @param bool $major_update
1003 - * @return true  
1004 */ 990 */
1005 function checkin($filename, $reason, $tempfilename, $major_update=false) 991 function checkin($filename, $reason, $tempfilename, $major_update=false)
1006 { 992 {
@@ -1038,14 +1024,12 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1038,14 +1024,12 @@ class KTAPI_Document extends KTAPI_FolderItem
1038 return new PEAR_Error(KTAPI_ERROR_INTERNAL_ERROR); 1024 return new PEAR_Error(KTAPI_ERROR_INTERNAL_ERROR);
1039 } 1025 }
1040 DBUtil::commit(); 1026 DBUtil::commit();
1041 - return true;  
1042 } 1027 }
1043 1028
1044 /** 1029 /**
1045 * This reverses the checkout process. 1030 * This reverses the checkout process.
1046 * 1031 *
1047 * @param string $reason 1032 * @param string $reason
1048 - * @return true  
1049 */ 1033 */
1050 function undo_checkout($reason) 1034 function undo_checkout($reason)
1051 { 1035 {
@@ -1080,14 +1064,12 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1080,14 +1064,12 @@ class KTAPI_Document extends KTAPI_FolderItem
1080 return new PEAR_Error(KTAPI_ERROR_INTERNAL_ERROR); 1064 return new PEAR_Error(KTAPI_ERROR_INTERNAL_ERROR);
1081 } 1065 }
1082 DBUtil::commit(); 1066 DBUtil::commit();
1083 - return true;  
1084 } 1067 }
1085 1068
1086 /** 1069 /**
1087 * This returns a URL to the file that can be downloaded. 1070 * This returns a URL to the file that can be downloaded.
1088 * 1071 *
1089 * @param string $reason 1072 * @param string $reason
1090 - * @return true;  
1091 */ 1073 */
1092 function checkout($reason) 1074 function checkout($reason)
1093 { 1075 {
@@ -1112,15 +1094,12 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1112,15 +1094,12 @@ class KTAPI_Document extends KTAPI_FolderItem
1112 } 1094 }
1113 1095
1114 DBUtil::commit(); 1096 DBUtil::commit();
1115 -  
1116 - return true;  
1117 } 1097 }
1118 1098
1119 /** 1099 /**
1120 * This deletes a document from the folder. 1100 * This deletes a document from the folder.
1121 * 1101 *
1122 * @param string $reason 1102 * @param string $reason
1123 - * @return mixed This returns true or a PEAR::Error  
1124 */ 1103 */
1125 function delete($reason) 1104 function delete($reason)
1126 { 1105 {
@@ -1145,15 +1124,12 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1145,15 +1124,12 @@ class KTAPI_Document extends KTAPI_FolderItem
1145 } 1124 }
1146 1125
1147 DBUtil::commit(); 1126 DBUtil::commit();
1148 -  
1149 - return true;  
1150 } 1127 }
1151 1128
1152 /** 1129 /**
1153 * This changes the owner of the file. 1130 * This changes the owner of the file.
1154 * 1131 *
1155 * @param string $ktapi_newuser 1132 * @param string $ktapi_newuser
1156 - * @return true  
1157 */ 1133 */
1158 function change_owner($newusername, $reason='Changing of owner.') 1134 function change_owner($newusername, $reason='Changing of owner.')
1159 { 1135 {
@@ -1200,7 +1176,6 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1200,7 +1176,6 @@ class KTAPI_Document extends KTAPI_FolderItem
1200 } 1176 }
1201 1177
1202 DBUtil::commit(); 1178 DBUtil::commit();
1203 - return true;  
1204 } 1179 }
1205 1180
1206 /** 1181 /**
@@ -1210,7 +1185,6 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1210,7 +1185,6 @@ class KTAPI_Document extends KTAPI_FolderItem
1210 * @param string $reason 1185 * @param string $reason
1211 * @param string $newname 1186 * @param string $newname
1212 * @param string $newfilename 1187 * @param string $newfilename
1213 - * @return true  
1214 */ 1188 */
1215 function copy(&$ktapi_target_folder, $reason, $newname=null, $newfilename=null) 1189 function copy(&$ktapi_target_folder, $reason, $newname=null, $newfilename=null)
1216 { 1190 {
@@ -1226,7 +1200,6 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1226,7 +1200,6 @@ class KTAPI_Document extends KTAPI_FolderItem
1226 $newfilename=null; 1200 $newfilename=null;
1227 } 1201 }
1228 1202
1229 -  
1230 $user = $this->ktapi->get_user(); 1203 $user = $this->ktapi->get_user();
1231 1204
1232 if ($this->document->getIsCheckedOut()) 1205 if ($this->document->getIsCheckedOut())
@@ -1303,9 +1276,7 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1303,9 +1276,7 @@ class KTAPI_Document extends KTAPI_FolderItem
1303 ); 1276 );
1304 $oTrigger->setInfo($aInfo); 1277 $oTrigger->setInfo($aInfo);
1305 $ret = $oTrigger->postValidate(); 1278 $ret = $oTrigger->postValidate();
1306 - }  
1307 -  
1308 - return true; 1279 + }
1309 } 1280 }
1310 1281
1311 /** 1282 /**
@@ -1315,7 +1286,6 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1315,7 +1286,6 @@ class KTAPI_Document extends KTAPI_FolderItem
1315 * @param string $reason 1286 * @param string $reason
1316 * @param string $newname 1287 * @param string $newname
1317 * @param string $newfilename 1288 * @param string $newfilename
1318 - * @return true  
1319 */ 1289 */
1320 function move(&$ktapi_target_folder, $reason, $newname=null, $newfilename=null) 1290 function move(&$ktapi_target_folder, $reason, $newname=null, $newfilename=null)
1321 { 1291 {
@@ -1403,15 +1373,12 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1403,15 +1373,12 @@ class KTAPI_Document extends KTAPI_FolderItem
1403 } 1373 }
1404 1374
1405 DBUtil::commit(); 1375 DBUtil::commit();
1406 -  
1407 - return true;  
1408 } 1376 }
1409 1377
1410 /** 1378 /**
1411 * This changes the filename of the document. 1379 * This changes the filename of the document.
1412 * 1380 *
1413 * @param string $newname 1381 * @param string $newname
1414 - * @return true  
1415 */ 1382 */
1416 function renameFile($newname) 1383 function renameFile($newname)
1417 { 1384 {
@@ -1430,15 +1397,12 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1430,15 +1397,12 @@ class KTAPI_Document extends KTAPI_FolderItem
1430 return new PEAR_Error(KTAPI_ERROR_INTERNAL_ERROR); 1397 return new PEAR_Error(KTAPI_ERROR_INTERNAL_ERROR);
1431 } 1398 }
1432 DBUtil::commit(); 1399 DBUtil::commit();
1433 -  
1434 - return true;  
1435 } 1400 }
1436 1401
1437 /** 1402 /**
1438 * This changes the document type of the document. 1403 * This changes the document type of the document.
1439 * 1404 *
1440 * @param string $newname 1405 * @param string $newname
1441 - * @return true  
1442 */ 1406 */
1443 function change_document_type($documenttype) 1407 function change_document_type($documenttype)
1444 { 1408 {
@@ -1464,14 +1428,12 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1464,14 +1428,12 @@ class KTAPI_Document extends KTAPI_FolderItem
1464 } 1428 }
1465 DBUtil::commit(); 1429 DBUtil::commit();
1466 } 1430 }
1467 - return true;  
1468 } 1431 }
1469 1432
1470 /** 1433 /**
1471 * This changes the title of the document. 1434 * This changes the title of the document.
1472 * 1435 *
1473 * @param string $newname 1436 * @param string $newname
1474 - * @return true  
1475 */ 1437 */
1476 function rename($newname) 1438 function rename($newname)
1477 { 1439 {
@@ -1496,15 +1458,12 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1496,15 +1458,12 @@ class KTAPI_Document extends KTAPI_FolderItem
1496 } 1458 }
1497 DBUtil::commit(); 1459 DBUtil::commit();
1498 } 1460 }
1499 -  
1500 - return true;  
1501 } 1461 }
1502 1462
1503 /** 1463 /**
1504 * This flags the document as 'archived'. 1464 * This flags the document as 'archived'.
1505 * 1465 *
1506 * @param string $reason 1466 * @param string $reason
1507 - * @return true  
1508 */ 1467 */
1509 function archive($reason) 1468 function archive($reason)
1510 { 1469 {
@@ -1541,16 +1500,13 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1541,16 +1500,13 @@ class KTAPI_Document extends KTAPI_FolderItem
1541 ); 1500 );
1542 $oTrigger->setInfo($aInfo); 1501 $oTrigger->setInfo($aInfo);
1543 $ret = $oTrigger->postValidate(); 1502 $ret = $oTrigger->postValidate();
1544 - }  
1545 -  
1546 - return true; 1503 + }
1547 } 1504 }
1548 1505
1549 /** 1506 /**
1550 * This starts a workflow on a document. 1507 * This starts a workflow on a document.
1551 * 1508 *
1552 * @param string $workflow 1509 * @param string $workflow
1553 - * @return true  
1554 */ 1510 */
1555 function start_workflow($workflow) 1511 function start_workflow($workflow)
1556 { 1512 {
@@ -1582,14 +1538,11 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1582,14 +1538,11 @@ class KTAPI_Document extends KTAPI_FolderItem
1582 return new PEAR_Error(KTAPI_ERROR_WORKFLOW_INVALID); 1538 return new PEAR_Error(KTAPI_ERROR_WORKFLOW_INVALID);
1583 } 1539 }
1584 DBUtil::commit(); 1540 DBUtil::commit();
1585 -  
1586 - return true;  
1587 } 1541 }
1588 1542
1589 /** 1543 /**
1590 * This deletes the workflow on the document. 1544 * This deletes the workflow on the document.
1591 * 1545 *
1592 - * @return true  
1593 */ 1546 */
1594 function delete_workflow() 1547 function delete_workflow()
1595 { 1548 {
@@ -1614,8 +1567,6 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1614,8 +1567,6 @@ class KTAPI_Document extends KTAPI_FolderItem
1614 return new PEAR_Error(KTAPI_ERROR_WORKFLOW_INVALID); 1567 return new PEAR_Error(KTAPI_ERROR_WORKFLOW_INVALID);
1615 } 1568 }
1616 DBUtil::commit(); 1569 DBUtil::commit();
1617 -  
1618 - return true;  
1619 } 1570 }
1620 1571
1621 /** 1572 /**
@@ -1623,7 +1574,6 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1623,7 +1574,6 @@ class KTAPI_Document extends KTAPI_FolderItem
1623 * 1574 *
1624 * @param string $transition 1575 * @param string $transition
1625 * @param string $reason 1576 * @param string $reason
1626 - * @return true  
1627 */ 1577 */
1628 function perform_workflow_transition($transition, $reason) 1578 function perform_workflow_transition($transition, $reason)
1629 { 1579 {
@@ -1653,9 +1603,7 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1653,9 +1603,7 @@ class KTAPI_Document extends KTAPI_FolderItem
1653 DBUtil::rollback(); 1603 DBUtil::rollback();
1654 return new PEAR_Error(KTAPI_ERROR_WORKFLOW_INVALID); 1604 return new PEAR_Error(KTAPI_ERROR_WORKFLOW_INVALID);
1655 } 1605 }
1656 - DBUtil::commit();  
1657 -  
1658 - return true; 1606 + DBUtil::commit();
1659 } 1607 }
1660 1608
1661 1609
@@ -1737,7 +1685,6 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1737,7 +1685,6 @@ class KTAPI_Document extends KTAPI_FolderItem
1737 * This updates the metadata on the file. This includes the 'title'. 1685 * This updates the metadata on the file. This includes the 'title'.
1738 * 1686 *
1739 * @param array This is an array containing the metadata to be associated with the file. 1687 * @param array This is an array containing the metadata to be associated with the file.
1740 - * @return mixed This returns true or a PEAR::Error  
1741 */ 1688 */
1742 function update_metadata($metadata) 1689 function update_metadata($metadata)
1743 { 1690 {
@@ -1782,8 +1729,6 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1782,8 +1729,6 @@ class KTAPI_Document extends KTAPI_FolderItem
1782 return new PEAR_Error(sprintf(_kt("Unexpected validation failure: %s."), $result->getMessage())); 1729 return new PEAR_Error(sprintf(_kt("Unexpected validation failure: %s."), $result->getMessage()));
1783 } 1730 }
1784 DBUtil::commit(); 1731 DBUtil::commit();
1785 -  
1786 - return true;  
1787 } 1732 }
1788 1733
1789 1734
@@ -1964,7 +1909,6 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1964,7 +1909,6 @@ class KTAPI_Document extends KTAPI_FolderItem
1964 * This does a download of a version of the document. 1909 * This does a download of a version of the document.
1965 * 1910 *
1966 * @param string $version 1911 * @param string $version
1967 - * @return true  
1968 */ 1912 */
1969 function download($version=null) 1913 function download($version=null)
1970 { 1914 {
@@ -1974,8 +1918,6 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -1974,8 +1918,6 @@ class KTAPI_Document extends KTAPI_FolderItem
1974 1918
1975 $oDocumentTransaction = & new DocumentTransaction($this->document, 'Document downloaded', 'ktcore.transactions.download', $aOptions); 1919 $oDocumentTransaction = & new DocumentTransaction($this->document, 'Document downloaded', 'ktcore.transactions.download', $aOptions);
1976 $oDocumentTransaction->create(); 1920 $oDocumentTransaction->create();
1977 -  
1978 - return true;  
1979 } 1921 }
1980 1922
1981 /** 1923 /**
@@ -2032,11 +1974,13 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -2032,11 +1974,13 @@ class KTAPI_Document extends KTAPI_FolderItem
2032 * This expunges a document from the system. 1974 * This expunges a document from the system.
2033 * 1975 *
2034 * @access public 1976 * @access public
2035 - * @return mixed This returns true or a PEAR::Error  
2036 */ 1977 */
2037 function expunge() 1978 function expunge()
2038 { 1979 {
2039 - if ($this->document->getStatusID()) 1980 + if ($this->document->getStatusID() != 3)
  1981 + {
  1982 + return new PEAR_Error('You should not purge this');
  1983 + }
2040 DBUtil::startTransaction(); 1984 DBUtil::startTransaction();
2041 1985
2042 $transaction = & new DocumentTransaction($this->document, "Document expunged", 'ktcore.transactions.expunge'); 1986 $transaction = & new DocumentTransaction($this->document, "Document expunged", 'ktcore.transactions.expunge');
@@ -2052,15 +1996,12 @@ class KTAPI_Document extends KTAPI_FolderItem @@ -2052,15 +1996,12 @@ class KTAPI_Document extends KTAPI_FolderItem
2052 $result= $storage->expunge($this->document); 1996 $result= $storage->expunge($this->document);
2053 1997
2054 $this->commitTransaction(); 1998 $this->commitTransaction();
2055 -  
2056 - return true;  
2057 } 1999 }
2058 2000
2059 /** 2001 /**
2060 * This expunges a document from the system. 2002 * This expunges a document from the system.
2061 * 2003 *
2062 * @access public 2004 * @access public
2063 - * @return mixed This returns true or a PEAR::Error  
2064 */ 2005 */
2065 function restore() 2006 function restore()
2066 { 2007 {