diff --git a/html/getxls.php b/html/getxls.php
index c8506ff11e49601facdaadaf9ee606af402eccfd..4e8096d6fbd10850f0d4905906b0ff9870395034 100644 (file)
--- a/html/getxls.php
+++ b/html/getxls.php
Copyright (C) 2003 Cajus Pollmeier
Copyright (C) 2005 Guillaume Delecourt
Copyright (C) 2005 Vincent Seynhaeve
Copyright (C) 2003 Cajus Pollmeier
Copyright (C) 2005 Guillaume Delecourt
Copyright (C) 2005 Vincent Seynhaeve
+ Copyright (C) 2005 Benoit Mortier
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
if($mode == 2){ // Single Entry Export !
$d = base64_decode($_GET['d']);
$n = base64_decode($_GET['n']);
if($mode == 2){ // Single Entry Export !
$d = base64_decode($_GET['d']);
$n = base64_decode($_GET['n']);
- // print_r($_GET);
$dn=$d.$n;
$dn=$d.$n;
- // echo $dn ;
+ $date=date('dS \of F Y ');
$fname = tempnam("/tmp", "demo.xls");
$workbook=& new writeexcel_workbook($fname);
$fname = tempnam("/tmp", "demo.xls");
$workbook=& new writeexcel_workbook($fname);
+ $title_title=& $workbook->addformat(array(
+ bold => 1,
+ color => 'green',
+ size => 11,
+ underline => 2,
+ font => 'Helvetica'
+ ));
+
$title_bold=& $workbook->addformat(array(
bold => 1,
color => 'black',
size => 10,
font => 'Helvetica'
));
$title_bold=& $workbook->addformat(array(
bold => 1,
color => 'black',
size => 10,
font => 'Helvetica'
));
+ # Create a format for the phone numbers
+ $f_phone =& $workbook->addformat();
+ $f_phone->set_align('left');
+ $f_phone->set_num_format('\0#');
switch ($d){
case "ou=people," :
$user= $ldap->gen_xls($dn,"(objectClass=*)",array("uid","dateOfBirth","gender","givenName","preferredLanguage"));
switch ($d){
case "ou=people," :
$user= $ldap->gen_xls($dn,"(objectClass=*)",array("uid","dateOfBirth","gender","givenName","preferredLanguage"));
- $intitul=array("Date de naissance:","Sexe:","Nom/prénom","Langue");
-
- $worksheet=& $workbook->addworksheet('Users');
- $worksheet->set_column('A:B', 32);
+ $intitul=array(_("Birthday").":", _("Sex").":", _("Surname")."/"._("Given name").":",_("Language").":");
+ //name of the xls file
+ $name_section=_("Users");
+
+ $worksheet=& $workbook->addworksheet(_("Users"));
+ $worksheet->set_column('A:B', 51);
$user_nbr=count($user);
$user_nbr=count($user);
- $r=1;
+ $worksheet->write('A1',sprintf(_("User list of %s on %s"),$n,$date),$title_title);
+ $r=3;
for($i=1;$i<$user_nbr;$i++)
{
if($i>1)
$worksheet->write('A'.$r++,"");
for($i=1;$i<$user_nbr;$i++)
{
if($i>1)
$worksheet->write('A'.$r++,"");
- $worksheet->write('A'.$r++,"uid : ".$user[$i][0],$title_bold);
+ $worksheet->write('A'.$r++,_("User ID").": ".$user[$i][0],$title_bold);
+
for($j=1;$j<5;$j++)
{
$r++;
$worksheet->write('A'.$r,$intitul[$j-1]);
for($j=1;$j<5;$j++)
{
$r++;
$worksheet->write('A'.$r,$intitul[$j-1]);
+ $user[$i][$j]=utf8_decode ($user[$i][$j]);
$worksheet->write('B'.$r,$user[$i][$j]);
}
$worksheet->write('A'.$r++,"");
$worksheet->write('B'.$r,$user[$i][$j]);
}
$worksheet->write('A'.$r++,"");
break;
case "ou=groups,": $groups= $ldap->gen_xls($dn,"(objectClass=*)",array("cn","memberUid"),TRUE,1);
break;
case "ou=groups,": $groups= $ldap->gen_xls($dn,"(objectClass=*)",array("cn","memberUid"),TRUE,1);
- $intitul=array("Membres:");
- $worksheet =& $workbook->addworksheet('Groups');
- $worksheet->set_column('A:B', 32);
+ $intitul=array(_("Members").":");
+
+ //name of the xls file
+ $name_section=_("Groups");
+
+ $worksheet =& $workbook->addworksheet(_("Groups"));
+ $worksheet->set_column('A:B', 51);
//count number of groups
$groups_nbr=count($groups);
//count number of groups
$groups_nbr=count($groups);
- $r=1;
+ $worksheet->write('A1', sprintf(_("Groups of %s on %s"), $n, $date),$title_title);
+ $r=3;
for($i=1;$i<$groups_nbr;$i++)
{
for($i=1;$i<$groups_nbr;$i++)
{
- $worksheet->write('A'.$r++,"uid : ".$groups[$i][0][0],$title_bold);
+ $worksheet->write('A'.$r++,_("User ID").": ".$groups[$i][0][0],$title_bold);
for($j=1;$j<=2;$j++)
{
$r++;
for($j=1;$j<=2;$j++)
{
$r++;
break;
case "ou=computers,": $computers= $ldap->gen_xls($dn,"(objectClass=*)",array("cn","description","uid"));
break;
case "ou=computers,": $computers= $ldap->gen_xls($dn,"(objectClass=*)",array("cn","description","uid"));
- $intitul=array("Description:","Uid:");
- $worksheet =& $workbook->addworksheet('Computers');
+ $intitul=array(_("Description").":",_("User ID").":");
+ $worksheet =& $workbook->addworksheet(_("Computers"));
$worksheet->set_column('A:B', 32);
$worksheet->set_column('A:B', 32);
-
//count number of computers
$computers_nbr=count($computers);
$r=1;
//count number of computers
$computers_nbr=count($computers);
$r=1;
{
if($i>1)
$worksheet->write('A'.$r++,"");
{
if($i>1)
$worksheet->write('A'.$r++,"");
- $worksheet->write('A'.$r++,"cn : ".$computers[$i][0],$title_bold);
+ $worksheet->write('A'.$r++,_("Common name").": ".$computers[$i][0],$title_bold);
for($j=1;$j<3;$j++)
{
$r++;
$worksheet->write('A'.$r,$intitul[$j-1]);
for($j=1;$j<3;$j++)
{
$r++;
$worksheet->write('A'.$r,$intitul[$j-1]);
+ $computers[$i][$j]=utf8_decode ($computers[$i][$j]);
$worksheet->write('B'.$r,$computers[$i][$j]);
}
$worksheet->write('A'.$r++,"");
$worksheet->write('B'.$r,$computers[$i][$j]);
}
$worksheet->write('A'.$r++,"");
break;
case "ou=servers,ou=systems,": $servers= $ldap->gen_xls($dn,"(objectClass=*)",array("cn"));
break;
case "ou=servers,ou=systems,": $servers= $ldap->gen_xls($dn,"(objectClass=*)",array("cn"));
- $intitul=array("cn:");
+ $intitul=array(_("Server name").":");
- $worksheet =& $workbook->addworksheet('Servers');
- $worksheet->set_column('A:B', 32);
+ //name of the xls file
+ $name_section=_("Servers");
+
+ $worksheet =& $workbook->addworksheet(_("Servers"));
+ $worksheet->set_column('A:B', 51);
//count number of servers
$servers_nbr=count($servers);
//count number of servers
$servers_nbr=count($servers);
- $r=1;
- $worksheet->write('A'.$r++,"Servers : ",$title_bold);
+ $worksheet->write('A1',sprintf(_("Servers of %s on %s"), $n, $date),$title_title);
+ $r=3;
+ $worksheet->write('A'.$r++,_("Servers").": ",$title_bold);
for($i=1;$i<$servers_nbr;$i++)
{
for($j=0;$j<1;$j++)
{
$r++;
$worksheet->write('A'.$r,$intitul[$j]);
for($i=1;$i<$servers_nbr;$i++)
{
for($j=0;$j<1;$j++)
{
$r++;
$worksheet->write('A'.$r,$intitul[$j]);
+ $servers[$i][$j]=utf8_decode ($servers[$i][$j]);
$worksheet->write('B'.$r,$servers[$i][$j]);
}
}
$worksheet->write('B'.$r,$servers[$i][$j]);
}
}
case "dc=addressbook,": //data about addressbook
$address= $ldap->gen_xls($dn,"(objectClass=*)",array("cn","displayName","facsimileTelephoneNumber","givenName","homePhone","homePostalAddress","initials","l","mail","mobile","o","ou","pager","telephoneNumber","postalAddress","postalCode","sn","st","title"));
case "dc=addressbook,": //data about addressbook
$address= $ldap->gen_xls($dn,"(objectClass=*)",array("cn","displayName","facsimileTelephoneNumber","givenName","homePhone","homePostalAddress","initials","l","mail","mobile","o","ou","pager","telephoneNumber","postalAddress","postalCode","sn","st","title"));
- $intitul=array("cn","DisplayName:","Fax:","Nom/prénom:","Numero de telelphone:","Adresse du domicile:","Initiales:","Ville:","Adresse email:","GSM:","Societe:","Poste:","Pager:","Numero de telelphone:","Adresse:","Code postal:","Sn:","Pays:","Fonction:");
+ $intitul=array(_("Common name").":",_("Display name").":",_("Fax").":",_("Name")."/"._("Given name").":",_("Home phone").":",_("Home postal address").":",_("Initials").":",_("Location").":",_("Mail address").":",_("Mobile phone").":",_("City").":",_("Postal address").":",_("Pager").":",_("Phone number").":",_("Address").":",_("Postal code").":",_("Surname").":",_("State").":",_("Function").":");
+
+ //name of the xls file
+ $name_section=_("Adressbook");
- $worksheet =& $workbook->addworksheet('Servers');
- $worksheet->set_column('A:B', 32);
+ $worksheet =& $workbook->addworksheet(_("Servers"));
+ $worksheet->set_column('A:B', 51);
//count number of entries
$address_nbr=count($address);
//count number of entries
$address_nbr=count($address);
- $r=1;
+ $worksheet->write('A1',sprintf(_("Adressbook of %s on %s"),$n, $date),$title_title);
+ $r=3;
for($i=1;$i<$address_nbr;$i++)
{
if($i>1)
$worksheet->write('A'.$r++,"");
for($i=1;$i<$address_nbr;$i++)
{
if($i>1)
$worksheet->write('A'.$r++,"");
- $worksheet->write('A'.$r++,"cn : ".$address[$i][0],$title_bold);
+ $worksheet->write('A'.$r++,_("Common Name").": ".$address[$i][0],$title_bold);
for($j=1;$j<19;$j++)
{
$r++;
$worksheet->write('A'.$r,$intitul[$j]);
for($j=1;$j<19;$j++)
{
$r++;
$worksheet->write('A'.$r,$intitul[$j]);
- $worksheet->write('B'.$r,$address[$i][$j]);
+ $address[$i][$j]=utf8_decode ($address[$i][$j]);
+ $worksheet->write('B'.$r,$address[$i][$j],$f_phone);
}
$worksheet->write('A'.$r++,"");
}
}
$worksheet->write('A'.$r++,"");
}
header('Content-type: application/x-msexcel');
// It will be called demo.xls
header('Content-type: application/x-msexcel');
// It will be called demo.xls
- header('Content-Disposition: attachment; filename="demo.xls"');
+ header('Content-Disposition: attachment; filename='.$name_section.".xls");
// The source is in original.xls
readfile($fname);
// The source is in original.xls
readfile($fname);
-
+ unlink ($fname);
}
elseif($mode == 3){ // Full Export !
$dn = base64_decode($_GET['dn']);
//data about users
$user= $ldap->gen_xls("ou=people,".$dn,"(objectClass=*)",array("uid","dateOfBirth","gender","givenName","preferredLanguage"));
}
elseif($mode == 3){ // Full Export !
$dn = base64_decode($_GET['dn']);
//data about users
$user= $ldap->gen_xls("ou=people,".$dn,"(objectClass=*)",array("uid","dateOfBirth","gender","givenName","preferredLanguage"));
- $user_intitul=array("Date de naissance:","Sexe:","Nom/prénom","Langue");
+ $user_intitul=array(_("Day of birth").":",_("Sex").":",_("Surname")."/"._("Given name").":",_("Language").":");
//data about groups
$groups= $ldap->gen_xls("ou=groups,".$dn,"(objectClass=*)",array("cn","memberUid"),TRUE,1);
//data about groups
$groups= $ldap->gen_xls("ou=groups,".$dn,"(objectClass=*)",array("cn","memberUid"),TRUE,1);
- $groups_intitul=array("Membres:");
+ $groups_intitul=array(_("Members").":");
//data about computers
$computers= $ldap->gen_xls("ou=computers,".$dn,"(objectClass=*)",array("cn","description","uid"));
//data about computers
$computers= $ldap->gen_xls("ou=computers,".$dn,"(objectClass=*)",array("cn","description","uid"));
- $computers_intitul=array("Description:","Uid:");
+ $computers_intitul=array(_("Description").":",_("UID").":");
//data about servers
$servers= $ldap->gen_xls("ou=servers,ou=systems,".$dn,"(objectClass=*)",array("cn"));
//data about servers
$servers= $ldap->gen_xls("ou=servers,ou=systems,".$dn,"(objectClass=*)",array("cn"));
- $servers_intitul=array("cn:");
+ $servers_intitul=array(_("Name").":");
//data about addressbook
$address= $ldap->gen_xls("dc=addressbook,".$dn,"(objectClass=*)",array("cn","displayName","facsimileTelephoneNumber","givenName","homePhone","homePostalAddress","initials","l","mail","mobile","o","ou","pager","telephoneNumber","postalAddress","postalCode","sn","st","title"));
//data about addressbook
$address= $ldap->gen_xls("dc=addressbook,".$dn,"(objectClass=*)",array("cn","displayName","facsimileTelephoneNumber","givenName","homePhone","homePostalAddress","initials","l","mail","mobile","o","ou","pager","telephoneNumber","postalAddress","postalCode","sn","st","title"));
- $address_intitul=array("cn","DisplayName:","Fax:","Nom/prénom:","Numero de telelphone:","Adresse du domicile:","Initiales:","Ville:","Adresse email:","GSM:","Societe:","Poste:","Pager:","Numero de telelphone:","Adresse:","Code postal:","Sn:","Pays:","Fonction:");
-
+ $address_intitul=array("cn",_("Display name").":",_("Fax").":",_("Surname")."/"._("Given name").":",_("Phone number").":",_("Postal address").":",_("Initials").":",_("City").":",_("Email address").":",_("Mobile").":",_("Organization").":",_("Organizational unit").":",_("Pager").":",_("Phone number").":",_("Postal address").":",_("Postal Code").":",_("Surename").":",_("State").":",_("Title").":");
+ //name of the xls file
+ $name_section=_("Full");
+ $date=date('dS \of F Y ');
$fname = tempnam("/tmp", "demo.xls");
$workbook =& new writeexcel_workbook($fname);
$fname = tempnam("/tmp", "demo.xls");
$workbook =& new writeexcel_workbook($fname);
- $worksheet =& $workbook->addworksheet('Users');
- $worksheet2 =& $workbook->addworksheet('Groups');
- $worksheet3 =& $workbook->addworksheet('Servers');
- $worksheet4 =& $workbook->addworksheet('Computers');
- $worksheet5 =& $workbook->addworksheet('Adressbook');
-
- $worksheet->set_column('A:B', 32);
- $worksheet2->set_column('A:B', 32);
- $worksheet3->set_column('A:B', 32);
- $worksheet4->set_column('A:B', 32);
- $worksheet5->set_column('A:B', 32);
+ $worksheet =& $workbook->addworksheet(_("Users"));
+ $worksheet2 =& $workbook->addworksheet(_("Groups"));
+ $worksheet3 =& $workbook->addworksheet(_("Servers"));
+ $worksheet4 =& $workbook->addworksheet(_("Computers"));
+ $worksheet5 =& $workbook->addworksheet(_("Adressbook"));
+
+ $worksheet->set_column('A:B', 51);
+ $worksheet2->set_column('A:B', 51);
+ $worksheet3->set_column('A:B', 51);
+ $worksheet4->set_column('A:B', 51);
+ $worksheet5->set_column('A:B', 51);
+
+ $title_title=& $workbook->addformat(array(
+ bold => 1,
+ color => 'green',
+ size => 11,
+ font => 'Helvetica'
+ ));
$title_bold =& $workbook->addformat(array(
bold => 1,
$title_bold =& $workbook->addformat(array(
bold => 1,
font => 'Helvetica'
));
font => 'Helvetica'
));
+ # Create a format for the phone numbers
+ $f_phone =& $workbook->addformat();
+ $f_phone->set_align('left');
+ $f_phone->set_num_format('\0#');
//count number of users
$user_nbr=count($user);
//count number of users
$user_nbr=count($user);
- $r=1;
+ $worksheet->write('A1',sprintf(_("User List of %s on %s"), $dn, $date),$title_title);
+ $r=3;
for($i=1;$i<$user_nbr;$i++)
{
if($i>1)
$worksheet->write('A'.$r++,"");
for($i=1;$i<$user_nbr;$i++)
{
if($i>1)
$worksheet->write('A'.$r++,"");
- $worksheet->write('A'.$r++,"uid : ".$user[$i][0],$title_bold);
+ $worksheet->write('A'.$r++,_("User ID").": ".$user[$i][0],$title_bold);
for($j=1;$j<5;$j++)
{
$r++;
$worksheet->write('A'.$r,$user_intitul[$j-1]);
for($j=1;$j<5;$j++)
{
$r++;
$worksheet->write('A'.$r,$user_intitul[$j-1]);
+ $user[$i][$j]=utf8_decode ($user[$i][$j]);
$worksheet->write('B'.$r,$user[$i][$j]);
}
$worksheet->write('A'.$r++,"");
$worksheet->write('B'.$r,$user[$i][$j]);
}
$worksheet->write('A'.$r++,"");
//count number of groups
$groups_nbr=count($groups);
//count number of groups
$groups_nbr=count($groups);
- $r=1;
+ $worksheet2->write('A1',sprintf(_("Groups of %s on %s"), $dn, $date),$title_title);
+ $r=3;
for($i=1;$i<$groups_nbr;$i++)
{
for($i=1;$i<$groups_nbr;$i++)
{
- $worksheet2->write('A'.$r++,"uid : ".$groups[$i][0][0],$title_bold);
+ $worksheet2->write('A'.$r++,_("User ID").": ".$groups[$i][0][0],$title_bold);
for($j=1;$j<=2;$j++)
{
$r++;
for($j=1;$j<=2;$j++)
{
$r++;
//count number of servers
$servers_nbr=count($servers);
//count number of servers
$servers_nbr=count($servers);
- $r=1;
- $worksheet3->write('A'.$r++,"Servers : ",$title_bold);
+ $worksheet3->write('A1',sprintf(_("Servers of %s on %s"),$dn,$date),$title_title);
+ $r=3;
+ $worksheet3->write('A'.$r++,_("Servers").": ",$title_bold);
for($i=1;$i<$servers_nbr;$i++)
{
for($j=0;$j<1;$j++)
{
$r++;
$worksheet3->write('A'.$r,$servers_intitul[$j]);
for($i=1;$i<$servers_nbr;$i++)
{
for($j=0;$j<1;$j++)
{
$r++;
$worksheet3->write('A'.$r,$servers_intitul[$j]);
+ $servers[$i][$j]=utf8_decode ($servers[$i][$j]);
$worksheet3->write('B'.$r,$servers[$i][$j]);
}
}
//count number of computers
$computers_nbr=count($computers);
$worksheet3->write('B'.$r,$servers[$i][$j]);
}
}
//count number of computers
$computers_nbr=count($computers);
- $r=1;
+ $worksheet4->write('A1',sprintf(_("Computers of %s on %s"),$dn,$date),$title_title);
+ $r=3;
for($i=1;$i<$computers_nbr;$i++)
{
if($i>1)
$worksheet->write('A'.$r++,"");
for($i=1;$i<$computers_nbr;$i++)
{
if($i>1)
$worksheet->write('A'.$r++,"");
- $worksheet4->write('A'.$r++,"cn : ".$computers[$i][0],$title_bold);
+ $worksheet4->write('A'.$r++,_("Common name").": ".$computers[$i][0],$title_bold);
for($j=1;$j<3;$j++)
{
$r++;
$worksheet4->write('A'.$r,$computers_intitul[$j-1]);
for($j=1;$j<3;$j++)
{
$r++;
$worksheet4->write('A'.$r,$computers_intitul[$j-1]);
+ $computers[$i][$j]=utf8_decode ($computers[$i][$j]);
$worksheet4->write('B'.$r,$computers[$i][$j]);
}
$worksheet4->write('A'.$r++,"");
$worksheet4->write('B'.$r,$computers[$i][$j]);
}
$worksheet4->write('A'.$r++,"");
//count number of entries
$address_nbr=count($address);
//count number of entries
$address_nbr=count($address);
- $r=1;
+ $worksheet5->write('A1',sprintf(_("Adressbook of %s on %s"),$dn, $date),$title_title);
+
+ $r=3;
for($i=1;$i<$address_nbr;$i++)
{
if($i>1)
$worksheet5->write('A'.$r++,"");
for($i=1;$i<$address_nbr;$i++)
{
if($i>1)
$worksheet5->write('A'.$r++,"");
- $worksheet5->write('A'.$r++,"cn : ".$address[$i][0],$title_bold);
+ $worksheet5->write('A'.$r++,_("Common name").": ".$address[$i][0],$title_bold);
for($j=1;$j<19;$j++)
{
$r++;
$worksheet5->write('A'.$r,$address_intitul[$j]);
for($j=1;$j<19;$j++)
{
$r++;
$worksheet5->write('A'.$r,$address_intitul[$j]);
- $worksheet5->write('B'.$r,$address[$i][$j]);
+ $address[$i][$j]=utf8_decode ($address[$i][$j]);
+ $worksheet5->write('B'.$r,$address[$i][$j],$f_phone);
}
$worksheet5->write('A'.$r++,"");
}
}
$worksheet5->write('A'.$r++,"");
}
header('Content-type: application/x-msexcel');
// It will be called demo.xls
header('Content-type: application/x-msexcel');
// It will be called demo.xls
- header('Content-Disposition: attachment; filename="demo.xls"');
+ header('Content-Disposition: attachment; filename='.$name_section.".xls");
- // The PDF source is in original.xl
readfile($fname);
readfile($fname);
+ unlink ($fname);
}
elseif($mode == 4){ // IVBB LDIF Export
$dn = base64_decode($_GET['dn']);
}
elseif($mode == 4){ // IVBB LDIF Export
$dn = base64_decode($_GET['dn']);
- /*$display= $ldap->gen_ldif($dn,"(objectClass=ivbbEntry)",array(
+ /*$display= $ldap->gen_ldif($dn,"(objectClass=ivbbentry)",array(
"GouvernmentOrganizationalUnit","houseIdentifier","vocation",
"ivbbLastDeliveryCollective","gouvernmentOrganizationalPersonLocality",
"gouvernmentOrganizationalUnitDescription","gouvernmentOrganizationalUnitSubjectArea",
"GouvernmentOrganizationalUnit","houseIdentifier","vocation",
"ivbbLastDeliveryCollective","gouvernmentOrganizationalPersonLocality",
"gouvernmentOrganizationalUnitDescription","gouvernmentOrganizationalUnitSubjectArea",