Commit 9d4fcadf807c36fbd997515c244f53b06e756688

Authored by kevin_fourie
1 parent 02429e63

Merged in from STABLE trunk...

KTS-2370
"Mass import from external authentication source does not work"
Fixed. The mass import will now display the full list if a search filter is not entered.

Committed by: Megan Watson
Reviewed by: Conrad Vermeulen


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/STABLE/branches/3.5.3-Release-Branch@8838 c91229c3-7414-0410-bfa2-8a42b809f60b
plugins/ktstandard/ldap/ldapbaseauthenticationprovider.inc.php
... ... @@ -410,11 +410,15 @@ class KTLDAPBaseAuthenticationProvider extends KTAuthenticationProvider {
410 410 if (!is_array($submit)) {
411 411 $submit = array();
412 412 }
  413 + // Check if its a mass import
  414 + $massimport = KTUtil::arrayGet($_REQUEST, 'massimport');
  415 + $isMassImport = ($massimport == 'on') ? true : false;
  416 +
413 417 if (KTUtil::arrayGet($submit, 'chosen')) {
414 418 $id = KTUtil::arrayGet($_REQUEST, 'id');
415   - $massimport = KTUtil::arrayGet($_REQUEST, 'massimport');
  419 +
416 420 if (!empty($id)) {
417   - if ($massimport) {
  421 + if ($isMassImport) {
418 422 return $this->_do_massCreateUsers();
419 423 } else {
420 424 return $this->_do_editUserFromSource();
... ... @@ -431,11 +435,15 @@ class KTLDAPBaseAuthenticationProvider extends KTAuthenticationProvider {
431 435  
432 436 $fields = array();
433 437 $fields[] = new KTStringWidget(_kt("User's name"), _kt("The user's name, or part thereof, to find the user that you wish to add"), 'ldap_name', '', $this->oPage, true);
434   - $fields[] = new KTCheckboxWidget(_kt("Mass import"), _kt("Allow for multiple users to be selected to be added (will not get to manually verify the details if selected)"), 'massimport', false, $this->oPage, true);
  438 + $fields[] = new KTCheckboxWidget(_kt("Mass import"),
  439 + _kt("Allow for multiple users to be selected to be added (will not get to manually verify the details if selected)").'.<br>'.
  440 + _kt('The list may be long and take some time to load if the search is not filtered and there are a number of users in the system.')
  441 + , 'massimport', $isMassImport, $this->oPage, true);
435 442  
436 443 $oAuthenticator = $this->getAuthenticator($oSource);
437 444 $name = KTUtil::arrayGet($_REQUEST, 'ldap_name');
438   - if (!empty($name)) {
  445 +
  446 + if (!empty($name) || $isMassImport) {
439 447 $aSearchResults = $oAuthenticator->searchUsers($name, array('cn', 'dn', $sIdentifierField));
440 448 if (PEAR::isError($aSearchResults)) {
441 449 $this->oPage->addError($aSearchResults->getMessage());
... ... @@ -468,8 +476,6 @@ class KTLDAPBaseAuthenticationProvider extends KTAuthenticationProvider {
468 476 }
469 477 }
470 478  
471   - $massimport = KTUtil::arrayGet($_REQUEST, 'massimport');
472   -
473 479 $aTemplateData = array(
474 480 'context' => &$this,
475 481 'fields' => $fields,
... ... @@ -910,7 +916,7 @@ class KTLDAPBaseAuthenticator extends Authenticator {
910 916 foreach ($this->aSearchAttributes as $sSearchAttribute) {
911 917 $sSearchAttributes .= sprintf('(%s=*%s*)', trim($sSearchAttribute), $sSearch);
912 918 }
913   - $sFilter = sprintf('(&(%s)(%s))', $sObjectClasses, $sSearchAttributes);
  919 + $sFilter = !empty($sSearch) ? sprintf('(&(%s)(%s))', $sObjectClasses, $sSearchAttributes) : null;
914 920 $default->log->debug("Search filter is: " . $sFilter);
915 921  
916 922 $oResult = $this->oLdap->search($rootDn, $sFilter, $aParams);
... ...
templates/ktstandard/authentication/ldapsearchuser.smarty
... ... @@ -30,7 +30,7 @@ begin.{/i18n}&lt;/p&gt;
30 30 <table class="listing">
31 31 <thead>
32 32 <tr>
33   - <th style="width:2em"><input type="checkbox" onclick="toggleSelectFor(this, 'id')" title="toggle all" /></th>
  33 + <th style="width:2em">{if $massimport}<input type="checkbox" onclick="toggleSelectFor(this, 'id')" title="toggle all" />{/if}</th>
34 34 <th>{i18n}Name{/i18n}</th>
35 35 <th>{i18n}Distinguished Name (LDAP DN){/i18n}</th>
36 36 </tr>
... ...