summaryrefslogtreecommitdiffstats
path: root/apps/contacts
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2012-03-07 20:57:05 +0100
committerThomas Tanghus <thomas@tanghus.net>2012-03-07 20:57:05 +0100
commit57c4d39b1e0becaeeb795cfbfd70f525bd89b9d8 (patch)
tree5a12c8c7d83574b9bff3e4271e88ec740820c2aa /apps/contacts
parent75323b86d157c48031b9ac8c151e4a41577a1481 (diff)
parentcf5d63f0abc2b4537098962ad5051180861f965b (diff)
downloadnextcloud-server-57c4d39b1e0becaeeb795cfbfd70f525bd89b9d8.tar.gz
nextcloud-server-57c4d39b1e0becaeeb795cfbfd70f525bd89b9d8.zip
Fix conflict.
Diffstat (limited to 'apps/contacts')
-rw-r--r--apps/contacts/appinfo/app.php6
-rw-r--r--apps/contacts/carddav.php2
-rw-r--r--apps/contacts/css/contacts.css6
-rw-r--r--apps/contacts/js/contacts.js17
-rw-r--r--apps/contacts/lib/app.php2
-rw-r--r--apps/contacts/lib/hooks.php60
-rw-r--r--apps/contacts/lib/search.php5
7 files changed, 79 insertions, 19 deletions
diff --git a/apps/contacts/appinfo/app.php b/apps/contacts/appinfo/app.php
index 9e424aa89f8..85c383c4c32 100644
--- a/apps/contacts/appinfo/app.php
+++ b/apps/contacts/appinfo/app.php
@@ -4,7 +4,11 @@ OC::$CLASSPATH['OC_Contacts_Addressbook'] = 'apps/contacts/lib/addressbook.php';
OC::$CLASSPATH['OC_Contacts_VCard'] = 'apps/contacts/lib/vcard.php';
OC::$CLASSPATH['OC_Contacts_Hooks'] = 'apps/contacts/lib/hooks.php';
OC::$CLASSPATH['OC_Connector_Sabre_CardDAV'] = 'apps/contacts/lib/connector_sabre.php';
+OC::$CLASSPATH['OC_Search_Provider_Contacts'] = 'apps/contacts/lib/search.php';
OC_HOOK::connect('OC_User', 'post_deleteUser', 'OC_Contacts_Hooks', 'deleteUser');
+OC_HOOK::connect('OC_Calendar', 'getEvents', 'OC_Contacts_Hooks', 'getBirthdayEvents');
+OC_HOOK::connect('OC_Calendar', 'getSources', 'OC_Contacts_Hooks', 'getCalenderSources');
+OC_Hook::connect('OC_DAV', 'initialize', 'OC_Contacts_Hooks', 'initializeCardDAV');
OC_App::register( array(
'order' => 10,
@@ -21,4 +25,4 @@ OC_App::addNavigationEntry( array(
OC_APP::registerPersonal('contacts','settings');
OC_UTIL::addScript('contacts', 'loader');
-require_once('apps/contacts/lib/search.php');
+OC_Search::registerProvider('OC_Search_Provider_Contacts');
diff --git a/apps/contacts/carddav.php b/apps/contacts/carddav.php
index a2bf492e206..654aeb66a72 100644
--- a/apps/contacts/carddav.php
+++ b/apps/contacts/carddav.php
@@ -39,7 +39,7 @@ $nodes = array(
// Fire up server
$server = new Sabre_DAV_Server($nodes);
-$server->setBaseUri(OC::$WEBROOT.'/apps/contacts/carddav.php');
+$server->setBaseUri(OC::$APPSWEBROOT.'/apps/contacts/carddav.php');
// Add plugins
$server->addPlugin(new Sabre_DAV_Auth_Plugin($authBackend,'ownCloud'));
$server->addPlugin(new Sabre_CardDAV_Plugin());
diff --git a/apps/contacts/css/contacts.css b/apps/contacts/css/contacts.css
index 65a6eb24809..a6f7d9316f8 100644
--- a/apps/contacts/css/contacts.css
+++ b/apps/contacts/css/contacts.css
@@ -17,8 +17,8 @@
#contacts_propertymenu li a:hover { color: #fff }
#actionbar { height: 30px; width: 200px; position: fixed; right: 0px; top: 75px; margin: 0 0 0 0; padding: 0 0 0 0;}
#card { /*max-width: 70em; border: thin solid lightgray; display: block;*/ }
-#firstrun { /*border: thin solid lightgray;*/ width: 80%; margin: 5em auto auto auto; text-align: center; font-weight:bold; font-size:1.5em; color:#777;}
-#firstrun #selections { /*border: thin solid lightgray;*/ font-size:0.8em; width: 100%; margin: 2em auto auto auto; clear: both; }
+#firstrun { width: 100%; position: absolute; top: 5em; left: 0; text-align: center; font-weight:bold; font-size:1.5em; color:#777; }
+#firstrun #selections { font-size:0.8em; margin: 2em auto auto auto; clear: both; }
#card input[type="text"].contacts_property,input[type="email"].contacts_property { width: 14em; }
.categories { float: left; width: 16em; }
@@ -194,4 +194,4 @@ input[type="checkbox"] { width: 20px; height: 20px; vertical-align: bottom; }
/*#categorylist { border:1px solid #ddd;}*/
#categorylist li { background:#f8f8f8; padding:.3em .8em; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; -webkit-transition:background-color 500ms; -moz-transition:background-color 500ms; -o-transition:background-color 500ms; transition:background-color 500ms; }
#categorylist li:hover, li:active { background:#eee; }
-#category_addinput { width: 10em; } \ No newline at end of file
+#category_addinput { width: 10em; }
diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js
index 7306e5714c9..626672cf788 100644
--- a/apps/contacts/js/contacts.js
+++ b/apps/contacts/js/contacts.js
@@ -4,6 +4,12 @@ function ucwords (str) {
});
}
+String.prototype.strip_tags = function(){
+ tags = this;
+ stripped = tags.replace(/[\<\>]/gi, "");
+ return stripped;
+};
+
Categories={
edit:function(){
console.log('Categories.edit');
@@ -238,7 +244,7 @@ Contacts={
alert(jsondata.data.message);
}
});
- }
+ };
},
loadListHandlers:function() {
//$('.add,.delete').hide();
@@ -425,7 +431,7 @@ Contacts={
}
});
},
- delete:function() {
+ delete: function() {
$('#contacts_deletecard').tipsy('hide');
$.getJSON('ajax/deletecard.php',{'id':this.id},function(jsondata){
if(jsondata.status == 'success'){
@@ -1508,10 +1514,3 @@ $(document).ready(function(){
$('#contacts_propertymenu').hide();
});
});
-
-String.prototype.strip_tags = function(){
- tags = this;
- stripped = tags.replace(/[\<\>]/gi, "");
- return stripped;
-}
-
diff --git a/apps/contacts/lib/app.php b/apps/contacts/lib/app.php
index 48298952c12..47220e0bc8c 100644
--- a/apps/contacts/lib/app.php
+++ b/apps/contacts/lib/app.php
@@ -85,7 +85,7 @@ class OC_Contacts_App {
$vcard = OC_VObject::parse($card['carddata']);
// Try to fix cards with missing 'N' field from pre ownCloud 4. Hot damn, this is ugly...
if(!is_null($vcard) && !$vcard->__isset('N')) {
- $appinfo = $info=OC_App::getAppInfo('contacts');
+ $appinfo = OC_App::getAppInfo('contacts');
if($appinfo['version'] >= 5) {
OC_Log::write('contacts','OC_Contacts_App::getContactVCard. Deprecated check for missing N field', OC_Log::DEBUG);
}
diff --git a/apps/contacts/lib/hooks.php b/apps/contacts/lib/hooks.php
index 155cf40f914..e09da20be86 100644
--- a/apps/contacts/lib/hooks.php
+++ b/apps/contacts/lib/hooks.php
@@ -29,7 +29,7 @@ class OC_Contacts_Hooks{
* @param paramters parameters from postDeleteUser-Hook
* @return array
*/
- public function deleteUser($parameters) {
+ static public function deleteUser($parameters) {
$addressbooks = OC_Contacts_Addressbook::all($parameters['uid']);
foreach($addressbooks as $addressbook) {
@@ -38,4 +38,62 @@ class OC_Contacts_Hooks{
return true;
}
+
+ /**
+ * @brief Adds the CardDAV resource to the DAV server
+ * @param paramters parameters from initialize-Hook
+ * @return array
+ */
+ static public function initializeCardDAV($parameters){
+ // We need a backend, the root node and the carddav plugin
+ $parameters['backends']['carddav'] = new OC_Connector_Sabre_CardDAV();
+ $parameters['nodes'][] = new Sabre_CardDAV_AddressBookRoot($parameters['backends']['principal'], $parameters['backends']['carddav']);
+ $parameters['plugins'][] = new Sabre_CardDAV_Plugin();
+ return true;
+ }
+
+ static public function getCalenderSources($parameters) {
+ $base_url = OC_Helper::linkTo('calendar', 'ajax/events.php').'?calendar_id=';
+ foreach(OC_Contacts_Addressbook::all(OC_User::getUser()) as $addressbook) {
+ $parameters['sources'][] =
+ array(
+ 'url' => $base_url.'birthday_'. $addressbook['id'],
+ 'backgroundColor' => '#cccccc',
+ 'borderColor' => '#888',
+ 'textColor' => 'black',
+ 'cache' => true,
+ 'editable' => false,
+ );
+ }
+ }
+
+ static public function getBirthdayEvents($parameters) {
+ $name = $parameters['calendar_id'];
+ if (strpos('birthday_', $name) != 0) {
+ return;
+ }
+ $info = explode('_', $name);
+ $aid = $info[1];
+ OC_Contacts_App::getAddressbook($aid);
+ foreach(OC_Contacts_VCard::all($aid) as $card){
+ $vcard = OC_VObject::parse($card['carddata']);
+ $birthday = $vcard->BDAY;
+ if ($birthday) {
+ $date = new DateTime($birthday);
+ $vevent = new OC_VObject('VEVENT');
+ $vevent->setDateTime('LAST-MODIFIED', new DateTime($vcard->REV));
+ $vevent->setDateTime('DTSTART', $date, Sabre_VObject_Element_DateTime::DATE);
+ $vevent->setString('DURATION', 'P1D');
+ // DESCRIPTION?
+ $vevent->setString('RRULE', 'FREQ=YEARLY');
+ $title = str_replace('{name}', $vcard->getAsString('FN'), OC_Contacts_App::$l10n->t('{name}\'s Birthday'));
+ $parameters['events'][] = array(
+ 'id' => 0,//$card['id'],
+ 'vevent' => $vevent,
+ 'repeating' => true,
+ 'summary' => $title,
+ );
+ }
+ }
+ }
}
diff --git a/apps/contacts/lib/search.php b/apps/contacts/lib/search.php
index 5aad6a25f09..cf0a5fe6997 100644
--- a/apps/contacts/lib/search.php
+++ b/apps/contacts/lib/search.php
@@ -1,6 +1,6 @@
<?php
-class OC_Search_Provider_Contacts extends OC_Search_Provider{
- function search($query){
+class OC_Search_Provider_Contacts implements OC_Search_Provider{
+ static function search($query){
$addressbooks = OC_Contacts_Addressbook::all(OC_User::getUser(), 1);
// if(count($calendars)==0 || !OC_App::isEnabled('contacts')){
// //return false;
@@ -26,4 +26,3 @@ class OC_Search_Provider_Contacts extends OC_Search_Provider{
return $results;
}
}
-new OC_Search_Provider_Contacts();