Roundcube Community Forum

Third Party Contributions => API Based Plugins => Topic started by: EdMolf on October 02, 2011, 04:23:32 PM

Title: [0.6] Roundcube CardDAV Plugin
Post by: EdMolf on October 02, 2011, 04:23:32 PM
Hi there,
I've developed a CardDAV-Plugin for roundcube 0.6 with fully vCard support!
I know that there allready exists a CardDAV-Plugin for roundcube but this plugin didn't made me happy. So I decided to develop my own CardDAV-Plugin.

A Davical Server should work because thats the server I've used to develop the plugin.


Features
--------
* add multiple CardDAV-Server for each user
* CardDAV-Contacts are stored in the local database which provides great performance
* read / add / delete / edit CardDAV-Contacts (partly implemented - read only)
* search for contacts in the addressbook

Planned features
----------------
* automaticly synchronized CardDAV-Contacts
* 2-way synchronization
* edit / add / delete CardDAV-Contacts


The Plugin is hosted on github: https://github.com/graviox/Roundcube-CardDAV
Please report feature requests and bugs here: https://github.com/graviox/Roundcube-CardDAV/issues

It would be great if someone provide some feedback :)


Greetings,
EdMolf
Title: [0.6] Roundcube CardDAV Plugin
Post by: hosenhans on October 04, 2011, 04:50:46 AM
Just when I thought about playing with carddav and roundcube you are releasing a promising plugin :-)
Installation went fine, as did issuing the SQL statements. However I am getting the following errors while searching for a contact in the message compose dialog. The searches table seems to be missing somehow...

