00001 <?php
00002
00003
00004
00005 class WidgetLatestNotifications implements IWidget {
00006
00007
00008
00009
00010
00011 public $page_data;
00012
00013
00014
00015
00016
00017 public $user;
00018 public $num;
00019
00020
00021
00022
00023
00024
00025
00026
00027 public static function output($page_data, $user, $num = 5, $policy = self::NONE) {
00028 $w = new WidgetLatestNotifications($page_data, $user, $num);
00029 return $w->render($policy);
00030 }
00031
00032 public function __construct($page_data, $user, $num) {
00033 $this->page_data = $page_data;
00034 $this->user = $user;
00035 $this->num = $num;
00036 }
00037
00038
00039
00040
00041
00042
00043
00044 public function render($policy = self::NONE) {
00045 Load::models('notifications');
00046 $notifications = Notifications::create_unread_user_adapter($this->user->id);
00047 $total = $notifications->count();
00048 $notifications->limit(0, $this->num);
00049
00050 $view = ViewFactory::create_view(IViewFactory::MESSAGE, 'widgets/notifications.latest', false);
00051 $view->assign('notifications', $notifications->execute());
00052 $view->assign('total', $total);
00053 $view->assign('page_data', $this->page_data);
00054 return $view->render();
00055 }
00056 }