]> git.sur5r.net Git - contagged/blobdiff - index.php
fall back to english if local language string is missing
[contagged] / index.php
index 5bd4fca712ba37020553766e7bde7e8841b1b763..9eba4f069cf7d8f0e8f2e662ebb401e3fd1bcd31 100644 (file)
--- a/index.php
+++ b/index.php
@@ -3,31 +3,25 @@
   require_once('inc/init.php');
   ldap_login();
 
-  //prepare filter
-  $ldapfilter = _makeldapfilter();
-
-  //check public addressbook
-  $sr = ldap_list($LDAP_CON,$conf['publicbook'],$ldapfilter);
-  $result1 = ldap_get_binentries($LDAP_CON, $sr);
-  //check users private addressbook
-  if(!empty($_SESSION['ldapab']['binddn'])){
-    $sr = @ldap_list($LDAP_CON,
-                    $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(!empty($_REQUEST['export']) && $_REQUEST['export'] == 'csv'){
-    $entrytpl = 'export_list_csv_entry.tpl';
+    $entrytpl = 'list_csv_entry.tpl';
+  }elseif(!empty($_REQUEST['export']) && $_REQUEST['export'] == 'map'){
+    $entrytpl = 'list_map_entry.tpl';
   }else{
     $entrytpl = 'list_entry.tpl';
   }
 
+  // check which fields are needed
+  $fields = get_fields_from_template($entrytpl);
+
+
+  //prepare filter
+  $ldapfilter = _makeldapfilter();
+
+  // fetch results
+  $result = ldap_queryabooks($ldapfilter,$fields);
+
   $list = '';
   if(count($result)==1 && $_REQUEST['search']){
     //only one result on a search -> display page
   $smarty->assign('marker',$_REQUEST['marker']);
   $smarty->assign('search',$_REQUEST['search']);
   //display templates
-  if(!empty($_REQUEST['export']) && $_REQUEST['export'] == 'csv'){
-    if ($conf['userlogreq'] == 1 && $user == '')
-    {
+  if(!empty($_REQUEST['export'])){
+    if ($conf['userlogreq'] == 1 && $user == ''){
       header("HTTP/1.1 401 ACCESS DENIED");
       exit();
-    } else {
+    }
+
+    if($_REQUEST['export'] == 'csv'){
       header("Content-Type: text/csv");
       header('Content-Disposition: Attachement; filename="contagged_export.csv"');
-      $smarty->display('export_list_csv.tpl');
+      $smarty->display('list_csv.tpl');
+      exit;
+    }elseif($_REQUEST['export'] == 'map'){
+      header('Content-Type: text/html; charset=utf-8');
+      $smarty->display('list_map.tpl');
+      exit;
     }
   }else{
     //save location in session