Code: [Select]
[Tue Oct 04 10:39:00 2011] [warn]  mod_fcgid: stderr: MDB2 Error: no such table (-18): _doQuery: [Error message: Could not execute statement], referer: https://mail/?_task=settings
[Tue Oct 04 10:39:00 2011] [warn]  mod_fcgid: stderr: [Last executed query: PREPARE mdb2_statement_mysql_68dff2d5c8f783d6858af6b040e86cd0b34e3ea3d FROM 'SELECT search_id AS id, `name` FROM searches WHERE user_id = ? AND `type` = ? ORDER BY `name`'], referer: https://mail/?_task=settings
[Tue Oct 04 10:39:00 2011] [warn]  mod_fcgid: stderr: [Native code: 1146], referer: https://mail/?_task=settings
[Tue Oct 04 10:39:00 2011] [warn]  mod_fcgid: stderr: [Native message: Table 'XXXXXX.searches' doesn't exist], referer: https://mail/?_task=settings
Title: [0.6] Roundcube CardDAV Plugin
Post by: EdMolf on October 04, 2011, 04:58:46 AM
Hmm, thats strange because my CardDAV-Plugin just adds two tables "carddav_contacts" and "carddav_server". The described query does not exists in the program code so it seems that your error isn't connected with the CardDAV-Plugin.
Title: [0.6] Roundcube CardDAV Plugin
Post by: hosenhans on October 04, 2011, 05:43:06 AM
Maybe it's because I am using roundcube trunk and the changes there aren't compatible with your plugin. Other address book plugins like the google contacts plugin still work though.

Another possible issue: the carddav server isn't a davical one (I think). You could try connecting to the carddav server I am using yourself. It's a free service from memotoo: Synchronize all you want: phone, computer, ... (http://www.memotoo.com)
Title: [0.6] Roundcube CardDAV Plugin
Post by: hosenhans on October 04, 2011, 05:57:57 AM
I am sorry for the noise. Running through the roundcube installer again it seems some more tables are missing. The issue is indeed not related to your plugin. But thanks to it I found some problems with my installation. That's at least something for now ;-)
Title: [0.6] Roundcube CardDAV Plugin
Post by: EdMolf on October 04, 2011, 06:08:05 AM
Great to hear that my plugin isn't responsible for your problems ;)
Please let me know if the plugin works with memotoo.
Title: [0.6] Roundcube CardDAV Plugin
Post by: hosenhans on October 05, 2011, 05:00:06 AM
Quote from: EdMolf;36831
Please let me know if the plugin works with memotoo.

I'm afraid it does not :( No contacts are shown, although the status bar at the bottom says "Contacts 1 to 1 of 1" (should be 3 contacts in my test case anyway). In the address filed of the compose windows auto-completion always shows "memotoo (1)", no matter what I type in there.
Title: [0.6] Roundcube CardDAV Plugin
Post by: EdMolf on October 05, 2011, 05:08:45 AM
I'll create and an account on memotoo and test it myself.
I think there is a problem while synchronize your contacts. Thats because I just had davical to test the synchronization so far.

The auto-completion thing seems to be a bug. It shows just the label of your CardDAV-Groups. I can confirm that error and will have a look at it.
Title: [0.6] Roundcube CardDAV Plugin
Post by: EdMolf on October 05, 2011, 11:10:48 AM
I've released an update with some bugfixes so that the autocomplete and some other bugs are fixed.
I'll try to figure out whats the problem with memotoo and create an account there so that more services / servers are supported by my plugin ;)
Title: [0.6] Roundcube CardDAV Plugin
Post by: hosenhans on October 05, 2011, 11:36:21 AM
Considering Apple's icloud will feature carddav synchronisation I am eager to test both icloud and your plugin once both are ready ;)
Title: [0.6] Roundcube CardDAV Plugin
Post by: EdMolf on October 30, 2011, 05:10:01 AM
I've updated the Plugin so that now apple addressbook servers are supported!
Title: [0.6] Roundcube CardDAV Plugin
Post by: EdMolf on October 30, 2011, 01:08:49 PM
Yay, next update finished! The CardDAV-Addressbooks are now searchable as well and Meetoo is suported from now ;)
The full changelog can be viewed here: https://raw.github.com/graviox/Roundcube-CardDAV/master/CHANGELOG
Title: [0.6] Roundcube CardDAV Plugin
Post by: hosenhans on October 31, 2011, 07:23:33 AM
That's great news! I tested the memotoo synchronisation and got an error at setup. However when I left the settings page and came back again, the entry was there, and the synchronisation is working. Here's the error log:

Code: [Select]
[31-Oct-2011 11:46:14 +0100]: DB Error: MDB2 Error: null value violates not-null constraint Query: _doQuery: [Error message: Could not execute statement] [Last executed query: EXECUTE mdb2_statement_mysql_69ad4324cf7e523a923431ebc4dc7c558f4a72be6 USING @0, @1, @2, @3, @4, @5, @6, @7] [Native code: 1048] [Native message: Column 'name' cannot be null]  in /var/www/web0815/html/mail.mydomain.org/trunk/program/include/rcube_mdb2.php on line 713 (POST /?_task=settings&_action=plugin.carddav-server-save?_task=&_action=)
[31-Oct-2011 11:47:33] PHP Warning:  SimpleXMLElement::__construct(): Entity: line 2: parser warning : xmlns:D: 'DAV:' is not a valid URI in /var/www/web0815/html/mail.mydomain.org/trunk/plugins/carddav/carddav_backend.php on line 243
[31-Oct-2011 11:47:33] PHP Warning:  SimpleXMLElement::__construct(): <multistatus xmlns:D=&quot;DAV:&quot; xmlns:ns1=&quot;http://calendarserver.org/ns/&quot;> in /var/www/web0815/html/mail.mydomain.org/trunk/plugins/carddav/carddav_backend.php on line 243
[31-Oct-2011 11:47:33] PHP Warning:  SimpleXMLElement::__construct():                            ^ in /var/www/web0815/html/mail.mydomain.org/trunk/plugins/carddav/carddav_backend.php on line 243
[31-Oct-2011 11:56:29] PHP Warning:  SimpleXMLElement::__construct(): Entity: line 2: parser warning : xmlns:D: 'DAV:' is not a valid URI in /var/www/web0815/html/mail.mydomain.org/trunk/plugins/carddav/carddav_backend.php on line 243
[31-Oct-2011 11:56:29] PHP Warning:  SimpleXMLElement::__construct(): <multistatus xmlns:D=&quot;DAV:&quot; xmlns:ns1=&quot;http://calendarserver.org/ns/&quot;> in /var/www/web0815/html/mail.mydomain.org/trunk/plugins/carddav/carddav_backend.php on line 243
[31-Oct-2011 11:56:29] PHP Warning:  SimpleXMLElement::__construct():                            ^ in /var/www/web0815/html/mail.mydomain.org/trunk/plugins/carddav/carddav_backend.php on line 243


Another issue I noticed while testing icloud synchronization a few days back: special characters in the username weren't escaped properly. It wasn't possible to use a username like "some+thing@domain.com". The + sign seems to be the issue there.

Thank you very much for your plugin. I am really close to get rid of my google contacts synchronisation :)
Title: [0.6] Roundcube CardDAV Plugin
Post by: EdMolf on November 01, 2011, 01:42:43 AM
Hi, thanks for the response. I'll have a look at it!
Title: [0.6] Roundcube CardDAV Plugin
Post by: EdMolf on November 02, 2011, 03:43:34 PM
Hi, I've developed an update that fixes the "+" sign bug and the bug that was responseible for that error:

