From 87bdd56b680bf26b5e37c5fb035a0c673f3ec046 Mon Sep 17 00:00:00 2001 From: kevin_fourie Date: Tue, 11 Sep 2007 09:54:45 +0000 Subject: [PATCH] Merged in from DEV trunk... --- config/config.ini | 2 +- config/dmsDefaults.php | 4 ++-- ktapi/ktapi.inc.php | 5 ----- ktwebservice/webservice.php | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------ plugins/ktcore/KTColumns.inc.php | 4 ++++ plugins/ktstandard/ldap/ldapbaseauthenticationprovider.inc.php | 32 +++++++++++++++++++++++++++++--- 6 files changed, 104 insertions(+), 35 deletions(-) diff --git a/config/config.ini b/config/config.ini index 1792063..7d288ca 100644 --- a/config/config.ini +++ b/config/config.ini @@ -291,7 +291,7 @@ safemode = on ; Identify the location of the mysql.exe and mysqldump.exe ;mysqlDirectory=c:/program files/ktdms/mysql/bin -[KTtoolsSettings] +[clientToolPolicies] ;These two settings control whether or not the client is prompted for metadata when a ;document is added to knowledgetree via KTtools. They default to true. explorerMetadataCapture = true diff --git a/config/dmsDefaults.php b/config/dmsDefaults.php index c23246f..7ca0bfb 100644 --- a/config/dmsDefaults.php +++ b/config/dmsDefaults.php @@ -451,8 +451,8 @@ class KTInit { $oKTConfig->setdefaultns('webservice', 'downloadExpiry', '30'); $oKTConfig->setdefaultns('webservice', 'randomKeyText', 'bkdfjhg23yskjdhf2iu'); - $oKTConfig->setdefaultns('KTtoolsSettings', 'explorerMetadataCapture', true); - $oKTConfig->setdefaultns('KTtoolsSettings', 'officeMetadataCapture', true); + $oKTConfig->setdefaultns('clientToolPolicies', 'explorerMetadataCapture', true); + $oKTConfig->setdefaultns('clientToolPolicies', 'officeMetadataCapture', true); $res = $this->readConfig(); diff --git a/ktapi/ktapi.inc.php b/ktapi/ktapi.inc.php index 5e45189..3e3dc9f 100644 --- a/ktapi/ktapi.inc.php +++ b/ktapi/ktapi.inc.php @@ -576,11 +576,6 @@ class KTAPI return $results; } - function get_dms_defaults() - { - global $default; - return $default; - } } diff --git a/ktwebservice/webservice.php b/ktwebservice/webservice.php index 7860508..08fda11 100644 --- a/ktwebservice/webservice.php +++ b/ktwebservice/webservice.php @@ -57,6 +57,21 @@ define('KTWS_ERR_INVALID_DEPTH', 25); define('KTWS_ERR_PROBLEM', 98); define('KTWS_ERR_DB_PROBLEM', 99); + + function bool2str($bool) + { + if (is_bool($bool)) + { + return $bool?'true':'false'; + } + if (is_numeric($bool)) + { + return ($bool+0)?'true':'false'; + } + // assume str + return (strtolower($bool) == 'true')?'true':'false'; + } + class KTWebService { /** @@ -323,17 +338,26 @@ class KTWebService 'document_types' => "{urn:$this->namespace}kt_document_types_array" ); - $this->__typedef["{urn:$this->namespace}kt_server_settings"] = + $this->__typedef["{urn:$this->namespace}kt_client_policy"] = + array( + 'name' => 'string', + 'value' => 'string', + 'type' => 'string', + ); + + $this->__typedef["{urn:$this->namespace}kt_client_policies_array"] = array( - 'explorer_metadata_capture' => 'boolean', - 'office_metadata_capture' => 'boolean' - ); + array( + 'policies' => "{urn:$this->namespace}kt_client_policy" + ) + ); + - $this->__typedef["{urn:$this->namespace}kt_server_settings_response"] = + $this->__typedef["{urn:$this->namespace}kt_client_policies_response"] = array( 'status_code' => 'int', 'message' => 'string', - 'settings' => "{urn:$this->namespace}kt_server_settings" + 'policies' => "{urn:$this->namespace}kt_client_policies_array" ); /* methods */ @@ -635,10 +659,10 @@ class KTWebService 'out' => array( 'return' => "{urn:$this->namespace}kt_document_types_response" ), ); - // get_server_settings - $this->__dispatch_map['get_server_settings'] = + // get_client_policies + $this->__dispatch_map['get_client_policies'] = array('in' => array('session_id'=>'string' ), - 'out' => array( 'return' => "{urn:$this->namespace}kt_server_settings_response" ), + 'out' => array( 'return' => "{urn:$this->namespace}kt_client_policies_response" ), ); @@ -2974,29 +2998,49 @@ class KTWebService return $response; } + function _encode_client_policies($policies) + { + $encoded=array(); + foreach($policies as $policy) + { + $encoded[] = new SOAP_Value('policy',"{urn:$this->namespace}kt_client_policy", $policy); + } + if (empty($encoded)) + { + $encoded=null; + } + return new SOAP_Value('policies',"{urn:$this->namespace}kt_client_policies_array", $encoded); + } + /** - * Retrieves the server settings for this server + * Retrieves the server policies for this server * * @param string $session_id - * @return kt_server_settings_response + * @return kt_client_policies_response */ - function get_server_settings($session_id) + function get_client_policies($session_id) { - $kt = &$this->get_ktapi($session_id ); - if (is_array($kt)) - { - return new SOAP_Value('return',"{urn:$this->namespace}kt_response", $kt); - } + $config = KTConfig::getSingleton(); - $dms_defaults = $kt->get_dms_defaults(); - $response['settings'] = array( - 'explorer_metadata_capture' => $dms_defaults->explorerMetadataCapture, - 'office_metadata_capture' => $dms_defaults->officeMetadataCapture - ); - $response['message'] = 'Knowledgetree server settings retrieval succeeded.'; + $policies = array( + array( + 'name' => 'explorer_metadata_capture', + 'value' => bool2str($config->get('clientToolPolicies/explorerMetadataCapture')), + 'type' => 'boolean' + ), + array( + 'name' => 'office_metadata_capture', + 'value' => bool2str($config->get('clientToolPolicies/officeMetadataCapture')), + 'type' => 'boolean' + ), + ); + + + $response['policies'] = $this->_encode_client_policies($policies); + $response['message'] = 'Knowledgetree client policies retrieval succeeded.'; $response['status_code'] = KTWS_SUCCESS; - return $response; + return new SOAP_Value('return',"{urn:$this->namespace}kt_client_policies_response", $response); } /** diff --git a/plugins/ktcore/KTColumns.inc.php b/plugins/ktcore/KTColumns.inc.php index 14bbb40..bdd8aef 100644 --- a/plugins/ktcore/KTColumns.inc.php +++ b/plugins/ktcore/KTColumns.inc.php @@ -420,6 +420,10 @@ class AdvancedDownloadColumn extends AdvancedColumn { $this->label = null; } + function renderHeader($sReturnURL) { + return ' '; + } + function renderData($aDataRow) { // only _ever_ show this for documents. if ($aDataRow["type"] === "folder") { diff --git a/plugins/ktstandard/ldap/ldapbaseauthenticationprovider.inc.php b/plugins/ktstandard/ldap/ldapbaseauthenticationprovider.inc.php index e8767c7..05caedb 100644 --- a/plugins/ktstandard/ldap/ldapbaseauthenticationprovider.inc.php +++ b/plugins/ktstandard/ldap/ldapbaseauthenticationprovider.inc.php @@ -235,9 +235,16 @@ class KTLDAPBaseAuthenticationProvider extends KTAuthenticationProvider { ); $this->oValidator->notError($aResults); + $sUserName = $aResults[$this->aAttributes[1]]; + // With LDAP, if the 'uid' is null then try using the 'givenname' instead. + // See activedirectoryauthenticationprovider.inc.php and ldapauthenticationprovider.inc.php for details. + if($this->sAuthenticatorClass == "KTLDAPAuthenticator" && empty($sUserName)) { + $sUserName = strtolower($aResults[$this->aAttributes[2]]); + } + $fields = array(); $fields[] = new KTStaticTextWidget(_kt('LDAP DN'), _kt('The location of the user within the LDAP directory.'), 'dn', $id, $this->oPage); - $fields[] = new KTStringWidget(_kt('Username'), sprintf(_kt('The username the user will enter to gain access to %s. e.g. jsmith'), APP_NAME), 'ldap_username', $aResults[$this->aAttributes[1]], $this->oPage, true); + $fields[] = new KTStringWidget(_kt('Username'), sprintf(_kt('The username the user will enter to gain access to %s. e.g. jsmith'), APP_NAME), 'ldap_username', $sUserName, $this->oPage, true); $fields[] = new KTStringWidget(_kt('Name'), _kt('The full name of the user. This is shown in reports and listings. e.g. John Smith'), 'name', $aResults[$this->aAttributes[0]], $this->oPage, true); $fields[] = new KTStringWidget(_kt('Email Address'), _kt('The email address of the user. Notifications and alerts are mailed to this address if email notifications is set below. e.g. jsmith@acme.com'), 'email_address', $aResults[$this->aAttributes[4]], $this->oPage, false); $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 Dashboard'), 'email_notifications', true, $this->oPage, false); @@ -265,7 +272,11 @@ class KTLDAPBaseAuthenticationProvider extends KTAuthenticationProvider { if (empty($name)) { $this->errorRedirectToMain(_kt('You must specify a name for the user.')); } $username = KTUtil::arrayGet($_REQUEST, 'ldap_username'); if (empty($username)) { $this->errorRedirectToMain(_kt('You must specify a new username.')); } - // FIXME check for non-clashing usernames. + + $dupUser =& User::getByUserName($username); + if(!PEAR::isError($dupUser)) { + $this->errorRedirectToMain(_kt("A user with that username already exists")); + } $email_address = KTUtil::arrayGet($_REQUEST, 'email_address'); $email_notifications = KTUtil::arrayGet($_REQUEST, 'email_notifications', false); @@ -286,7 +297,7 @@ class KTLDAPBaseAuthenticationProvider extends KTAuthenticationProvider { "authenticationdetails2" => $samaccountname, "password" => "", )); - + if (PEAR::isError($oUser) || ($oUser == false)) { $this->errorRedirectToMain(_kt("failed to create user") . ": " . $oUser->message); exit(0); @@ -303,14 +314,29 @@ class KTLDAPBaseAuthenticationProvider extends KTAuthenticationProvider { $oSource =& KTAuthenticationSource::get($_REQUEST['source_id']); $oAuthenticator = $this->getAuthenticator($oSource); $aNames = array(); + foreach ($aIds as $sId) { $aResults = $oAuthenticator->getUser($sId); $dn = $sId; $sUserName = $aResults[$this->aAttributes[1]]; + // With LDAP, if the 'uid' is null then try using the 'givenname' instead. + // See activedirectoryauthenticationprovider.inc.php and ldapauthenticationprovider.inc.php for details. + if($this->sAuthenticatorClass == "KTLDAPAuthenticator" && empty($sUserName)) { + $sUserName = strtolower($aResults[$this->aAttributes[2]]); + } $sName = $aResults[$this->aAttributes[0]]; $sEmailAddress = $aResults[$this->aAttributes[4]]; $sMobileNumber = $aResults[$this->aAttributes[5]]; + // If the user already exists append some text so the admin can see the duplicates. + $appending = true; + while($appending) { + if(!PEAR::isError(User::getByUserName($sUserName))) { + $sUserName = $sUserName . "_DUPLICATE"; + $appending = true; + } else $appending = false; + } + $oUser = User::createFromArray(array( "Username" => $sUserName, "Name" => $sName, -- libgit2 0.21.4