コード例 #1
0
 /**
  * Display a listing of the resource.
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     \Nexus\Helpers\ActivityHelper::updateActivity(\Auth::user()->id, "Checking out <em>who else is online</em>", action('Nexus\\ActivityController@index'));
     $activities = \Nexus\Helpers\ActivityHelper::recentActivities();
     $breadcrumbs = \Nexus\Helpers\BreadcrumbHelper::breadcumbForUtility('Who is Online');
     return view('activities.index', compact('activities', 'breadcrumbs'));
 }
コード例 #2
0
 /**
  * Display the specified resource.
  *
  * @param  string  $user_name - the name of the user
  * @return Response
  */
 public function show($user_name)
 {
     try {
         $user = \Nexus\User::with('comments', 'comments.author')->where('username', $user_name)->firstOrFail();
     } catch (ModelNotFoundException $ex) {
         $message = "{$user_name} not found. Maybe you're thinking of someone else";
         \Nexus\Helpers\FlashHelper::showAlert($message, 'warning');
         return redirect('/users/');
     }
     if ($user->id === \Auth::user()->id) {
         \Auth::user()->markCommentsAsRead();
         \Auth::user()->save();
     }
     \Nexus\Helpers\ActivityHelper::updateActivity(\Auth::user()->id, "Examining <em>{$user->username}</em>", action('Nexus\\UserController@show', ['user_name' => $user_name]));
     $breadcrumbs = \Nexus\Helpers\BreadcrumbHelper::breadcrumbForUser($user);
     return view('users.show', compact('user', 'breadcrumbs'));
 }
コード例 #3
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $trashedSections = \Nexus\Section::onlyTrashed()->where('user_id', \Auth::user()->id)->with('trashedTopics')->get();
     // add trashed sections which are children of moderated sections which are not moderated by the user
     // @todo: can this be a query?
     foreach (\Auth::user()->sections as $moderatedSections) {
         $unmoderatedSections = $moderatedSections->sections()->onlyTrashed()->with('trashedTopics')->where('user_id', '!=', \Auth::user()->id)->get();
         foreach ($unmoderatedSections as $unmoderatedSection) {
             $trashedSections->push($unmoderatedSection);
         }
     }
     $trashedSections = $trashedSections->sortByDesc('deleted_at');
     $trashedTopics = \Auth::user()->trashedTopics;
     $breadcrumbs = \Nexus\Helpers\BreadcrumbHelper::breadcumbForUtility('Your Archive');
     $destinationSections = \Auth::user()->sections()->get();
     return view('restore.index', compact('trashedSections', 'trashedTopics', 'breadcrumbs', 'destinationSections'));
 }
コード例 #4
0
 /**
  * Displays a list of messages sent to the logged in user
  * @todo - generate $activeUsers array from a list of active users
  * @return Response
  */
 public function index($selected = null)
 {
     $allMessages = \Nexus\Message::with('user')->with('author')->where('user_id', \Auth::user()->id)->orderBy('id', 'desc')->get()->all();
     $messages = array_slice($allMessages, 5);
     $recentMessages = array_reverse(array_slice($allMessages, 0, 5));
     $recentActivities = \Nexus\Helpers\ActivityHelper::recentActivities();
     $activeUsers = array();
     foreach ($recentActivities as $activity) {
         if (\Auth::user()->id != $activity['user_id']) {
             $activeUsers[$activity['user_id']] = $activity->user->username;
         }
     }
     // mark all messages as read
     \Nexus\Message::where('user_id', \Auth::user()->id)->update(['read' => true]);
     \Nexus\Helpers\ActivityHelper::updateActivity(\Auth::user()->id, "Viewing <em>Inbox</em>", action('Nexus\\MessageController@index'));
     $breadcrumbs = \Nexus\Helpers\BreadcrumbHelper::breadcumbForUtility('Inbox');
     return view('messages.index')->with(compact('messages', 'recentMessages', 'activeUsers', 'selected', 'breadcrumbs'));
 }
