Commit 2e34a678f6fe02929f9a0fba4f0b3dae3bce9120

Authored by kevin_fourie
1 parent b80cf190

Merged in from DEV trunk...

BBS-1036
"Option to turn off request for metadata on document upload"
Changed the architecture of the mechanism to retrieve settings from the server.

Committed By: Isaac Lundall
Reviewed By: Conrad Vermeulen

BBS-1036
"Option to turn off request for metadata on document upload"
Tweeked the delivery of the config options.

Committed By: Isaac Lundall
Reviewed By: Martin Kirsten

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/STABLE/trunk@7114 c91229c3-7414-0410-bfa2-8a42b809f60b
config/config.ini
... ... @@ -291,7 +291,7 @@ safemode = on
291 291 ; Identify the location of the mysql.exe and mysqldump.exe
292 292 ;mysqlDirectory=c:/program files/ktdms/mysql/bin
293 293  
294   -[KTtoolsSettings]
  294 +[clientToolPolicies]
295 295 ;These two settings control whether or not the client is prompted for metadata when a
296 296 ;document is added to knowledgetree via KTtools. They default to true.
297 297 explorerMetadataCapture = true
... ...
config/dmsDefaults.php
... ... @@ -451,8 +451,8 @@ class KTInit {
451 451 $oKTConfig->setdefaultns('webservice', 'downloadExpiry', '30');
452 452 $oKTConfig->setdefaultns('webservice', 'randomKeyText', 'bkdfjhg23yskjdhf2iu');
453 453  
454   - $oKTConfig->setdefaultns('KTtoolsSettings', 'explorerMetadataCapture', true);
455   - $oKTConfig->setdefaultns('KTtoolsSettings', 'officeMetadataCapture', true);
  454 + $oKTConfig->setdefaultns('clientToolPolicies', 'explorerMetadataCapture', true);
  455 + $oKTConfig->setdefaultns('clientToolPolicies', 'officeMetadataCapture', true);
456 456  
457 457  
458 458 $res = $this->readConfig();
... ...
ktapi/ktapi.inc.php
... ... @@ -576,11 +576,6 @@ class KTAPI
576 576 return $results;
577 577 }
578 578  
579   - function get_dms_defaults()
580   - {
581   - global $default;
582   - return $default;
583   - }
584 579  
585 580 }
586 581  
... ...
ktwebservice/webservice.php
... ... @@ -57,6 +57,21 @@ define('KTWS_ERR_INVALID_DEPTH', 25);
57 57 define('KTWS_ERR_PROBLEM', 98);
58 58 define('KTWS_ERR_DB_PROBLEM', 99);
59 59  
  60 +
  61 + function bool2str($bool)
  62 + {
  63 + if (is_bool($bool))
  64 + {
  65 + return $bool?'true':'false';
  66 + }
  67 + if (is_numeric($bool))
  68 + {
  69 + return ($bool+0)?'true':'false';
  70 + }
  71 + // assume str
  72 + return (strtolower($bool) == 'true')?'true':'false';
  73 + }
  74 +
