/** * Store a notification to database. * * <code> * $userId = 1; * $note = "...."; * * $notification = new Prism\Integration\Notification\Gamification($userId, $note); * $notification->send(); * </code> * * @param string $content */ public function send($content = '') { if ($content !== '') { $this->content = $content; } $notification = new Notification($this->db); $notification->setContent($this->getContent()); $notification->setUserId($this->getUserId()); if ($this->title !== null) { $notification->setTitle($this->getTitle()); } if ($this->image !== null) { $notification->setImage($this->getImage()); } if ($this->url !== null) { $notification->setUrl($this->getUrl()); } $notification->store(); }
/** * Return the notifications as array with objects. * * <code> * $options = array( * "ids" => array(1,2,3,4,5) * ); * * $notifications = new Gamification\Notification\Notifications(\JFactory::getDbo()); * $notifications->load($options); * * $notifications = $notifications->getNotifications(); * </code> * * @return array */ public function getNotifications() { $results = array(); $i = 0; foreach ($this->items as $item) { $notification = new Notification($this->db); $notification->bind($item); $results[$i] = $notification; $i++; } return $results; }
/** * Store a notification to database. * * <code> * $userId = 1; * $note = "...."; * * $notification = new Prism\Integration\Notification\Gamification($userId, $note); * $notification->send(); * </code> * * @param string $content */ public function send($content = '') { if (\JString::strlen($content) > 0) { $this->content = $content; } $notification = new Notification(\JFactory::getDbo()); $notification->setContent($this->getContent()); $notification->setUserId($this->getUserId()); if ($this->title !== null) { $notification->setTitle($this->getTitle()); } if ($this->image !== null) { $notification->setImage($this->getImage()); } if ($this->url !== null) { $notification->setUrl($this->getUrl()); } $notification->store(); }
/** * Store a notification to database. * * <code> * $userId = 1; * $note = "...."; * * $notification = new Prism\Integration\Notification\Gamification($userId, $note); * $notification->send(); * </code> * * @param string $content */ public function send($content = "") { if (!empty($note)) { $this->content = $content; } $notification = new Notification(\JFactory::getDbo()); $notification->setContent($this->getContent()); $notification->setUserId($this->getUserId()); if (!empty($this->title)) { $notification->setTitle($this->getTitle()); } if (!empty($this->image)) { $notification->setImage($this->getImage()); } if (!empty($this->url)) { $notification->setUrl($this->getUrl()); } $notification->store(); }