コード例 #1
0
ファイル: PostController.php プロジェクト: fant0m/VAII
 public function create($request)
 {
     $validate = $this->validate($request, $this->rules);
     if ($validate->errors() == 0) {
         $user = Auth::get();
         if ($user) {
             $post = new Post($request);
             $post->user_id = Auth::getUserId();
             $post->text = nl2br($post->text);
             $post->update();
             foreach ($user->followers() as $follower) {
                 $notification = new Notification();
                 $notification->text = 'Používateľ ' . $user->nick . ' pridal nový príspevok s nadpisom ' . $post->title . '!';
                 $notification->user_id = $follower->id;
                 $notification->link = 'prispevok/' . $post->id;
                 $notification->save();
             }
             return json_encode(['success' => 'Hejt bol úspešne pridaný!']);
         }
     } else {
         return json_encode(['errors' => $validate->getErrors()]);
     }
 }
コード例 #2
0
ファイル: Note.php プロジェクト: OneTimeCZ/Tasker
 /**
  * @param ChildNotification $notification The ChildNotification object to add.
  */
 protected function doAddNotification(ChildNotification $notification)
 {
     $this->collNotifications[] = $notification;
     $notification->setNote($this);
 }
コード例 #3
0
 /**
  * Exclude object from result
  *
  * @param   ChildNotification $notification Object to remove from the list of results
  *
  * @return $this|ChildNotificationQuery The current query, for fluid interface
  */
 public function prune($notification = null)
 {
     if ($notification) {
         $this->addUsingAlias(NotificationTableMap::COL_ID, $notification->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
コード例 #4
0
ファイル: UserQuery.php プロジェクト: OneTimeCZ/Tasker
 /**
  * Filter the query by a related \Models\Notification object
  *
  * @param \Models\Notification|ObjectCollection $notification the related object to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildUserQuery The current query, for fluid interface
  */
 public function filterByNotificationRelatedByOriginTypeOriginId($notification, $comparison = null)
 {
     if ($notification instanceof \Models\Notification) {
         return $this->where("'user' = ?", $notification->getOriginType(), 2)->addUsingAlias(UserTableMap::COL_ID, $notification->getOriginId(), $comparison);
     } else {
         throw new PropelException('filterByNotificationRelatedByOriginTypeOriginId() only accepts arguments of type \\Models\\Notification');
     }
 }
コード例 #5
0
ファイル: MessageController.php プロジェクト: fant0m/VAII
 public function update($request)
 {
     $validate = $this->validate($request, $this->rules);
     if ($validate->errors() == 0 && Auth::get()) {
         $conversation = new Conversation();
         $conversation = $conversation->find((int) $request->id);
         if ($conversation) {
             if ($conversation->hasAccess()) {
                 $conversation->updated_at = date('Y-m-d H:i:s');
                 $conversation->update();
                 $message = new Message();
                 $message->conversation_id = $conversation->id;
                 $message->sender_id = Auth::get()->id;
                 $message->text = nl2br(htmlspecialchars($request->text));
                 $message->save();
                 $notification = new Notification();
                 $notification->text = 'Používateľ ' . Auth::get()->nick . ' vám poslal novú správu!';
                 $notification->user_id = $conversation->getUserId();
                 $notification->link = 'sprava/' . $conversation->id;
                 $notification->save();
                 return json_encode(['success' => 'Správa bola úspešne odoslaná!']);
             } else {
                 return json_encode(['errors' => ['Nemáte prístup!']]);
             }
         }
     } else {
         return json_encode(['errors' => $validate->getErrors()]);
     }
 }
コード例 #6
0
ファイル: User.php プロジェクト: OneTimeCZ/Tasker
 /**
  * @param ChildNotification $notificationRelatedByOriginTypeOriginId The ChildNotification object to add.
  */
 protected function doAddNotificationRelatedByOriginTypeOriginId(ChildNotification $notificationRelatedByOriginTypeOriginId)
 {
     $this->collNotificationsRelatedByOriginTypeOriginId[] = $notificationRelatedByOriginTypeOriginId;
     $notificationRelatedByOriginTypeOriginId->setOriginUser($this);
 }