/**
  * Dispatch a notification
  * @param OrongoNotification $paramNotification OrongoNotification 
  * @param User $paramUser User to notify
  */
 public static function dispatchNotification($paramNotification, $paramUser)
 {
     if ($paramNotification instanceof OrongoNotification == false) {
         throw new IllegalArgumentException("Invalid argument, OrongoNotification expected.");
     }
     if ($paramUser instanceof User == false) {
         throw new IllegalArgumentException("Invalid argument, User object expected.");
     }
     getDatabase()->insert("notifications", array("id" => self::getLastNotificationID() + 1, "title" => $paramNotification->getTitle(), "text" => $paramNotification->getText(), "image" => $paramNotification->getImage(), "time" => $paramNotification->getTime(), "userID" => $paramUser->getID()));
 }
 public function __invoke($args)
 {
     if (count($args) < 2) {
         throw new OrongoScriptParseException("Arguments missing for Notification.Notify()");
     }
     $title = isset($args[2]) ? $args[2] : "OrongoCMS";
     $image = isset($args[3]) ? $args[3] : null;
     $time = isset($args[4]) && is_numeric($args[4]) ? intval($args[4]) : 10000;
     $n = new OrongoNotification($title, $args[1], $image, $time);
     $n->dispatch(new User($args[0]));
 }
Example #3
0
 /**
  * Shortcut for notifying user 
  * @param String $paramTitle title of notification
  * @param String $paramText text of notification
  * @param String $paramImage image url for notification [optional]
  * @param int $paramTime duration of notification (default = 10000 ms)
  */
 public function notify($paramTitle, $paramText, $paramImage = null, $paramTime = 10000)
 {
     $n = new OrongoNotification($paramTitle, $paramText, $paramImage, $paramTime);
     $n->dispatch($this);
 }