Beispiel #1
0
 /**
  * Get user's notifications.
  *
  * @param   Model_User  $target
  * @return  array
  */
 public static function get_notifications(Model_User $target)
 {
     $notifications = array();
     /** @var  Model_Notification  $notification */
     foreach (Model_Notification::factory()->find_by_target($target) as $notification) {
         // Ignored?
         if ($target->is_ignored($notification->user_id)) {
             $notification->delete();
             continue;
         }
         $class = 'Notification_' . $notification->class;
         if (method_exists($class, 'get') && ($text = call_user_func(array($class, 'get'), $notification))) {
             $notifications[$notification->id] = $text;
         }
     }
     return $notifications;
 }
Beispiel #2
0
 /**
  * Controller default action
  */
 public function action_index()
 {
     // Dismiss notification?
     if ($dismiss = (int) Arr::get($_REQUEST, 'dismiss')) {
         $notification = Model_Notification::factory($dismiss);
         if ($notification->loaded()) {
             Permission::required($notification, Model_Notification::PERMISSION_DELETE);
             $notification->delete();
             /*				if ($this->_request_type == self::REQUEST_AJAX) {
             					$this->response->body('');
             
             					return;
             				}*/
         }
     }
     $section = $this->section_notifications(Notification::get_notifications(Visitor::$user));
     if ($this->_request_type == self::REQUEST_AJAX) {
         $this->response->body($section);
     } else {
         $this->view = new View_Page('Notifications');
         $this->view->add(View_Page::COLUMN_CENTER, $section);
     }
 }