Beispiel #1
0
 /**
  * Add a Notification.
  *
  * @static
  * @param   Model_User  $user
  * @param   Model_User  $target
  * @param   string      $class  e.g. 'user'
  * @param   string      $type   e.g. 'login'
  * @param   integer     $data_id
  * @param   string      $text   extra data
  * @return  boolean
  */
 protected static function add(Model_User $user, Model_User $target, $class, $type, $data_id = null, $text = null)
 {
     $notification = new Model_Notification();
     $notification->set_fields(array('user_id' => $user->id, 'target_id' => $target->id, 'class' => $class, 'type' => $type, 'data_id' => $data_id, 'text' => $text, 'stamp' => time()));
     if (!Permission::has($notification, Model_Notification::PERMISSION_CREATE, $user)) {
         return false;
     }
     $notification->save();
     return $notification->loaded();
 }