Commit da2d9b442a135e4f75ac130cb738d5867c812319

Authored by Megan Watson
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 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');
67   -
68 63 /**
69 64 * This class defines functions that MUST exist in the inheriting class
70 65 *
... ... @@ -309,7 +304,7 @@ class KTAPI
309 304 );
310 305  
311 306 }
312   -
  307 +
313 308 /**
314 309 * Returns folder permissions
315 310 *
... ... @@ -331,7 +326,7 @@ class KTAPI
331 326 $user_ktapi->start_system_session($username);
332 327  
333 328 $document = KTAPI_Document::get($user_ktapi, $document_id);
334   -
  329 +
335 330 if (get_class($document) == 'PEAR_Error') {
336 331 return array(
337 332 "status_code" => 0,
... ... @@ -1238,7 +1233,7 @@ class KTAPI
1238 1233 $response = $this->_check_electronic_signature($target_folder_id, $sig_username, $sig_password, $reason, $reason,
1239 1234 'ktcore.transactions.permissions_change');
1240 1235 if ($response['status_code'] == 1) return $response;
1241   -
  1236 +
1242 1237 $response['status_code'] = 1;
1243 1238  
1244 1239 if(!is_array($items)){
... ... @@ -1633,7 +1628,7 @@ class KTAPI
1633 1628 * @param string $update The type of modification - add | remove
1634 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 1632 $sig_username = '', $sig_password = '', $reason = '')
1638 1633 {
1639 1634 $response = $this->_check_electronic_signature($folder_id, $sig_username, $sig_password, $reason, $reason,
... ... @@ -2108,7 +2103,7 @@ class KTAPI
2108 2103 $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason,
2109 2104 'ktcore.transactions.create_shortcut');
2110 2105 if ($response['status_code'] == 1) return $response;
2111   -
  2106 +
2112 2107 $folder = &$this->get_folder_by_id($target_folder_id);
2113 2108 if (PEAR::isError($folder))
2114 2109 {
... ... @@ -2268,7 +2263,7 @@ class KTAPI
2268 2263 $response = $this->_check_electronic_signature($source_id, $sig_username, $sig_password, $reason, $reason,
2269 2264 'ktcore.transactions.copy');
2270 2265 if ($response['status_code'] == 1) return $response;
2271   -
  2266 +
2272 2267 $src_folder = &$this->get_folder_by_id($source_id);
2273 2268 if (PEAR::isError($src_folder))
2274 2269 {
... ... @@ -2292,7 +2287,7 @@ class KTAPI
2292 2287 $response['message']= $result->getMessage();
2293 2288 return $response;
2294 2289 }
2295   -
  2290 +
2296 2291 $response['status_code'] = 0;
2297 2292  
2298 2293 if($this->version >= 2){
... ... @@ -2716,7 +2711,7 @@ class KTAPI
2716 2711 * @param string $tempfilename
2717 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 2715 $sig_username = '', $sig_password = '', $reason = '')
2721 2716 {
2722 2717 $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason,
... ... @@ -2918,7 +2913,7 @@ class KTAPI
2918 2913 $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason,
2919 2914 'ktcore.transactions.check_in');
2920 2915 if ($response['status_code'] == 1) return $response;
2921   -
  2916 +
2922 2917 // we need to add some security to ensure that people don't frig the checkin process to access restricted files.
2923 2918 // possibly should change 'tempfilename' to be a hash or id of some sort if this is troublesome.
2924 2919 $upload_manager = new KTUploadManager();
... ... @@ -2950,7 +2945,7 @@ class KTAPI
2950 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 2949 $metadata, $sysdata, $sig_username = '', $sig_password = '')
2955 2950 {
2956 2951 $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason,
... ... @@ -2984,7 +2979,7 @@ class KTAPI
2984 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 2983 $metadata, $sysdata, $sig_username = '', $sig_password = '')
2989 2984 {
2990 2985 $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason,
... ... @@ -3336,7 +3331,7 @@ class KTAPI
3336 3331 'ktcore.transactions.delete');
3337 3332 if ($response['status_code'] == 1) return $response;
3338 3333 }
3339   -
  3334 +
3340 3335 $document = &$this->get_document_by_id($document_id);
3341 3336 if (PEAR::isError($document))
3342 3337 {
... ... @@ -3369,10 +3364,10 @@ class KTAPI
3369 3364 */
3370 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 3368 'ktcore.transactions.document_type_change');
3374 3369 if ($response['status_code'] == 1) return $response;
3375   -
  3370 +
3376 3371 $document = &$this->get_document_by_id($document_id);
3377 3372 if (PEAR::isError($document))
3378 3373 {
... ... @@ -3410,7 +3405,7 @@ class KTAPI
3410 3405 $response = $this->_check_electronic_signature($document_id, $sig_username, $sig_password, $reason, $reason,
3411 3406 'ktcore.transactions.copy');
3412 3407 if ($response['status_code'] == 1) return $response;
3413   -
  3408 +
3414 3409 $document = &$this->get_document_by_id($document_id);
3415 3410 if (PEAR::isError($document))
3416 3411 {
... ... @@ -3576,7 +3571,7 @@ class KTAPI
3576 3571 */
3577 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 3575 'ktcore.transactions.document_owner_change');
3581 3576 if ($response['status_code'] == 1) return $response;
3582 3577  
... ... @@ -4631,25 +4626,25 @@ class KTAPI
4631 4626 }
4632 4627 return $response;
4633 4628 }
4634   -
  4629 +
4635 4630 public function is_latest_version($documentID, $contentID)
4636 4631 {
4637 4632 $sql = 'SELECT COUNT(document_content_version.id) AS newdocumentcount
4638 4633 FROM document_content_version
4639 4634 WHERE document_content_version.document_id ="'.$documentID.'" AND
4640 4635 document_content_version.id > "'.$contentID.'"';
4641   -
  4636 +
4642 4637 $row = DBUtil::getOneResult($sql);
4643 4638 $row = (int)$row['newdocumentcount'];
4644   -
  4639 +
4645 4640 if ($row > 0) {
4646 4641 $response['is_latest'] = 'FALSE';
4647 4642 } else {
4648 4643 $response['is_latest'] = 'TRUE';
4649 4644 }
4650   -
  4645 +
4651 4646 $response['status_code'] = 0;
4652   -
  4647 +
4653 4648 return $response;
4654 4649 }
4655 4650  
... ... @@ -4661,7 +4656,12 @@ class KTAPI
4661 4656 * @return bool $enabled true or false
4662 4657 */
4663 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 4665 // Check config for api signatures enabled
4666 4666 $oConfig =& KTConfig::getSingleton();
4667 4667 $enabled = $oConfig->get('e_signatures/enableApiSignatures', false);
... ... @@ -4707,7 +4707,7 @@ class KTAPI
4707 4707 {
4708 4708 $response['status_code'] = 1;
4709 4709 $response['message'] = $this->esig_error;
4710   -
  4710 +
4711 4711 return $response;
4712 4712 }
4713 4713  
... ...