+ function buildBirthRef(Profile $profile)
+ {
+ $date = strtotime($profile->birthdate);
+ $tomorrow = $date + 86400;
+ return array(
+ 'timestamp' => $date,
+ 'date' => date('Ymd', $date),
+ 'tomorrow' => date('Ymd', $tomorrow),
+ 'hruid' => $profile->hrid(),
+ 'summary' => 'Anniversaire de ' . $profile->fullName(true)
+ );
+ }
+
+ function handler_csv_birthday(&$page, $alias = null, $hash = null)
+ {
+ $user = Platal::session()->tokenAuth($alias, $hash);
+ if (is_null($user)) {
+ if (S::logged()) {
+ $user == S::user();
+ } else {
+ return PL_FORBIDDEN;
+ }
+ }
+
+ $page->changeTpl('carnet/calendar.outlook.tpl', NO_SKIN);
+ $filter = new UserFilter(new UFC_Contact($user));
+ $profiles = $filter->iterProfiles();
+ $page->assign('events', PlIteratorUtils::map($profiles, array($this, 'buildBirthRef')));
+ $years = array(date("Y"));
+ for ($i = 1; $i <= 10; ++$i) {
+ $years[] = $years[0] + $i;
+ }
+ $page->assign('years', $years);
+ $lang = 'fr';
+ if (preg_match('/([a-zA-Z]{2,8})($|[^a-zA-Z])/', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $matches)) {
+ $lang = strtolower($matches[1]);
+ }
+ $page->assign('lang', $lang);
+ if ($lang == 'fr') {
+ $encoding = 'iso8859-15';
+ } else {
+ $encoding = 'utf-8';
+ }
+ pl_content_headers("text/comma-separated-values;charset=".$encoding);
+ }
+