Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- Added automaticly synchronized CardDAV contacts via cronjob

- Added package.xml
  • Loading branch information...
commit 4ff727d3b379445186f2c5fa62964186ac54c1d6 1 parent d23399e
Christian Putzke authored
1  CHANGELOG
View
@@ -4,6 +4,7 @@ Changes from v0.4 to v0.5
- Added list of CardDAV servers
- Added read only option for CardDAV servers
- Added SOGo support
+- Added package.xml
- CardDAV backend class update to v0.5.1
- Minor comment, phpdoc and documentation changes
4 carddav.php
View
@@ -3,8 +3,8 @@
/**
* Include required CardDAV classes
*/
-require_once dirname(__FILE__).'/carddav_backend.php';
-require_once dirname(__FILE__).'/carddav_addressbook.php';
+require_once dirname(__FILE__) . '/carddav_backend.php';
+require_once dirname(__FILE__) . '/carddav_addressbook.php';
/**
* Roundcube CardDAV implementation
1  cronjob/.htaccess
View
@@ -0,0 +1 @@
+deny from all
135 cronjob/synchronize.php
View
@@ -0,0 +1,135 @@
+<?php
+
+/**
+ * Roundcube CardDAV synchronization
+ *
+ * @author Christian Putzke <christian.putzke@graviox.de>
+ * @copyright Christian Putzke @ Graviox Studios
+ * @since 31.03.2012
+ * @link http://www.graviox.de/
+ * @link https://twitter.com/graviox/
+ * @version 0.5
+ * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
+ *
+ */
+class carddav_synchronization_cronjob
+{
+ /**
+ * @var string $doc_root Roundcubes document root
+ */
+ private $doc_root;
+
+ /**
+ * @var string $rc_inset Roundcubes iniset script
+ */
+ private $rc_iniset = 'program/include/iniset.php';
+
+ /**
+ * Init CardDAV synchronization cronjob
+ *
+ * @param boolean $init Initialization
+ */
+ public function __construct($init = true)
+ {
+ if ($init === true)
+ {
+ $this->init();
+ }
+ }
+
+ /**
+ * Init CardDAV synchronization cronjob
+ *
+ * @return void
+ */
+ public function init()
+ {
+ $this->detect_document_root();
+ $this->include_rc_iniset();
+ }
+
+ /**
+ * Detect Roundcubes real document root
+ *
+ * @return void
+ */
+ private function detect_document_root()
+ {
+ $dir = dirname(__FILE__);
+ $dir = str_replace('plugins\\carddav\\cronjob', null, $dir);
+ $this->doc_root = str_replace('plugins/carddav/cronjob', null, $dir);
+ }
+
+ /**
+ * Include Roundcubes initset so that the internal Roundcube functions can be used inside this cronjob
+ *
+ * @return void
+ */
+ private function include_rc_iniset()
+ {
+ if (file_exists($this->doc_root . $this->rc_iniset))
+ {
+ chdir($this->doc_root);
+ require_once $this->doc_root . '/program/include/iniset.php';
+ }
+ else
+ {
+ die('Can\'t detect file path correctly! I got this as Roundcubes document root: '. $this->doc_root);
+ }
+ }
+
+ /**
+ * Get all CardDAV servers
+ *
+ * @return array $servers CardDAV server array with label, url, username, password (encrypted)
+ */
+ private function get_carddav_servers()
+ {
+ $servers = array();
+ $rcmail = rcmail::get_instance();
+
+ $query = "
+ SELECT
+ *
+ FROM
+ ".get_table_name('carddav_server')."
+ ";
+
+ $result = $rcmail->db->query($query);
+
+ while($server = $rcmail->db->fetch_assoc($result))
+ {
+ $servers[] = $server;
+ }
+
+ return $servers;
+ }
+
+ /**
+ * Synchronize all available CardDAV servers
+ *
+ * @return void
+ */
+ public function synchronize()
+ {
+ $servers = $this->get_carddav_servers();
+ $rcmail = rcmail::get_instance();
+
+ carddav::write_log('CRONJOB: Starting automatic CardDAV synchronization!');
+
+ if (!empty($servers))
+ {
+ foreach ($servers as $server)
+ {
+ $rcmail->user->data['user_id'] = $server['user_id'];
+ $carddav_addressbook = new carddav_addressbook($server['carddav_server_id'], $server['label']);
+ $carddav_addressbook->carddav_addressbook_sync($server);
+ }
+ }
+
+ carddav::write_log('CRONJOB: Automatic CardDAV synchronization finished!');
+ }
+}
+
+$cronjob = new carddav_synchronization_cronjob();
+$cronjob->synchronize();
80 package.xml
View
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" packagerversion="1.9.0" version="2.0" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
+ http://pear.php.net/dtd/tasks-1.0.xsd
+ http://pear.php.net/dtd/package-2.0
+ http://pear.php.net/dtd/package-2.0.xsd">
+ <name>Roundcube CardDAV</name>
+ <uri>https://github.com/graviox/Roundcube-CardDAV</uri>
+ <summary>CardDAV implementation for Roundcube</summary>
+ <description>
+ This is a CardDAV implementation for Roundcube 0.6 or higher.
+ It allows every user to add multiple CardDAV server in their settings.
+ The CardDAV contacts (vCards) will be synchronized automaticly with their roundcube addressbook.
+ </description>
+ <lead>
+ <name>Christian Putzke</name>
+ <email>christian.putzke@graviox.de</email>
+ <active>yes</active>
+ </lead>
+ <date>2012-03-31</date>
+ <version>
+ <release>0.5</release>
+ </version>
+ <stability>
+ <release>stable</release>
+ </stability>
+ <license uri="http://www.gnu.org/licenses/agpl.html">GNU AGPL v3 or later</license>
+ <notes>-</notes>
+ <contents>
+ <dir baseinstalldir="/" name="/">
+ <file name="carddav.php" role="php">
+ <tasks:replace from="@name@" to="name" type="package-info"/>
+ <tasks:replace from="@package_version@" to="version" type="package-info"/>
+ </file>
+ <file name="carddav_addressbook.js" role="data">
+ <tasks:replace from="@name@" to="name" type="package-info"/>
+ <tasks:replace from="@package_version@" to="version" type="package-info"/>
+ </file>
+ <file name="carddav_addressbook.php" role="php">
+ <tasks:replace from="@name@" to="name" type="package-info"/>
+ <tasks:replace from="@package_version@" to="version" type="package-info"/>
+ </file>
+ <file name="carddav_backend.php" role="php">
+ <tasks:replace from="@name@" to="name" type="package-info"/>
+ <tasks:replace from="@package_version@" to="version" type="package-info"/>
+ </file>
+ <file name="carddav_settings.js" role="data">
+ <tasks:replace from="@name@" to="name" type="package-info"/>
+ <tasks:replace from="@package_version@" to="version" type="package-info"/>
+ </file>
+ <file name="jquery.base64.js" role="data">
+ <tasks:replace from="@name@" to="name" type="package-info"/>
+ <tasks:replace from="@package_version@" to="version" type="package-info"/>
+ </file>
+ <file name="cronjob/synchronize.php" role="data">
+ <tasks:replace from="@name@" to="name" type="package-info"/>
+ <tasks:replace from="@package_version@" to="version" type="package-info"/>
+ </file>
+ <file name="localization/de_DE.inc" role="data"></file>
+ <file name="localization/en_US.inc" role="data"></file>
+ <file name="localization/fr_FR.inc" role="data"></file>
+ <file name="localization/it_IT.inc" role="data"></file>
+ <file name="skins/default/sync_act.png" role="data"></file>
+ <file name="skins/default/sync_pas.png" role="data"></file>
+ <file name="SQL/mysql.sql" role="data"></file>
+ <file name="SQL/mysql.update.sql" role="data"></file>
+ </dir>
+ <!-- / -->
+ </contents>
+ <dependencies>
+ <required>
+ <php>
+ <min>5.2.1</min>
+ </php>
+ <pearinstaller>
+ <min>1.7.0</min>
+ </pearinstaller>
+ </required>
+ </dependencies>
+ <phprelease/>
+</package>
Please sign in to comment.
Something went wrong with that request. Please try again.