Commit af8627bb64d77ed6b67c773e6a39b2754ca2da6c

Authored by Paul Barrett
1 parent 1a750644

Story ID: 456150. Added checks for electronic signatures in ktapi code. Also cr…

…eated some unit tests (incomplete) to test aspects of the signature code within the api.  Modified some of the api unit tests to successfully pass when api signatures are turned on, but there are several which will still fail unless the signatures are off.

Fixed

Committed by: Paul Barrett

Reviewed by: Megan Watson
ktapi/ktapi.inc.php
@@ -60,6 +60,10 @@ require_once(KTAPI_DIR .'/KTAPIAcl.inc.php'); @@ -60,6 +60,10 @@ require_once(KTAPI_DIR .'/KTAPIAcl.inc.php');
60 require_once(KTAPI_DIR .'/KTAPICollection.inc.php'); 60 require_once(KTAPI_DIR .'/KTAPICollection.inc.php');
61 require_once(KTAPI_DIR .'/KTAPIBulkActions.inc.php'); 61 require_once(KTAPI_DIR .'/KTAPIBulkActions.inc.php');
62 62
  63 +//$dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..';
  64 +//$dir = realpath($dir).DIRECTORY_SEPARATOR;
  65 +//require_once($dir . 'plugins/wintools/baobabkeyutil.inc.php');
  66 +//require_once($dir . 'plugins/electronic-signatures/Esignature.inc.php');
