Commit da2d9b442a135e4f75ac130cb738d5867c812319
1 parent
2cb9318d
Added check for the wintools plugin before using the baobabkeyutil class which w…
…on't be included in a source / community edition installation. Committed by: Megan Watson Reviewed by: Prince Mbekwa
Showing
1 changed file
with
28 additions
and
28 deletions
ktapi/ktapi.inc.php
| @@ -60,11 +60,6 @@ require_once(KTAPI_DIR .'/KTAPIAcl.inc.php'); | @@ -60,11 +60,6 @@ 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'); | ||
| 67 | - | ||
| 68 | /** | 63 | /** |
| 69 | * This class defines functions that MUST exist in the inheriting class | 64 | * This class defines functions that MUST exist in the inheriting class |
| 70 | * | 65 | * |
| @@ -309,7 +304,7 @@ class KTAPI | @@ -309,7 +304,7 @@ class KTAPI | ||
| 309 | ); | 304 | ); |
| 310 | 305 | ||
| 311 | } | 306 | } |
| 312 | - | 307 | + |
| 313 | /** | 308 | /** |
| 314 | * Returns folder permissions | 309 | * Returns folder permissions |
| 315 | * | 310 | * |
| @@ -331,7 +326,7 @@ class KTAPI | @@ -331,7 +326,7 @@ class KTAPI | ||
| 331 | $user_ktapi->start_system_session($username); | 326 | $user_ktapi->start_system_session($username); |
| 332 | 327 | ||
| 333 | $document = KTAPI_Document::get($user_ktapi, $document_id); | 328 | $document = KTAPI_Document::get($user_ktapi, $document_id); |
| 334 | - | 329 | + |
| 335 | if (get_class($document) == 'PEAR_Error') { | 330 | if (get_class($document) == 'PEAR_Error') { |
| 336 | return array( | 331 | return array( |
| 337 | "status_code" => 0, | 332 | "status_code" => 0, |
| @@ -1238,7 +1233,7 @@ class KTAPI | @@ -1238,7 +1233,7 @@ class KTAPI | ||
| 1238 | $response = $this->_check_electronic_signature($target_folder_id, $sig_username, $sig_password, $reason, $reason, | 1233 | $response = $this->_check_electronic_signature($target_folder_id, $sig_username, $sig_password, $reason, $reason, |
| 1239 | 'ktcore.transactions.permissions_change'); | 1234 | 'ktcore.transactions.permissions_change'); |
| 1240 | if ($response['status_code'] == 1) return $response; | 1235 | if ($response['status_code'] == 1) return $response; |
| 1241 | - | 1236 | + |
| 1242 | $response['status_code'] = 1; | 1237 | $response['status_code'] = 1; |
| 1243 | 1238 | ||
| 1244 | if(!is_array($items)){ | 1239 | if(!is_array($items)){ |
| @@ -1633,7 +1628,7 @@ class KTAPI | @@ -1633,7 +1628,7 @@ class KTAPI | ||
| 1633 | * @param string $update The type of modification - add | remove | 1628 | * @param string $update The type of modification - add | remove |
| 1634 | * @return array Response | 1629 | * @return array Response |
| 1635 | */ | 1630 | */ |
| 1636 | - private function update_members_on_role_on_folder($folder_id, $role_id, $members, $update = 'add', | 1631 | + private function update_members_on_role_on_folder($folder_id, $role_id, $members, $update = 'add', |
| 1637 | $sig_username = '', $sig_password = '', $reason = '') | 1632 | $sig_username = '', $sig_password = '', $reason = '') |
| 1638 | { | 1633 | { |
| 1639 | $response = $this->_check_electronic_signature($folder_id, $sig_username, $sig_password, $reason, $reason, | 1634 | $response = $this->_check_electronic_signature($folder_id, $sig_username, $sig_password, $reason, $reason, |
| @@ -2108,7 +2103,7 @@ class KTAPI | @@ -2108,7 +2103,7 @@ class KTAPI | ||
| 2108 | $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason, | 2103 | $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason, |
| 2109 | 'ktcore.transactions.create_shortcut'); | 2104 | 'ktcore.transactions.create_shortcut'); |
| 2110 | if ($response['status_code'] == 1) return $response; | 2105 | if ($response['status_code'] == 1) return $response; |
| 2111 | - | 2106 | + |
| 2112 | $folder = &$this->get_folder_by_id($target_folder_id); | 2107 | $folder = &$this->get_folder_by_id($target_folder_id); |
| 2113 | if (PEAR::isError($folder)) | 2108 | if (PEAR::isError($folder)) |
| 2114 | { | 2109 | { |
| @@ -2268,7 +2263,7 @@ class KTAPI | @@ -2268,7 +2263,7 @@ class KTAPI | ||
| 2268 | $response = $this->_check_electronic_signature($source_id, $sig_username, $sig_password, $reason, $reason, | 2263 | $response = $this->_check_electronic_signature($source_id, $sig_username, $sig_password, $reason, $reason, |
| 2269 | 'ktcore.transactions.copy'); | 2264 | 'ktcore.transactions.copy'); |
| 2270 | if ($response['status_code'] == 1) return $response; | 2265 | if ($response['status_code'] == 1) return $response; |
| 2271 | - | 2266 | + |
| 2272 | $src_folder = &$this->get_folder_by_id($source_id); | 2267 | $src_folder = &$this->get_folder_by_id($source_id); |
| 2273 | if (PEAR::isError($src_folder)) | 2268 | if (PEAR::isError($src_folder)) |
| 2274 | { | 2269 | { |
| @@ -2292,7 +2287,7 @@ class KTAPI | @@ -2292,7 +2287,7 @@ class KTAPI | ||
| 2292 | $response['message']= $result->getMessage(); | 2287 | $response['message']= $result->getMessage(); |
| 2293 | return $response; | 2288 | return $response; |
| 2294 | } | 2289 | } |
| 2295 | - | 2290 | + |
| 2296 | $response['status_code'] = 0; | 2291 | $response['status_code'] = 0; |
| 2297 | 2292 | ||
| 2298 | if($this->version >= 2){ | 2293 | if($this->version >= 2){ |
| @@ -2716,7 +2711,7 @@ class KTAPI | @@ -2716,7 +2711,7 @@ class KTAPI | ||
| 2716 | * @param string $tempfilename | 2711 | * @param string $tempfilename |
| 2717 | * @return kt_document_detail. | 2712 | * @return kt_document_detail. |
| 2718 | */ | 2713 | */ |
| 2719 | - public function add_document($folder_id, $title, $filename, $documenttype, $tempfilename, | 2714 | + public function add_document($folder_id, $title, $filename, $documenttype, $tempfilename, |
| 2720 | $sig_username = '', $sig_password = '', $reason = '') | 2715 | $sig_username = '', $sig_password = '', $reason = '') |
| 2721 | { | 2716 | { |
| 2722 | $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason, | 2717 | $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason, |
| @@ -2918,7 +2913,7 @@ class KTAPI | @@ -2918,7 +2913,7 @@ class KTAPI | ||
| 2918 | $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason, | 2913 | $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason, |
| 2919 | 'ktcore.transactions.check_in'); | 2914 | 'ktcore.transactions.check_in'); |
| 2920 | if ($response['status_code'] == 1) return $response; | 2915 | if ($response['status_code'] == 1) return $response; |
| 2921 | - | 2916 | + |
| 2922 | // we need to add some security to ensure that people don't frig the checkin process to access restricted files. | 2917 | // we need to add some security to ensure that people don't frig the checkin process to access restricted files. |
| 2923 | // possibly should change 'tempfilename' to be a hash or id of some sort if this is troublesome. | 2918 | // possibly should change 'tempfilename' to be a hash or id of some sort if this is troublesome. |
| 2924 | $upload_manager = new KTUploadManager(); | 2919 | $upload_manager = new KTUploadManager(); |
| @@ -2950,7 +2945,7 @@ class KTAPI | @@ -2950,7 +2945,7 @@ class KTAPI | ||
| 2950 | return $this->get_document_detail($document_id); | 2945 | return $this->get_document_detail($document_id); |
| 2951 | } | 2946 | } |
| 2952 | 2947 | ||
| 2953 | - public function checkin_small_document_with_metadata($document_id, $filename, $reason, $base64, $major_update, | 2948 | + public function checkin_small_document_with_metadata($document_id, $filename, $reason, $base64, $major_update, |
| 2954 | $metadata, $sysdata, $sig_username = '', $sig_password = '') | 2949 | $metadata, $sysdata, $sig_username = '', $sig_password = '') |
| 2955 | { | 2950 | { |
| 2956 | $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason, | 2951 | $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason, |
| @@ -2984,7 +2979,7 @@ class KTAPI | @@ -2984,7 +2979,7 @@ class KTAPI | ||
| 2984 | return $update_result; | 2979 | return $update_result; |
| 2985 | } | 2980 | } |
| 2986 | 2981 | ||
| 2987 | - public function checkin_document_with_metadata($document_id, $filename, $reason, $tempfilename, $major_update, | 2982 | + public function checkin_document_with_metadata($document_id, $filename, $reason, $tempfilename, $major_update, |
| 2988 | $metadata, $sysdata, $sig_username = '', $sig_password = '') | 2983 | $metadata, $sysdata, $sig_username = '', $sig_password = '') |
| 2989 | { | 2984 | { |
| 2990 | $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason, | 2985 | $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason, |
| @@ -3336,7 +3331,7 @@ class KTAPI | @@ -3336,7 +3331,7 @@ class KTAPI | ||
| 3336 | 'ktcore.transactions.delete'); | 3331 | 'ktcore.transactions.delete'); |
| 3337 | if ($response['status_code'] == 1) return $response; | 3332 | if ($response['status_code'] == 1) return $response; |
| 3338 | } | 3333 | } |
| 3339 | - | 3334 | + |
| 3340 | $document = &$this->get_document_by_id($document_id); | 3335 | $document = &$this->get_document_by_id($document_id); |
| 3341 | if (PEAR::isError($document)) | 3336 | if (PEAR::isError($document)) |
| 3342 | { | 3337 | { |
| @@ -3369,10 +3364,10 @@ class KTAPI | @@ -3369,10 +3364,10 @@ class KTAPI | ||
| 3369 | */ | 3364 | */ |
| 3370 | public function change_document_type($document_id, $documenttype, $sig_username = '', $sig_password = '', $reason = '') | 3365 | public function change_document_type($document_id, $documenttype, $sig_username = '', $sig_password = '', $reason = '') |
| 3371 | { | 3366 | { |
| 3372 | - $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason, | 3367 | + $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason, |
| 3373 | 'ktcore.transactions.document_type_change'); | 3368 | 'ktcore.transactions.document_type_change'); |
| 3374 | if ($response['status_code'] == 1) return $response; | 3369 | if ($response['status_code'] == 1) return $response; |
| 3375 | - | 3370 | + |
| 3376 | $document = &$this->get_document_by_id($document_id); | 3371 | $document = &$this->get_document_by_id($document_id); |
| 3377 | if (PEAR::isError($document)) | 3372 | if (PEAR::isError($document)) |
| 3378 | { | 3373 | { |
| @@ -3410,7 +3405,7 @@ class KTAPI | @@ -3410,7 +3405,7 @@ class KTAPI | ||
| 3410 | $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason, | 3405 | $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason, |
| 3411 | 'ktcore.transactions.copy'); | 3406 | 'ktcore.transactions.copy'); |
| 3412 | if ($response['status_code'] == 1) return $response; | 3407 | if ($response['status_code'] == 1) return $response; |
| 3413 | - | 3408 | + |
| 3414 | $document = &$this->get_document_by_id($document_id); | 3409 | $document = &$this->get_document_by_id($document_id); |
| 3415 | if (PEAR::isError($document)) | 3410 | if (PEAR::isError($document)) |
| 3416 | { | 3411 | { |
| @@ -3576,7 +3571,7 @@ class KTAPI | @@ -3576,7 +3571,7 @@ class KTAPI | ||
| 3576 | */ | 3571 | */ |
| 3577 | public function change_document_owner($document_id, $username, $reason, $sig_username = '', $sig_password = '') | 3572 | public function change_document_owner($document_id, $username, $reason, $sig_username = '', $sig_password = '') |
| 3578 | { | 3573 | { |
| 3579 | - $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason, | 3574 | + $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason, |
| 3580 | 'ktcore.transactions.document_owner_change'); | 3575 | 'ktcore.transactions.document_owner_change'); |
| 3581 | if ($response['status_code'] == 1) return $response; | 3576 | if ($response['status_code'] == 1) return $response; |
| 3582 | 3577 | ||
| @@ -4631,25 +4626,25 @@ class KTAPI | @@ -4631,25 +4626,25 @@ class KTAPI | ||
| 4631 | } | 4626 | } |
| 4632 | return $response; | 4627 | return $response; |
| 4633 | } | 4628 | } |
| 4634 | - | 4629 | + |
| 4635 | public function is_latest_version($documentID, $contentID) | 4630 | public function is_latest_version($documentID, $contentID) |
| 4636 | { | 4631 | { |
| 4637 | $sql = 'SELECT COUNT(document_content_version.id) AS newdocumentcount | 4632 | $sql = 'SELECT COUNT(document_content_version.id) AS newdocumentcount |
| 4638 | FROM document_content_version | 4633 | FROM document_content_version |
| 4639 | WHERE document_content_version.document_id ="'.$documentID.'" AND | 4634 | WHERE document_content_version.document_id ="'.$documentID.'" AND |
| 4640 | document_content_version.id > "'.$contentID.'"'; | 4635 | document_content_version.id > "'.$contentID.'"'; |
| 4641 | - | 4636 | + |
| 4642 | $row = DBUtil::getOneResult($sql); | 4637 | $row = DBUtil::getOneResult($sql); |
| 4643 | $row = (int)$row['newdocumentcount']; | 4638 | $row = (int)$row['newdocumentcount']; |
| 4644 | - | 4639 | + |
| 4645 | if ($row > 0) { | 4640 | if ($row > 0) { |
| 4646 | $response['is_latest'] = 'FALSE'; | 4641 | $response['is_latest'] = 'FALSE'; |
| 4647 | } else { | 4642 | } else { |
| 4648 | $response['is_latest'] = 'TRUE'; | 4643 | $response['is_latest'] = 'TRUE'; |
| 4649 | } | 4644 | } |
| 4650 | - | 4645 | + |
| 4651 | $response['status_code'] = 0; | 4646 | $response['status_code'] = 0; |
| 4652 | - | 4647 | + |
| 4653 | return $response; | 4648 | return $response; |
| 4654 | } | 4649 | } |
| 4655 | 4650 | ||
| @@ -4661,7 +4656,12 @@ class KTAPI | @@ -4661,7 +4656,12 @@ class KTAPI | ||
| 4661 | * @return bool $enabled true or false | 4656 | * @return bool $enabled true or false |
| 4662 | */ | 4657 | */ |
| 4663 | public function electronic_sig_enabled() | 4658 | public function electronic_sig_enabled() |
| 4664 | - { | 4659 | + { |
| 4660 | + // Check that the wintools plugin is active and available, return false if not. | ||
| 4661 | + if (KTPluginUtil::pluginIsActive('ktdms.wintools')) { | ||
| 4662 | + return false; | ||
| 4663 | + } | ||
| 4664 | + | ||
| 4665 | // Check config for api signatures enabled | 4665 | // Check config for api signatures enabled |
| 4666 | $oConfig =& KTConfig::getSingleton(); | 4666 | $oConfig =& KTConfig::getSingleton(); |
| 4667 | $enabled = $oConfig->get('e_signatures/enableApiSignatures', false); | 4667 | $enabled = $oConfig->get('e_signatures/enableApiSignatures', false); |
| @@ -4707,7 +4707,7 @@ class KTAPI | @@ -4707,7 +4707,7 @@ class KTAPI | ||
| 4707 | { | 4707 | { |
| 4708 | $response['status_code'] = 1; | 4708 | $response['status_code'] = 1; |
| 4709 | $response['message'] = $this->esig_error; | 4709 | $response['message'] = $this->esig_error; |
| 4710 | - | 4710 | + |
| 4711 | return $response; | 4711 | return $response; |
| 4712 | } | 4712 | } |
| 4713 | 4713 |