addNotification() public static method

addNotification
public static addNotification ( string $type = 'topic', integer $targetId, integer $userId ) : mixed | Windwalker\Data\Data
$type string
$targetId integer
$userId integer
return mixed | Windwalker\Data\Data
Esempio n. 1
0
 /**
  * postSave
  *
  * @param Data $data
  *
  * @throws ValidFailException
  */
 protected function postSave(Data $data)
 {
     $input = array('item' => array('topic_id' => $data->id, 'primary' => 1, 'body' => $data->body));
     if (!$this->hmvc($controller = new \Forum\Controller\Post\SaveController(), $input)) {
         list($url, $msg, $type) = $controller->getRedirect(true);
         throw new ValidFailException($msg);
     }
     $post = $controller->getPost();
     $data->last_reply_post = $post->id;
     // Add Notification
     Notification::addNotification('topic', $data->id, $data->user_id);
 }
Esempio n. 2
0
 /**
  * postSave
  *
  * @param Data $data
  *
  * @return  void
  */
 protected function postSave(Data $data)
 {
     $this->post = $data;
     $this->topic = $topic = $this->model->getRecord('Topic');
     $topic->load($data->topic_id);
     $this->category = $this->model->getRecord('Category');
     $this->category->load($topic->category_id);
     if ($this->isNew) {
         if (!$data->primary) {
             $user = User::get();
             $date = DateTime::create();
             $topic->last_reply_user = $user->id;
             $topic->last_reply_post = $data->id;
             $topic->last_reply_date = $date->toSql();
             $topic->replies++;
             $topic->store();
         } else {
             $this->category->topics++;
         }
         $this->category->posts++;
         $this->category->store();
     }
     // Mail
     $this->sendMail($topic, $data);
     // Add Notification
     Notification::addNotification('topic', $topic->id, $topic->user_id);
 }
Esempio n. 3
0
 /**
  * doSave
  *
  * @param Data $data
  *
  * @return  void
  *
  * @throws ValidFailException
  */
 protected function doSave(Data $data)
 {
     $user = User::get();
     if (!$user->isMember()) {
         throw new ValidFailException('User not login');
     }
     Notification::addNotification($data->type, $data->target_id, $user->id);
 }