function get_notices($limit=0) {
$user = $this->user;
- $notices = array();
-
- $notice = DB_DataObject::factory('notice');
-
- $notice->whereAdd('EXISTS (SELECT subscribed from subscription where subscriber = '.$user->id.' and subscribed = notice.profile_id)', 'OR');
- $notice->whereAdd('profile_id = ' . $user->id, 'OR');
-
- $notice->orderBy('created DESC');
- if ($limit != 0) {
- $notice->limit(0, $limit);
- }
- $notice->find();
-
+
+ $notice = $user->noticesWithFriends(0, $limit);
+
while ($notice->fetch()) {
$notices[] = clone($notice);
}
function get_image() {
$user = $this->user;
$profile = $user->getProfile();
+ if (!$profile) {
+ return NULL;
+ }
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
return ($avatar) ? $avatar->url : NULL;
}