Code: [Select]
[31-Oct-2011 11:46:14 +0100]: DB Error: MDB2 Error: null value violates not-null constraint Query: _doQuery: [Error message: Could not execute statement] [Last executed query: EXECUTE mdb2_statement_mysql_69ad4324cf7e523a923431ebc4dc7c558f4a72be6 USING @0, @1, @2, @3, @4, @5, @6, @7] [Native code: 1048] [Native message: Column 'name' cannot be null]  in /var/www/web0815/html/mail.mydomain.org/trunk/program/include/rcube_mdb2.php on line 713 (POST /?_task=settings&_action=plugin.carddav-server-save?_task=&_action=)

Now you can insert a memotoo account and get a success message as it should be.


I can't reproduce the warnings that you get. It seems that this is a bug of your libxml2 version. Which environment and libxml2 version do you use?

It would be great if you can add bugs or feature requests here please: https://github.com/graviox/Roundcube-cardDAV/issues


Thanks for the feedback and best regards,
EdMolf
Title: [0.6] Roundcube CardDAV Plugin
Post by: hosenhans on November 03, 2011, 05:15:47 AM
Quote from: EdMolf;37163
Hi, I've developed an update that fixes the "+" sign bug and the bug that was responseible for that error:

Code: [Select]
[31-Oct-2011 11:46:14 +0100]: DB Error: MDB2 Error: null value violates not-null constraint Query: _doQuery: [Error message: Could not execute statement] [Last executed query: EXECUTE mdb2_statement_mysql_69ad4324cf7e523a923431ebc4dc7c558f4a72be6 USING @0, @1, @2, @3, @4, @5, @6, @7] [Native code: 1048] [Native message: Column 'name' cannot be null]  in /var/www/web0815/html/mail.mydomain.org/trunk/program/include/rcube_mdb2.php on line 713 (POST /?_task=settings&_action=plugin.carddav-server-save?_task=&_action=)

Now you can insert a memotoo account and get a success message as it should be.

I'll test it as soon as I get the chance.

Quote
I can't reproduce the warnings that you get. It seems that this is a bug of your libxml2 version. Which environment and libxml2 version do you use?

libxml: 2.6.32 php: 5.3.6 mysql: 5.0.51a

Quote
It would be great if you can add bugs or feature requests here please: https://github.com/graviox/Roundcube-cardDAV/issues

I will do that from now on. It's gems like your plugin that make roundcube so pleasurable to use :)
Title: Roundcube to iCloud possible?
Post by: dahacouk on November 22, 2011, 05:52:40 AM
Quote from: hosenhans;36851
Considering Apple's icloud will feature carddav synchronisation I am eager to test both icloud and your plugin once both are ready ;)


