Exemplo n.º 1
0
 public function putBanAndDeleteThreads($userId)
 {
     // Ban the user
     $user = $this->users->requireById($userId);
     $user->is_banned = 1;
     $this->users->save($user);
     // Remove all threads by the user
     $this->threads->deleteByAuthorId($userId);
     return $this->redirectAction('Admin\\UsersController@getIndex', ['success' => 'The user has been banned and its threads have been removed.']);
 }
Exemplo n.º 2
0
 private function validateAndSave($thread, $listener, $data)
 {
     if ($this->spamDetector->detectsSpam($thread->subject)) {
         $this->logSpam($thread->subject, $thread->author);
         $this->increaseUserSpamCount($thread->author);
         return $listener->threadCreationError(new MessageBag(['subject' => 'Title contains spam. Your account has been flagged.']));
     }
     if ($this->spamDetector->detectsSpam($thread->body)) {
         $this->logSpam($thread->body, $thread->author);
         $this->increaseUserSpamCount($thread->author);
         return $listener->threadCreationError(new MessageBag(['body' => 'Body contains spam. Your account has been flagged.']));
     }
     // check the model validation
     if (!$this->threads->save($thread)) {
         return $listener->threadCreationError($thread->getErrors());
     }
     // attach any tags that were passed through
     if (isset($data['tags'])) {
         $thread->setTags($data['tags']);
     }
     return $listener->threadCreated($thread);
 }