From: Florent Bruneau Date: Sat, 13 Feb 2010 21:56:02 +0000 (+0100) Subject: Use UserFilter to generate birthday calendar. X-Git-Tag: xorg/1.0.0~332^2~289 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=19550958a5a575ef8251f4f1ba34f41d6e190836;p=platal.git Use UserFilter to generate birthday calendar. Kill one usage of auth_user_md5. Signed-off-by: Florent Bruneau --- diff --git a/modules/carnet.php b/modules/carnet.php index aa51c29..7c656cc 100644 --- a/modules/carnet.php +++ b/modules/carnet.php @@ -371,30 +371,18 @@ class CarnetModule extends PLModule $page->changeTpl('carnet/calendar.tpl', NO_SKIN); $page->register_function('display_ical', 'display_ical'); - $res = XDB::iterRow( - 'SELECT u.prenom, - IF(u.nom_usage = \'\',u.nom,u.nom_usage) AS nom, - u.promo, - u.naissance, - DATE_ADD(u.naissance, INTERVAL 1 DAY) AS end, - u.date_ins, - u.hruid - FROM contacts AS c - INNER JOIN auth_user_md5 AS u ON (u.user_id = c.contact) - INNER JOIN aliases AS a ON (u.user_id = a.id AND a.type = \'a_vie\') - WHERE c.uid = {?}', $user->id()); - + $filter = new UserFilter(new UFC_Contact($user)); $annivs = Array(); - while (list($prenom, $nom, $promo, $naissance, $end, $ts, $hruid) = $res->next()) { - $naissance = str_replace('-', '', $naissance); - $end = str_replace('-', '', $end); + foreach ($filter->getUsers() as $u) { + $profile = $u->profile(); + $date = strtotime($profile->birthdate); + $tomorrow = $date + 86400; $annivs[] = array( - 'timestamp' => strtotime($ts), - 'date' => $naissance, - 'tomorrow' => $end, - 'hruid' => $hruid, - 'summary' => 'Anniversaire de '.$prenom - .' '.$nom.' - x '.$promo, + 'timestamp' => strtotime($user->registration_date), + 'date' => date('Ymd', $date), + 'tomorrow' => date('Ymd', $tomorrow), + 'hruid' => $profile->hrid(), + 'summary' => 'Anniversaire de ' . $profile->fullName(true) ); } $page->assign('events', $annivs);