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,11 +410,15 @@ class KTLDAPBaseAuthenticationProvider extends KTAuthenticationProvider {
410 if (!is_array($submit)) { 410 if (!is_array($submit)) {
411 $submit = array(); 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 if (KTUtil::arrayGet($submit, 'chosen')) { 417 if (KTUtil::arrayGet($submit, 'chosen')) {
414 $id = KTUtil::arrayGet($_REQUEST, 'id'); 418 $id = KTUtil::arrayGet($_REQUEST, 'id');
415 - $massimport = KTUtil::arrayGet($_REQUEST, 'massimport'); 419 +
416 if (!empty($id)) { 420 if (!empty($id)) {
417 - if ($massimport) { 421 + if ($isMassImport) {
418 return $this->_do_massCreateUsers(); 422 return $this->_do_massCreateUsers();
419 } else { 423 } else {
420 return $this->_do_editUserFromSource(); 424 return $this->_do_editUserFromSource();
@@ -431,11 +435,15 @@ class KTLDAPBaseAuthenticationProvider extends KTAuthenticationProvider { @@ -431,11 +435,15 @@ class KTLDAPBaseAuthenticationProvider extends KTAuthenticationProvider {
431 435
432 $fields = array(); 436 $fields = array();
433 $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); 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 $oAuthenticator = $this->getAuthenticator($oSource); 443 $oAuthenticator = $this->getAuthenticator($oSource);
437 $name = KTUtil::arrayGet($_REQUEST, 'ldap_name'); 444 $name = KTUtil::arrayGet($_REQUEST, 'ldap_name');
438 - if (!empty($name)) { 445 +
  446 + if (!empty($name) || $isMassImport) {
439 $aSearchResults = $oAuthenticator->searchUsers($name, array('cn', 'dn', $sIdentifierField)); 447 $aSearchResults = $oAuthenticator->searchUsers($name, array('cn', 'dn', $sIdentifierField));
440 if (PEAR::isError($aSearchResults)) { 448 if (PEAR::isError($aSearchResults)) {
441 $this->oPage->addError($aSearchResults->getMessage()); 449 $this->oPage->addError($aSearchResults->getMessage());
@@ -468,8 +476,6 @@ class KTLDAPBaseAuthenticationProvider extends KTAuthenticationProvider { @@ -468,8 +476,6 @@ class KTLDAPBaseAuthenticationProvider extends KTAuthenticationProvider {
468 } 476 }
469 } 477 }
470 478
471 - $massimport = KTUtil::arrayGet($_REQUEST, 'massimport');  
472 -  
473 $aTemplateData = array( 479 $aTemplateData = array(
474 'context' => &$this, 480 'context' => &$this,
475 'fields' => $fields, 481 'fields' => $fields,
@@ -910,7 +916,7 @@ class KTLDAPBaseAuthenticator extends Authenticator { @@ -910,7 +916,7 @@ class KTLDAPBaseAuthenticator extends Authenticator {
910 foreach ($this->aSearchAttributes as $sSearchAttribute) { 916 foreach ($this->aSearchAttributes as $sSearchAttribute) {
911 $sSearchAttributes .= sprintf('(%s=*%s*)', trim($sSearchAttribute), $sSearch); 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 $default->log->debug("Search filter is: " . $sFilter); 920 $default->log->debug("Search filter is: " . $sFilter);
915 921
916 $oResult = $this->oLdap->search($rootDn, $sFilter, $aParams); 922 $oResult = $this->oLdap->search($rootDn, $sFilter, $aParams);
templates/ktstandard/authentication/ldapsearchuser.smarty
@@ -30,7 +30,7 @@ begin.{/i18n}&lt;/p&gt; @@ -30,7 +30,7 @@ begin.{/i18n}&lt;/p&gt;
30 <table class="listing"> 30 <table class="listing">
31 <thead> 31 <thead>
32 <tr> 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 <th>{i18n}Name{/i18n}</th> 34 <th>{i18n}Name{/i18n}</th>
35 <th>{i18n}Distinguished Name (LDAP DN){/i18n}</th> 35 <th>{i18n}Distinguished Name (LDAP DN){/i18n}</th>
36 </tr> 36 </tr>