From 8d3ec9c92076e172e5871e3603c143333d73ac3c Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 7 Jul 2008 01:43:58 -0400 Subject: twiddle a few bits to make replies work correctly darcs-hash:20080707054358-84dde-916977a2af4f792e0dc9e02a9f5344ec60911319.gz --- classes/Profile.php | 15 +++++++++++++++ classes/User.php | 17 ++++------------- 2 files changed, 19 insertions(+), 13 deletions(-) (limited to 'classes') diff --git a/classes/Profile.php b/classes/Profile.php index 000590a98..f41acad4c 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -137,4 +137,19 @@ class Profile extends DB_DataObject function getBestName() { return ($this->fullname) ? $this->fullname : $this->nickname; } + + # Get latest notice on or before date; default now + function getCurrentNotice($dt=NULL) { + $notice = new Notice(); + $notice->profile_id = $this->id; + if ($dt) { + $notice->whereAdd('created < "' . $dt . '"'); + } + $notice->orderBy('created DESC'); + $notice->limit(1); + if ($notice->find(true)) { + return $notice; + } + return NULL; + } } diff --git a/classes/User.php b/classes/User.php index b22e486f3..c5119de15 100644 --- a/classes/User.php +++ b/classes/User.php @@ -95,17 +95,8 @@ class User extends DB_DataObject return !in_array($nickname, $merged); } - function getCurrentNotice() { - $notice = DB_DataObject::factory('notice'); - $profile = $this->getProfile(); - $notice->profile_id = $profile->id; - $notice->limit(1); - $notice->orderBy('created DESC'); - if ($notice->find()) { - $notice->fetch(); - return $notice; - } - return NULL; - } - + function getCurrentNotice($dt=NULL) { + $profile = $this->getProfile(); + return $profile->getCurrentNotice($dt); + } } -- cgit v1.2.3-54-g00ecf