60 75 class KTWebService
61 76 {
62 77 /**
... ... @@ -323,17 +338,26 @@ class KTWebService
323 338 'document_types' => "{urn:$this->namespace}kt_document_types_array"
324 339 );
325 340  
326   - $this->__typedef["{urn:$this->namespace}kt_server_settings"] =
  341 + $this->__typedef["{urn:$this->namespace}kt_client_policy"] =
  342 + array(
  343 + 'name' => 'string',
  344 + 'value' => 'string',
  345 + 'type' => 'string',
  346 + );
  347 +
  348 + $this->__typedef["{urn:$this->namespace}kt_client_policies_array"] =
327 349 array(
328   - 'explorer_metadata_capture' => 'boolean',
329   - 'office_metadata_capture' => 'boolean'
330   - );
  350 + array(
  351 + 'policies' => "{urn:$this->namespace}kt_client_policy"
  352 + )
  353 + );
  354 +
331 355  
332   - $this->__typedef["{urn:$this->namespace}kt_server_settings_response"] =
  356 + $this->__typedef["{urn:$this->namespace}kt_client_policies_response"] =
333 357 array(
334 358 'status_code' => 'int',
335 359 'message' => 'string',
336   - 'settings' => "{urn:$this->namespace}kt_server_settings"
  360 + 'policies' => "{urn:$this->namespace}kt_client_policies_array"
337 361 );
338 362  
339 363 /* methods */
... ... @@ -635,10 +659,10 @@ class KTWebService
635 659 'out' => array( 'return' => "{urn:$this->namespace}kt_document_types_response" ),
636 660 );
637 661  
638   - // get_server_settings
639   - $this->__dispatch_map['get_server_settings'] =
  662 + // get_client_policies
  663 + $this->__dispatch_map['get_client_policies'] =
640 664 array('in' => array('session_id'=>'string' ),
641   - 'out' => array( 'return' => "{urn:$this->namespace}kt_server_settings_response" ),
  665 + 'out' => array( 'return' => "{urn:$this->namespace}kt_client_policies_response" ),
642 666 );
643 667  
644 668  
... ... @@ -2974,29 +2998,49 @@ class KTWebService
2974 2998 return $response;
2975 2999 }
2976 3000  
  3001 + function _encode_client_policies($policies)
  3002 + {
  3003 + $encoded=array();
  3004 + foreach($policies as $policy)
  3005 + {
  3006 + $encoded[] = new SOAP_Value('policy',"{urn:$this->namespace}kt_client_policy", $policy);
  3007 + }
  3008 + if (empty($encoded))
  3009 + {
  3010 + $encoded=null;
  3011 + }
  3012 + return new SOAP_Value('policies',"{urn:$this->namespace}kt_client_policies_array", $encoded);
  3013 + }
  3014 +
2977 3015 /**
2978   - * Retrieves the server settings for this server
  3016 + * Retrieves the server policies for this server
2979 3017 *
2980 3018 * @param string $session_id
2981   - * @return kt_server_settings_response
  3019 + * @return kt_client_policies_response
2982 3020 */
2983   - function get_server_settings($session_id)
  3021 + function get_client_policies($session_id)
2984 3022 {
2985   - $kt = &$this->get_ktapi($session_id );
2986   - if (is_array($kt))
2987   - {
2988   - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $kt);
2989   - }
  3023 + $config = KTConfig::getSingleton();
2990 3024  
2991   - $dms_defaults = $kt->get_dms_defaults();
2992   - $response['settings'] = array(
2993   - 'explorer_metadata_capture' => $dms_defaults->explorerMetadataCapture,
2994   - 'office_metadata_capture' => $dms_defaults->officeMetadataCapture
2995   - );
2996   - $response['message'] = 'Knowledgetree server settings retrieval succeeded.';
  3025 + $policies = array(
  3026 + array(
  3027 + 'name' => 'explorer_metadata_capture',
  3028 + 'value' => bool2str($config->get('clientToolPolicies/explorerMetadataCapture')),
  3029 + 'type' => 'boolean'
  3030 + ),
  3031 + array(
  3032 + 'name' => 'office_metadata_capture',
  3033 + 'value' => bool2str($config->get('clientToolPolicies/officeMetadataCapture')),
  3034 + 'type' => 'boolean'
  3035 + ),
  3036 + );
  3037 +
  3038 +
  3039 + $response['policies'] = $this->_encode_client_policies($policies);
  3040 + $response['message'] = 'Knowledgetree client policies retrieval succeeded.';
2997 3041 $response['status_code'] = KTWS_SUCCESS;
2998 3042  
2999   - return $response;
  3043 + return new SOAP_Value('return',"{urn:$this->namespace}kt_client_policies_response", $response);
3000 3044 }
3001 3045  
3002 3046 /**
... ...