From: cajus Date: Mon, 14 Apr 2008 08:25:48 +0000 (+0000) Subject: Moved addressbook around X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=12006902985a0f5e6f0dc495a42d0a8426b7a7ed;p=gosa.git Moved addressbook around git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10386 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/addressbook/html/addressbook/getvcard.php b/gosa-plugins/addressbook/html/addressbook/getvcard.php deleted file mode 100644 index 919f1b3b7..000000000 --- a/gosa-plugins/addressbook/html/addressbook/getvcard.php +++ /dev/null @@ -1,170 +0,0 @@ -get_ldap_link(); -$ldap->cat(base64_decode(validate($_GET['dn']))); - -/* - * Generate vcard for specified IDs - */ -while ($attrs= $ldap->fetch()){ - /* Header / Name */ - echo "BEGIN:VCARD\n"; - echo "VERSION:3.0\n"; - echo "FN:".preg_replace('/,/', '\\,', $attrs['cn'][0])."\n"; - - /* Assemble titles for N attribute */ - $titles= ""; - if (isset($attrs['personalTitle'])){ - $titles= $attrs['personalTitle'][0]; - } - if (isset($attrs['academicTitle'])){ - if ($titles != ""){ - $titles.= ",".$attrs['academicTitle'][0]; - } else { - $titles= $attrs['academicTitle'][0]; - } - } - echo "N:".$attrs['sn'][0].";".$attrs['givenName'][0].";;;$titles\n"; - - /* Generate random UID */ - $uid= ""; - srand(make_seed()); - $chars= '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; - for ($i= 0; $i<16; $i++){ - $uid.= $chars[rand(0, strlen($chars)-1)]; - } - echo "UID:$uid\n"; - - /* Mail addresses */ - if (isset($attrs['mail'][0])){ - echo "EMAIL;TYPE=internet,pref:".$attrs['mail'][0]."\n"; - if (isset($attrs['gosaMailAlternateAddress'])){ - for ($i= 0; $i<$attrs['gosaMailAlternateAddress']['count']; $i++){ - echo "EMAIL;TYPE=internet:". - $attrs['gosaMailAlternateAddress'][$i]."\n"; - } - } - } - - /* Export date */ - echo "REV:".date("Y-m-d")."\n"; - echo "CLASS:PUBLIC\n"; - - /* Fill address */ - if (isset($attrs['homePostalAddress'])){ - @list($street,$town,$country)= preg_split('/\n/', $attrs['homePostalAddress'][0]); - echo "ADR;TYPE=home:;;".trim($street).";".trim($town).";;;". - trim($country)."\n"; - } - if (isset($attrs['postalAddress'])){ - @list($street,$town,$country)= preg_split('/\n/', $attrs['postalAddress'][0]); - echo "ADR;TYPE=work,pref:;;".trim($street).";".trim($town).";;;". - trim($country)."\n"; - } - - /* Telephone numbers */ - if (isset($attrs['homePhone'])){ - echo "TEL;TYPE=home:".$attrs['homePhone'][0]."\n"; - } - if (isset($attrs['telephoneNumber'])){ - echo "TEL;TYPE=work,pref:".$attrs['telephoneNumber'][0]."\n"; - } - if (isset($attrs['mobile'])){ - echo "TEL;TYPE=cell:".$attrs['mobile'][0]."\n"; - } - if (isset($attrs['pager'])){ - echo "TEL;TYPE=pager:".$attrs['pager'][0]."\n"; - } - - /* Set organization */ - if (isset($attrs['o'])){ - echo "ORG:".$attrs['o'][0]."\n"; - } - - echo "NOTE:Exported by GOsa - https://gosa.gonicus.de\n"; - echo "SORT-STRING:".$attrs['sn'][0]."\n"; - if (isset($attrs['labeledURI'][0])){ - echo "URL:".$attrs['labeledURI'][0]."\n"; - } - - /* Add user certificate */ -#if (isset($attrs['userCertificate;binary'])){ -# $cert= $ldap->get_attribute($ldap->getDN(), "userCertificate;binary"); -# $cert= preg_replace('/\r\n/', chr(10).' ', chunk_split(base64_encode($cert))); -# echo "KEY;ENCODING=b:".preg_replace('/\n $/', '', $cert)."\n"; -#} - - /* Add picture */ - if (isset($attrs['jpegPhoto'])){ - $photodata= $ldap->get_attribute($ldap->getDN(), "jpegPhoto"); - $photodata= preg_replace('/\r\n/', chr(10).' ', chunk_split(base64_encode($photodata))); - echo "PHOTO;ENCODING=b;TYPE=JPEG:".preg_replace('/\n $/', '', $photodata)."\n"; - } - - /* Day of birth */ - if (isset($attrs['dayOfBirth'][0])){ - echo "BDAY:".$attrs['dayOfBirth'][0]."\n"; - } - - echo "END:VCARD\n\n"; -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/gosa-plugins/addressbook/html/getvcard.php b/gosa-plugins/addressbook/html/getvcard.php new file mode 100644 index 000000000..919f1b3b7 --- /dev/null +++ b/gosa-plugins/addressbook/html/getvcard.php @@ -0,0 +1,170 @@ +get_ldap_link(); +$ldap->cat(base64_decode(validate($_GET['dn']))); + +/* + * Generate vcard for specified IDs + */ +while ($attrs= $ldap->fetch()){ + /* Header / Name */ + echo "BEGIN:VCARD\n"; + echo "VERSION:3.0\n"; + echo "FN:".preg_replace('/,/', '\\,', $attrs['cn'][0])."\n"; + + /* Assemble titles for N attribute */ + $titles= ""; + if (isset($attrs['personalTitle'])){ + $titles= $attrs['personalTitle'][0]; + } + if (isset($attrs['academicTitle'])){ + if ($titles != ""){ + $titles.= ",".$attrs['academicTitle'][0]; + } else { + $titles= $attrs['academicTitle'][0]; + } + } + echo "N:".$attrs['sn'][0].";".$attrs['givenName'][0].";;;$titles\n"; + + /* Generate random UID */ + $uid= ""; + srand(make_seed()); + $chars= '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + for ($i= 0; $i<16; $i++){ + $uid.= $chars[rand(0, strlen($chars)-1)]; + } + echo "UID:$uid\n"; + + /* Mail addresses */ + if (isset($attrs['mail'][0])){ + echo "EMAIL;TYPE=internet,pref:".$attrs['mail'][0]."\n"; + if (isset($attrs['gosaMailAlternateAddress'])){ + for ($i= 0; $i<$attrs['gosaMailAlternateAddress']['count']; $i++){ + echo "EMAIL;TYPE=internet:". + $attrs['gosaMailAlternateAddress'][$i]."\n"; + } + } + } + + /* Export date */ + echo "REV:".date("Y-m-d")."\n"; + echo "CLASS:PUBLIC\n"; + + /* Fill address */ + if (isset($attrs['homePostalAddress'])){ + @list($street,$town,$country)= preg_split('/\n/', $attrs['homePostalAddress'][0]); + echo "ADR;TYPE=home:;;".trim($street).";".trim($town).";;;". + trim($country)."\n"; + } + if (isset($attrs['postalAddress'])){ + @list($street,$town,$country)= preg_split('/\n/', $attrs['postalAddress'][0]); + echo "ADR;TYPE=work,pref:;;".trim($street).";".trim($town).";;;". + trim($country)."\n"; + } + + /* Telephone numbers */ + if (isset($attrs['homePhone'])){ + echo "TEL;TYPE=home:".$attrs['homePhone'][0]."\n"; + } + if (isset($attrs['telephoneNumber'])){ + echo "TEL;TYPE=work,pref:".$attrs['telephoneNumber'][0]."\n"; + } + if (isset($attrs['mobile'])){ + echo "TEL;TYPE=cell:".$attrs['mobile'][0]."\n"; + } + if (isset($attrs['pager'])){ + echo "TEL;TYPE=pager:".$attrs['pager'][0]."\n"; + } + + /* Set organization */ + if (isset($attrs['o'])){ + echo "ORG:".$attrs['o'][0]."\n"; + } + + echo "NOTE:Exported by GOsa - https://gosa.gonicus.de\n"; + echo "SORT-STRING:".$attrs['sn'][0]."\n"; + if (isset($attrs['labeledURI'][0])){ + echo "URL:".$attrs['labeledURI'][0]."\n"; + } + + /* Add user certificate */ +#if (isset($attrs['userCertificate;binary'])){ +# $cert= $ldap->get_attribute($ldap->getDN(), "userCertificate;binary"); +# $cert= preg_replace('/\r\n/', chr(10).' ', chunk_split(base64_encode($cert))); +# echo "KEY;ENCODING=b:".preg_replace('/\n $/', '', $cert)."\n"; +#} + + /* Add picture */ + if (isset($attrs['jpegPhoto'])){ + $photodata= $ldap->get_attribute($ldap->getDN(), "jpegPhoto"); + $photodata= preg_replace('/\r\n/', chr(10).' ', chunk_split(base64_encode($photodata))); + echo "PHOTO;ENCODING=b;TYPE=JPEG:".preg_replace('/\n $/', '', $photodata)."\n"; + } + + /* Day of birth */ + if (isset($attrs['dayOfBirth'][0])){ + echo "BDAY:".$attrs['dayOfBirth'][0]."\n"; + } + + echo "END:VCARD\n\n"; +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?>