Пример #1
0
 /**
  * @param string                               $slug
  * @param int                                  $id
  * @param ProfileFieldGroupRepositoryInterface $profileFieldGroups
  * @param Breadcrumbs                          $breadcrumbs
  *
  * @return \Illuminate\View\View
  */
 public function profile($slug, $id, ProfileFieldGroupRepositoryInterface $profileFieldGroups, Breadcrumbs $breadcrumbs)
 {
     $user = $this->users->find($id);
     if (!$user) {
         throw new UserNotFoundException();
     }
     $groups = $profileFieldGroups->getAll();
     $breadcrumbs->setCurrentRoute('user.profile', $user);
     return view('user.profile', ['user' => $user, 'profile_field_groups' => $groups]);
 }
 /**
  * {@inheritdoc}
  */
 public function addMessageToConversation(Conversation $conversation, array $details, $checkParticipants = true)
 {
     $details['message_parsed'] = $this->messageFormatter->parse($details['message'], [MessageFormatter::ME_USERNAME => $this->userRepository->find($details['author_id'])->name]);
     // TODO: Parser options...
     $message = $conversation->messages()->create($details);
     if ($message) {
         $conversation->update(['last_message_id' => $message->id]);
         if ($checkParticipants) {
             $users = $conversation->participants()->wherePivot('has_left', true)->get(['user_id'])->lists('user_id');
             $conversation->participants()->newPivotStatement()->where('conversation_id', $conversation->id)->whereIn('user_id', $users)->update(['has_left' => false]);
             // This would be the better query but only MySQL wants to run it, PgSQL and SQLite don't like it
             // $conversation->participants()->wherePivot('has_left', true)->update(['has_left' => false]);
         }
     }
     return $message;
 }
Пример #3
0
 /**
  * @param string $route
  * @param array  $parameters
  *
  * @return array
  */
 private function getWioData($route, array $parameters)
 {
     $data = array();
     switch ($route) {
         case 'forums.show':
             $forum = $this->forumRepository->find($parameters['id']);
             // Either the forum has been deleted or this user doesn't have permission to view it
             if ($forum != null) {
                 $data['forum'] = e($forum->title);
             } else {
                 $data['langString'] = 'forums.invalid';
             }
             break;
         case 'topics.show':
         case 'topics.reply':
         case 'topics.quote':
         case 'topics.reply.post':
         case 'topics.edit':
         case 'topics.delete':
         case 'topics.restore':
             $topic = $this->topicRepository->find($parameters['id']);
             // Either the topic has been deleted or this user doesn't have permission to view it
             if ($topic != null) {
                 $data['topic'] = e($topic->title);
                 $data['url'] = route('topics.show', [$parameters['slug'], $parameters['id']]);
             } else {
                 $data['langString'] = 'topics.invalid';
             }
             break;
         case 'topics.create':
             $forum = $this->forumRepository->find($parameters['forumId']);
             // Either the forum has been deleted or this user doesn't have permission to view it
             if ($forum != null) {
                 $data['forum'] = e($forum->title);
                 $data['url'] = route('forums.show', [$forum->slug, $forum->id]);
             } else {
                 $data['langString'] = 'forums.invalid';
             }
             break;
         case 'search.post':
         case 'search.results':
             $data['url'] = route('search');
             break;
         case 'user.profile':
             $user = $this->userRepository->find($parameters['id']);
             if ($user != null) {
                 $data['user'] = e($user->name);
                 $data['url'] = route('user.profile', [$user->name, $user->id]);
             } else {
                 $data['langString'] = 'user.invalid';
             }
             break;
         case 'conversations.index':
         case 'conversations.compose':
         case 'conversations.read':
         case 'conversations.reply':
         case 'conversations.leave':
         case 'conversations.newParticipant':
             $data['langString'] = 'conversations';
             break;
     }
     // TODO: Here's a nice place for a plugin hook
     return $data;
 }