Is Roundcube to iCloud address book syncing really possible?
Title: [0.6] Roundcube CardDAV Plugin
Post by: hosenhans on November 22, 2011, 06:19:19 AM
I switched to memotoo, so I didn't try the latest versions with icloud. But it should work. Of course the best way to find out is not to let others do the work but try yourself ;-) and report back here. You need to get hold of the contacts server address first (it looks like p__-contacts.icloud.com), just follow one of the many tutorials on the net, e.g. this one: Linking iCloud to pre-Lion and/or pre-iOS5 | Klaus' Korner (http://www.klauskorner.com/2011/11/21/linking-icloud-to-pre-lion-andor-pre-ios5/) Good luck!
Title: curl_init error
Post by: roggie on December 05, 2011, 02:26:47 PM
Hi - thanks for such a really cool plugin, the installation instructions are great and I got the plugin working in a few minutes - except it doesn't connect to my carddav server. The roundcube log shows the following:
[05-Dec-2011 19:05:30] PHP Fatal error:  Call to undefined function curl_init() in /usr/share/roundcube/plugins/carddav/carddav_backend.php on line 305

I had a quick google with that error message but nothing came back.

I'm using roundcube 0.6, installed from the tarball, running on Ubuntu Lucid.

I'm sorry if this is a dumb question, but any pointers to a solution would be much appreciated. -Roggie
Title: [0.6] Roundcube CardDAV Plugin
Post by: SKaero on December 05, 2011, 02:46:25 PM
You need to install curl on your server, it should be in the Ubuntu repositories.
Title: [0.6] Roundcube CardDAV Plugin
Post by: hosenhans on December 05, 2011, 02:46:28 PM
It seems as if the server you are running roundcube on lacks php-curl support. See e.g. Call to undefined function curl init() - Php (http://php.syntaxerrors.info/index.php?title=Call_to_undefined_function_curl_init()) for more details.
Title: [0.6] Roundcube CardDAV Plugin
Post by: roggie on December 05, 2011, 02:55:14 PM
Quote from: skaero;37536
You need to install curl on your server, it should be in the Ubuntu repositories.

 Thanks for your reply - curl is already installed e.g. apt-get says its already the latest version, and man curl produces the curl man page.

Do I need to do anything to roundcube or apache to hook them together?
Title: [0.6] Roundcube CardDAV Plugin
Post by: SKaero on December 05, 2011, 02:59:57 PM
You'll also need php-curl.
Title: [0.6] Roundcube CardDAV Plugin
Post by: roggie on December 05, 2011, 03:01:44 PM
doh, many thanks, that fixed it :)
Title: iCloud - no contacts after sync
Post by: roggie on December 05, 2011, 05:17:52 PM
I've got the plugin working for my memtoo account, but it doesn't get any contacts from my icloud account.

The icloud server address is set to https://p03-contacts.icloud.com, and the account appears to connect properly (no username/passord error).

But there are no addresses shown in the roundcube icloud address book, although there are plenty if i check the icloud account on the icloud website.

Grateful for any advice :)
Title: [0.6] Roundcube CardDAV Plugin
Post by: EdMolf on December 06, 2011, 05:05:04 AM
I have no access to an icloud Account so I couldn't check if my CardDAV-Plugin works with icloud. If someone can provide me a test account, I'll try to add icloud support.
Title: [0.6] Roundcube CardDAV Plugin
Post by: peterwatson on December 07, 2011, 12:34:48 AM
0:)adult dating (http://adultdating.co.uk/)
Naples luxury real estate (http://levitanrealtors.com/)
Title: [0.6] Roundcube CardDAV Plugin
Post by: mik0r on December 08, 2011, 08:50:23 AM
The current subversion trunk version of the other carddav plugin (www.crash-override.net - CardDAV plugin for Roundcube (http://www.crash-override.net/carddav.html)) works with iCloud. Just enter https://contacts.icloud.com as the server name, use the same user and password as for the iCloud.com website. Also supports addressbook groups and has write support.
Title: new version 0.3
Post by: EdMolf on February 19, 2012, 08:50:11 AM
I've finished the new version of my Roundcube-CardDAV Plugin v0.3. Now you can edit and delete CardDAV-Contacts! There are also some other improvements. For more detailed information have a look at the changelog.
If you update to the newest version don't forget to update the database and please readd your CardDAV-Servers so that the new database fileds will be filled correctly.

CHAGELOG
- added edit and delete functionality for CardDAV-Contacts
- added sabreDAV support
- added ownCloud support
- CardDAV-Backend class update to v0.4.6
- restructured and cleaned carddav_addressbook class (not completly done yet)
- minor improvements (CURL install check, usability improvements, sync don't add empty vcards now, ...)
- added IT and FR language files
Title: [0.6] Roundcube CardDAV Plugin
Post by: EdMolf on February 22, 2012, 03:40:03 PM
I've just released a little update 0.3.1 with a bugfix.

CHANGELOG
- bugfix: didn't merged vCards on edit correctly
Title: [0.6] Roundcube CardDAV Plugin
Post by: EdMolf on March 04, 2012, 12:55:48 AM
I've finished version 0.4 of my Roundcube CardDAV-Plugin with many new major features! Have a look at the changelog:

- added add-functionality for CardDAV-Contacts
- added vCard import-functionality for CardDAV-Addressbooks
- license change from LGPLv2 to AGPLv3
- CardDAV-Backend class update to v0.4.9
- added logging
- each CardDAV-Server is now an own addressbook not a group of a global CardDAV-Addressbook like before
- minor bugfixes
- improved synchronization

You can download the new version at github: https://github.com/graviox/Roundcube-CardDAV/zipball/v0.4
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: EdMolf on April 01, 2012, 12:29:39 PM
Just finished version 0.5 of Roundcube CardDAV with many improvements and the major new feature: automatic contact synchronization! For more information have a look at the changelog:

- Added automaticly synchronized CardDAV contacts via cronjob
- Added larry skin support
- Added list of CardDAV server URLs
- Added read only option for CardDAV servers
- Added SOGo support
- Added package.xml
- Major standard skin UI improvements
- CardDAV backend class update to v0.5.1
- Minor comment, phpdoc and documentation changes
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: hosenhans on April 01, 2012, 12:38:42 PM
Thank you very much for implementing the feature I suggested
Quote
- Added read only option for CardDAV servers
I already tested it briefly without problems (roundcube svn + owncloud3) and so far I really like it :-)

Danke schön!
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: EdMolf on April 11, 2012, 12:51:22 AM
There is a new release of Roundcube CardDAV available! Now with PostgresSQL support. For more information have a look at the changelog:

Changes from v0.5 to v0.5.1
- Added PostgreSQL support (Thanks to B5r1oJ0A9G for the PostgreSQL statements!)
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: ineo on April 14, 2012, 09:00:08 AM

Can somebody share his iCloud settings when using this plugin?
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: EdMolf on April 24, 2012, 04:13:22 AM
I'm sorry but iCloud is not supported yet. It's on my roadmap but it will last a bit longer.
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: seascape on May 05, 2012, 06:25:03 PM
This looks like a very promising plugin. I was hoping that it would be able to sync my Yahoo contacts with RoundCube. Unfortunately it doesn't. This is the error I get when I try to sync after setting up:

Code: [Select]
An error occurred while synchronizing the CardDAV contacts
Settings I am using:

Quote
Label: Yahoo Mail
Server Address: https://carddav.address.yahoo.com
Username: Yahoo username
Password: Yahoo password
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: EdMolf on May 08, 2012, 09:07:07 AM
Hi!
There is actually no yahoo contacts support but I'll have a look at it.
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: rosali on June 12, 2012, 04:24:34 AM
I have problems to get this plugin working with SabreDAV.

Please contact me and I'll set up a SabreDAV test account for you:

myroundcube at mail4us dot net - Thanks!

Problems:
- Contacts are not deleted from local database but they are deleted from SabreDAV
- When adding a new contact the new contact is not loaded into the iframe and it is not editable when selecting the contact;
  after reloading the addressbook page the contact appears just fine.
- Problems remain regardless if using RC 0.7.2 or 0.8-RC
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: ineo on June 22, 2012, 05:28:59 AM
I'm sorry but iCloud is not supported yet. It's on my roadmap but it will last a bit longer.

Is there any news on using this plugin with iCloud?

I would like to integrate contacts and calendar with iCloud

Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: seascape on July 01, 2012, 09:01:55 PM
Hi!
There is actually no yahoo contacts support but I'll have a look at it.

It would be great if there was. Then I'd be making near-constant use of this plugin! Any progress?
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: speedy80 on July 03, 2012, 03:10:42 AM
Hi

I'm using Roundcube 0.8 RC and the latest version of the CardDAV plugin and a davical server.

I can add new contacts in roundcube and they are added to my davical server. But whenever I synchronize all contacts disappear in roundcube. The contacts still exist as they still appear on my Iphone.

Has anybody else had a similar experience? What could I try?

Thank you.
speedy80

I found following entries:
[13-Jul-2012 20:22:10 +0200]: v0.5.1 |  carddav_server_id: 5 | No CardDAV XML-Element found! The CardDAV-Server seems to have no contacts
[13-Jul-2012 20:22:10 +0200]: v0.5.1 |  carddav_server_id: 5 | all CardDAV-Data are synchronous, nothing todo!
[13-Jul-2012 20:22:10 +0200]: v0.5.1 |  carddav_server_id: 5 | Syncronization complete!
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: belkira on August 08, 2012, 11:16:53 PM
Thank you for this. It works great! Is there any way to show the groups from the address book? I am connecting to an Apple Address Book Server and I get all the contacts, but I would like them in there groups as they are if I open AddressBook on my mac.

Thanks again!
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: dcrobertson01 on January 04, 2013, 03:28:02 PM
I've finished version 0.4 of my Roundcube CardDAV-Plugin with many new major features! Have a look at the changelog:

Hi - I have been trying to get the MyRoundCube Webdav client working for ages - off and on. This morning I disabled the MyRoundCube Plugin Manager, removed their carddav plugin, and installed yours.

Everything is working perfectly - as far as I know after a bit of testing.

 ;D So thanks for this. Now to sort out a calendar :-)
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: oldschool on January 18, 2013, 10:10:48 AM
Hi!

Currently i am testing RC 0.9beta.
I downloaded the latest version from the master branch.

And get this:
PHP Fatal error:  Call to undefined method rcube_db_mysql::num_rows() in .../webmail/plugins/carddav/carddav.php on line 364

Any hint?



Thanks. Rgds.
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: alec on January 18, 2013, 11:49:42 AM
There's no num_rows() method in 0.9. Carddav plugin need to be updated to use other method.
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: oldschool on January 18, 2013, 11:55:33 AM
There's no num_rows() method in 0.9. Carddav plugin need to be updated to use other method.

Arrgghh!
Thaaaanks!

Hi, Christian, bekommst das vielleicht zeitnah hin?
;)


Rgds.
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: huhn_m on January 27, 2013, 09:45:34 AM
Code: [Select]
--- carddav.php.orig    2013-01-27 15:37:45.285051841 +0100
+++ carddav.php 2013-01-27 15:39:55.035182800 +0100
@@ -352,7 +351,7 @@
 
                $query = "
                        SELECT
-                               *
+                               COUNT(*)
                        FROM
                                ".get_table_name('carddav_server')."
                        WHERE
@@ -361,7 +360,7 @@
 
                $result = $rcmail->db->query($query, $user_id);
 
-               if ($rcmail->db->num_rows($result))
+               if ($rcmail->db->fetch_array($result)[0] > 0)
                {
                        return true;
                }

Code: [Select]
--- carddav_addressbook.php.orig        2013-01-27 15:37:26.504033155 +0100
+++ carddav_addressbook.php     2013-01-27 15:43:15.075379470 +0100
@@ -162,14 +162,11 @@
                        $result = $rcmail->db->limitquery($query, $limit['start'], $limit['length'], $rcmail->user->data['user_id'], $this->carddav_server_id);
                }
 
-               if ($rcmail->db->num_rows($result))
+               while ($contact = $rcmail->db->fetch_assoc($result))
                {
-                       while ($contact = $rcmail->db->fetch_assoc($result))
-                       {
-                               $carddav_addressbook_contacts[$contact['vcard_id']] = $contact;
-                       }
+                       $carddav_addressbook_contacts[$contact['vcard_id']] = $contact;
                }
-
+
                return $carddav_addressbook_contacts;
        }
 