63 67
64 /** 68 /**
65 * This class defines functions that MUST exist in the inheriting class 69 * This class defines functions that MUST exist in the inheriting class
@@ -171,6 +175,13 @@ class KTAPI @@ -171,6 +175,13 @@ class KTAPI
171 175
172 protected $version = 3; 176 protected $version = 3;
173 177
  178 + private $esig_enabled;
  179 +
  180 + public function KTAPI()
  181 + {
  182 + $this->esig_enabled = $this->electronic_sig_enabled();
  183 + }
  184 +
174 /** 185 /**
175 * This returns the current session. 186 * This returns the current session.
176 * 187 *
@@ -349,7 +360,12 @@ class KTAPI @@ -349,7 +360,12 @@ class KTAPI
349 * @param int 360 * @param int
350 * 361 *
351 */ 362 */
352 - public function add_folder_user_permissions($username, $folder_id, $namespace) { 363 + public function add_folder_user_permissions($username, $folder_id, $namespace, $sig_username = '', $sig_password = '', $reason = '')
  364 + {
  365 + $response = $this->_check_electronic_signature($folder_id, $sig_username, $sig_password, $reason, $reason,
  366 + 'ktcore.transactions.permissions_change');
  367 + if ($response['status_code'] == 1) return $response;
  368 +
353 if (is_null($this->session)) 369 if (is_null($this->session))
354 { 370 {
355 return array( 371 return array(
@@ -417,7 +433,12 @@ class KTAPI @@ -417,7 +433,12 @@ class KTAPI
417 * @param int 433 * @param int
418 * 434 *
419 */ 435 */
420 - public function add_folder_role_permissions($role, $folder_id, $namespace) { 436 + public function add_folder_role_permissions($role, $folder_id, $namespace, $sig_username = '', $sig_password = '', $reason = '')
  437 + {
  438 + $response = $this->_check_electronic_signature($folder_id, $sig_username, $sig_password, $reason, $reason,
  439 + 'ktcore.transactions.permissions_change');
  440 + if ($response['status_code'] == 1) return $response;
  441 +
421 if (is_null($this->session)) 442 if (is_null($this->session))
422 { 443 {
423 return array( 444 return array(
@@ -478,7 +499,12 @@ class KTAPI @@ -478,7 +499,12 @@ class KTAPI
478 * @param int 499 * @param int
479 * 500 *
480 */ 501 */
481 - public function add_folder_group_permissions($group, $folder_id, $namespace) { 502 + public function add_folder_group_permissions($group, $folder_id, $namespace, $sig_username = '', $sig_password = '', $reason = '')
  503 + {
  504 + $response = $this->_check_electronic_signature($folder_id, $sig_username, $sig_password, $reason, $reason,
  505 + 'ktcore.transactions.permissions_change');
  506 + if ($response['status_code'] == 1) return $response;
  507 +
482 if (is_null($this->session)) 508 if (is_null($this->session))
483 { 509 {
484 return array( 510 return array(
@@ -530,9 +556,6 @@ class KTAPI @@ -530,9 +556,6 @@ class KTAPI
530 $permissions->save(); 556 $permissions->save();
531 } 557 }
532 558
533 -  
534 -  
535 -  
536 /** 559 /**
537 * This checks if a user can access an object with a certain permission. 560 * This checks if a user can access an object with a certain permission.
538 * 561 *
@@ -711,7 +734,6 @@ class KTAPI @@ -711,7 +734,6 @@ class KTAPI
711 return $session; 734 return $session;
712 } 735 }
713 736
714 -  
715 /** 737 /**
716 * start a root session. 738 * start a root session.
717 * 739 *
@@ -738,8 +760,6 @@ class KTAPI @@ -738,8 +760,6 @@ class KTAPI
738 return $session; 760 return $session;
739 } 761 }
740 762
741 -  
742 -  
743 /** 763 /**
744 * Starts an anonymous session. 764 * Starts an anonymous session.
745 * 765 *
@@ -1048,7 +1068,6 @@ class KTAPI @@ -1048,7 +1068,6 @@ class KTAPI
1048 return $results; 1068 return $results;
1049 } 1069 }
1050 1070
1051 -  
1052 /** 1071 /**
1053 * Returns an array of username/name combinations or an error object. 1072 * Returns an array of username/name combinations or an error object.
1054 * 1073 *
@@ -1213,8 +1232,13 @@ class KTAPI @@ -1213,8 +1232,13 @@ class KTAPI
1213 * @param integer $target_folder_id The id of the target folder if required - copy and move require this. 1232 * @param integer $target_folder_id The id of the target folder if required - copy and move require this.
1214 * @return array The response array. On success response['results'] will be empty | contain an array of failed items. 1233 * @return array The response array. On success response['results'] will be empty | contain an array of failed items.
1215 */ 1234 */
1216 - public function performBulkAction($action, $items, $reason = '', $target_folder_id = null) 1235 + public function performBulkAction($action, $items, $reason = '', $target_folder_id = null,
  1236 + $sig_username = '', $sig_password = '')
1217 { 1237 {
  1238 + $response = $this->_check_electronic_signature($target_folder_id, $sig_username, $sig_password, $reason, $reason,
  1239 + 'ktcore.transactions.permissions_change');
  1240 + if ($response['status_code'] == 1) return $response;
  1241 +
1218 $response['status_code'] = 1; 1242 $response['status_code'] = 1;
1219 1243
1220 if(!is_array($items)){ 1244 if(!is_array($items)){
@@ -1474,8 +1498,12 @@ class KTAPI @@ -1474,8 +1498,12 @@ class KTAPI
1474 * @param integer $user_id The id of the user to be added 1498 * @param integer $user_id The id of the user to be added
1475 * @return array Response 1499 * @return array Response
1476 */ 1500 */
1477 - public function add_user_to_role_on_folder($folder_id, $role_id, $user_id) 1501 + public function add_user_to_role_on_folder($folder_id, $role_id, $user_id, $sig_username = '', $sig_password = '', $reason = '')
1478 { 1502 {
  1503 + $response = $this->_check_electronic_signature($folder_id, $sig_username, $sig_password, $reason, $reason,
  1504 + 'ktcore.transactions.role_allocations_change');
  1505 + if ($response['status_code'] == 1) return $response;
  1506 +
1479 $response['status_code'] = 1; 1507 $response['status_code'] = 1;
1480 if(!is_numeric($user_id)){ 1508 if(!is_numeric($user_id)){
1481 $response['message'] = _kt('User id must be numeric.'); 1509 $response['message'] = _kt('User id must be numeric.');
@@ -1496,8 +1524,12 @@ class KTAPI @@ -1496,8 +1524,12 @@ class KTAPI
1496 * @param integer $group_id The id of the group to be added 1524 * @param integer $group_id The id of the group to be added
1497 * @return array Response 1525 * @return array Response
1498 */ 1526 */
1499 - public function add_group_to_role_on_folder($folder_id, $role_id, $group_id) 1527 + public function add_group_to_role_on_folder($folder_id, $role_id, $group_id, $sig_username = '', $sig_password = '', $reason = '')
1500 { 1528 {
  1529 + $response = $this->_check_electronic_signature($folder_id, $sig_username, $sig_password, $reason, $reason,
  1530 + 'ktcore.transactions.role_allocations_change');
  1531 + if ($response['status_code'] == 1) return $response;
  1532 +
1501 $response['status_code'] = 1; 1533 $response['status_code'] = 1;
1502 if(!is_numeric($group_id)){ 1534 if(!is_numeric($group_id)){
1503 $response['message'] = _kt('Group id must be numeric.'); 1535 $response['message'] = _kt('Group id must be numeric.');
@@ -1518,8 +1550,12 @@ class KTAPI @@ -1518,8 +1550,12 @@ class KTAPI
1518 * @param integer $user_id The id of the user to be removed 1550 * @param integer $user_id The id of the user to be removed
1519 * @return array Response 1551 * @return array Response
1520 */ 1552 */
1521 - public function remove_user_from_role_on_folder($folder_id, $role_id, $user_id) 1553 + public function remove_user_from_role_on_folder($folder_id, $role_id, $user_id, $sig_username = '', $sig_password = '', $reason = '')
1522 { 1554 {
  1555 + $response = $this->_check_electronic_signature($folder_id, $sig_username, $sig_password, $reason, $reason,
  1556 + 'ktcore.transactions.role_allocations_change');
  1557 + if ($response['status_code'] == 1) return $response;
  1558 +
1523 $response['status_code'] = 1; 1559 $response['status_code'] = 1;
1524 if(!is_numeric($user_id)){ 1560 if(!is_numeric($user_id)){
1525 $response['message'] = _kt('User id must be numeric.'); 1561 $response['message'] = _kt('User id must be numeric.');
@@ -1540,8 +1576,12 @@ class KTAPI @@ -1540,8 +1576,12 @@ class KTAPI
1540 * @param integer $group_id The id of the group to be removied 1576 * @param integer $group_id The id of the group to be removied
1541 * @return array Response 1577 * @return array Response
1542 */ 1578 */
1543 - public function remove_group_from_role_on_folder($folder_id, $role_id, $group_id) 1579 + public function remove_group_from_role_on_folder($folder_id, $role_id, $group_id, $sig_username = '', $sig_password = '', $reason = '')
1544 { 1580 {
  1581 + $response = $this->_check_electronic_signature($folder_id, $sig_username, $sig_password, $reason, $reason,
  1582 + 'ktcore.transactions.role_allocations_change');
  1583 + if ($response['status_code'] == 1) return $response;
  1584 +
1545 $response['status_code'] = 1; 1585 $response['status_code'] = 1;
1546 if(!is_numeric($group_id)){ 1586 if(!is_numeric($group_id)){
1547 $response['message'] = _kt('Group id must be numeric.'); 1587 $response['message'] = _kt('Group id must be numeric.');
@@ -1593,8 +1633,13 @@ class KTAPI @@ -1593,8 +1633,13 @@ class KTAPI
1593 * @param string $update The type of modification - add | remove 1633 * @param string $update The type of modification - add | remove
1594 * @return array Response 1634 * @return array Response
1595 */ 1635 */
1596 - private function update_members_on_role_on_folder($folder_id, $role_id, $members, $update = 'add') 1636 + private function update_members_on_role_on_folder($folder_id, $role_id, $members, $update = 'add',
  1637 + $sig_username = '', $sig_password = '', $reason = '')
1597 { 1638 {
  1639 + $response = $this->_check_electronic_signature($folder_id, $sig_username, $sig_password, $reason, $reason,
  1640 + 'ktcore.transactions.role_allocations_change');
  1641 + if ($response['status_code'] == 1) return $response;
  1642 +
1598 // Check input information 1643 // Check input information
1599 $response['status_code'] = 1; 1644 $response['status_code'] = 1;
1600 if(!is_numeric($folder_id)){ 1645 if(!is_numeric($folder_id)){
@@ -1740,8 +1785,12 @@ class KTAPI @@ -1740,8 +1785,12 @@ class KTAPI
1740 * @param integer $role_id Optional. The id of the role being reset. 1785 * @param integer $role_id Optional. The id of the role being reset.
1741 * @return array Response 1786 * @return array Response
1742 */ 1787 */
1743 - public function remove_all_role_allocation_from_folder($folder_id, $role_id = null) 1788 + public function remove_all_role_allocation_from_folder($folder_id, $role_id = null, $sig_username = '', $sig_password = '', $reason = '')
1744 { 1789 {
  1790 + $response = $this->_check_electronic_signature($folder_id, $sig_username, $sig_password, $reason, $reason,
  1791 + 'ktcore.transactions.role_allocations_change');
  1792 + if ($response['status_code'] == 1) return $response;
  1793 +
1745 $response['status_code'] = 1; 1794 $response['status_code'] = 1;
1746 1795
1747 // Get folder and role objects 1796 // Get folder and role objects
@@ -1778,8 +1827,12 @@ class KTAPI @@ -1778,8 +1827,12 @@ class KTAPI
1778 * @param integer $folder_id The folder id 1827 * @param integer $folder_id The folder id
1779 * @return array Response 1828 * @return array Response
1780 */ 1829 */
1781 - public function override_role_allocation_on_folder($folder_id) 1830 + public function override_role_allocation_on_folder($folder_id, $sig_username = '', $sig_password = '', $reason = '')
1782 { 1831 {
  1832 + $response = $this->_check_electronic_signature($folder_id, $sig_username, $sig_password, $reason, $reason,
  1833 + 'ktcore.transactions.role_allocations_change');
  1834 + if ($response['status_code'] == 1) return $response;
  1835 +
1783 $response['status_code'] = 1; 1836 $response['status_code'] = 1;
1784 1837
1785 // Get folder object 1838 // Get folder object
@@ -1829,7 +1882,6 @@ class KTAPI @@ -1829,7 +1882,6 @@ class KTAPI
1829 1882
1830 /* *** Refactored web services functions *** */ 1883 /* *** Refactored web services functions *** */
1831 1884
1832 -  
1833 /** 1885 /**
1834 * Creates a new anonymous session. 1886 * Creates a new anonymous session.
1835 * 1887 *
@@ -2022,8 +2074,12 @@ class KTAPI @@ -2022,8 +2074,12 @@ class KTAPI
2022 * @param string $folder_name The name of the new folder 2074 * @param string $folder_name The name of the new folder
2023 * @return array Response 'results' contains kt_folder_detail | 'message' contains error message on failure 2075 * @return array Response 'results' contains kt_folder_detail | 'message' contains error message on failure
2024 */ 2076 */
2025 - function create_folder($folder_id, $folder_name) 2077 + function create_folder($folder_id, $folder_name, $sig_username = '', $sig_password = '', $reason = '')
2026 { 2078 {
  2079 + $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason,
  2080 + 'ktcore.transactions.add');
  2081 + if ($response['status_code'] == 1) return $response;
  2082 +
2027 $folder = &$this->get_folder_by_id($folder_id); 2083 $folder = &$this->get_folder_by_id($folder_id);
2028 if (PEAR::isError($folder)) 2084 if (PEAR::isError($folder))
2029 { 2085 {
@@ -2047,8 +2103,12 @@ class KTAPI @@ -2047,8 +2103,12 @@ class KTAPI
2047 * @param integer $source_folder_id Id of the folder to which the shortcut will point. 2103 * @param integer $source_folder_id Id of the folder to which the shortcut will point.
2048 * @return array Response 'results' contains kt_shortcut_detail | 'message' contains error message on failure 2104 * @return array Response 'results' contains kt_shortcut_detail | 'message' contains error message on failure
2049 */ 2105 */
2050 - function create_folder_shortcut($target_folder_id, $source_folder_id) 2106 + function create_folder_shortcut($target_folder_id, $source_folder_id, $sig_username = '', $sig_password = '', $reason = '')
2051 { 2107 {
  2108 + $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason,
  2109 + 'ktcore.transactions.create_shortcut');
  2110 + if ($response['status_code'] == 1) return $response;
  2111 +
2052 $folder = &$this->get_folder_by_id($target_folder_id); 2112 $folder = &$this->get_folder_by_id($target_folder_id);
2053 if (PEAR::isError($folder)) 2113 if (PEAR::isError($folder))
2054 { 2114 {
@@ -2088,8 +2148,12 @@ class KTAPI @@ -2088,8 +2148,12 @@ class KTAPI
2088 * @param integer $source_document_id Id of the document to which the shortcut will point 2148 * @param integer $source_document_id Id of the document to which the shortcut will point
2089 * @return array Response 'results' contains kt_document_detail | 'message' contains error message on failure 2149 * @return array Response 'results' contains kt_document_detail | 'message' contains error message on failure
2090 */ 2150 */
2091 - function create_document_shortcut($target_folder_id, $source_document_id) 2151 + function create_document_shortcut($target_folder_id, $source_document_id, $sig_username = '', $sig_password = '', $reason = '')
2092 { 2152 {
  2153 + $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason,
  2154 + 'ktcore.transactions.create_shortcut');
  2155 + if ($response['status_code'] == 1) return $response;
  2156 +
2093 $folder = &$this->get_folder_by_id($target_folder_id); 2157 $folder = &$this->get_folder_by_id($target_folder_id);
2094 if (PEAR::isError($folder)) 2158 if (PEAR::isError($folder))
2095 { 2159 {
@@ -2129,8 +2193,12 @@ class KTAPI @@ -2129,8 +2193,12 @@ class KTAPI
2129 * @param string $reason The reason for performing the deletion 2193 * @param string $reason The reason for performing the deletion
2130 * @return array Response | 'message' contains error message on failure 2194 * @return array Response | 'message' contains error message on failure
2131 */ 2195 */
2132 - function delete_folder($folder_id, $reason) 2196 + function delete_folder($folder_id, $reason, $sig_username = '', $sig_password = '')
2133 { 2197 {
  2198 + $response = $this->_check_electronic_signature($folder_id, $sig_username, $sig_password, $reason, $reason,
  2199 + 'ktcore.transactions.delete');
  2200 + if ($response['status_code'] == 1) return $response;
  2201 +
2134 $folder = &$this->get_folder_by_id($folder_id); 2202 $folder = &$this->get_folder_by_id($folder_id);
2135 if (PEAR::isError($folder)) 2203 if (PEAR::isError($folder))
2136 { 2204 {
@@ -2160,8 +2228,12 @@ class KTAPI @@ -2160,8 +2228,12 @@ class KTAPI
2160 * @param string $newname The new name of the folder 2228 * @param string $newname The new name of the folder
2161 * @return array Response | 'message' contains error message on failure 2229 * @return array Response | 'message' contains error message on failure
2162 */ 2230 */
2163 - function rename_folder($folder_id, $newname) 2231 + function rename_folder($folder_id, $newname, $sig_username = '', $sig_password = '', $reason = '')
2164 { 2232 {
  2233 + $response = $this->_check_electronic_signature($folder_id, $sig_username, $sig_password, $reason, $reason,
  2234 + 'ktcore.transactions.rename');
  2235 + if ($response['status_code'] == 1) return $response;
  2236 +
2165 $folder = &$this->get_folder_by_id($folder_id); 2237 $folder = &$this->get_folder_by_id($folder_id);
2166 if (PEAR::isError($folder)) 2238 if (PEAR::isError($folder))
2167 { 2239 {
@@ -2191,8 +2263,12 @@ class KTAPI @@ -2191,8 +2263,12 @@ class KTAPI
2191 * @param string $reason The reason for performing the copy 2263 * @param string $reason The reason for performing the copy
2192 * @return array Response | 'message' contains error message on failure 2264 * @return array Response | 'message' contains error message on failure
2193 */ 2265 */
2194 - function copy_folder($source_id, $target_id, $reason) 2266 + function copy_folder($source_id, $target_id, $reason, $sig_username = '', $sig_password = '')
2195 { 2267 {
  2268 + $response = $this->_check_electronic_signature($source_id, $sig_username, $sig_password, $reason, $reason,
  2269 + 'ktcore.transactions.copy');
  2270 + if ($response['status_code'] == 1) return $response;
  2271 +
2196 $src_folder = &$this->get_folder_by_id($source_id); 2272 $src_folder = &$this->get_folder_by_id($source_id);
2197 if (PEAR::isError($src_folder)) 2273 if (PEAR::isError($src_folder))
2198 { 2274 {
@@ -2216,7 +2292,7 @@ class KTAPI @@ -2216,7 +2292,7 @@ class KTAPI
2216 $response['message']= $result->getMessage(); 2292 $response['message']= $result->getMessage();
2217 return $response; 2293 return $response;
2218 } 2294 }
2219 - 2295 +
2220 $response['status_code'] = 0; 2296 $response['status_code'] = 0;
2221 2297
2222 if($this->version >= 2){ 2298 if($this->version >= 2){
@@ -2240,8 +2316,12 @@ class KTAPI @@ -2240,8 +2316,12 @@ class KTAPI
2240 * @param string $reason The reason for performing the move 2316 * @param string $reason The reason for performing the move
2241 * @return array Response | 'message' contains error message on failure 2317 * @return array Response | 'message' contains error message on failure
2242 */ 2318 */
2243 - function move_folder($source_id, $target_id, $reason) 2319 + function move_folder($source_id, $target_id, $reason, $sig_username = '', $sig_password = '')
2244 { 2320 {
  2321 + $response = $this->_check_electronic_signature($source_id, $sig_username, $sig_password, $reason, $reason,
  2322 + 'ktcore.transactions.move');
  2323 + if ($response['status_code'] == 1) return $response;
  2324 +
2245 $src_folder = &$this->get_folder_by_id($source_id); 2325 $src_folder = &$this->get_folder_by_id($source_id);
2246 if (PEAR::isError($src_folder)) 2326 if (PEAR::isError($src_folder))
2247 { 2327 {
@@ -2636,8 +2716,13 @@ class KTAPI @@ -2636,8 +2716,13 @@ class KTAPI
2636 * @param string $tempfilename 2716 * @param string $tempfilename
2637 * @return kt_document_detail. 2717 * @return kt_document_detail.
2638 */ 2718 */
2639 - public function add_document($folder_id, $title, $filename, $documenttype, $tempfilename) 2719 + public function add_document($folder_id, $title, $filename, $documenttype, $tempfilename,
  2720 + $sig_username = '', $sig_password = '', $reason = '')
2640 { 2721 {
  2722 + $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason,
  2723 + 'ktcore.transactions.add');
  2724 + if ($response['status_code'] == 1) return $response;
  2725 +
2641 // we need to add some security to ensure that people don't frig the checkin process to access restricted files. 2726 // we need to add some security to ensure that people don't frig the checkin process to access restricted files.
2642 // possibly should change 'tempfilename' to be a hash or id of some sort if this is troublesome. 2727 // possibly should change 'tempfilename' to be a hash or id of some sort if this is troublesome.
2643 $upload_manager = new KTUploadManager(); 2728 $upload_manager = new KTUploadManager();
@@ -2682,7 +2767,7 @@ class KTAPI @@ -2682,7 +2767,7 @@ class KTAPI
2682 2767
2683 $update_result = $this->update_document_metadata($document_id, $metadata, $sysdata); 2768 $update_result = $this->update_document_metadata($document_id, $metadata, $sysdata);
2684 if($update_result['status_code'] != 0){ 2769 if($update_result['status_code'] != 0){
2685 - $this->delete_document($document_id, 'Rollback because metadata could not be added'); 2770 + $this->delete_document($document_id, 'Rollback because metadata could not be added', false);
2686 return $update_result; 2771 return $update_result;
2687 } 2772 }
2688 2773
@@ -2713,7 +2798,7 @@ class KTAPI @@ -2713,7 +2798,7 @@ class KTAPI
2713 2798
2714 $update_result = $this->update_document_metadata($document_id, $metadata, $sysdata); 2799 $update_result = $this->update_document_metadata($document_id, $metadata, $sysdata);
2715 if($update_result['status_code'] != 0){ 2800 if($update_result['status_code'] != 0){
2716 - $this->delete_document($document_id, 'Rollback because metadata could not be added'); 2801 + $this->delete_document($document_id, 'Rollback because metadata could not be added', false);
2717 return $update_result; 2802 return $update_result;
2718 } 2803 }
2719 2804
@@ -2827,8 +2912,13 @@ class KTAPI @@ -2827,8 +2912,13 @@ class KTAPI
2827 * @param string $tempfilename 2912 * @param string $tempfilename
2828 * @return kt_document_detail. status_code can be KTWS_ERR_INVALID_SESSION, KTWS_ERR_INVALID_FOLDER, KTWS_ERR_INVALID_DOCUMENT or KTWS_SUCCESS 2913 * @return kt_document_detail. status_code can be KTWS_ERR_INVALID_SESSION, KTWS_ERR_INVALID_FOLDER, KTWS_ERR_INVALID_DOCUMENT or KTWS_SUCCESS
2829 */ 2914 */
2830 - public function checkin_document($document_id, $filename, $reason, $tempfilename, $major_update ) 2915 + public function checkin_document($document_id, $filename, $reason, $tempfilename, $major_update,
  2916 + $sig_username = '', $sig_password = '' )
2831 { 2917 {
  2918 + $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason,
  2919 + 'ktcore.transactions.check_in');
  2920 + if ($response['status_code'] == 1) return $response;
  2921 +
2832 // we need to add some security to ensure that people don't frig the checkin process to access restricted files. 2922 // we need to add some security to ensure that people don't frig the checkin process to access restricted files.
2833 // possibly should change 'tempfilename' to be a hash or id of some sort if this is troublesome. 2923 // possibly should change 'tempfilename' to be a hash or id of some sort if this is troublesome.
2834 $upload_manager = new KTUploadManager(); 2924 $upload_manager = new KTUploadManager();
@@ -2860,8 +2950,13 @@ class KTAPI @@ -2860,8 +2950,13 @@ class KTAPI
2860 return $this->get_document_detail($document_id); 2950 return $this->get_document_detail($document_id);
2861 } 2951 }
2862 2952
2863 - public function checkin_small_document_with_metadata($document_id, $filename, $reason, $base64, $major_update, $metadata, $sysdata) 2953 + public function checkin_small_document_with_metadata($document_id, $filename, $reason, $base64, $major_update,
  2954 + $metadata, $sysdata, $sig_username = '', $sig_password = '')
2864 { 2955 {
  2956 + $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason,
  2957 + 'ktcore.transactions.check_in');
  2958 + if ($response['status_code'] == 1) return $response;
  2959 +
2865 $add_result = $this->checkin_small_document($document_id, $filename, $reason, $base64, $major_update); 2960 $add_result = $this->checkin_small_document($document_id, $filename, $reason, $base64, $major_update);
2866 2961
2867 if($add_result['status_code'] != 0){ 2962 if($add_result['status_code'] != 0){
@@ -2889,8 +2984,13 @@ class KTAPI @@ -2889,8 +2984,13 @@ class KTAPI
2889 return $update_result; 2984 return $update_result;
2890 } 2985 }
2891 2986
2892 - public function checkin_document_with_metadata($document_id, $filename, $reason, $tempfilename, $major_update, $metadata, $sysdata) 2987 + public function checkin_document_with_metadata($document_id, $filename, $reason, $tempfilename, $major_update,
  2988 + $metadata, $sysdata, $sig_username = '', $sig_password = '')
2893 { 2989 {
  2990 + $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason,
  2991 + 'ktcore.transactions.check_in');
  2992 + if ($response['status_code'] == 1) return $response;
  2993 +
2894 $add_result = $this->checkin_document($document_id, $filename, $reason, $tempfilename, $major_update); 2994 $add_result = $this->checkin_document($document_id, $filename, $reason, $tempfilename, $major_update);
2895 2995
2896 if($add_result['status_code'] != 0){ 2996 if($add_result['status_code'] != 0){
@@ -2917,7 +3017,6 @@ class KTAPI @@ -2917,7 +3017,6 @@ class KTAPI
2917 return $update_result; 3017 return $update_result;
2918 } 3018 }
2919 3019
2920 -  
2921 /** 3020 /**
2922 * Does a document checkin. 3021 * Does a document checkin.
2923 * 3022 *
@@ -2930,8 +3029,12 @@ class KTAPI @@ -2930,8 +3029,12 @@ class KTAPI
2930 * @param boolean $major_update 3029 * @param boolean $major_update
2931 * @return kt_document_detail. 3030 * @return kt_document_detail.
2932 */ 3031 */
2933 - public function checkin_small_document($document_id, $filename, $reason, $base64, $major_update ) 3032 + public function checkin_small_document($document_id, $filename, $reason, $base64, $major_update, $sig_username = '', $sig_password = '' )
2934 { 3033 {
  3034 + $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason,
  3035 + 'ktcore.transactions.check_in');
  3036 + if ($response['status_code'] == 1) return $response;
  3037 +
2935 $upload_manager = new KTUploadManager(); 3038 $upload_manager = new KTUploadManager();
2936 $tempfilename = $upload_manager->store_base64_file($base64, 'su_'); 3039 $tempfilename = $upload_manager->store_base64_file($base64, 'su_');
2937 if (PEAR::isError($tempfilename)) 3040 if (PEAR::isError($tempfilename))
@@ -2973,8 +3076,12 @@ class KTAPI @@ -2973,8 +3076,12 @@ class KTAPI
2973 * @param string $reason 3076 * @param string $reason
2974 * @return kt_document_detail. 3077 * @return kt_document_detail.
2975 */ 3078 */
2976 - public function checkout_document($document_id, $reason, $download=true) 3079 + public function checkout_document($document_id, $reason, $download=true, $sig_username = '', $sig_password = '')
2977 { 3080 {
  3081 + $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason,
  3082 + 'ktcore.transactions.check_out');
  3083 + if ($response['status_code'] == 1) return $response;
  3084 +
2978 $document = &$this->get_document_by_id($document_id); 3085 $document = &$this->get_document_by_id($document_id);
2979 if (PEAR::isError($document)) 3086 if (PEAR::isError($document))
2980 { 3087 {
@@ -3028,8 +3135,12 @@ class KTAPI @@ -3028,8 +3135,12 @@ class KTAPI
3028 * @param boolean $download 3135 * @param boolean $download
3029 * @return kt_document_detail 3136 * @return kt_document_detail
3030 */ 3137 */
3031 - public function checkout_small_document($document_id, $reason, $download) 3138 + public function checkout_small_document($document_id, $reason, $download, $sig_username = '', $sig_password = '')
3032 { 3139 {
  3140 + $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason,
  3141 + 'ktcore.transactions.check_out');
  3142 + if ($response['status_code'] == 1) return $response;
  3143 +
3033 $document = &$this->get_document_by_id($document_id); 3144 $document = &$this->get_document_by_id($document_id);
3034 if (PEAR::isError($document)) 3145 if (PEAR::isError($document))
3035 { 3146 {
@@ -3088,8 +3199,12 @@ class KTAPI @@ -3088,8 +3199,12 @@ class KTAPI
3088 * @param string $reason 3199 * @param string $reason
3089 * @return kt_document_detail. 3200 * @return kt_document_detail.
3090 */ 3201 */
3091 - public function undo_document_checkout($document_id, $reason) 3202 + public function undo_document_checkout($document_id, $reason, $sig_username = '', $sig_password = '')
3092 { 3203 {
  3204 + $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason,
  3205 + 'ktcore.transactions.force_checkin');
  3206 + if ($response['status_code'] == 1) return $response;
  3207 +
3093 $document = &$this->get_document_by_id($document_id); 3208 $document = &$this->get_document_by_id($document_id);
3094 if (PEAR::isError($document)) 3209 if (PEAR::isError($document))
3095 { 3210 {
@@ -3213,8 +3328,15 @@ class KTAPI @@ -3213,8 +3328,15 @@ class KTAPI
3213 * @param string $reason 3328 * @param string $reason
3214 * @return kt_response 3329 * @return kt_response
3215 */ 3330 */
3216 - public function delete_document($document_id, $reason) 3331 + public function delete_document($document_id, $reason, $sig_username = '', $sig_password = '', $auth_sig = true)
3217 { 3332 {
  3333 + if ($auth_sig)
  3334 + {
  3335 + $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason,
  3336 + 'ktcore.transactions.delete');
  3337 + if ($response['status_code'] == 1) return $response;
  3338 + }
  3339 +
3218 $document = &$this->get_document_by_id($document_id); 3340 $document = &$this->get_document_by_id($document_id);
3219 if (PEAR::isError($document)) 3341 if (PEAR::isError($document))
3220 { 3342 {
@@ -3245,8 +3367,12 @@ class KTAPI @@ -3245,8 +3367,12 @@ class KTAPI
3245 * @param string $documenttype 3367 * @param string $documenttype
3246 * @return array 3368 * @return array
3247 */ 3369 */
3248 - public function change_document_type($document_id, $documenttype) 3370 + public function change_document_type($document_id, $documenttype, $sig_username = '', $sig_password = '', $reason = '')
3249 { 3371 {
  3372 + $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason,
  3373 + 'ktcore.transactions.document_type_change');
  3374 + if ($response['status_code'] == 1) return $response;
  3375 +
3250 $document = &$this->get_document_by_id($document_id); 3376 $document = &$this->get_document_by_id($document_id);
3251 if (PEAR::isError($document)) 3377 if (PEAR::isError($document))
3252 { 3378 {
@@ -3279,8 +3405,12 @@ class KTAPI @@ -3279,8 +3405,12 @@ class KTAPI
3279 * @param string $newfilename 3405 * @param string $newfilename
3280 * @return array 3406 * @return array
3281 */ 3407 */
3282 - public function copy_document($document_id,$folder_id,$reason,$newtitle=null,$newfilename=null) 3408 + public function copy_document($document_id,$folder_id,$reason,$newtitle=null,$newfilename=null, $sig_username = '', $sig_password = '')
3283 { 3409 {
  3410 + $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason,
  3411 + 'ktcore.transactions.copy');
  3412 + if ($response['status_code'] == 1) return $response;
  3413 +
3284 $document = &$this->get_document_by_id($document_id); 3414 $document = &$this->get_document_by_id($document_id);
3285 if (PEAR::isError($document)) 3415 if (PEAR::isError($document))
3286 { 3416 {
@@ -3311,7 +3441,7 @@ class KTAPI @@ -3311,7 +3441,7 @@ class KTAPI
3311 } 3441 }
3312 3442
3313 /** 3443 /**
3314 - * Move a folder to another location. 3444 + * Move a document to another location.
3315 * 3445 *
3316 * @author KnowledgeTree Team 3446 * @author KnowledgeTree Team
3317 * @access public 3447 * @access public
@@ -3322,8 +3452,12 @@ class KTAPI @@ -3322,8 +3452,12 @@ class KTAPI
3322 * @param string $newfilename 3452 * @param string $newfilename
3323 * @return array 3453 * @return array
3324 */ 3454 */
3325 - public function move_document($document_id,$folder_id,$reason,$newtitle=null,$newfilename=null) 3455 + public function move_document($document_id,$folder_id,$reason,$newtitle=null,$newfilename=null, $sig_username = '', $sig_password = '')
3326 { 3456 {
  3457 + $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason,
  3458 + 'ktcore.transactions.move');
  3459 + if ($response['status_code'] == 1) return $response;
  3460 +
3327 $document = &$this->get_document_by_id($document_id); 3461 $document = &$this->get_document_by_id($document_id);
3328 if (PEAR::isError($document)) 3462 if (PEAR::isError($document))
3329 { 3463 {
@@ -3368,8 +3502,12 @@ class KTAPI @@ -3368,8 +3502,12 @@ class KTAPI
3368 * @param string $newtitle 3502 * @param string $newtitle
3369 * @return arry 3503 * @return arry
3370 */ 3504 */
3371 - public function rename_document_title($document_id,$newtitle) 3505 + public function rename_document_title($document_id,$newtitle, $sig_username = '', $sig_password = '', $reason = '')
3372 { 3506 {
  3507 + $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason,
  3508 + 'ktcore.transactions.rename');
  3509 + if ($response['status_code'] == 1) return $response;
  3510 +
3373 $document = &$this->get_document_by_id($document_id); 3511 $document = &$this->get_document_by_id($document_id);
3374 if (PEAR::isError($document)) 3512 if (PEAR::isError($document))
3375 { 3513 {
@@ -3400,8 +3538,12 @@ class KTAPI @@ -3400,8 +3538,12 @@ class KTAPI
3400 * @param string $newfilename 3538 * @param string $newfilename
3401 * @return array 3539 * @return array
3402 */ 3540 */
3403 - public function rename_document_filename($document_id,$newfilename) 3541 + public function rename_document_filename($document_id,$newfilename, $sig_username = '', $sig_password = '', $reason = '')
3404 { 3542 {
  3543 + $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason,
  3544 + 'ktcore.transactions.rename');
  3545 + if ($response['status_code'] == 1) return $response;
  3546 +
3405 $document = &$this->get_document_by_id($document_id); 3547 $document = &$this->get_document_by_id($document_id);
3406 if (PEAR::isError($document)) 3548 if (PEAR::isError($document))
3407 { 3549 {
@@ -3432,8 +3574,12 @@ class KTAPI @@ -3432,8 +3574,12 @@ class KTAPI
3432 * @param string $reason 3574 * @param string $reason
3433 * @return array 3575 * @return array
3434 */ 3576 */
3435 - public function change_document_owner($document_id, $username, $reason) 3577 + public function change_document_owner($document_id, $username, $reason, $sig_username = '', $sig_password = '')
3436 { 3578 {
  3579 + $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason,
  3580 + 'ktcore.transactions.document_owner_change');
  3581 + if ($response['status_code'] == 1) return $response;
  3582 +
3437 $document = &$this->get_document_by_id($document_id); 3583 $document = &$this->get_document_by_id($document_id);
3438 if (PEAR::isError($document)) 3584 if (PEAR::isError($document))
3439 { 3585 {
@@ -3465,8 +3611,12 @@ class KTAPI @@ -3465,8 +3611,12 @@ class KTAPI
3465 * @param string $workflow 3611 * @param string $workflow
3466 * @return array 3612 * @return array
3467 */ 3613 */
3468 - public function start_document_workflow($document_id,$workflow) 3614 + public function start_document_workflow($document_id,$workflow, $sig_username = '', $sig_password = '', $reason = '')
3469 { 3615 {
  3616 + $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason,
  3617 + 'ktcore.transactions.workflow_state_transition');
  3618 + if ($response['status_code'] == 1) return $response;
  3619 +
3470 $document = &$this->get_document_by_id($document_id); 3620 $document = &$this->get_document_by_id($document_id);
3471 if (PEAR::isError($document)) 3621 if (PEAR::isError($document))
3472 { 3622 {
@@ -3495,8 +3645,12 @@ class KTAPI @@ -3495,8 +3645,12 @@ class KTAPI
3495 * @param int $document_id 3645 * @param int $document_id
3496 * @return array 3646 * @return array
3497 */ 3647 */
3498 - public function delete_document_workflow($document_id) 3648 + public function delete_document_workflow($document_id, $sig_username = '', $sig_password = '', $reason = '')
3499 { 3649 {
  3650 + $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason,
  3651 + 'ktcore.transactions.workflow_state_transition');
  3652 + if ($response['status_code'] == 1) return $response;
  3653 +
3500 $document = &$this->get_document_by_id($document_id); 3654 $document = &$this->get_document_by_id($document_id);
3501 if (PEAR::isError($document)) 3655 if (PEAR::isError($document))
3502 { 3656 {
@@ -3527,8 +3681,12 @@ class KTAPI @@ -3527,8 +3681,12 @@ class KTAPI
3527 * @param string $reason 3681 * @param string $reason
3528 * @return array 3682 * @return array
3529 */ 3683 */
3530 - public function perform_document_workflow_transition($document_id,$transition,$reason) 3684 + public function perform_document_workflow_transition($document_id,$transition,$reason, $sig_username = '', $sig_password = '')
3531 { 3685 {
  3686 + $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason,
  3687 + 'ktcore.transactions.workflow_state_transition');
  3688 + if ($response['status_code'] == 1) return $response;
  3689 +
3532 $document = &$this->get_document_by_id($document_id); 3690 $document = &$this->get_document_by_id($document_id);
3533 if (PEAR::isError($document)) 3691 if (PEAR::isError($document))
3534 { 3692 {
@@ -3546,11 +3704,8 @@ class KTAPI @@ -3546,11 +3704,8 @@ class KTAPI
3546 } 3704 }
3547 3705
3548 return $this->get_document_detail($document_id); 3706 return $this->get_document_detail($document_id);
3549 -  
3550 } 3707 }
3551 3708
3552 -  
3553 -  
3554 /** 3709 /**
3555 * Returns the metadata on a document. 3710 * Returns the metadata on a document.
3556 * 3711 *
@@ -3607,8 +3762,11 @@ class KTAPI @@ -3607,8 +3762,11 @@ class KTAPI
3607 * @param array $metadata 3762 * @param array $metadata
3608 * @return array 3763 * @return array
3609 */ 3764 */
3610 - public function update_document_metadata($document_id,$metadata, $sysdata=null) 3765 + public function update_document_metadata($document_id,$metadata, $sysdata=null, $sig_username = '', $sig_password = '', $reason = '')
3611 { 3766 {
  3767 + $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason,
  3768 + 'ktcore.transactions.metadata_update');
  3769 + if ($response['status_code'] == 1) return $response;
3612 3770
3613 $document = &$this->get_document_by_id($document_id); 3771 $document = &$this->get_document_by_id($document_id);
3614 if (PEAR::isError($document)) 3772 if (PEAR::isError($document))
@@ -3649,7 +3807,6 @@ class KTAPI @@ -3649,7 +3807,6 @@ class KTAPI
3649 */ 3807 */
3650 public function get_document_workflow_transitions($document_id) 3808 public function get_document_workflow_transitions($document_id)
3651 { 3809 {
3652 -  
3653 $document = &$this->get_document_by_id($document_id); 3810 $document = &$this->get_document_by_id($document_id);
3654 if (PEAR::isError($document)) 3811 if (PEAR::isError($document))
3655 { 3812 {
@@ -3712,7 +3869,6 @@ class KTAPI @@ -3712,7 +3869,6 @@ class KTAPI
3712 */ 3869 */
3713 public function get_document_transaction_history($document_id) 3870 public function get_document_transaction_history($document_id)
3714 { 3871 {
3715 -  
3716 $document = &$this->get_document_by_id($document_id); 3872 $document = &$this->get_document_by_id($document_id);
3717 if (PEAR::isError($document)) 3873 if (PEAR::isError($document))
3718 { 3874 {
@@ -3744,7 +3900,6 @@ class KTAPI @@ -3744,7 +3900,6 @@ class KTAPI
3744 */ 3900 */
3745 public function get_folder_transaction_history($folder_id) 3901 public function get_folder_transaction_history($folder_id)
3746 { 3902 {
3747 -  
3748 $folder = &$this->get_folder_by_id($folder_id); 3903 $folder = &$this->get_folder_by_id($folder_id);
3749 if (PEAR::isError($folder)) 3904 if (PEAR::isError($folder))
3750 { 3905 {
@@ -3840,8 +3995,12 @@ class KTAPI @@ -3840,8 +3995,12 @@ class KTAPI
3840 * @param int $child_document_id 3995 * @param int $child_document_id
3841 * @return kt_response 3996 * @return kt_response
3842 */ 3997 */
3843 - public function unlink_documents($parent_document_id, $child_document_id) 3998 + public function unlink_documents($parent_document_id, $child_document_id, $sig_username = '', $sig_password = '', $reason = '')
3844 { 3999 {
  4000 + $response = $this->_check_electronic_signature($parent_document_id, $sig_username, $sig_password, $reason, $reason,
  4001 + 'ktcore.transactions.unlink');
  4002 + if ($response['status_code'] == 1) return $response;
  4003 +
3845 $document = &$this->get_document_by_id($parent_document_id); 4004 $document = &$this->get_document_by_id($parent_document_id);
3846 if (PEAR::isError($document)) 4005 if (PEAR::isError($document))
3847 { 4006 {
@@ -3880,8 +4039,11 @@ class KTAPI @@ -3880,8 +4039,11 @@ class KTAPI
3880 * @param string $type 4039 * @param string $type
3881 * @return boolean 4040 * @return boolean
3882 */ 4041 */
3883 - public function link_documents($parent_document_id, $child_document_id, $type) 4042 + public function link_documents($parent_document_id, $child_document_id, $type, $sig_username = '', $sig_password = '', $reason = '')
3884 { 4043 {
  4044 + $response = $this->_check_electronic_signature($parent_document_id, $sig_username, $sig_password, $reason, $reason,
  4045 + 'ktcore.transactions.link');
  4046 + if ($response['status_code'] == 1) return $response;
3885 4047
3886 $document = &$this->get_document_by_id($parent_document_id); 4048 $document = &$this->get_document_by_id($parent_document_id);
3887 if (PEAR::isError($document)) 4049 if (PEAR::isError($document))
@@ -4490,6 +4652,67 @@ class KTAPI @@ -4490,6 +4652,67 @@ class KTAPI
4490 4652
4491 return $response; 4653 return $response;
4492 } 4654 }
  4655 +
  4656 + /**
  4657 + * Method to check whether electronic signatures are enabled
  4658 + *
  4659 + * @author KnowledgeTree Team
  4660 + * @access public
  4661 + * @return bool $enabled true or false
  4662 + */
  4663 + public function electronic_sig_enabled()
  4664 + {
  4665 + // Check config for api signatures enabled
  4666 + $oConfig =& KTConfig::getSingleton();
  4667 + $enabled = $oConfig->get('e_signatures/enableApiSignatures', false);
  4668 + // Check that the license is valid
  4669 + $enabled = (BaobabKeyUtil::getLicenseCount() >= MIN_LICENSES) & $enabled;
  4670 +
  4671 + return $enabled;
  4672 + }
  4673 +
  4674 + /**
  4675 + * Attempts authentication of the signature
  4676 + *
  4677 + * @author KnowledgeTree Team
  4678 + * @access private
  4679 + * @param string $username The users username.
  4680 + * @param string $password The users password.
  4681 + * @param string $comment A comment on the action performed.
  4682 + * @param string $action The action performed.
  4683 + * @param string $details Details about the action performed.
  4684 + * @return bool True if authenticated | False if rejected
  4685 + */
  4686 + private function _authenticateSignature($username, $password, $comment, $action, $details)
  4687 + {
  4688 + $eSignature = new ESignature('api');
  4689 + $result = $eSignature->sign($username, $password, $comment, $action, $details);
  4690 + if(!$result){
  4691 + $this->esig_error = $eSignature->getError();
  4692 + }
  4693 +
  4694 + return $result;
  4695 + }
  4696 +
  4697 + /**
  4698 + * Method to execute electronic signature checks on action
  4699 + */
  4700 + private function _check_electronic_signature($item_id, $username, $password, $comment, $details, $action)
  4701 + {
  4702 + $response = array();
  4703 + $response['status_code'] = 0;
  4704 +
  4705 + // check electronic signature authentication, if on
  4706 + if ($this->esig_enabled && !$this->_authenticateSignature($username, $password, $comment, $action, $item_id))
  4707 + {
  4708 + $response['status_code'] = 1;
  4709 + $response['message'] = $this->esig_error;
  4710 +
  4711 + return $response;
  4712 + }
  4713 +
  4714 + return $response;
  4715 + }
4493 } 4716 }
4494 4717
4495 4718
tests/api/testApi.php
@@ -117,7 +117,7 @@ class APITestCase extends KTUnitTestCase { @@ -117,7 +117,7 @@ class APITestCase extends KTUnitTestCase {
117 117
118 // create the document object 118 // create the document object
119 $randomFile = $this->createRandomFile(); 119 $randomFile = $this->createRandomFile();
120 - $document = $this->root->add_document('title_1.txt', 'name_1.txt', 'Default', $randomFile); 120 + $document = $this->root->add_document('title_1.txt', 'name_1.txt', 'Default', $randomFile, 'admin', 'admin', 'Testing API');
121 @unlink($randomFile); 121 @unlink($randomFile);
122 122
123 $internalDocObject = $document->getObject(); 123 $internalDocObject = $document->getObject();
@@ -132,7 +132,8 @@ class APITestCase extends KTUnitTestCase { @@ -132,7 +132,8 @@ class APITestCase extends KTUnitTestCase {
132 132
133 // create the document object 133 // create the document object
134 $randomFile = $this->createRandomFile(); 134 $randomFile = $this->createRandomFile();
135 - $document2 = $this->root->add_document('title_2.txt', 'name_2.txt', 'Default', $randomFile); 135 + $document2 = $this->root->add_document('title_2.txt', 'name_2.txt', 'Default', $randomFile, 'admin', 'admin', 'Testing API');
  136 +
136 @unlink($randomFile); 137 @unlink($randomFile);
137 138
138 $internalDocObject2 = $document2->getObject(); 139 $internalDocObject2 = $document2->getObject();
@@ -301,7 +302,7 @@ class APITestCase extends KTUnitTestCase { @@ -301,7 +302,7 @@ class APITestCase extends KTUnitTestCase {
301 { 302 {
302 // create the document object 303 // create the document object
303 $randomFile = $this->createRandomFile(); 304 $randomFile = $this->createRandomFile();
304 - $document = $this->root->add_document('title_5.txt', 'name_5.txt', 'Default', $randomFile); 305 + $document = $this->root->add_document('title_5.txt', 'name_5.txt', 'Default', $randomFile, 'admin', 'admin', 'reason');
305 @unlink($randomFile); 306 @unlink($randomFile);
306 307
307 $documentID = $document->get_documentid(); 308 $documentID = $document->get_documentid();
@@ -432,7 +433,7 @@ class APITestCase extends KTUnitTestCase { @@ -432,7 +433,7 @@ class APITestCase extends KTUnitTestCase {
432 { 433 {
433 // Create a document and subscribe to it 434 // Create a document and subscribe to it
434 $randomFile = $this->createRandomFile(); 435 $randomFile = $this->createRandomFile();
435 - $document = $this->root->add_document('test title 1', 'testfile1.txt', 'Default', $randomFile); 436 + $document = $this->root->add_document('test title 1', 'testfile1.txt', 'Default', $randomFile, 'admin', 'admin', 'Testing API');
436 @unlink($randomFile); 437 @unlink($randomFile);
437 438
438 $this->assertEntity($document, 'KTAPI_Document'); 439 $this->assertEntity($document, 'KTAPI_Document');
@@ -458,18 +459,18 @@ class APITestCase extends KTUnitTestCase { @@ -458,18 +459,18 @@ class APITestCase extends KTUnitTestCase {
458 public function testFolderApiFunctions() 459 public function testFolderApiFunctions()
459 { 460 {
460 // check for a negative result 461 // check for a negative result
461 - $result = $this->ktapi->create_folder(0, 'New test error api folder'); 462 + $result = $this->ktapi->create_folder(0, 'New test error api folder', 'admin', 'admin', 'Testing API');
462 $this->assertNotEqual($result['status_code'], 0); 463 $this->assertNotEqual($result['status_code'], 0);
463 464
464 // Create a folder 465 // Create a folder
465 - $result1 = $this->ktapi->create_folder(1, 'New test api folder'); 466 + $result1 = $this->ktapi->create_folder(1, 'New test api folder', 'admin', 'admin', 'Testing API');
466 $folder_id = $result1['results']['id']; 467 $folder_id = $result1['results']['id'];
467 468
468 $this->assertEqual($result1['status_code'], 0); 469 $this->assertEqual($result1['status_code'], 0);
469 $this->assertTrue($result1['results']['parent_id'] == 1); 470 $this->assertTrue($result1['results']['parent_id'] == 1);
470 471
471 // Create a sub folder 472 // Create a sub folder
472 - $result2 = $this->ktapi->create_folder($folder_id, 'New test api sub-folder'); 473 + $result2 = $this->ktapi->create_folder($folder_id, 'New test api sub-folder', 'admin', 'admin', 'Testing API');
473 $folder_id2 = $result2['results']['id']; 474 $folder_id2 = $result2['results']['id'];
474 $this->assertEqual($result2['status_code'], 0); 475 $this->assertEqual($result2['status_code'], 0);
475 476
@@ -477,8 +478,10 @@ class APITestCase extends KTUnitTestCase { @@ -477,8 +478,10 @@ class APITestCase extends KTUnitTestCase {
477 global $default; 478 global $default;
478 $dir = $default->uploadDirectory; 479 $dir = $default->uploadDirectory;
479 $tempfilename = $this->createRandomFile('some text', $dir); 480 $tempfilename = $this->createRandomFile('some text', $dir);
480 - $doc = $this->ktapi->add_document($folder_id, 'New API test doc', 'testdoc1.txt', 'Default', $tempfilename);  
481 481
  482 + $doc = $this->ktapi->add_document($folder_id, 'New API test doc', 'testdoc1.txt', 'Default',
  483 + $tempfilename, 'admin', 'admin', 'Testing API');
  484 +
482 $this->assertEqual($doc['status_code'], 0); 485 $this->assertEqual($doc['status_code'], 0);
483 $this->assertEqual($doc['results']['title'], 'New API test doc'); 486 $this->assertEqual($doc['results']['title'], 'New API test doc');
484 487
@@ -492,7 +495,7 @@ class APITestCase extends KTUnitTestCase { @@ -492,7 +495,7 @@ class APITestCase extends KTUnitTestCase {
492 $this->assertTrue($detail['results']['parent_id'] == $folder_id); 495 $this->assertTrue($detail['results']['parent_id'] == $folder_id);
493 496
494 // Create a shortcut to the subfolder from the root folder 497 // Create a shortcut to the subfolder from the root folder
495 - $shortcut = $this->ktapi->create_folder_shortcut(1, $folder_id2); 498 + $shortcut = $this->ktapi->create_folder_shortcut(1, $folder_id2, 'admin', 'admin', 'Testing API');
496 $this->assertEqual($shortcut['status_code'], 0); 499 $this->assertEqual($shortcut['status_code'], 0);
497 $this->assertEqual($shortcut['results']['folder_name'], 'New test api sub-folder'); 500 $this->assertEqual($shortcut['results']['folder_name'], 'New test api sub-folder');
498 $this->assertEqual($shortcut['results']['parent_id'], 1); 501 $this->assertEqual($shortcut['results']['parent_id'], 1);
@@ -502,7 +505,7 @@ class APITestCase extends KTUnitTestCase { @@ -502,7 +505,7 @@ class APITestCase extends KTUnitTestCase {
502 $this->assertEqual(count($shortcut_list['results']), 1); 505 $this->assertEqual(count($shortcut_list['results']), 1);
503 506
504 // Rename the folder 507 // Rename the folder
505 - $renamed = $this->ktapi->rename_folder($folder_id, 'Renamed test folder'); 508 + $renamed = $this->ktapi->rename_folder($folder_id, 'Renamed test folder', 'admin', 'admin', 'Testing API');
506 $this->assertEqual($renamed['status_code'], 0); 509 $this->assertEqual($renamed['status_code'], 0);
507 510
508 $renamed_detail = $this->ktapi->get_folder_detail_by_name('Renamed test folder'); 511 $renamed_detail = $this->ktapi->get_folder_detail_by_name('Renamed test folder');
@@ -512,9 +515,9 @@ class APITestCase extends KTUnitTestCase { @@ -512,9 +515,9 @@ class APITestCase extends KTUnitTestCase {
512 // $this->ktapi->copy_folder($source_id, $target_id, $reason); 515 // $this->ktapi->copy_folder($source_id, $target_id, $reason);
513 // $this->ktapi->move_folder($source_id, $target_id, $reason); 516 // $this->ktapi->move_folder($source_id, $target_id, $reason);
514 517
515 -  
516 // Clean up - delete the folder 518 // Clean up - delete the folder
517 - $this->ktapi->delete_folder($folder_id, 'Testing API'); 519 + $this->ktapi->delete_folder($folder_id, 'Testing API', 'admin', 'admin');
  520 +
518 $detail2 = $this->ktapi->get_folder_detail($folder_id); 521 $detail2 = $this->ktapi->get_folder_detail($folder_id);
519 $this->assertNotEqual($detail2['status_code'], 0); 522 $this->assertNotEqual($detail2['status_code'], 0);
520 } 523 }
@@ -525,12 +528,12 @@ class APITestCase extends KTUnitTestCase { @@ -525,12 +528,12 @@ class APITestCase extends KTUnitTestCase {
525 public function testDocumentApiFunctions() 528 public function testDocumentApiFunctions()
526 { 529 {
527 // Create a folder 530 // Create a folder
528 - $result1 = $this->ktapi->create_folder(1, 'New test api folder'); 531 + $result1 = $this->ktapi->create_folder(1, 'New test api folder', 'admin', 'admin', 'Testing API');
529 $folder_id = $result1['results']['id']; 532 $folder_id = $result1['results']['id'];
530 $this->assertEqual($result1['status_code'], 0); 533 $this->assertEqual($result1['status_code'], 0);
531 534
532 // Create a sub folder 535 // Create a sub folder
533 - $result2 = $this->ktapi->create_folder($folder_id, 'New test api sub-folder'); 536 + $result2 = $this->ktapi->create_folder($folder_id, 'New test api sub-folder', 'admin', 'admin', 'Testing API');
534 $folder_id2 = $result2['results']['id']; 537 $folder_id2 = $result2['results']['id'];
535 $this->assertEqual($result2['status_code'], 0); 538 $this->assertEqual($result2['status_code'], 0);
536 539
@@ -538,8 +541,9 @@ class APITestCase extends KTUnitTestCase { @@ -538,8 +541,9 @@ class APITestCase extends KTUnitTestCase {
538 global $default; 541 global $default;
539 $dir = $default->uploadDirectory; 542 $dir = $default->uploadDirectory;
540 $tempfilename = $this->createRandomFile('some text', $dir); 543 $tempfilename = $this->createRandomFile('some text', $dir);
541 - $doc = $this->ktapi->add_document($folder_id, 'New API test doc', 'testdoc1.txt', 'Default', $tempfilename);  
542 - 544 + $doc = $this->ktapi->add_document($folder_id, 'New API test doc', 'testdoc1.txt', 'Default', $tempfilename,
  545 + 'admin', 'admin', 'Testing API');
  546 +
543 $doc_id = $doc['results']['document_id']; 547 $doc_id = $doc['results']['document_id'];
544 $this->assertEqual($doc['status_code'], 0); 548 $this->assertEqual($doc['status_code'], 0);
545 549
@@ -565,15 +569,15 @@ class APITestCase extends KTUnitTestCase { @@ -565,15 +569,15 @@ class APITestCase extends KTUnitTestCase {
565 $this->assertEqual($detail4['results']['title'], 'New API test doc'); 569 $this->assertEqual($detail4['results']['title'], 'New API test doc');
566 570
567 // Checkout the document 571 // Checkout the document
568 - $result1 = $this->ktapi->checkout_document($doc_id, 'Testing API', true); 572 + $result1 = $this->ktapi->checkout_document($doc_id, 'Testing API', true, 'admin', 'admin');
569 $this->assertEqual($result1['status_code'], 0); 573 $this->assertEqual($result1['status_code'], 0);
570 $this->assertTrue(!empty($result1['results'])); 574 $this->assertTrue(!empty($result1['results']));
571 575
572 // Checkin the document 576 // Checkin the document
573 $dir = $default->uploadDirectory; 577 $dir = $default->uploadDirectory;
574 $tempfilename = $this->createRandomFile('some text', $dir); 578 $tempfilename = $this->createRandomFile('some text', $dir);
575 - $result2 = $this->ktapi->checkin_document($doc_id, 'testdoc1.txt', 'Testing API', $tempfilename, false);  
576 - 579 + $result2 = $this->ktapi->checkin_document($doc_id, 'testdoc1.txt', 'Testing API', $tempfilename, false, 'admin', 'admin');
  580 +
577 $this->assertEqual($result2['status_code'], 0); 581 $this->assertEqual($result2['status_code'], 0);
578 $this->assertEqual($result2['results']['document_id'], $doc_id); 582 $this->assertEqual($result2['results']['document_id'], $doc_id);
579 583
@@ -584,11 +588,12 @@ class APITestCase extends KTUnitTestCase { @@ -584,11 +588,12 @@ class APITestCase extends KTUnitTestCase {
584 $this->assertEqual($shortcut['results']['folder_id'], $folder_id); 588 $this->assertEqual($shortcut['results']['folder_id'], $folder_id);
585 589
586 // Delete the document 590 // Delete the document
587 - $result3 = $this->ktapi->delete_document($doc_id, 'Testing API'); 591 + $result3 = $this->ktapi->delete_document($doc_id, 'Testing API', 'admin', 'admin', true);
588 $this->assertEqual($result3['status_code'], 0); 592 $this->assertEqual($result3['status_code'], 0);
589 593
590 // Clean up - delete the folder 594 // Clean up - delete the folder
591 - $this->ktapi->delete_folder($folder_id, 'Testing API'); 595 + $this->ktapi->delete_folder($folder_id, 'Testing API', 'admin', 'admin');
  596 +
592 $detail2 = $this->ktapi->get_folder_detail($folder_id); 597 $detail2 = $this->ktapi->get_folder_detail($folder_id);
593 $this->assertNotEqual($detail2['status_code'], 0); 598 $this->assertNotEqual($detail2['status_code'], 0);
594 } 599 }
@@ -606,7 +611,7 @@ class APITestCase extends KTUnitTestCase { @@ -606,7 +611,7 @@ class APITestCase extends KTUnitTestCase {
606 $randomFile = $this->createRandomFile(); 611 $randomFile = $this->createRandomFile();
607 $this->assertTrue(is_file($randomFile)); 612 $this->assertTrue(is_file($randomFile));
608 613
609 - $document = $folder->add_document($title, $filename, 'Default', $randomFile); 614 + $document = $folder->add_document($title, $filename, 'Default', $randomFile, 'admin', 'admin', 'Testing API');
610 $this->assertNotError($document); 615 $this->assertNotError($document);
611 616
612 @unlink($randomFile); 617 @unlink($randomFile);
tests/api/testAuto.php
@@ -22,7 +22,7 @@ class APIAutoTestCase extends KTUnitTestCase { @@ -22,7 +22,7 @@ class APIAutoTestCase extends KTUnitTestCase {
22 * @var object $root The KT folder object 22 * @var object $root The KT folder object
23 */ 23 */
24 var $root; 24 var $root;
25 - 25 +
26 /** 26 /**
27 * This method sets up the KT session 27 * This method sets up the KT session
28 * 28 *
@@ -42,8 +42,6 @@ class APIAutoTestCase extends KTUnitTestCase { @@ -42,8 +42,6 @@ class APIAutoTestCase extends KTUnitTestCase {
42 $this->session->logout(); 42 $this->session->logout();
43 } 43 }
44 44
45 -  
46 -  
47 function testJunkanonymous_login() { 45 function testJunkanonymous_login() {
48 $result = $this->ktapi->anonymous_login(null); 46 $result = $this->ktapi->anonymous_login(null);
49 $this->assertIsA($result, 'array'); 47 $this->assertIsA($result, 'array');
@@ -92,31 +90,29 @@ class APIAutoTestCase extends KTUnitTestCase { @@ -92,31 +90,29 @@ class APIAutoTestCase extends KTUnitTestCase {
92 90
93 91
94 92
95 - function tesRealdelete_folder() {  
96 - $result = $this->ktapi->delete_folder($folder_id, $reason);  
97 - $this->assertIsA($result, 'array'); 93 + function tesRealdelete_folder() {
  94 + $result = $this->ktapi->delete_folder($folder_id, $reason, 'admin', 'admin');
  95 + $this->assertIsA($result, 'array');
98 $this->assertEqual($result['status_code'], 0); 96 $this->assertEqual($result['status_code'], 0);
99 } 97 }
100 98
101 -  
102 -  
103 function tesRealrename_folder() { 99 function tesRealrename_folder() {
104 - $result = $this->ktapi->rename_folder($folder_id, $newname);  
105 - $this->assertIsA($result, 'array'); 100 + $result = $this->ktapi->rename_folder($folder_id, $newname, 'admin', 'admin', 'Testing API');
  101 + $this->assertIsA($result, 'array');
106 $this->assertEqual($result['status_code'], 0); 102 $this->assertEqual($result['status_code'], 0);
107 } 103 }
108 104
109 105
110 function tesRealcopy_folder() { 106 function tesRealcopy_folder() {
111 - $result = $this->ktapi->copy_folder($source_id, $target_id, $reason);  
112 - $this->assertIsA($result, 'array'); 107 + $result = $this->ktapi->copy_folder($source_id, $target_id, $reason, 'admin', 'admin');
  108 + $this->assertIsA($result, 'array');
113 $this->assertEqual($result['status_code'], 0); 109 $this->assertEqual($result['status_code'], 0);
114 } 110 }
115 111
116 112
117 function tesRealmove_folder() { 113 function tesRealmove_folder() {
118 - $result = $this->ktapi->move_folder($source_id, $target_id, $reason);  
119 - $this->assertIsA($result, 'array'); 114 + $result = $this->ktapi->move_folder($source_id, $target_id, $reason, 'admin', 'admin');
  115 + $this->assertIsA($result, 'array');
120 $this->assertEqual($result['status_code'], 0); 116 $this->assertEqual($result['status_code'], 0);
121 } 117 }
122 118
@@ -132,7 +128,7 @@ class APIAutoTestCase extends KTUnitTestCase { @@ -132,7 +128,7 @@ class APIAutoTestCase extends KTUnitTestCase {
132 $this->assertEqual($result['status_code'], 0); 128 $this->assertEqual($result['status_code'], 0);
133 } 129 }
134 130
135 - function testJunkget_document_detail_by_filename() { 131 + function testJunkget_document_detail_by_filename() {
136 $result = $this->ktapi->get_document_detail_by_filename(null, null, null); 132 $result = $this->ktapi->get_document_detail_by_filename(null, null, null);
137 $this->assertIsA($result, 'array'); 133 $this->assertIsA($result, 'array');
138 $this->assertEqual($result['status_code'], 1); 134 $this->assertEqual($result['status_code'], 1);
@@ -168,27 +164,25 @@ class APIAutoTestCase extends KTUnitTestCase { @@ -168,27 +164,25 @@ class APIAutoTestCase extends KTUnitTestCase {
168 $this->assertEqual($result['status_code'], 0); 164 $this->assertEqual($result['status_code'], 0);
169 } 165 }
170 166
171 -  
172 - function tesRealget_document_shortcuts() { 167 + function tesRealget_document_shortcuts() {
173 $result = $this->ktapi->get_document_shortcuts($document_id); 168 $result = $this->ktapi->get_document_shortcuts($document_id);
174 $this->assertIsA($result, 'array'); 169 $this->assertIsA($result, 'array');
175 $this->assertEqual($result['status_code'], 0); 170 $this->assertEqual($result['status_code'], 0);
176 } 171 }
177 172
178 - function testJunkadd_document() {  
179 - $result = $this->ktapi->add_document(null, null, null, null, null); 173 + function testJunkadd_document() {
  174 + $result = $this->ktapi->add_document(null, null, null, null, null, 'admin', 'admin', 'Testing API');
180 $this->assertIsA($result, 'array'); 175 $this->assertIsA($result, 'array');
181 $this->assertEqual($result['status_code'], 1); 176 $this->assertEqual($result['status_code'], 1);
182 } 177 }
183 178
184 function tesRealadd_document() { 179 function tesRealadd_document() {
185 - $result = $this->ktapi->add_document($folder_id, $title, $filename, $documenttype, $tempfilename); 180 + $result = $this->ktapi->add_document($folder_id, $title, $filename, $documenttype, $tempfilename,
  181 + 'admin', 'admin', 'Testing API');
186 $this->assertIsA($result, 'array'); 182 $this->assertIsA($result, 'array');
187 $this->assertEqual($result['status_code'], 0); 183 $this->assertEqual($result['status_code'], 0);
188 } 184 }
189 185
190 -  
191 -  
192 function tesRealadd_small_document_with_metadata() { 186 function tesRealadd_small_document_with_metadata() {
193 $result = $this->ktapi->add_small_document_with_metadata($folder_id, $title, $filename, $documenttype, $base64, $metadata, $sysdata); 187 $result = $this->ktapi->add_small_document_with_metadata($folder_id, $title, $filename, $documenttype, $base64, $metadata, $sysdata);
194 $this->assertIsA($result, 'array'); 188 $this->assertIsA($result, 'array');
@@ -214,18 +208,17 @@ class APIAutoTestCase extends KTUnitTestCase { @@ -214,18 +208,17 @@ class APIAutoTestCase extends KTUnitTestCase {
214 } 208 }
215 209
216 function testJunkcheckin_document() { 210 function testJunkcheckin_document() {
217 - $result = $this->ktapi->checkin_document(null, null, null, null, null); 211 + $result = $this->ktapi->checkin_document(null, null, null, null, null, 'admin', 'admin');
218 $this->assertIsA($result, 'array'); 212 $this->assertIsA($result, 'array');
219 $this->assertEqual($result['status_code'], 1); 213 $this->assertEqual($result['status_code'], 1);
220 } 214 }
221 215
222 function tesRealcheckin_document() { 216 function tesRealcheckin_document() {
223 - $result = $this->ktapi->checkin_document($document_id, $filename, $reason, $tempfilename, $major_update); 217 + $result = $this->ktapi->checkin_document($document_id, $filename, $reason, $tempfilename, $major_update, 'admin', 'admin');
224 $this->assertIsA($result, 'array'); 218 $this->assertIsA($result, 'array');
225 $this->assertEqual($result['status_code'], 0); 219 $this->assertEqual($result['status_code'], 0);
226 } 220 }
227 221
228 -  
229 function tesRealcheckin_small_document_with_metadata() { 222 function tesRealcheckin_small_document_with_metadata() {
230 $result = $this->ktapi->checkin_small_document_with_metadata($document_id, $filename, $reason, $base64, $major_update, $metadata, $sysdata); 223 $result = $this->ktapi->checkin_small_document_with_metadata($document_id, $filename, $reason, $base64, $major_update, $metadata, $sysdata);
231 $this->assertIsA($result, 'array'); 224 $this->assertIsA($result, 'array');
@@ -238,62 +231,48 @@ class APIAutoTestCase extends KTUnitTestCase { @@ -238,62 +231,48 @@ class APIAutoTestCase extends KTUnitTestCase {
238 $this->assertEqual($result['status_code'], 0); 231 $this->assertEqual($result['status_code'], 0);
239 } 232 }
240 233
241 -  
242 -  
243 function tesRealcheckin_small_document() { 234 function tesRealcheckin_small_document() {
244 $result = $this->ktapi->checkin_small_document($document_id, $filename, $reason, $base64, $major_update); 235 $result = $this->ktapi->checkin_small_document($document_id, $filename, $reason, $base64, $major_update);
245 $this->assertIsA($result, 'array'); 236 $this->assertIsA($result, 'array');
246 $this->assertEqual($result['status_code'], 0); 237 $this->assertEqual($result['status_code'], 0);
247 } 238 }
248 239
249 -  
250 -  
251 function tesRealcheckout_document() { 240 function tesRealcheckout_document() {
252 $result = $this->ktapi->checkout_document($document_id, $reason, $download); 241 $result = $this->ktapi->checkout_document($document_id, $reason, $download);
253 $this->assertIsA($result, 'array'); 242 $this->assertIsA($result, 'array');
254 $this->assertEqual($result['status_code'], 0); 243 $this->assertEqual($result['status_code'], 0);
255 } 244 }
256 245
257 -  
258 -  
259 function tesRealcheckout_small_document() { 246 function tesRealcheckout_small_document() {
260 $result = $this->ktapi->checkout_small_document($document_id, $reason, $download); 247 $result = $this->ktapi->checkout_small_document($document_id, $reason, $download);
261 $this->assertIsA($result, 'array'); 248 $this->assertIsA($result, 'array');
262 $this->assertEqual($result['status_code'], 0); 249 $this->assertEqual($result['status_code'], 0);
263 } 250 }
264 251
265 -  
266 function tesRealundo_document_checkout() { 252 function tesRealundo_document_checkout() {
267 - $result = $this->ktapi->undo_document_checkout($document_id, $reason); 253 + $result = $this->ktapi->undo_document_checkout($document_id, $reason, 'admin', 'admin');
268 $this->assertIsA($result, 'array'); 254 $this->assertIsA($result, 'array');
269 $this->assertEqual($result['status_code'], 0); 255 $this->assertEqual($result['status_code'], 0);
270 } 256 }
271 257
272 -  
273 -  
274 function tesRealdownload_document() { 258 function tesRealdownload_document() {
275 $result = $this->ktapi->download_document($document_id, $version); 259 $result = $this->ktapi->download_document($document_id, $version);
276 $this->assertIsA($result, 'array'); 260 $this->assertIsA($result, 'array');
277 $this->assertEqual($result['status_code'], 0); 261 $this->assertEqual($result['status_code'], 0);
278 } 262 }
279 263
280 -  
281 -  
282 function tesRealdownload_small_document() { 264 function tesRealdownload_small_document() {
283 $result = $this->ktapi->download_small_document($document_id, $version); 265 $result = $this->ktapi->download_small_document($document_id, $version);
284 $this->assertIsA($result, 'array'); 266 $this->assertIsA($result, 'array');
285 $this->assertEqual($result['status_code'], 0); 267 $this->assertEqual($result['status_code'], 0);
286 } 268 }
287 269
288 -  
289 function tesRealdelete_document() { 270 function tesRealdelete_document() {
290 $result = $this->ktapi->delete_document($document_id, $reason); 271 $result = $this->ktapi->delete_document($document_id, $reason);
291 $this->assertIsA($result, 'array'); 272 $this->assertIsA($result, 'array');
292 $this->assertEqual($result['status_code'], 0); 273 $this->assertEqual($result['status_code'], 0);
293 } 274 }
294 275
295 -  
296 -  
297 function tesRealchange_document_type() { 276 function tesRealchange_document_type() {
298 $result = $this->ktapi->change_document_type($document_id, $documenttype); 277 $result = $this->ktapi->change_document_type($document_id, $documenttype);
299 $this->assertIsA($result, 'array'); 278 $this->assertIsA($result, 'array');
@@ -306,86 +285,72 @@ class APIAutoTestCase extends KTUnitTestCase { @@ -306,86 +285,72 @@ class APIAutoTestCase extends KTUnitTestCase {
306 $this->assertEqual($result['status_code'], 0); 285 $this->assertEqual($result['status_code'], 0);
307 } 286 }
308 287
309 -  
310 -  
311 function tesRealrename_document_title() { 288 function tesRealrename_document_title() {
312 $result = $this->ktapi->rename_document_title($document_id, $newtitle); 289 $result = $this->ktapi->rename_document_title($document_id, $newtitle);
313 $this->assertIsA($result, 'array'); 290 $this->assertIsA($result, 'array');
314 $this->assertEqual($result['status_code'], 0); 291 $this->assertEqual($result['status_code'], 0);
315 } 292 }
316 293
317 -  
318 -  
319 function tesRealrename_document_filename() { 294 function tesRealrename_document_filename() {
320 $result = $this->ktapi->rename_document_filename($document_id, $newfilename); 295 $result = $this->ktapi->rename_document_filename($document_id, $newfilename);
321 $this->assertIsA($result, 'array'); 296 $this->assertIsA($result, 'array');
322 $this->assertEqual($result['status_code'], 0); 297 $this->assertEqual($result['status_code'], 0);
323 } 298 }
324 299
325 -  
326 function tesRealchange_document_owner() { 300 function tesRealchange_document_owner() {
327 $result = $this->ktapi->change_document_owner($document_id, $username, $reason); 301 $result = $this->ktapi->change_document_owner($document_id, $username, $reason);
328 $this->assertIsA($result, 'array'); 302 $this->assertIsA($result, 'array');
329 $this->assertEqual($result['status_code'], 0); 303 $this->assertEqual($result['status_code'], 0);
330 } 304 }
331 305
332 -  
333 function tesRealstart_document_workflow() { 306 function tesRealstart_document_workflow() {
334 $result = $this->ktapi->start_document_workflow($document_id, $workflow); 307 $result = $this->ktapi->start_document_workflow($document_id, $workflow);
335 $this->assertIsA($result, 'array'); 308 $this->assertIsA($result, 'array');
336 $this->assertEqual($result['status_code'], 0); 309 $this->assertEqual($result['status_code'], 0);
337 } 310 }
338 311
339 -  
340 function tesRealdelete_document_workflow() { 312 function tesRealdelete_document_workflow() {
341 - $result = $this->ktapi->delete_document_workflow($document_id); 313 + $result = $this->ktapi->delete_document_workflow($document_id, 'Testing API', 'admin', 'admin', true);
342 $this->assertIsA($result, 'array'); 314 $this->assertIsA($result, 'array');
343 $this->assertEqual($result['status_code'], 0); 315 $this->assertEqual($result['status_code'], 0);
344 } 316 }
345 317
346 -  
347 function tesRealperform_document_workflow_transition() { 318 function tesRealperform_document_workflow_transition() {
348 $result = $this->ktapi->perform_document_workflow_transition($document_id, $transition, $reason); 319 $result = $this->ktapi->perform_document_workflow_transition($document_id, $transition, $reason);
349 $this->assertIsA($result, 'array'); 320 $this->assertIsA($result, 'array');
350 $this->assertEqual($result['status_code'], 0); 321 $this->assertEqual($result['status_code'], 0);
351 } 322 }
352 323
353 -  
354 function tesRealget_document_metadata() { 324 function tesRealget_document_metadata() {
355 $result = $this->ktapi->get_document_metadata($document_id); 325 $result = $this->ktapi->get_document_metadata($document_id);
356 $this->assertIsA($result, 'array'); 326 $this->assertIsA($result, 'array');
357 $this->assertEqual($result['status_code'], 0); 327 $this->assertEqual($result['status_code'], 0);
358 } 328 }
359 329
360 -  
361 function tesRealupdate_document_metadata() { 330 function tesRealupdate_document_metadata() {
362 $result = $this->ktapi->update_document_metadata($document_id, $metadata, $sysdata); 331 $result = $this->ktapi->update_document_metadata($document_id, $metadata, $sysdata);
363 $this->assertIsA($result, 'array'); 332 $this->assertIsA($result, 'array');
364 $this->assertEqual($result['status_code'], 0); 333 $this->assertEqual($result['status_code'], 0);
365 } 334 }
366 335
367 -  
368 function tesRealget_document_workflow_state() { 336 function tesRealget_document_workflow_state() {
369 $result = $this->ktapi->get_document_workflow_state($document_id); 337 $result = $this->ktapi->get_document_workflow_state($document_id);
370 $this->assertIsA($result, 'array'); 338 $this->assertIsA($result, 'array');
371 $this->assertEqual($result['status_code'], 0); 339 $this->assertEqual($result['status_code'], 0);
372 } 340 }
373 341
374 -  
375 function tesRealget_document_transaction_history() { 342 function tesRealget_document_transaction_history() {
376 $result = $this->ktapi->get_document_transaction_history($document_id); 343 $result = $this->ktapi->get_document_transaction_history($document_id);
377 $this->assertIsA($result, 'array'); 344 $this->assertIsA($result, 'array');
378 $this->assertEqual($result['status_code'], 0); 345 $this->assertEqual($result['status_code'], 0);
379 } 346 }
380 347
381 -  
382 function tesRealget_document_version_history() { 348 function tesRealget_document_version_history() {
383 $result = $this->ktapi->get_document_version_history($document_id); 349 $result = $this->ktapi->get_document_version_history($document_id);
384 $this->assertIsA($result, 'array'); 350 $this->assertIsA($result, 'array');
385 $this->assertEqual($result['status_code'], 0); 351 $this->assertEqual($result['status_code'], 0);
386 } 352 }
387 353
388 -  
389 function tesRealget_document_links() { 354 function tesRealget_document_links() {
390 $result = $this->ktapi->get_document_links($document_id); 355 $result = $this->ktapi->get_document_links($document_id);
391 $this->assertIsA($result, 'array'); 356 $this->assertIsA($result, 'array');