Commit 87bdd56b680bf26b5e37c5fb035a0c673f3ec046

Authored by kevin_fourie
1 parent 053e0c5c

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

KTS-2302
"Download column missing border in IE"
Fixed. Added &nbsp as per patch. Thanks Kenny!

Committed By: Kevin Fourie
Reviewed By: Conrad Vermeulen

KTS-2323
"DB Constraint Error when adding a duplicate user from an authentication source."
Fixed. Added duplicate user check.

Committed By: Kevin Fourie
Reviewed By: Conrad Vermeulen

KTS-2266
"When adding a single user via authenticated source, you need to fill in the username manually and this breaks the Mass Import"
Fixed. Added check for LDAP vs AD and created username based on 'givenname' if 'uid' is null in LDAP. The Jam 'uid' is always null but we can't assume all LDAP servers will return null for 'uid'. Also added a check for duplicate users when doing mass add of users from Authentication Source. Instead of failing or ignoring the user is created with '_DUPLICATE' appended so an admin can clean up afterwards.

Committed By: Kevin Fourie
Reviewed By: Conrad Vermeulen

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/STABLE/branches/3.4.3-Release-Branch@7129 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 /**
... ...
plugins/ktcore/KTColumns.inc.php
... ... @@ -420,6 +420,10 @@ class AdvancedDownloadColumn extends AdvancedColumn {
420 420 $this->label = null;
421 421 }
422 422  
  423 + function renderHeader($sReturnURL) {
  424 + return ' ';
  425 + }
  426 +
423 427 function renderData($aDataRow) {
424 428 // only _ever_ show this for documents.
425 429 if ($aDataRow["type"] === "folder") {
... ...
plugins/ktstandard/ldap/ldapbaseauthenticationprovider.inc.php
... ... @@ -235,9 +235,16 @@ class KTLDAPBaseAuthenticationProvider extends KTAuthenticationProvider {
235 235 );
236 236 $this->oValidator->notError($aResults);
237 237  
  238 + $sUserName = $aResults[$this->aAttributes[1]];
  239 + // With LDAP, if the 'uid' is null then try using the 'givenname' instead.
  240 + // See activedirectoryauthenticationprovider.inc.php and ldapauthenticationprovider.inc.php for details.
  241 + if($this->sAuthenticatorClass == "KTLDAPAuthenticator" && empty($sUserName)) {
  242 + $sUserName = strtolower($aResults[$this->aAttributes[2]]);
  243 + }
  244 +
238 245 $fields = array();
239 246 $fields[] = new KTStaticTextWidget(_kt('LDAP DN'), _kt('The location of the user within the LDAP directory.'), 'dn', $id, $this->oPage);
240   - $fields[] = new KTStringWidget(_kt('Username'), sprintf(_kt('The username the user will enter to gain access to %s. e.g. <strong>jsmith</strong>'), APP_NAME), 'ldap_username', $aResults[$this->aAttributes[1]], $this->oPage, true);
  247 + $fields[] = new KTStringWidget(_kt('Username'), sprintf(_kt('The username the user will enter to gain access to %s. e.g. <strong>jsmith</strong>'), APP_NAME), 'ldap_username', $sUserName, $this->oPage, true);
241 248 $fields[] = new KTStringWidget(_kt('Name'), _kt('The full name of the user. This is shown in reports and listings. e.g. <strong>John Smith</strong>'), 'name', $aResults[$this->aAttributes[0]], $this->oPage, true);
242 249 $fields[] = new KTStringWidget(_kt('Email Address'), _kt('The email address of the user. Notifications and alerts are mailed to this address if <strong>email notifications</strong> is set below. e.g. <strong>jsmith@acme.com</strong>'), 'email_address', $aResults[$this->aAttributes[4]], $this->oPage, false);
243 250 $fields[] = new KTCheckboxWidget(_kt('Email Notifications'), _kt('If this is specified then the user will have notifications sent to the email address entered above. If it is not set, then the user will only see notifications on the <strong>Dashboard</strong>'), 'email_notifications', true, $this->oPage, false);
... ... @@ -265,7 +272,11 @@ class KTLDAPBaseAuthenticationProvider extends KTAuthenticationProvider {
265 272 if (empty($name)) { $this->errorRedirectToMain(_kt('You must specify a name for the user.')); }
266 273 $username = KTUtil::arrayGet($_REQUEST, 'ldap_username');
267 274 if (empty($username)) { $this->errorRedirectToMain(_kt('You must specify a new username.')); }
268   - // FIXME check for non-clashing usernames.
  275 +
  276 + $dupUser =& User::getByUserName($username);
  277 + if(!PEAR::isError($dupUser)) {
  278 + $this->errorRedirectToMain(_kt("A user with that username already exists"));
  279 + }
269 280  
270 281 $email_address = KTUtil::arrayGet($_REQUEST, 'email_address');
271 282 $email_notifications = KTUtil::arrayGet($_REQUEST, 'email_notifications', false);
... ... @@ -286,7 +297,7 @@ class KTLDAPBaseAuthenticationProvider extends KTAuthenticationProvider {
286 297 "authenticationdetails2" => $samaccountname,
287 298 "password" => "",
288 299 ));
289   -
  300 +
290 301 if (PEAR::isError($oUser) || ($oUser == false)) {
291 302 $this->errorRedirectToMain(_kt("failed to create user") . ": " . $oUser->message);
292 303 exit(0);
... ... @@ -303,14 +314,29 @@ class KTLDAPBaseAuthenticationProvider extends KTAuthenticationProvider {
303 314 $oSource =& KTAuthenticationSource::get($_REQUEST['source_id']);
304 315 $oAuthenticator = $this->getAuthenticator($oSource);
305 316 $aNames = array();
  317 +
306 318 foreach ($aIds as $sId) {
307 319 $aResults = $oAuthenticator->getUser($sId);
308 320 $dn = $sId;
309 321 $sUserName = $aResults[$this->aAttributes[1]];
  322 + // With LDAP, if the 'uid' is null then try using the 'givenname' instead.
  323 + // See activedirectoryauthenticationprovider.inc.php and ldapauthenticationprovider.inc.php for details.
  324 + if($this->sAuthenticatorClass == "KTLDAPAuthenticator" && empty($sUserName)) {
  325 + $sUserName = strtolower($aResults[$this->aAttributes[2]]);
  326 + }
310 327 $sName = $aResults[$this->aAttributes[0]];
311 328 $sEmailAddress = $aResults[$this->aAttributes[4]];
312 329 $sMobileNumber = $aResults[$this->aAttributes[5]];
313 330  
  331 + // If the user already exists append some text so the admin can see the duplicates.
  332 + $appending = true;
  333 + while($appending) {
  334 + if(!PEAR::isError(User::getByUserName($sUserName))) {
  335 + $sUserName = $sUserName . "_DUPLICATE";
  336 + $appending = true;
  337 + } else $appending = false;
  338 + }
  339 +
314 340 $oUser = User::createFromArray(array(
315 341 "Username" => $sUserName,
316 342 "Name" => $sName,
... ...