コード例 #5
0
    /**
     * perform a search against all the posts and
     * return some results
     * @todo - ignore word order
     * @todo - remove stop words
     * @todo - deal with exact phrases
     */
    public function find($text)
    {
        $phraseSearch = false;
        $displaySearchResults = true;
        // if text is ^"(.*)"$ or ^'(.*)'$ then we are searching for a phrase
        $pattern = <<<'pattern'
/^['|"](.*)['|"]$/
pattern;
        $matches = false;
        preg_match($pattern, $text, $matches);
        if (!$matches) {
            // set initial results as nothing
            $results = false;
            // look for all the words
            $rawSearchTerms = explode(' ', $text);
            $searchTerms = array();
            // remove stop words here
            foreach ($rawSearchTerms as $word) {
                if (!in_array(strtolower($word), self::$stopWords)) {
                    $searchTerms[] = $word;
                }
            }
            // dd($searchTerms);
            foreach ($searchTerms as $word) {
                // remove unwanted characters from the start and end
                // @todo this does not remove multiple unwanted commas etc
                $word = trim($word);
                if (strlen($word) !== 0) {
                    if ($results) {
                        $results = $results->where('text', 'like', "%{$word}%");
                    } else {
                        // first where
                        $results = \Nexus\Post::where('text', 'like', "%{$word}%");
                    }
                }
            }
        } else {
            $phrase = trim($matches[1]);
            $results = \Nexus\Post::where('text', 'like', "%{$phrase}%");
        }
        if ($results) {
            $results->orderBy('time', 'desc');
        }
        \Nexus\Helpers\ActivityHelper::updateActivity(\Auth::user()->id, "Searching", action('Nexus\\SearchController@index'));
        $breadcrumbs = \Nexus\Helpers\BreadcrumbHelper::breadcumbForUtility('Search');
        return view('search.results', compact('results', 'breadcrumbs', 'text', 'displaySearchResults'));
    }
コード例 #6
0
 public function latest()
 {
     $heading = 'Latest Posts';
     $lead = "The most recent posts from across Nexus";
     $topics = $this::recentTopics();
     $breadcrumbs = \Nexus\Helpers\BreadcrumbHelper::breadcumbForUtility($heading);
     return view('topics.unread', compact('topics', 'heading', 'lead', 'breadcrumbs'));
 }
コード例 #7
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($topic_id)
 {
     $posts = \Nexus\Post::with('author')->where('topic_id', $topic_id)->orderBy('id', 'dsc');
     $topic = \Nexus\Topic::findOrFail($topic_id);
     // is this topic readonly to the authenticated user?
     $readonly = true;
     if ($topic->readonly == false) {
         $readonly = false;
     }
     if ($topic->section->moderator->id === \Auth::user()->id) {
         $readonly = false;
     }
     if (\Auth::user()->administrator) {
         $readonly = false;
     }
     // is this topic secret to the authenticated user?
     $userCanSeeSecrets = false;
     if ($topic->section->moderator->id === \Auth::user()->id) {
         $userCanSeeSecrets = true;
     }
     if (\Auth::user()->administrator) {
         $userCanSeeSecrets = true;
     }
     // get the previously read progress so we can indicate this in the view
     $readProgress = \Nexus\Helpers\ViewHelper::getReadProgress(\Auth::user(), $topic);
     // get the subscription status
     $topicStatus = \Nexus\Helpers\ViewHelper::getTopicStatus(\Auth::user(), $topic);
     $unsubscribed = $topicStatus['unsubscribed'];
     \Nexus\Helpers\ViewHelper::updateReadProgress(\Auth::user(), $topic);
     \Nexus\Helpers\ActivityHelper::updateActivity(\Auth::user()->id, "Reading <em>{$topic->title}</em>", action('Nexus\\TopicController@show', ['id' => $topic->id]));
     $breadcrumbs = \Nexus\Helpers\BreadcrumbHelper::breadcrumbForTopic($topic);
     return view('topics.index', compact('topic', 'posts', 'readonly', 'userCanSeeSecrets', 'readProgress', 'breadcrumbs', 'unsubscribed'));
 }