mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 00:54:15 +01:00
Add handling of zip file collections of .csv, .vcf, or .ldif files; Cleanup template and add lang calls for import instructions.
This commit is contained in:
parent
ca4fd40dd9
commit
9efb12491d
@ -133,7 +133,15 @@
|
||||
$contacts = new import_conv;
|
||||
|
||||
$buffer = $contacts->import_start_file($buffer);
|
||||
$fp = fopen($tsvfile,'r');
|
||||
|
||||
if($tsvfile['type'] == 'application/zip')
|
||||
{
|
||||
$fp = $this->unzip($tsvfile['tmp_name'],$contacts->type);
|
||||
}
|
||||
else
|
||||
{
|
||||
$fp = fopen($tsvfile['tmp_name'],'r');
|
||||
}
|
||||
if($contacts->type == 'csv')
|
||||
{
|
||||
while($data = fgetcsv($fp,8000,','))
|
||||
@ -269,6 +277,56 @@
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
/* Use the Zip extension to open a zip file, hopefully containing multiple .vcf files
|
||||
* Return a pointer to a temporary file that will then contain all files concatenated.
|
||||
*/
|
||||
function unzip($filename,$type)
|
||||
{
|
||||
$ext = '';
|
||||
switch($type)
|
||||
{
|
||||
case 'vcard':
|
||||
$ext = '.vcf';
|
||||
break;
|
||||
case 'csv':
|
||||
$ext = '.csv';
|
||||
break;
|
||||
case 'ldif':
|
||||
$ext = '.ldif';
|
||||
break;
|
||||
default:
|
||||
return False;
|
||||
}
|
||||
|
||||
/* Open the (uploaded) zip file */
|
||||
$zip = zip_open($filename);
|
||||
|
||||
$temp = tempnam('/tmp','zip2vcf');
|
||||
/* Open a temp file for read/write */
|
||||
$fp = fopen($temp, 'w+');
|
||||
|
||||
$out = '';
|
||||
/* Now read each entry in the zip file */
|
||||
while($dirent = zip_read($zip))
|
||||
{
|
||||
if(zip_entry_open($zip,$dirent,'r'))
|
||||
{
|
||||
//echo '<br>zip_entry_name==' . zip_entry_name($dirent);
|
||||
/* If an allowed extenstion based on conversion type */
|
||||
if(ereg($ext,zip_entry_name($dirent)))
|
||||
{
|
||||
/* Write the data to our temp file */
|
||||
$data = zip_entry_read($dirent,zip_entry_filesize($dirent));
|
||||
//echo $data;
|
||||
fwrite($fp,$data);
|
||||
}
|
||||
zip_entry_close($dirent);
|
||||
}
|
||||
}
|
||||
rewind($fp);
|
||||
return $fp;
|
||||
}
|
||||
|
||||
function export($conv_type,$cat_id='')
|
||||
{
|
||||
if($conv_type == 'none')
|
||||
|
@ -101,6 +101,7 @@
|
||||
$cat_id = get_var('cat_id','POST');
|
||||
$fcat_id = get_var('fcat_id','POST');
|
||||
$private = get_var('private','POST');
|
||||
$download = get_var('download','POST');
|
||||
|
||||
if($convert)
|
||||
{
|
||||
@ -115,11 +116,11 @@
|
||||
$GLOBALS['phpgw']->common->phpgw_footer();
|
||||
$GLOBALS['phpgw']->common->phpgw_exit();
|
||||
}
|
||||
$buffer = $this->bo->import($tsvfile['tmp_name'],$conv_type,$private,$fcat_id);
|
||||
$buffer = $this->bo->import($tsvfile,$conv_type,$private,$fcat_id);
|
||||
|
||||
if($download == '')
|
||||
{
|
||||
if($conv_type == 'Debug LDAP' || $conv_type == 'Debug SQL' )
|
||||
if($conv_type == 'Debug LDAP' || $conv_type == 'Debug SQL')
|
||||
{
|
||||
// filename, default application/octet-stream, length of file, default nocache True
|
||||
$GLOBALS['phpgw']->browser->content_header($tsvfilename,'',strlen($buffer));
|
||||
@ -189,6 +190,19 @@
|
||||
$this->template->set_var('filter',$this->filter);
|
||||
$this->template->set_var('query',$this->query);
|
||||
$this->template->set_var('cat_id',$this->cat_id);
|
||||
$this->template->set_var('lang_import_instructions',lang('import_instructions'));
|
||||
if(extension_loaded('zip'))
|
||||
{
|
||||
$this->template->set_var('zip_note',lang('zip_note'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->template->set_var('zip_note','');
|
||||
}
|
||||
$this->template->set_var('lang_exported_file',lang('enter the path to the exported file here'));
|
||||
$this->template->set_var('lang_conv_type',lang('select the type of conversion'));
|
||||
$this->template->set_var('lang_mark_priv',lang('Mark records as private'));
|
||||
$this->template->set_var('lang_debug',lang('Debug output in browser'));
|
||||
$this->template->pparse('out','import');
|
||||
}
|
||||
// $GLOBALS['phpgw']->common->phpgw_footer();
|
||||
|
@ -147,3 +147,9 @@ work phone addressbook en Work Phone
|
||||
you must select a vcard. (*.vcf) addressbook en You must select a vcard. (*.vcf)
|
||||
you must select at least 1 column to display addressbook en You must select at least 1 column to display
|
||||
zip code common en ZIP Code
|
||||
import_instructions addressbook en In Netscape, open the Addressbook and select <b>Export</b> from the <b>File</b> menu. The file exported will be in LDIF format.<p>Or, in Outlook, select your Contacts folder, select <b>Import and Export...</b> from the <b>File</b> menu and export your contacts into a comma separated text (CSV) file. <p>Or, in Palm Desktop 4.0 or greater, visit your addressbook and select <b>Export</b> from the <b>File</b> menu. The file exported will be in VCard format.
|
||||
zip_note addressbook en <p><b>Note:</b> The file may be a zip file collection of .csv, .vcf, or .ldif files. However, do not mix file types per import.
|
||||
enter the path to the exported file here addressbook en Enter the path to the exported file here
|
||||
select the type of conversion addressbook en Select the type of conversion
|
||||
mark records as private addressbook en Mark records as private
|
||||
debug output in browser addressbook en Debug output in browser
|
||||
|
@ -1,50 +1,45 @@
|
||||
|
||||
<!-- BEGIN import -->
|
||||
<CENTER>
|
||||
<TABLE WIDTH=90%>
|
||||
<TR BGCOLOR="{navbar_bg}">
|
||||
<TD><B><FONT SIZE=+2 COLOR="{navbar_text}"><CENTER>{import_text}</CENTER></FONT></B>
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
<TABLE WIDTH=85%>
|
||||
<TR>
|
||||
<TD><FORM ENCTYPE="multipart/form-data" action="{action_url}" method="post">
|
||||
<OL>
|
||||
<LI>In Netscape, open the Addressbook and select <b>Export</b> from the <b>File</b> menu.
|
||||
The file exported will be in LDIF format.
|
||||
<P>Or, in Outlook, select your Contacts folder, select <b>Import
|
||||
and Export...</b> from the <b>File</b>
|
||||
menu and export your contacts into a comma separated text (CSV) file.
|
||||
<P>Or, in Palm Desktop 4.0 or greater, visit your addressbook and select <b>Export</b> from the <b>File</b> menu.
|
||||
The file exported will be in VCard format.<P>
|
||||
</LI>
|
||||
<LI>Enter the path to the exported file here:
|
||||
<INPUT NAME="tsvfile" SIZE="48" TYPE="file" VALUE="{tsvfilename}"><P></LI>
|
||||
<LI>Select the type of conversion:
|
||||
<SELECT NAME="conv_type">
|
||||
<OPTION VALUE="none"><none></OPTION>
|
||||
<div align="center">
|
||||
<table width="90%">
|
||||
<tr bgcolor="{navbar_bg}">
|
||||
<th colspan="2"><b>{import_text}</b></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<table width="85%">
|
||||
<tr>
|
||||
<td><form enctype="multipart/form-data" action="{action_url}" method="post">
|
||||
<ol>
|
||||
<li>{lang_import_instructions}{zip_note}</li>
|
||||
<li>{lang_exported_file}
|
||||
<input name="tsvfile" size="48" type="file" value="{tsvfilename}"><p></li>
|
||||
<li>{lang_conv_type}:
|
||||
<select name="conv_type">
|
||||
<option value="none"><none></option>
|
||||
{conv}
|
||||
</SELECT><P></LI>
|
||||
<LI>{lang_cat}:{cat_link}</LI>
|
||||
<LI><INPUT NAME="private" TYPE="checkbox" VALUE="private" CHECKED>Mark records as private</LI>
|
||||
<LI><INPUT NAME="download" TYPE="checkbox" VALUE="{debug}" CHECKED>Debug output in browser</LI>
|
||||
<LI><INPUT NAME="convert" TYPE="submit" VALUE="{download}"></LI>
|
||||
</OL>
|
||||
</select><p></li>
|
||||
<li>{lang_cat}:{cat_link}</li>
|
||||
<li><input name="private" type="checkbox" value="private" checked>{lang_mark_priv}</li>
|
||||
<li><input name="download" type="checkbox" value="{debug}" checked>{lang_debug}</li>
|
||||
</ol>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="8%">
|
||||
<div align="left">
|
||||
<input name="convert" type="submit" value="{download}">
|
||||
</ol>
|
||||
<input type="hidden" name="sort" value="{sort}">
|
||||
<input type="hidden" name="order" value="{order}">
|
||||
<input type="hidden" name="filter" value="{filter}">
|
||||
<input type="hidden" name="query" value="{query}">
|
||||
<input type="hidden" name="start" value="{start}">
|
||||
</FORM></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</TD>
|
||||
</TR>
|
||||
<tr>
|
||||
</form>
|
||||
</td>
|
||||
<td width="8%">
|
||||
<div align="left">
|
||||
<form action="{cancel_url}" method="post">
|
||||
<input type="hidden" name="sort" value="{sort}">
|
||||
<input type="hidden" name="order" value="{order}">
|
||||
@ -58,6 +53,6 @@
|
||||
<td width="64%"> </td>
|
||||
<td width="32"> </td>
|
||||
</tr>
|
||||
</TABLE>
|
||||
</CENTER>
|
||||
</table>
|
||||
</div>
|
||||
<!-- END import -->
|
||||
|
Loading…
Reference in New Issue
Block a user