$conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
$ldapfilter);
$result2 = ldap_get_binentries($LDAP_CON, $sr);
+ }else{
+ $result2 = '';
}
-
+
$result = array_merge((array)$result1,(array)$result2);
// select entry template
- if($_REQUEST['export'] == 'csv'){
+ if(!empty($_REQUEST['export']) && $_REQUEST['export'] == 'csv'){
$entrytpl = 'export_list_csv_entry.tpl';
}else{
$entrytpl = 'list_entry.tpl';
tpl_categories();
tpl_timezone();
tpl_country();
+ if (empty($_REQUEST['filter'])) $_REQUEST['filter']='';
+ if (empty($_REQUEST['marker'])) $_REQUEST['marker']='';
+ if (empty($_REQUEST['search'])) $_REQUEST['search']='';
$smarty->assign('list',$list);
$smarty->assign('filter',$_REQUEST['filter']);
$smarty->assign('marker',$_REQUEST['marker']);
$smarty->assign('search',$_REQUEST['search']);
//display templates
- if($_REQUEST['export'] == 'csv'){
+ if(!empty($_REQUEST['export']) && $_REQUEST['export'] == 'csv'){
if ($conf['userlogreq'] == 1 && $user == '')
{
header("HTTP/1.1 401 ACCESS DENIED");
exit();
} else {
header("Content-Type: text/csv");
- header('Content-Disposition: Attachement; filename="ldapabexport.csv"');
+ header('Content-Disposition: Attachement; filename="contagged_export.csv"');
$smarty->display('export_list_csv.tpl');
}
}else{
*/
function _namesort($a,$b){
global $result;
- $x = $result[$a]['sn'][0].$result[$a]['givenName'][0];
- $y = $result[$b]['sn'][0].$result[$b]['givenName'][0];
+ global $FIELDS;
+ if (empty($result[$a][$FIELDS['givenname']])) { $result[$a][$FIELDS['givenname']]=''; }
+ if (empty($result[$b][$FIELDS['givenname']])) { $result[$b][$FIELDS['givenname']]=''; }
+ $x = $result[$a][$FIELDS['name']][0].$result[$a][$FIELDS['givenname']][0];
+ $y = $result[$b][$FIELDS['name']][0].$result[$b][$FIELDS['givenname']][0];
return(strcasecmp($x,$y));
}
* Creates an LDAP filter from given request variables search or filter
*/
function _makeldapfilter(){
+ global $FIELDS;
+
//handle given filter
+ if (empty($_REQUEST['filter'])) { $_REQUEST['filter']=''; }
+ if (empty($_REQUEST['search'])) { $_REQUEST['search']=''; }
+ if (empty($_REQUEST['org'])) { $_REQUEST['org']=''; }
+ if (empty($_REQUEST['marker'])) { $_REQUEST['marker']=''; }
$filter = ldap_filterescape($_REQUEST['filter']);
$search = ldap_filterescape($_REQUEST['search']);
$org = ldap_filterescape($_REQUEST['org']);
$marker = ldap_filterescape($_REQUEST['marker']);
- $categories = ldap_filterescape($_REQUEST['categories']);
$_SESSION['ldapab']['filter'] = $_REQUEST['filter'];
if(empty($filter)) $filter='a';
if(!empty($marker)){
+ // Search by tag
$ldapfilter = '(&(objectClass=contactPerson)';
$marker = explode(',',$marker);
foreach($marker as $m){
$m = trim($m);
- $ldapfilter .= "(marker=$m)";
+ $ldapfilter .= '('.$FIELDS['*marker'].'='.$m.')';
}
$ldapfilter .= ')';
- }elseif(!empty($categories)){
- $ldapfilter = "(&(objectClass=OXUserObject)(OXUserCategories=$categories))";
}elseif(!empty($search)){
+ // Search name and organization
$search = trim($search);
$words=preg_split('/\s+/',$search);
$filter='';
foreach($words as $word){
- $filter .= "(|(|(sn=*$word*)(givenName=*$word*))(o=*$word*))";
+ $filter .= '(|(|('.$FIELDS['name'].'=*'.$word.'*)('.
+ $FIELDS['givenname'].'=*'.$word.'*))('.
+ $FIELDS['organization'].'=*'.$word.'*))';
}
$ldapfilter = "(&(objectClass=inetOrgPerson)$filter)";
}elseif(!empty($org)){
- $ldapfilter = "(&(objectClass=inetOrgPerson)(o=$org))";
+ // List organization members
+ $ldapfilter = '(&(objectClass=inetOrgPerson)('.$FIELDS['organization']."=$org))";
}elseif($filter=='other'){
+ // Alphabetic listing of last names
$other='';
for ($i=ord('a');$i<=ord('z');$i++){
- $other .= '(!(sn='.chr($i).'*))';
+ $other .= '(!('.$FIELDS['name'].'='.chr($i).'*))';
}
$ldapfilter = "(&(objectClass=inetOrgPerson)$other)";
}elseif($filter=='*'){
+ // List all
$ldapfilter = "(objectClass=inetOrgPerson)";
}else{
- $ldapfilter = "(&(objectClass=inetOrgPerson)(sn=$filter*))";
+ // Search by last name start
+ $ldapfilter = '(&(objectClass=inetOrgPerson)('.$FIELDS['name']."=$filter*))";
}
return $ldapfilter;
}