RoundCube Webmail Forum  

Go Back   RoundCube Webmail Forum > Third Party Contributions > Old Style Plug-Ins

For more information about the ads and why they're here, please see the FAQ

Reply
  2 links from elsewhere to this Post. Click to view. #1  
Old 11-10-2007, 04:34 PM
Registered User
 
Join Date: May 2007
Posts: 6
Default Import .CSV Address Book

Hi users,

I've enjoyed using roundcube for over a year now, and it's been a great tool. If you're like me, with 1000+ contacts, adding contacts manually to an address book was not something I was up for.

So here's a quick patch I've made, to handle .csv uploads, and adding contacts to the database

This patch is based on 0.1rc1 not the newer 0.2 version (released Nov/07). I cannot guarantee it'll work on the new version.

The patch creates a new directory csv_upload in the root of the RC installation - I know this is not common practice, but it makes updating the rest of the program much easier.

I noticed a recent post on here for uploading .csv files server-side and doing one-off address book updates, but here's a glorified version, which will do the following:
  • Handles file upload
  • Checks columns for correct data
  • Adds NEW contacts to the database
  • Old (already inserted) contacts are ignored
  • Interface is all via one additional link on the 'address book' page

Todo:
  • Use RC-approved methods of including files
  • Change add-on's folder structure
  • Secure the uploading of .csv files. Temp files are currently held one at a time, at $_server_root/imported.csv
  • Link to the uploading interface via one of the buttons, as opposed to a static link


Download the patch at http://www.rmacd.com/downloads/howto...cube-csv.patch
Download .tar.gz http://www.rmacd.com/downloads/howto...rc1-CSV.tar.gz

If anyone would like to contribute to this little add-on, please let me know. My email address is ronald@rmacd.com.

Address Book Page Preview:


Upload Interface Preview


________________________
Ronald MacDonald
ronald@rmacd.com
www.rmacd.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2  
Old 11-11-2007, 10:42 AM
Registered User
 
Join Date: Nov 2007
Posts: 4
Default Re: Import .CSV Address Book

I tried installing your script on RC2 manually (copied files and modified theme).

As I am on a shared host I modified
uploader.php
$system_temp and $csvTempFile to link to roundcubes temp dir. However when I upload I get this error:
Quote:
Warning: move_uploaded_file(/home/***/webmail/temp/import.csv) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/***/public_html/webmail/csv_upload/uploader.php on line 30

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpYS6161' to '/home/***/webmail/temp/import.csv' in /home/***/public_html/webmail/csv_upload/uploader.php on line 30
I tried to look through the code but I cannot figure out where /tmp/phpYS6161 comes from...
Couldn't you include the roundcube configuration and then use the built in temp dir?

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3  
Old 11-11-2007, 10:50 AM
Registered User
 
Join Date: Oct 2006
Posts: 84
Default Re: Import .CSV Address Book


Maybe you can upload this patch to the bugtracker as type PATCH...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4  
Old 11-11-2007, 11:39 AM
Registered User
 
Join Date: May 2007
Posts: 6
Default Re: Import .CSV Address Book

Hi there,

Quote:
Originally Posted by wormie_dk
I tried installing your script on RC2 manually (copied files and modified theme).

As I am on a shared host I modified
uploader.php
$system_temp and $csvTempFile to link to roundcubes temp dir. However when I upload I get this error:
Quote:
Warning: move_uploaded_file(/home/***/webmail/temp/import.csv) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/***/public_html/webmail/csv_upload/uploader.php on line 30

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpYS6161' to '/home/***/webmail/temp/import.csv' in /home/***/public_html/webmail/csv_upload/uploader.php on line 30
I tried to look through the code but I cannot figure out where /tmp/phpYS6161 comes from...
Couldn't you include the roundcube configuration and then use the built in temp dir?

Thanks

You'll see that on line 28 of uploader.php, the /tmp/phpYS6161 comes from
Code:
ini_get("session.save_path");
This variable is set by your web host, and if you wish to use a different directory (shared hosting, for example), you'll need to change this to your RC temp directory. In this case you should change the line
Code:
$system_temp = ini_get("session.save_path");
to
Code:
$system_temp = "/path/to/your/roundcube/temp";

Quote:
Originally Posted by seansan
Maybe you can upload this patch to the bugtracker as type PATCH...
It's a good idea - I'll look at this once the plug-in is a little more developed!

