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 60 require_once(KTAPI_DIR .'/KTAPICollection.inc.php');
61 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 69 * This class defines functions that MUST exist in the inheriting class
... ... @@ -171,6 +175,13 @@ class KTAPI
171 175  
172 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 186 * This returns the current session.
176 187 *
... ... @@ -349,7 +360,12 @@ class KTAPI
349 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 369 if (is_null($this->session))
354 370 {
355 371 return array(
... ... @@ -417,7 +433,12 @@ class KTAPI
417 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 442 if (is_null($this->session))
422 443 {
423 444 return array(
... ... @@ -478,7 +499,12 @@ class KTAPI
478 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 508 if (is_null($this->session))
483 509 {
484 510 return array(
... ... @@ -530,9 +556,6 @@ class KTAPI
530 556 $permissions->save();
531 557 }
532 558  
533   -
534   -
535   -
536 559 /**
537 560 * This checks if a user can access an object with a certain permission.
538 561 *
... ... @@ -711,7 +734,6 @@ class KTAPI
711 734 return $session;
712 735 }
713 736  
714   -
715 737 /**
716 738 * start a root session.
717 739 *
... ... @@ -738,8 +760,6 @@ class KTAPI
738 760 return $session;
739 761 }
740 762  
741   -
742   -
743 763 /**
744 764 * Starts an anonymous session.
745 765 *
... ... @@ -1048,7 +1068,6 @@ class KTAPI
1048 1068 return $results;
1049 1069 }
1050 1070  
1051   -
1052 1071 /**
1053 1072 * Returns an array of username/name combinations or an error object.
1054 1073 *
... ... @@ -1213,8 +1232,13 @@ class KTAPI
1213 1232 * @param integer $target_folder_id The id of the target folder if required - copy and move require this.
1214 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 1242 $response['status_code'] = 1;
1219 1243  
1220 1244 if(!is_array($items)){
... ... @@ -1474,8 +1498,12 @@ class KTAPI
1474 1498 * @param integer $user_id The id of the user to be added
1475 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 1507 $response['status_code'] = 1;
1480 1508 if(!is_numeric($user_id)){
1481 1509 $response['message'] = _kt('User id must be numeric.');
... ... @@ -1496,8 +1524,12 @@ class KTAPI
1496 1524 * @param integer $group_id The id of the group to be added
1497 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 1533 $response['status_code'] = 1;
1502 1534 if(!is_numeric($group_id)){
1503 1535 $response['message'] = _kt('Group id must be numeric.');
... ... @@ -1518,8 +1550,12 @@ class KTAPI
1518 1550 * @param integer $user_id The id of the user to be removed
1519 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 1559 $response['status_code'] = 1;
1524 1560 if(!is_numeric($user_id)){
1525 1561 $response['message'] = _kt('User id must be numeric.');
... ... @@ -1540,8 +1576,12 @@ class KTAPI
1540 1576 * @param integer $group_id The id of the group to be removied
1541 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 1585 $response['status_code'] = 1;
1546 1586 if(!is_numeric($group_id)){
1547 1587 $response['message'] = _kt('Group id must be numeric.');
... ... @@ -1593,8 +1633,13 @@ class KTAPI
1593 1633 * @param string $update The type of modification - add | remove
1594 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 1643 // Check input information
1599 1644 $response['status_code'] = 1;
1600 1645 if(!is_numeric($folder_id)){
... ... @@ -1740,8 +1785,12 @@ class KTAPI
1740 1785 * @param integer $role_id Optional. The id of the role being reset.
1741 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 1794 $response['status_code'] = 1;
1746 1795  
1747 1796 // Get folder and role objects
... ... @@ -1778,8 +1827,12 @@ class KTAPI
1778 1827 * @param integer $folder_id The folder id
1779 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 1836 $response['status_code'] = 1;
1784 1837  
1785 1838 // Get folder object
... ... @@ -1829,7 +1882,6 @@ class KTAPI
1829 1882  
1830 1883 /* *** Refactored web services functions *** */
1831 1884  
1832   -
1833 1885 /**
1834 1886 * Creates a new anonymous session.
1835 1887 *
... ... @@ -2022,8 +2074,12 @@ class KTAPI
2022 2074 * @param string $folder_name The name of the new folder
2023 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 2083 $folder = &$this->get_folder_by_id($folder_id);
2028 2084 if (PEAR::isError($folder))
2029 2085 {
... ... @@ -2047,8 +2103,12 @@ class KTAPI
2047 2103 * @param integer $source_folder_id Id of the folder to which the shortcut will point.
2048 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 2112 $folder = &$this->get_folder_by_id($target_folder_id);
2053 2113 if (PEAR::isError($folder))
2054 2114 {
... ... @@ -2088,8 +2148,12 @@ class KTAPI
2088 2148 * @param integer $source_document_id Id of the document to which the shortcut will point
2089 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 2157 $folder = &$this->get_folder_by_id($target_folder_id);
2094 2158 if (PEAR::isError($folder))
2095 2159 {
... ... @@ -2129,8 +2193,12 @@ class KTAPI
2129 2193 * @param string $reason The reason for performing the deletion
2130 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 2202 $folder = &$this->get_folder_by_id($folder_id);
2135 2203 if (PEAR::isError($folder))
2136 2204 {
... ... @@ -2160,8 +2228,12 @@ class KTAPI
2160 2228 * @param string $newname The new name of the folder
2161 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 2237 $folder = &$this->get_folder_by_id($folder_id);
2166 2238 if (PEAR::isError($folder))
2167 2239 {
... ... @@ -2191,8 +2263,12 @@ class KTAPI
2191 2263 * @param string $reason The reason for performing the copy
2192 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 2272 $src_folder = &$this->get_folder_by_id($source_id);
2197 2273 if (PEAR::isError($src_folder))
2198 2274 {
... ... @@ -2216,7 +2292,7 @@ class KTAPI
2216 2292 $response['message']= $result->getMessage();
2217 2293 return $response;
2218 2294 }
2219   -
  2295 +
2220 2296 $response['status_code'] = 0;
2221 2297  
2222 2298 if($this->version >= 2){
... ... @@ -2240,8 +2316,12 @@ class KTAPI
2240 2316 * @param string $reason The reason for performing the move
2241 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 2325 $src_folder = &$this->get_folder_by_id($source_id);
2246 2326 if (PEAR::isError($src_folder))
2247 2327 {
... ... @@ -2636,8 +2716,13 @@ class KTAPI
2636 2716 * @param string $tempfilename
2637 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 2726 // we need to add some security to ensure that people don't frig the checkin process to access restricted files.
2642 2727 // possibly should change 'tempfilename' to be a hash or id of some sort if this is troublesome.
2643 2728 $upload_manager = new KTUploadManager();
... ... @@ -2682,7 +2767,7 @@ class KTAPI
2682 2767  
2683 2768 $update_result = $this->update_document_metadata($document_id, $metadata, $sysdata);
2684 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 2771 return $update_result;
2687 2772 }
2688 2773  
... ... @@ -2713,7 +2798,7 @@ class KTAPI
2713 2798  
2714 2799 $update_result = $this->update_document_metadata($document_id, $metadata, $sysdata);
2715 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 2802 return $update_result;
2718 2803 }
2719 2804  
... ... @@ -2827,8 +2912,13 @@ class KTAPI
2827 2912 * @param string $tempfilename
2828 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 2922 // we need to add some security to ensure that people don't frig the checkin process to access restricted files.
2833 2923 // possibly should change 'tempfilename' to be a hash or id of some sort if this is troublesome.
2834 2924 $upload_manager = new KTUploadManager();
... ... @@ -2860,8 +2950,13 @@ class KTAPI
2860 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 2960 $add_result = $this->checkin_small_document($document_id, $filename, $reason, $base64, $major_update);
2866 2961  
2867 2962 if($add_result['status_code'] != 0){
... ... @@ -2889,8 +2984,13 @@ class KTAPI
2889 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 2994 $add_result = $this->checkin_document($document_id, $filename, $reason, $tempfilename, $major_update);
2895 2995  
2896 2996 if($add_result['status_code'] != 0){
... ... @@ -2917,7 +3017,6 @@ class KTAPI
2917 3017 return $update_result;
2918 3018 }
2919 3019  
2920   -
2921 3020 /**
2922 3021 * Does a document checkin.
2923 3022 *
... ... @@ -2930,8 +3029,12 @@ class KTAPI
2930 3029 * @param boolean $major_update
2931 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 3038 $upload_manager = new KTUploadManager();
2936 3039 $tempfilename = $upload_manager->store_base64_file($base64, 'su_');
2937 3040 if (PEAR::isError($tempfilename))
... ... @@ -2973,8 +3076,12 @@ class KTAPI
2973 3076 * @param string $reason
2974 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 3085 $document = &$this->get_document_by_id($document_id);
2979 3086 if (PEAR::isError($document))
2980 3087 {
... ... @@ -3028,8 +3135,12 @@ class KTAPI
3028 3135 * @param boolean $download
3029 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 3144 $document = &$this->get_document_by_id($document_id);
3034 3145 if (PEAR::isError($document))
3035 3146 {
... ... @@ -3088,8 +3199,12 @@ class KTAPI
3088 3199 * @param string $reason
3089 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 3208 $document = &$this->get_document_by_id($document_id);
3094 3209 if (PEAR::isError($document))
3095 3210 {
... ... @@ -3213,8 +3328,15 @@ class KTAPI
3213 3328 * @param string $reason
3214 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 3340 $document = &$this->get_document_by_id($document_id);
3219 3341 if (PEAR::isError($document))
3220 3342 {
... ... @@ -3245,8 +3367,12 @@ class KTAPI
3245 3367 * @param string $documenttype
3246 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 3376 $document = &$this->get_document_by_id($document_id);
3251 3377 if (PEAR::isError($document))
3252 3378 {
... ... @@ -3279,8 +3405,12 @@ class KTAPI
3279 3405 * @param string $newfilename
3280 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 3414 $document = &$this->get_document_by_id($document_id);
3285 3415 if (PEAR::isError($document))
3286 3416 {
... ... @@ -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 3446 * @author KnowledgeTree Team
3317 3447 * @access public
... ... @@ -3322,8 +3452,12 @@ class KTAPI
3322 3452 * @param string $newfilename
3323 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 3461 $document = &$this->get_document_by_id($document_id);
3328 3462 if (PEAR::isError($document))
3329 3463 {
... ... @@ -3368,8 +3502,12 @@ class KTAPI
3368 3502 * @param string $newtitle
3369 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 3511 $document = &$this->get_document_by_id($document_id);
3374 3512 if (PEAR::isError($document))
3375 3513 {
... ... @@ -3400,8 +3538,12 @@ class KTAPI
3400 3538 * @param string $newfilename
3401 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 3547 $document = &$this->get_document_by_id($document_id);
3406 3548 if (PEAR::isError($document))
3407 3549 {
... ... @@ -3432,8 +3574,12 @@ class KTAPI
3432 3574 * @param string $reason
3433 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 3583 $document = &$this->get_document_by_id($document_id);
3438 3584 if (PEAR::isError($document))
3439 3585 {
... ... @@ -3465,8 +3611,12 @@ class KTAPI
3465 3611 * @param string $workflow
3466 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 3620 $document = &$this->get_document_by_id($document_id);
3471 3621 if (PEAR::isError($document))
3472 3622 {
... ... @@ -3495,8 +3645,12 @@ class KTAPI
3495 3645 * @param int $document_id
3496 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 3654 $document = &$this->get_document_by_id($document_id);
3501 3655 if (PEAR::isError($document))
3502 3656 {
... ... @@ -3527,8 +3681,12 @@ class KTAPI
3527 3681 * @param string $reason
3528 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 3690 $document = &$this->get_document_by_id($document_id);
3533 3691 if (PEAR::isError($document))
3534 3692 {
... ... @@ -3546,11 +3704,8 @@ class KTAPI
3546 3704 }
3547 3705  
3548 3706 return $this->get_document_detail($document_id);
3549   -
3550 3707 }
3551 3708  
3552   -
3553   -
3554 3709 /**
3555 3710 * Returns the metadata on a document.
3556 3711 *
... ... @@ -3607,8 +3762,11 @@ class KTAPI
3607 3762 * @param array $metadata
3608 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 3771 $document = &$this->get_document_by_id($document_id);
3614 3772 if (PEAR::isError($document))
... ... @@ -3649,7 +3807,6 @@ class KTAPI
3649 3807 */
3650 3808 public function get_document_workflow_transitions($document_id)
3651 3809 {
3652   -
3653 3810 $document = &$this->get_document_by_id($document_id);
3654 3811 if (PEAR::isError($document))
3655 3812 {
... ... @@ -3712,7 +3869,6 @@ class KTAPI
3712 3869 */
3713 3870 public function get_document_transaction_history($document_id)
3714 3871 {
3715   -
3716 3872 $document = &$this->get_document_by_id($document_id);
3717 3873 if (PEAR::isError($document))
3718 3874 {
... ... @@ -3744,7 +3900,6 @@ class KTAPI
3744 3900 */
3745 3901 public function get_folder_transaction_history($folder_id)
3746 3902 {
3747   -
3748 3903 $folder = &$this->get_folder_by_id($folder_id);
3749 3904 if (PEAR::isError($folder))
3750 3905 {
... ... @@ -3840,8 +3995,12 @@ class KTAPI
3840 3995 * @param int $child_document_id
3841 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 4004 $document = &$this->get_document_by_id($parent_document_id);
3846 4005 if (PEAR::isError($document))
3847 4006 {
... ... @@ -3880,8 +4039,11 @@ class KTAPI
3880 4039 * @param string $type
3881 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 4048 $document = &$this->get_document_by_id($parent_document_id);
3887 4049 if (PEAR::isError($document))
... ... @@ -4490,6 +4652,67 @@ class KTAPI
4490 4652  
4491 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 117  
118 118 // create the document object
119 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 121 @unlink($randomFile);
122 122  
123 123 $internalDocObject = $document->getObject();
... ... @@ -132,7 +132,8 @@ class APITestCase extends KTUnitTestCase {
132 132  
133 133 // create the document object
134 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 137 @unlink($randomFile);
137 138  
138 139 $internalDocObject2 = $document2->getObject();
... ... @@ -301,7 +302,7 @@ class APITestCase extends KTUnitTestCase {
301 302 {
302 303 // create the document object
303 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 306 @unlink($randomFile);
306 307  
307 308 $documentID = $document->get_documentid();
... ... @@ -432,7 +433,7 @@ class APITestCase extends KTUnitTestCase {
432 433 {
433 434 // Create a document and subscribe to it
434 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 437 @unlink($randomFile);
437 438  
438 439 $this->assertEntity($document, 'KTAPI_Document');
... ... @@ -458,18 +459,18 @@ class APITestCase extends KTUnitTestCase {
458 459 public function testFolderApiFunctions()
459 460 {
460 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 463 $this->assertNotEqual($result['status_code'], 0);
463 464  
464 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 467 $folder_id = $result1['results']['id'];
467 468  
468 469 $this->assertEqual($result1['status_code'], 0);
469 470 $this->assertTrue($result1['results']['parent_id'] == 1);
470 471  
471 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 474 $folder_id2 = $result2['results']['id'];
474 475 $this->assertEqual($result2['status_code'], 0);
475 476  
... ... @@ -477,8 +478,10 @@ class APITestCase extends KTUnitTestCase {
477 478 global $default;
478 479 $dir = $default->uploadDirectory;
479 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 485 $this->assertEqual($doc['status_code'], 0);
483 486 $this->assertEqual($doc['results']['title'], 'New API test doc');
484 487  
... ... @@ -492,7 +495,7 @@ class APITestCase extends KTUnitTestCase {
492 495 $this->assertTrue($detail['results']['parent_id'] == $folder_id);
493 496  
494 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 499 $this->assertEqual($shortcut['status_code'], 0);
497 500 $this->assertEqual($shortcut['results']['folder_name'], 'New test api sub-folder');
498 501 $this->assertEqual($shortcut['results']['parent_id'], 1);
... ... @@ -502,7 +505,7 @@ class APITestCase extends KTUnitTestCase {
502 505 $this->assertEqual(count($shortcut_list['results']), 1);
503 506  
504 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 509 $this->assertEqual($renamed['status_code'], 0);
507 510  
508 511 $renamed_detail = $this->ktapi->get_folder_detail_by_name('Renamed test folder');
... ... @@ -512,9 +515,9 @@ class APITestCase extends KTUnitTestCase {
512 515 // $this->ktapi->copy_folder($source_id, $target_id, $reason);
513 516 // $this->ktapi->move_folder($source_id, $target_id, $reason);
514 517  
515   -
516 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 521 $detail2 = $this->ktapi->get_folder_detail($folder_id);
519 522 $this->assertNotEqual($detail2['status_code'], 0);
520 523 }
... ... @@ -525,12 +528,12 @@ class APITestCase extends KTUnitTestCase {
525 528 public function testDocumentApiFunctions()
526 529 {
527 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 532 $folder_id = $result1['results']['id'];
530 533 $this->assertEqual($result1['status_code'], 0);
531 534  
532 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 537 $folder_id2 = $result2['results']['id'];
535 538 $this->assertEqual($result2['status_code'], 0);
536 539  
... ... @@ -538,8 +541,9 @@ class APITestCase extends KTUnitTestCase {
538 541 global $default;
539 542 $dir = $default->uploadDirectory;
540 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 547 $doc_id = $doc['results']['document_id'];
544 548 $this->assertEqual($doc['status_code'], 0);
545 549  
... ... @@ -565,15 +569,15 @@ class APITestCase extends KTUnitTestCase {
565 569 $this->assertEqual($detail4['results']['title'], 'New API test doc');
566 570  
567 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 573 $this->assertEqual($result1['status_code'], 0);
570 574 $this->assertTrue(!empty($result1['results']));
571 575  
572 576 // Checkin the document
573 577 $dir = $default->uploadDirectory;
574 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 581 $this->assertEqual($result2['status_code'], 0);
578 582 $this->assertEqual($result2['results']['document_id'], $doc_id);
579 583  
... ... @@ -584,11 +588,12 @@ class APITestCase extends KTUnitTestCase {
584 588 $this->assertEqual($shortcut['results']['folder_id'], $folder_id);
585 589  
586 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 592 $this->assertEqual($result3['status_code'], 0);
589 593  
590 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 597 $detail2 = $this->ktapi->get_folder_detail($folder_id);
593 598 $this->assertNotEqual($detail2['status_code'], 0);
594 599 }
... ... @@ -606,7 +611,7 @@ class APITestCase extends KTUnitTestCase {
606 611 $randomFile = $this->createRandomFile();
607 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 615 $this->assertNotError($document);
611 616  
612 617 @unlink($randomFile);
... ...
tests/api/testAuto.php
... ... @@ -22,7 +22,7 @@ class APIAutoTestCase extends KTUnitTestCase {
22 22 * @var object $root The KT folder object
23 23 */
24 24 var $root;
25   -
  25 +
26 26 /**
27 27 * This method sets up the KT session
28 28 *
... ... @@ -42,8 +42,6 @@ class APIAutoTestCase extends KTUnitTestCase {
42 42 $this->session->logout();
43 43 }
44 44  
45   -
46   -
47 45 function testJunkanonymous_login() {
48 46 $result = $this->ktapi->anonymous_login(null);
49 47 $this->assertIsA($result, 'array');
... ... @@ -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 96 $this->assertEqual($result['status_code'], 0);
99 97 }
100 98  
101   -
102   -
103 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 102 $this->assertEqual($result['status_code'], 0);
107 103 }
108 104  
109 105  
110 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 109 $this->assertEqual($result['status_code'], 0);
114 110 }
115 111  
116 112  
117 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 116 $this->assertEqual($result['status_code'], 0);
121 117 }
122 118  
... ... @@ -132,7 +128,7 @@ class APIAutoTestCase extends KTUnitTestCase {
132 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 132 $result = $this->ktapi->get_document_detail_by_filename(null, null, null);
137 133 $this->assertIsA($result, 'array');
138 134 $this->assertEqual($result['status_code'], 1);
... ... @@ -168,27 +164,25 @@ class APIAutoTestCase extends KTUnitTestCase {
168 164 $this->assertEqual($result['status_code'], 0);
169 165 }
170 166  
171   -
172   - function tesRealget_document_shortcuts() {
  167 + function tesRealget_document_shortcuts() {
173 168 $result = $this->ktapi->get_document_shortcuts($document_id);
174 169 $this->assertIsA($result, 'array');
175 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 175 $this->assertIsA($result, 'array');
181 176 $this->assertEqual($result['status_code'], 1);
182 177 }
183 178  
184 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 182 $this->assertIsA($result, 'array');
187 183 $this->assertEqual($result['status_code'], 0);
188 184 }
189 185  
190   -
191   -
192 186 function tesRealadd_small_document_with_metadata() {
193 187 $result = $this->ktapi->add_small_document_with_metadata($folder_id, $title, $filename, $documenttype, $base64, $metadata, $sysdata);
194 188 $this->assertIsA($result, 'array');
... ... @@ -214,18 +208,17 @@ class APIAutoTestCase extends KTUnitTestCase {
214 208 }
215 209  
216 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 212 $this->assertIsA($result, 'array');
219 213 $this->assertEqual($result['status_code'], 1);
220 214 }
221 215  
222 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 218 $this->assertIsA($result, 'array');
225 219 $this->assertEqual($result['status_code'], 0);
226 220 }
227 221  
228   -
229 222 function tesRealcheckin_small_document_with_metadata() {
230 223 $result = $this->ktapi->checkin_small_document_with_metadata($document_id, $filename, $reason, $base64, $major_update, $metadata, $sysdata);
231 224 $this->assertIsA($result, 'array');
... ... @@ -238,62 +231,48 @@ class APIAutoTestCase extends KTUnitTestCase {
238 231 $this->assertEqual($result['status_code'], 0);
239 232 }
240 233  
241   -
242   -
243 234 function tesRealcheckin_small_document() {
244 235 $result = $this->ktapi->checkin_small_document($document_id, $filename, $reason, $base64, $major_update);
245 236 $this->assertIsA($result, 'array');
246 237 $this->assertEqual($result['status_code'], 0);
247 238 }
248 239  
249   -
250   -
251 240 function tesRealcheckout_document() {
252 241 $result = $this->ktapi->checkout_document($document_id, $reason, $download);
253 242 $this->assertIsA($result, 'array');
254 243 $this->assertEqual($result['status_code'], 0);
255 244 }
256 245  
257   -
258   -
259 246 function tesRealcheckout_small_document() {
260 247 $result = $this->ktapi->checkout_small_document($document_id, $reason, $download);
261 248 $this->assertIsA($result, 'array');
262 249 $this->assertEqual($result['status_code'], 0);
263 250 }
264 251  
265   -
266 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 254 $this->assertIsA($result, 'array');
269 255 $this->assertEqual($result['status_code'], 0);
270 256 }
271 257  
272   -
273   -
274 258 function tesRealdownload_document() {
275 259 $result = $this->ktapi->download_document($document_id, $version);
276 260 $this->assertIsA($result, 'array');
277 261 $this->assertEqual($result['status_code'], 0);
278 262 }
279 263  
280   -
281   -
282 264 function tesRealdownload_small_document() {
283 265 $result = $this->ktapi->download_small_document($document_id, $version);
284 266 $this->assertIsA($result, 'array');
285 267 $this->assertEqual($result['status_code'], 0);
286 268 }
287 269  
288   -
289 270 function tesRealdelete_document() {
290 271 $result = $this->ktapi->delete_document($document_id, $reason);
291 272 $this->assertIsA($result, 'array');
292 273 $this->assertEqual($result['status_code'], 0);
293 274 }
294 275  
295   -
296   -
297 276 function tesRealchange_document_type() {
298 277 $result = $this->ktapi->change_document_type($document_id, $documenttype);
299 278 $this->assertIsA($result, 'array');
... ... @@ -306,86 +285,72 @@ class APIAutoTestCase extends KTUnitTestCase {
306 285 $this->assertEqual($result['status_code'], 0);
307 286 }
308 287  
309   -
310   -
311 288 function tesRealrename_document_title() {
312 289 $result = $this->ktapi->rename_document_title($document_id, $newtitle);
313 290 $this->assertIsA($result, 'array');
314 291 $this->assertEqual($result['status_code'], 0);
315 292 }
316 293  
317   -
318   -
319 294 function tesRealrename_document_filename() {
320 295 $result = $this->ktapi->rename_document_filename($document_id, $newfilename);
321 296 $this->assertIsA($result, 'array');
322 297 $this->assertEqual($result['status_code'], 0);
323 298 }
324 299  
325   -
326 300 function tesRealchange_document_owner() {
327 301 $result = $this->ktapi->change_document_owner($document_id, $username, $reason);
328 302 $this->assertIsA($result, 'array');
329 303 $this->assertEqual($result['status_code'], 0);
330 304 }
331 305  
332   -
333 306 function tesRealstart_document_workflow() {
334 307 $result = $this->ktapi->start_document_workflow($document_id, $workflow);
335 308 $this->assertIsA($result, 'array');
336 309 $this->assertEqual($result['status_code'], 0);
337 310 }
338 311  
339   -
340 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 314 $this->assertIsA($result, 'array');
343 315 $this->assertEqual($result['status_code'], 0);
344 316 }
345 317  
346   -
347 318 function tesRealperform_document_workflow_transition() {
348 319 $result = $this->ktapi->perform_document_workflow_transition($document_id, $transition, $reason);
349 320 $this->assertIsA($result, 'array');
350 321 $this->assertEqual($result['status_code'], 0);
351 322 }
352 323  
353   -
354 324 function tesRealget_document_metadata() {
355 325 $result = $this->ktapi->get_document_metadata($document_id);
356 326 $this->assertIsA($result, 'array');
357 327 $this->assertEqual($result['status_code'], 0);
358 328 }
359 329  
360   -
361 330 function tesRealupdate_document_metadata() {
362 331 $result = $this->ktapi->update_document_metadata($document_id, $metadata, $sysdata);
363 332 $this->assertIsA($result, 'array');
364 333 $this->assertEqual($result['status_code'], 0);
365 334 }
366 335  
367   -
368 336 function tesRealget_document_workflow_state() {
369 337 $result = $this->ktapi->get_document_workflow_state($document_id);
370 338 $this->assertIsA($result, 'array');
371 339 $this->assertEqual($result['status_code'], 0);
372 340 }
373 341  
374   -
375 342 function tesRealget_document_transaction_history() {
376 343 $result = $this->ktapi->get_document_transaction_history($document_id);
377 344 $this->assertIsA($result, 'array');
378 345 $this->assertEqual($result['status_code'], 0);
379 346 }
380 347  
381   -
382 348 function tesRealget_document_version_history() {
383 349 $result = $this->ktapi->get_document_version_history($document_id);
384 350 $this->assertIsA($result, 'array');
385 351 $this->assertEqual($result['status_code'], 0);
386 352 }
387 353  
388   -
389 354 function tesRealget_document_links() {
390 355 $result = $this->ktapi->get_document_links($document_id);
391 356 $this->assertIsA($result, 'array');
... ...