@@ -196,12 +193,7 @@
 
                $result = $rcmail->db->query($query, $rcmail->user->data['user_id'], $carddav_contact_id);
 
-               if ($rcmail->db->num_rows($result))
-               {
-                       return $rcmail->db->fetch_assoc($result);
-               }
-
-               return false;
+               return $rcmail->db->fetch_assoc($result);
        }
 
        /**
@@ -215,7 +207,7 @@
 
                $query = "
                        SELECT
-                               *
+                               COUNT (*)
                        FROM
                                ".get_table_name('carddav_contacts')."
                        WHERE
@@ -229,7 +221,7 @@
 
                $result = $rcmail->db->query($query, $rcmail->user->data['user_id'], $this->carddav_server_id);
 
-               return $rcmail->db->num_rows($result);
+               return $rcmail->db->fetch_array($result)[0];
        }
 
        /**
@@ -791,16 +783,12 @@
 
                $result = $rcmail->db->query($query, $rcmail->user->data['user_id']);
 
-               if ($rcmail->db->num_rows($result))
+               while ($contact = $rcmail->db->fetch_assoc($result))
                {
-                       while ($contact = $rcmail->db->fetch_assoc($result))
-                       {
-                               $record['name'] = $contact['name'];
-                               $record['email'] = explode(', ', $contact['email']);
-
-                               $this->result->add($record);
-                       }
+                       $record['name'] = $contact['name'];
+                       $record['email'] = explode(', ', $contact['email']);
 
+                       $this->result->add($record);
                }
 
                return $this->result;

And for people that like sqlite here is the sqlite.sql  for the SQL directory:

Code: [Select]
PRAGMA foreign_keys = ON;

CREATE TABLE IF NOT EXISTS `carddav_server` (
  `carddav_server_id` INTEGER PRIMARY KEY AUTOINCREMENT,
  `user_id` int(10) NOT NULL REFERENCES `users` (`user_id`) ON DELETE CASCADE,
  `url` varchar(255) NOT NULL,
  `username` varchar(128) NOT NULL,
  `password` varchar(128) NOT NULL,
  `label` varchar(128) NOT NULL,
  `read_only` tinyint(1) NOT NULL
);

CREATE TABLE IF NOT EXISTS `carddav_contacts` (
  `carddav_contact_id` INTEGER PRIMARY KEY AUTOINCREMENT,
  `carddav_server_id` int(10)  NOT NULL REFERENCES `carddav_server` (`carddav_server_id`) ON DELETE CASCADE,
  `user_id` int(10) NOT NULL,
  `etag` varchar(64) NOT NULL,
  `last_modified` varchar(128) NOT NULL,
  `vcard_id` varchar(64) NOT NULL,
  `vcard` longtext NOT NULL,
  `words` text,
  `firstname` varchar(128) DEFAULT NULL,
  `surname` varchar(128) DEFAULT NULL,
  `name` varchar(255) DEFAULT NULL,
  `email` varchar(255) DEFAULT NULL,
  UNIQUE (`carddav_server_id`,`user_id`,`vcard_id`)
);
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: oldschool on January 27, 2013, 02:34:37 PM
Hi and thanks a lot!

Will give it a try.


Have a nice day!
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: oldschool on January 27, 2013, 10:47:39 PM
Hi!

I get a:
Code: [Select]
syntax error, unexpected '[' in .../plugins/carddav/carddav.php on line 364
Rgds.
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: huhn_m on January 29, 2013, 07:16:32 AM
Huh? Works for me. fetchArray returns an array and i retrieve the first element. What php version are you using?
Are you sure you have not mistyped a bracket or something? Can you show me the lines arround the error (e.g. 5 before, 5 after or sth. like that)
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: oldschool on January 29, 2013, 12:07:26 PM
Hi!


Currently using PHP Version 5.3.5.


Code: [Select]
protected function carddav_server_available()
{
$rcmail = rcmail::get_instance();
$user_id = $rcmail->user->data['user_id'];

$query = "
SELECT
      COUNT(*)
      FROM
      ".get_table_name('carddav_server')."
      WHERE
user_id = ?
";

$result = $rcmail->db->query($query, $user_id);

if ($rcmail->db->fetch_array($result)[0] > 0)
{
return true;
}
else
{
return false;
}
}

I removed the
Code: [Select]
[0] with the result the generated contacts are not shown.
But copied to the carddav server...


Rgds.
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: huhn_m on January 30, 2013, 04:00:00 AM
Hm. Might be it works for me because I use php 5.4. But I'm not sure. Also, the function should not have the effect you described. It just decides whether a server is available (and based on that if anything works at all with this server). So there might be another problem (because I use the same method with the index in another method in carddav_addressbook.php).

One try might be to use
Code: [Select]
                            $result = $rcmail->db->query($query, $user_id);
                            $resultArray = $rcmail->db->fetch_array($result);

if ($resultArray[0] > 0)
{
return true;
}
else
{
return false;
}

instead if the above code.
(And the anologous version in the carddav_addressbook.php). Could you give this a try?
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: oldschool on January 30, 2013, 07:07:41 PM
Okay, i tried this:


Replace
Code: [Select]
($rcmail->db->num_rows($result))with
Code: [Select]
($rcmail->db->affected_rows($result))in carddav_addressbook.php and carddav.php.


But currently i still get a
Code: [Select]
Couldn't delete CardDAV-Contact from the local database with the vCard idwhen copying a contact to the davical server...


Rgds.


PS: Update. This fix problems with previous releases, too!
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: huhn_m on January 31, 2013, 03:26:23 AM
you can NOT replace num_rows with affected rows for select statements. It only returns affected rows (DELETE, INSERT, UPDATE). You need to replace the SELECT * with SELECT COUNT(*) and evaluate the result, just like my patch did. Else you effectively always get zero results for SELECT statements.
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: oldschool on January 31, 2013, 08:59:09 AM
Hi!

Have you checked your PMs?


Rgds.
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: huhn_m on February 01, 2013, 10:12:44 AM
Sorry ;) I totally missed that. You got a reply now.
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: mbsouth on February 02, 2013, 09:48:08 PM
Der hier produzierte Code-Hick/Hack ist absoluter Schrott!
Seht euch die Methoden in RC0.9 einmal an, zumal betrifft das "num_rows($result)" - Problem nicht nur dieses sondern viele der 3d-Party PlugIns!
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: oldschool on February 03, 2013, 07:40:07 AM
Der hier produzierte Code-Hick/Hack ist absoluter Schrott!
Seht euch die Methoden in RC0.9 einmal an, zumal betrifft das "num_rows($result)" - Problem nicht nur dieses sondern viele der 3d-Party PlugIns!

Hi!

Nicht nur rumhupen.
Haste auch was Konstruktives am Start?
;)


Gruss.
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: mbsouth on February 04, 2013, 07:40:33 AM

You can read all relevant post on the project home: https://github.com/graviox/Roundcube-CardDAV/issues (https://github.com/graviox/Roundcube-CardDAV/issues).
It seems, that the developement is at a stilstand; therefore it would be better, to post bugs or feature requests on the project page. Perhaps, Christian Putzke is further continuing the development of this great plugin.
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: huhn_m on February 04, 2013, 08:42:12 AM
Thanks for the nice and constructive comment, mbsouth. Really makes you feel your contribution is valued in this community .... not ...

It works for me. With the div presented above and honestly I could care less if it works for others. Which "Methoden in RC0.9" should I look at? I investigated the git head database abstractions and came up with this - for me working - solution. And I don't care for the other 3rd party plugins. I don't want to fix all problems but only mine.

But why bother. Owncloud 5 will have its own mail program and obsolete roundcube for me anyways.
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: mbsouth on February 05, 2013, 02:39:49 PM


Quote
...contribution is valued in this "community"...
As you have already said is this is a "user to user community".

Quote
I don't want to fix all problems but only mine.
You just solves your problems but you want constructive comments ;-)

Quote
...And I don't care for the other 3rd party plugins....
That's right. Changes in source code belongs to the author's code repository - or fork it the right way.

"rcube_contacts" doesn't use num_rows() any more because PDO does not offer a function like "num_rows", it only offers "rowCount()"  which returns the number of affected rows. Just in this case, in MySQL, the effect is the same - "rowCount" returns the number of rows in a select - but this behavior does not necessarily extend to other databases. http://php.net/manual/en/pdostatement.rowcount.php (http://php.net/manual/en/pdostatement.rowcount.php)

Instead the code above
Code: [Select]
($rcmail->db->affected_rows($result))you can also use
Code: [Select]
...( 0 == 0 )...it has no effect and isn´t a solution! Other methods and a source code revision are necessary.

The best way in this case:  contact the author.
https://github.com/graviox/Roundcube-CardDAV/issues (https://github.com/graviox/Roundcube-CardDAV/issues)

just my 2 cents
mbsouth
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: huhn_m on February 12, 2013, 10:14:31 AM
Not sure if trolling ....

My patches REPLACED the affected_rows commands with the correct SQL queries that do return the rowcount in a result. Are you sure you wanted to reply to me? Could you please re-read my posts?
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: nerbrume on March 07, 2013, 05:48:00 AM
Hi,
I'm in the same situation as oldschool : huhn_m patches are not working for me, and replacing num_rows with affected_rows (yes, I know it's bad) almost works, except for contact creation. In my logs, I get the following errors : "CardDAV-Server XML-Response is malformed. Synchronization aborted!"(affected_rows method) or "Couldn't delete CardDAV-Contact from the local database with the vCard id" (huhn_m method).
This is happening with davical and owncloud (sabreDav-based).
note : I have applied the patches explained here (https://github.com/graviox/Roundcube-CardDAV/issues/28), since this error was happening to me even on RC 8.4

Oldschool, how did you solved this ?

Does anyone have an idea of where this might come from ?
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: oldschool on March 08, 2013, 01:13:24 PM
Hi!

Currently i am testing the 0.9 with this plugin V0.5.1 and with the "affected_rows" patches applied.

And, yes, i tested your experiences creating a new contact one minute ago.
It gives the described error, but without the "CardDAV-Server XML-Response is malformed. Synchronization aborted!".
After synchronising the new contact appears...

As i understand the contact is created locally and then transferred to the davical server...
And, the prob is not solved.


Rgds.
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: Accudio on June 25, 2013, 03:54:02 PM
Hey, I'm a noob when it comes to SQL databases, and cannot work out what
"Execute SQL statements from /plugins/carddav/SQL/yourDatabase.sql"
wants me to do in the install instructions. Can anyone give me quick helping hand and give me a slightly simpler explanation here?
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: Happyfeet on November 01, 2013, 02:31:44 AM
Good morning. After upgrade the Plugin from 0.8.0 to 0.9.x in Plugin manager I get an error for the database.
The Table roundcubemail.carddav_server doesn't exsist.

How can I fix this?

Gesendet von meinem HTC One X mit Tapatalk

Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: oldschool on December 09, 2013, 10:46:05 PM
Hi!

My friend Allan did it! We made a "hardcore" session this night.
;)
Is there any need for the fixed plugin?


Greetz.
Title: Re: [0.6] Roundcube CardDAV Plugin
Post by: oldschool on December 10, 2013, 06:48:28 PM
Okay!

Currently i am testing the fixed CardDAV-Plugin with the actual RC 0.95 and it seems to work.
;D
More to come...


Greets.



Update:
There's no num_rows() method in 0.9. Carddav plugin need to be updated to use other method.

Checked -> Bullsh*t!