Roundcube Community Forum

Third Party Contributions => Old Style Plug-Ins => Topic started by: ronald on November 10, 2007, 12:34:31 PM

Title: Import .CSV Address Book
Post by: ronald on November 10, 2007, 12:34:31 PM
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:


Todo:


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

Title: Re: Import .CSV Address Book
Post by: wormie_dk on November 11, 2007, 06:42:20 AM
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
Title: Re: Import .CSV Address Book
Post by: seansan on November 11, 2007, 06:50:23 AM

Maybe you can upload this patch to the bugtracker as type PATCH...
Title: Re: Import .CSV Address Book
Post by: ronald on November 11, 2007, 07:39:09 AM
Hi there,

Quote from: 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: [Select]
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: [Select]
$system_temp = ini_get("session.save_path");to
Code: [Select]
$system_temp = "/path/to/your/roundcube/temp";

Quote from: 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!

Title: Re: Import .CSV Address Book
Post by: wormie_dk on November 11, 2007, 08:37:58 AM
[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?
Title: Re: Import .CSV Address Book
Post by: ronald on November 11, 2007, 09:33:43 AM
Quote from: 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

Title: Re: Import .CSV Address Book
Post by: lostmatt on March 14, 2008, 05:19:40 PM
Any word on this being added into a release?
Title: Re: Import .CSV Address Book
Post by: BlueC on April 06, 2008, 03:40:59 PM
(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: [Select]
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
Title: Re: Import .CSV Address Book
Post by: marcuseide on April 11, 2008, 08:26:33 AM
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
Title: Re: Import .CSV Address Book
Post by: BlueC on April 11, 2008, 08:33:38 AM
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
Title: Re: Import .CSV Address Book
Post by: BlueC on April 12, 2008, 07:17:42 AM
Right, here's some screenshots and an updated tarball containing patches for RC 0.1 and RC0.1.1

Read the enclosed readme.txt for installation instructions, but it's basically as simple as

Code: [Select]
patch -p1 < roundcube-import-contacts-0.3-RC<version>.patch
where is either 0.1 or 0.1.1 depending on your RC version.

If you want to add different localizations then just add translations of the following strings to the labels.inc file in the localization that you desire. If anyone can provide translations that I can include then please post them here.

Code: [Select]
$labels['importcontacts'] = 'Import Contacts';
$labels['confirm'] = 'Confirm';
$labels['confirmimportcsv'] = 'This is a sample set of the data you uploaded. Please confirm that the headers correspond to the correct columns and press Confirm. If they don\'t then please press cancel, change your file, and re-upload it.';
$labels['instructimportcsv'] = 'Use the form below to import contacts from a CSV file.';

Enjoy!
Chris
Title: Re: Import .CSV Address Book
Post by: pagedeveloping on April 12, 2008, 01:50:46 PM
Hello,

This is a greate plugin thank you. I have patched the stable version and all works well within firefox.
On IE7 the icon is faded out and will not allow you to use the import function. Could this perhaps be something inside the .css file that IE7 is unable to recognize?

Regards,
Title: Re: Import .CSV Address Book
Post by: BlueC on April 12, 2008, 02:35:36 PM
Hi, thanks for testing it and for the feedback

I had not thought to test it outside of firefox! It is a javscript problem that you describe (not CSS)... I have an idea of where and how to fix it but it may be tomorrow before I get chance. I'll post back here when I do.
Title: Re: Import .CSV Address Book
Post by: BlueC on April 13, 2008, 08:53:29 AM
pagedeveloping, I had a look at this and couldn't reproduce the problem in IE6 (I don't have IE7 to hand right now). However, could you please try forcing a refresh of the cache in IE7 (is it CTRL + F5?) and see if that solves the problem? It may be that your browser hasn't refreshed the app.js file from roundcube.
Title: Re: Import .CSV Address Book
Post by: pagedeveloping on April 13, 2008, 02:22:09 PM
Quote from: BlueC
pagedeveloping, I had a look at this and couldn't reproduce the problem in IE6 (I don't have IE7 to hand right now). However, could you please try forcing a refresh of the cache in IE7 (is it CTRL + F5?) and see if that solves the problem? It may be that your browser hasn't refreshed the app.js file from roundcube.

Thanks! :D Worked like a charm. Just to let you know I have updated to the latest RC0.1.1 and applied your 1.1 patch and it is working greate.

Peter
Title: Re: Import .CSV Address Book
Post by: BlueC on April 13, 2008, 03:14:09 PM
Great, glad to know its working for you.

In a future release I intend to make the import file format a little more flexible (e.g. allow user mapping of fields), but at the moment it suits my simple needs so unless there is a call for it I may not get round to it in the near future.

If anyone else has any feedback or suggestions please post here.
Title: Re: Import .CSV Address Book
Post by: marcuseide on April 15, 2008, 08:30:57 AM
Works like a charm. Thank you very much!
Title: Re: Import .CSV Address Book
Post by: cbrace on April 19, 2008, 08:38:03 AM
A very big thanks, this is very helpful; I just imported around 400 addresses from gmail.

Probably unrelated to the plugin, but... when I try to modify an entry, I get an error message:

Quote
SERVICE CURRENTLY NOT AVAILABLE!

