]> git.sur5r.net Git - contagged/blobdiff - inc/template.php
Added country to ldapab.schema. Closes #1
[contagged] / inc / template.php
index 8ebe359f26c24a60e4e8339c1788537eca3fb54b..a86152092c22bce1dd12c3f257bfd9df02e12f4a 100644 (file)
@@ -26,6 +26,12 @@ function tpl_std(){
   $smarty->assign('conf',$conf);
   $smarty->assign('lang',$lang);
   $smarty->assign('fields',$FIELDS);
+  $smarty->assign('lettertabs',explode(' ',$lang['lettertabs']));
+
+  if(isset($FIELDS['country'])){
+      include dirname(__FILE__).'/iso3166.php';
+      $smarty->assign('iso3166',$iso3166);
+  }
 }
 
 /**
@@ -65,7 +71,7 @@ function tpl_entry($in){
   $out['dn']          = normalize_dn($out['dn']);
   $conf['publicbook'] = normalize_dn($conf['publicbook']);
   if($out['dn']){
-      if(strstr($out['dn'],$conf['publicbook'])){
+      if(stristr($out['dn'],$conf['publicbook'])){
           $out['type'] = 'public';
       }else{
           $out['type'] = 'private';
@@ -75,6 +81,8 @@ function tpl_entry($in){
   // join marker field to markers
   if(is_array($out['marker'])) $out['markers'] = join(', ',$out['marker']);
 
+  $out['qrcode'] = tpl_qrcode($out);
+
 /*
 print '<pre>';
 print_r($out);
@@ -84,6 +92,20 @@ print '</pre>';
   $smarty->assign('entry',$out);
 }
 
+function tpl_qrcode($in){
+    $data = "BEGIN:VCARD\n";
+    $data .= "N:{$in['name']};{$in['givenname']}\n";
+    if($in['mobile'])    $data .= "TEL;CELL:{$in['mobile']}\n";
+    if($in['phone'])     $data .= "TEL;WORK:{$in['phone']}\n";
+    if($in['homephone']) $data .= "TEL;HOME:{$in['homephone']}\n";
+    if($in['mail'][0])   $data .= "EMAIL:{$in['mail'][0]}\n";
+    $data .= "END:VCARD";
+    $data = rawurlencode($data);
+
+    return 'http://chart.apis.google.com/chart?cht=qr&chld=L|5&chs=500x500&chl='.$data.'&.png';
+}
+
+
 /**
  * assigns the last LDAP error to the template
  */
@@ -96,8 +118,10 @@ function tpl_ldaperror($message=""){
     $__LDAPERROR__ .= ldap_err2str($errno);
     if(!empty($message)){
       $__LDAPERROR__ .= "($message)";
+    }elseif($errno == 4){
+      $__LDAPERROR__ .= "(You need to increase this limit in your server config)";
     }
-    $__LDAPERROR__ .= '\n';
+    $__LDAPERROR__ .= '<br />';
   }
   $smarty->assign("LDAPERRORS",$__LDAPERROR__);
 }
@@ -117,7 +141,7 @@ function tpl_markers(){
   $sr = ldap_list($LDAP_CON,$conf['publicbook'],"ObjectClass=inetOrgPerson",array("marker"));
   $result1 = ldap_get_binentries($LDAP_CON, $sr);
   //check users private addressbook
-  if(!empty($_SESSION['ldapab']['binddn'])){
+  if(!empty($_SESSION['ldapab']['binddn']) && $conf['privatebook']){
     $sr = @ldap_list($LDAP_CON,
                     $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
                     "ObjectClass=inetOrgPerson",array("marker"));
@@ -181,7 +205,7 @@ function tpl_categories(){
   $sr = ldap_list($LDAP_CON,$conf['publicbook'],"ObjectClass=OXUserObject",array("OXUserCategories"));
   $result1 = ldap_get_binentries($LDAP_CON, $sr);
   //check users private addressbook
-  if(!empty($_SESSION['ldapab']['binddn'])){
+  if(!empty($_SESSION['ldapab']['binddn']) && $conf['privatebook']){
     $sr = @ldap_list($LDAP_CON,
                     $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
                     "ObjectClass=OXUserObject",array("OXUserCategories"));
@@ -219,7 +243,7 @@ function tpl_timezone(){
   $sr = ldap_list($LDAP_CON,$conf['publicbook'],"ObjectClass=OXUserObject",array("OXTimeZone"));
   $result1 = ldap_get_binentries($LDAP_CON, $sr);
   //check users private addressbook
-  if(!empty($_SESSION['ldapab']['binddn'])){
+  if(!empty($_SESSION['ldapab']['binddn']) && $conf['privatebook']){
     $sr = @ldap_list($LDAP_CON,
                     $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
                     "ObjectClass=OXUserObject",array("OXTimeZone"));
@@ -257,7 +281,7 @@ function tpl_country(){
   $sr = ldap_list($LDAP_CON,$conf['publicbook'],"ObjectClass=OXUserObject",array("userCountry"));
   $result1 = ldap_get_binentries($LDAP_CON, $sr);
   //check users private addressbook
-  if(!empty($_SESSION['ldapab']['binddn'])){
+  if(!empty($_SESSION['ldapab']['binddn']) && $conf['privatebook']){
     $sr = @ldap_list($LDAP_CON,
                     $conf['privatebook'].','.$_SESSION['ldapab']['binddn'],
                     "ObjectClass=OXUserObject",array("userCountry"));