1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2025-01-30 19:52:17 +01:00

Fix conflict.

This commit is contained in:
Thomas Tanghus 2012-03-07 20:57:05 +01:00
commit df70d9eeed
7 changed files with 79 additions and 19 deletions

View File

@ -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');

View File

@ -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());

View File

@ -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; }
#category_addinput { width: 10em; }

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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,
);
}
}
}
}

View File

@ -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();