diff options
Diffstat (limited to 'apps/contacts/lib/hooks.php')
-rw-r--r-- | apps/contacts/lib/hooks.php | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/apps/contacts/lib/hooks.php b/apps/contacts/lib/hooks.php index 3afad1ef7d3..8b7adc60f27 100644 --- a/apps/contacts/lib/hooks.php +++ b/apps/contacts/lib/hooks.php @@ -21,6 +21,15 @@ */ /** + * The following signals are being emitted: + * + * OC_Contacts_VCard::post_moveToAddressbook(array('aid' => $aid, 'id' => $id)) + * OC_Contacts_VCard::pre_deleteVCard(array('aid' => $aid, 'id' => $id, 'uri' = $uri)); (NOTE: the values can be null depending on which method emits them) + * OC_Contacts_VCard::post_updateVCard($id) + * OC_Contacts_VCard::post_createVCard($newid) + */ + +/** * This class contains all hooks. */ class OC_Contacts_Hooks{ @@ -30,7 +39,7 @@ class OC_Contacts_Hooks{ * @return array */ static public function createUser($parameters) { - OC_Contacts_Addressbook::add($parameters['uid'],'default','Default Address Book'); + OC_Contacts_Addressbook::addDefault($parameters['uid']); return true; } @@ -52,8 +61,8 @@ class OC_Contacts_Hooks{ static public function getCalenderSources($parameters) { $base_url = OCP\Util::linkTo('calendar', 'ajax/events.php').'?calendar_id='; foreach(OC_Contacts_Addressbook::all(OCP\USER::getUser()) as $addressbook) { - $parameters['sources'][] = - array( + $parameters['sources'][] + = array( 'url' => $base_url.'birthday_'. $addressbook['id'], 'backgroundColor' => '#cccccc', 'borderColor' => '#888', @@ -66,7 +75,7 @@ class OC_Contacts_Hooks{ static public function getBirthdayEvents($parameters) { $name = $parameters['calendar_id']; - if (strpos('birthday_', $name) != 0) { + if (strpos($name, 'birthday_') != 0) { return; } $info = explode('_', $name); @@ -81,17 +90,25 @@ class OC_Contacts_Hooks{ 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->setDateTime('LAST-MODIFIED', new DateTime($vcard->REV)); + $vevent->setDateTime('DTSTART', $date, + Sabre_VObject_Element_DateTime::DATE); $vevent->setString('DURATION', 'P1D'); + $vevent->setString('UID', substr(md5(rand().time()), 0, 10)); // DESCRIPTION? $vevent->setString('RRULE', 'FREQ=YEARLY'); - $title = str_replace('{name}', $vcard->getAsString('FN'), OC_Contacts_App::$l10n->t('{name}\'s Birthday')); + $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, + 'calendardata' => "BEGIN:VCALENDAR\nVERSION:2.0\n" + . "PRODID:ownCloud Contacts " + . OCP\App::getAppVersion('contacts') . "\n" + . $vevent->serialize() . "END:VCALENDAR" ); } } |