From 641f2115180050769dd7519b82d21246f329a997 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Tue, 16 Feb 2010 21:45:22 +0100 Subject: [PATCH] User ProfileIterator for contacts (pdf and calendar). Also fix the code of ProfileIterator: Profile constructor is private, so use Profile::get() factory with the current row. Signed-off-by: Florent Bruneau --- classes/profile.php | 5 ++++- core | 2 +- modules/carnet.php | 12 ++++++------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/classes/profile.php b/classes/profile.php index 3e9ea2d..d6694ba 100644 --- a/classes/profile.php +++ b/classes/profile.php @@ -495,6 +495,9 @@ class Profile */ public static function get($login) { + if (is_array($login)) { + return new Profile($login); + } $pid = self::getPID($login); if (!is_null($pid)) { $it = self::iterOverPIDs(array($pid), false); @@ -590,7 +593,7 @@ class ProfileIterator implements PlIterator if ($data == null) { return null; } else { - return new Profile($data); + return Profile::get($data); } } diff --git a/core b/core index 47595f9..29bd16d 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 47595f9a4a4f4ee903e6ac02d64b9b5b5b6bf191 +Subproject commit 29bd16dff22ad53c92c51e799a1e68dadf9aeff5 diff --git a/modules/carnet.php b/modules/carnet.php index 0c8f790..51d2fdc 100644 --- a/modules/carnet.php +++ b/modules/carnet.php @@ -321,7 +321,7 @@ class CarnetModule extends PLModule Platal::session()->close(); - $order = array(new UFO_Name(UserFilter::LASTNAME), new UFO_Name(UserFilter::FIRSTNAME)); + $order = array(new UFO_Name(Profile::LASTNAME), new UFO_Name(Profile::FIRSTNAME)); if ($arg0 == 'promo') { $order = array_unshift($order, new UFO_Promo()); } else { @@ -331,8 +331,8 @@ class CarnetModule extends PLModule $pdf = new ContactsPDF(); - $profiles = $filter->getProfiles(); - foreach ($profiles as $p) { + $it = $filter->iterProfiles(); + while ($p = $it->next()) { $pdf = ContactsPDF::addContact($pdf, $p, $arg0 == 'photos' || $arg1 == 'photos'); } $pdf->Output(); @@ -363,13 +363,13 @@ class CarnetModule extends PLModule $page->register_function('display_ical', 'display_ical'); $filter = new UserFilter(new UFC_Contact($user)); + $profiles = $filter->iterProfiles(); $annivs = Array(); - foreach ($filter->getUsers() as $u) { - $profile = $u->profile(); + while ($profile = $profiles->next()) { $date = strtotime($profile->birthdate); $tomorrow = $date + 86400; $annivs[] = array( - 'timestamp' => strtotime($user->registration_date), + 'timestamp' => $date, 'date' => date('Ymd', $date), 'tomorrow' => date('Ymd', $tomorrow), 'hruid' => $profile->hrid(), -- 2.1.4