diff options
author | Thomas Tanghus <thomas@tanghus.net> | 2012-03-07 20:57:05 +0100 |
---|---|---|
committer | Thomas Tanghus <thomas@tanghus.net> | 2012-03-07 20:57:05 +0100 |
commit | 57c4d39b1e0becaeeb795cfbfd70f525bd89b9d8 (patch) | |
tree | 5a12c8c7d83574b9bff3e4271e88ec740820c2aa /apps/contacts/lib | |
parent | 75323b86d157c48031b9ac8c151e4a41577a1481 (diff) | |
parent | cf5d63f0abc2b4537098962ad5051180861f965b (diff) | |
download | nextcloud-server-57c4d39b1e0becaeeb795cfbfd70f525bd89b9d8.tar.gz nextcloud-server-57c4d39b1e0becaeeb795cfbfd70f525bd89b9d8.zip |
Fix conflict.
Diffstat (limited to 'apps/contacts/lib')
-rw-r--r-- | apps/contacts/lib/app.php | 2 | ||||
-rw-r--r-- | apps/contacts/lib/hooks.php | 60 | ||||
-rw-r--r-- | apps/contacts/lib/search.php | 5 |
3 files changed, 62 insertions, 5 deletions
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(); |