Kind regards,
Ronald.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5  
Old 11-11-2007, 12:37 PM
Registered User
 
Join Date: Nov 2007
Posts: 4
Default Re: Import .CSV Address Book

[quoute]
You'll see that on line 28 of uploader.php, the /tmp/phpYS6161 comes from
[/quote]
But I already changed line 28 to:
$system_temp = '/home/***/webmail/temp';

Which I why I wonder where uploader gets the /tmp/phpYS6161 from...

But probably any form submitted with a file parameter gets uploaded to the session dir... Maybe I should try to copy the file instead of moving

EDIT: DOH DOH DOH: I forgot the public_html part of the path... Now that part works but the includes in inseter.php are giinclude/rcube_shared.inc are giving me a hard time. E.g require_once('include/rcube_shared.inc') does not work. Should the csv_upload files be in rcdir/program?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6  
Old 11-11-2007, 01:33 PM
Registered User
 
Join Date: May 2007
Posts: 6
Default Re: Import .CSV Address Book

Quote:
Originally Posted by wormie_dk
Now that part works but the includes in inseter.php are giinclude/rcube_shared.inc are giving me a hard time. E.g require_once('include/rcube_shared.inc') does not work. Should the csv_upload files be in rcdir/program?
No,

if you applied the patch, as-is, then the csv_upload folder is in the *root* of the RC installation

thus the path for uploader.php is

/path/to/rc/installation/csv_upload/uploader.php

Kind regards,
Ronald.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7  
Old 03-14-2008, 08:19 PM
Registered User
 
Join Date: Mar 2008
Posts: 14
Default Re: Import .CSV Address Book

Any word on this being added into a release?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8  
Old 04-06-2008, 07:40 PM
Registered User
 
Join Date: Apr 2008
Posts: 26
Default Re: Import .CSV Address Book

(Attachment removed - I have created a newer cleaner version with some bug fixes that I will upload shortly)

I have re-written this patch and also updated it for 0.1 final. It is now more fully integrated into the roundcube UI and hopefully slightly cleaner.

It gives you the ability to import address book contacts from a CSV file. The format of the CSV file should be as follows:

Code:
Name,Email Address
name1,name1@example.com
name2,name2@example.com
In later versions I will make this more flexible, but for now the CSV file you wish to import MUST be of that format (including the header line!).

The following patch applies cleanly against a fresh install of 0.1 final. Note: the new labels only work for en_US localization at the moment.

To install it, copy the patch to your roundcube installation directory, then "cd" to that directory. Then run the following command:

patch -p1 < roundcube_csv_v2.patch.txt

The following five files are patched:

index.php
program/js/app.js
program/localization/en_US/labels.inc
skins/default/addresses.css
skins/default/templates/addressbook.html

And the following two files are created:

program/steps/addressbook/uploadcsv.inc
skins/default/templates/uploadcsv.html

Please give feedback in this thread.

Best
Chris
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9  
Old 04-11-2008, 12:26 PM
Registered User
 
Join Date: Apr 2008
Posts: 5
Default Re: Import .CSV Address Book

Hi,
This sounds really nice. Many of my users are requesting a feature like this. A few questions though:

1. Do you have some screenshots of how it looks?

2. Does this port to any language, or just en_US? If not, how can I install this patch in another language?

Thanks!
/Marcus
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10  
Old 04-11-2008, 12:33 PM
Registered User
 
Join Date: Apr 2008
Posts: 26
Default Re: Import .CSV Address Book

Hi

I will provide some screenshots shortly, I also deleted the attachment above because I have made some big changes recently and I would advise people to use my newer file which I will upload when I get back home.

You could easily port it to any language, it would be a simple case of adding a couple of lines to the relevant file, I'll show you how to do this or you can provide translations that I will include in the patch.

I'll post again soon with the updated version and screenshots.

Chris
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


LinkBacks (?)
LinkBack to this Thread: http://www.roundcubeforum.net/7-third-party-contributions/25-old-style-plug-ins/2281-import-csv-address-book.html
Posted By For Type Date
#1485067 (Import contacts from .csv or other file) ? RoundCube Webmail ? Trac This thread Refback 09-13-2008 01:39 PM
#1326103 (Import Contacts) ? RoundCube Webmail ? Trac This thread Refback 09-12-2008 05:46 PM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 03:25 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Copyright © 2006-2008 RoundCube Webmail Community