Error No. [0x01F4]
Any ideas what is going on here?
Title: Re: Import .CSV Address Book
Post by: BlueC on April 19, 2008, 10:37:07 AM
Don't know, but its unrelated to this mod AFAIK.
Title: Patch?
Post by: carldevans on May 07, 2008, 11:26:14 PM
OK, I'm totally trying to figure out how to install a patch.  Do you install it locally or by ftp after you upload it?  Where do you type the "patch -p1..." command!?
Title: Import .CSV Address Book
Post by: paszczus on May 13, 2008, 04:24:50 AM
Hello,
it seems to be a great plugin and that`s really nice that is in patch, but i have problem. I got svn version od 0.1.1 (from yesterday) and patched succesfully but when i click on Address book and then "import contact" it open new "address book" window near first one and then when i click again import in new address book it fork to another, and another...

Any ideas how to fix it ?

Thanks
Title: italian translation
Post by: dikdust on May 30, 2008, 07:31:45 AM
Quote from: BlueC;11489
...

If you want to add different localizations then just add translations of the following strings to the labels.inc file in the localization that you desire. If anyone can provide translations that I can include then please post them here.
...


For the italians like me here's the translation ;)

Gj anyway this patch has saved my life :D


$labels['importcontacts'] = 'Importa Contatti';
$labels['confirm'] = 'Conferma';
$labels['confirmimportcsv'] = 'Questo è un esempio dei dai che hai uploadato. Per favore controlla che le intestazioni corrispondano alle colonne corrette e premi Conferma. Se non corrispondono premi Annulla, modifica il file csv e riuploadalo.';
$labels['instructimportcsv'] = 'Usa il form qui di seguito per importare i contatti da un file CSV.';
Title: Problem when run on rc 0.1.1
Post by: Scubes13 on June 26, 2008, 03:24:29 PM
I am using RC 0.1.1

I ran the patch for 0.1.1 from the root of the RC install. It ran without any errors.

I logged into a specific account, went to addressbook, clicked on the import button.

From there, I select my csv file, then click upload.

I was then presented with the screen where I was supposed to see a sample of the data to be imported, but I do not see any info at all.

I checked my temp/ directory and the file is uploaded as a "rcmAttmnt(randomstringhere)" file.

When I take a peek in that file, I see my csv content as expected.

Code: [Select]

Name,Email Address
John Doe,jdoe@yourdomain.org
Jane Smith,jsmith@yourdomain.org
Jesse James,jjames@yourdomain.org


Any thoughts?

Thanks,
Scubes
Title: Import .CSV Address Book
Post by: Scubes13 on July 07, 2008, 12:15:08 PM
Anyone? I am still unable to import contacts.
Title: Import .CSV Address Book
Post by: zippy on July 18, 2008, 12:07:41 AM
I have the same issue - did you ever get a answer to this - or does any one have a suggestion ?
Title: Import .CSV Address Book
Post by: nunya on August 06, 2008, 10:06:11 AM
happens to me too with version .3 of this mod.  I'm trying to see where the problem lies, but I don't know enough about this system.  If i find anything, ill see if can post my first patch file....  Otherwise its a no go, and a manual one time import using back end scripting.
Title: Import .CSV Address Book
Post by: killinghall on August 08, 2008, 02:05:44 AM
Seriously, I wish you would improve this plugin aesthetically instead of dumping a simple piece of  ugly looking text on the top right hand side of the screen.

Common sense would tell you that the link should belong to the Address Book section, and reside amongst as one of the icons as the top.

But you probably did this in a hurry...so...:-X
Title: Intalling Import Patch
Post by: ajmusic24 on August 14, 2008, 12:07:25 PM
Is there a way I can install this import patch without doing the following:

patch -p1 < roundcube-import-contacts-0.3-RC.patch

I don't know what that is.

Thanks,
AJ
Title: Import .CSV Address Book
Post by: mdr on August 14, 2008, 02:18:13 PM
No that is the way you apply a patch.  Once you have downloaded the "roundcube-import-contacts-0.3-RC.patch" file cp it to the roudcube directory and run the above command, that will apply the patch to the files in the directory.
Title: Import .CSV Address Book
Post by: ajmusic24 on August 15, 2008, 12:00:36 PM
Thanks for the reply MDR.  How do I run the command:
patch -p1 < roundcube-import-contacts-0.3-RC.patch

I'm using CuteFTP to add my files to the directories on the server.

Thanks,
AJ
Title: Import .CSV Address Book
Post by: ajmusic24 on August 18, 2008, 10:52:20 PM
What software do I use (Windows XP) to do this command?  I have RoundCube installed on a Linux server.

patch -p1 < roundcube-import-contacts-0.3-RC.patch

Thanks,
AJ
Title: rc0.2-alpha
Post by: binary.koala on August 31, 2008, 06:10:45 PM
thanks a lot for the clear patch,
following it by hand I was able to make CSV import work with RCv0.2-alpha, nothing special had to be done, just watch the code.

i put all the files i edited into a single TAR with default dir structure, it's a ready-made drop-in patch ;)
http://k0a1a.net/rc2.0-csv-patch
(version 0.2-alpha STRICTLY)
Title: Pluging open new window again and again
Post by: igor@libe.org on September 08, 2008, 06:06:30 AM
Hello,
I've patched successfully but when i click on Address book and then "import contact" it open new "address book" window near first one and then when i click again import in new address book it fork to another, and another...

Environment : Windows 2003
Roundcube : V0.1.1
How to fix it ?

Thanks
Title: Import .CSV Address Book
Post by: marswaco on October 20, 2009, 05:40:32 PM
anyone has tested this patch in the version 0.3-stable? or 0.2.2-stable  ?