Esempio n. 1
0
 /**
  * Execute the command.
  *
  * @return void
  */
 public function handle()
 {
     $forum = Forum::create($this->data);
     $this->user->forums()->save($forum);
     $this->project->forums()->save($forum);
     event(new FeedableEvent('ForumPosted', $this->user, $forum));
     return $forum;
 }
Esempio n. 2
0
 /**
  * Displays threads belonging to the given forum.
  *
  * @param $id The forum to find threads for
  * @return Response
  */
 public function listThreadsForForum($id)
 {
     // We only care about the ID before the first hyphen
     $id = strtok($id, '-');
     $forum = Forum::where('id', $id)->first();
     $threads = Thread::where('forum', $id)->join('users', 'users.id', '=', 'threads.author')->join('categories', 'categories.id', '=', 'threads.forum')->select('threads.*', 'users.username')->paginate(20);
     return view('forum', compact('threads', 'forum'));
 }
Esempio n. 3
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     try {
         App\Thread::findOrFail($id);
     } catch (ModelNotFoundException $e) {
         return redirect('/');
     }
     $this->data['posts'] = App\Thread::findOrFail($id)->posts()->select('posts.*', 'threads.forum_id')->join('threads', 'threads.id', '=', 'posts.thread_id')->paginate(10);
     foreach ($this->data['posts'] as $post) {
         $post->user = App\Post::findOrFail($post->id)->author;
         $post->user->post_count = App\User::findOrFail($post->user->id)->posts()->count();
     }
     $this->data['forum'] = App\Forum::where('id', $this->data['posts'][0]->forum_id)->first();
     $this->data['thread'] = App\Thread::where('id', $id)->first();
     return view('forum.threads.show', $this->data);
 }
 /**
  * Get forum page (a listing of containing threads)
  * @param integer $fid Forum ID
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
  */
 public function getForum($fid)
 {
     $forum = Forum::where('id', $fid)->first();
     if ($forum->type == 0) {
         // Viewing standard forum
         return view('clearboard.pages.forum', ['forum' => $forum]);
     } elseif ($forum->type == 1) {
         // Viewing category
         // @TODO implement viewing of categories
         abort(501);
         // Not Implemented
     } elseif ($forum->type == 2) {
         // Viewing redirect
         $redirect = $forum->meta;
         return redirect($redirect);
     }
 }
Esempio n. 5
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     try {
         App\Forum::findOrFail($id);
     } catch (ModelNotFoundException $e) {
         return redirect('/');
     }
     $this->data['threads'] = App\Thread::where('threads.forum_id', '=', $id)->join('users', 'users.id', '=', 'threads.user_id')->select('users.username', 'threads.*')->orderBy('threads.updated_at', 'desc')->paginate(15);
     foreach ($this->data['threads'] as $thread) {
         $thread->latest = App\Post::where('posts.thread_id', '=', $thread->id)->orderBy('posts.id', 'desc')->join('users', 'users.id', '=', 'posts.user_id')->first();
         foreach ($this->data['threads'] as $thread) {
             $thread->post_count = App\Post::where('posts.thread_id', '=', $thread->id)->count();
         }
     }
     $this->data['forum'] = App\Forum::findOrFail($id);
     return view('forum.show', $this->data);
 }
Esempio n. 6
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     $users = \App\User::lists('id')->all();
     $forums = \App\Forum::lists('id')->all();
     $faker = \Faker\Factory::create();
     foreach (range(1, 200) as $index) {
         $user_id = $faker->randomElement($users);
         $thread = \App\Thread::create(['user_id' => $user_id, 'forum_id' => $faker->randomElement($forums), 'title' => $faker->sentence(6), 'slug' => $faker->slug]);
         $text = $faker->paragraphs(mt_rand(1, 5));
         $paragraphs = '';
         foreach ($text as $index => $t) {
             $paragraphs .= $t;
             if ($index != count($text) - 1) {
                 $paragraphs .= "\n\n";
             }
         }
         \App\Post::create(['user_id' => $user_id, 'thread_id' => $thread->id, 'thread_first' => $thread->id, 'post' => $paragraphs]);
     }
     Model::reguard();
 }
Esempio n. 7
0
 /**
  *  Display the user dashboard
  *
  */
 public function dashboard()
 {
     // Get user data to display
     $user = Auth::user();
     $job_list = array('paladin' => 'Paladin', 'monk' => 'Monk', 'warrior' => 'Warrior', 'dragoon' => 'Dragoon', 'bard' => 'Bard', 'ninja' => 'Ninja', 'white-mage' => 'White Mage', 'black-mage' => 'Black Mage', 'scholar' => 'Scholar', 'summoner' => 'Summoner', 'dark-knight' => 'Dark Knight', 'machinist' => 'Machinist', 'astrologian' => 'Astrologian');
     // Have a look for any posts that mention the user
     $mention_posts = collect();
     if ($user->character_name) {
         $character_name = explode(' ', $user->character_name);
         $mention_posts = Post::with('thread')->with('user')->where('content', 'like', '%@' . $character_name[0] . '%')->orWhere('content', 'like', '%@' . $character_name[0] . $character_name[1] . '%')->orderBy('created_at', 'DESC')->limit(5)->get();
     }
     // Get the latest topics
     // Get the users permissions
     $accessCollection = $user->forumAccess;
     $latest_posts = Post::with('thread')->with('user')->whereIn('forum_id', $accessCollection)->orderBy('created_at', 'DESC')->limit(7)->get();
     if ($user->hasRole('administrators')) {
         $group_list = Role::all();
         $group_array = array();
         foreach ($group_list as $group) {
             $group_array[$group->id] = $group->display_name;
         }
         $permission_list = Permission::all();
         $permission_array = array();
         foreach ($permission_list as $permission) {
             $permission_array[$permission->id] = $permission->display_name;
         }
         $users_list = User::all();
         $users_array = array();
         foreach ($users_list as $users) {
             $users_array[$users->id] = $users->character_name ? $users->character_name : $users->name;
         }
         $forums_list = Forum::orderBy('display_order', 'asc')->get();
         return view('user.dashboard')->withUser($user)->withMentionPosts($mention_posts)->withLatestPosts($latest_posts)->withJobList($job_list)->withGroupList($group_list)->withGroupArray($group_array)->withPermissionArray($permission_array)->withUsersArray($users_array)->withForumList($forums_list);
     } else {
         return view('user.dashboard')->withUser($user)->withJobList($job_list)->withMentionPosts($mention_posts)->withLatestPosts($latest_posts);
     }
 }
Esempio n. 8
0
<?php

namespace App;

use App\PostProcessor\PostProcessor;
use Route;
/*
 * Clearboard Routes
 */
Route::get('/', function () {
    return view('clearboard.pages.index', ['forums' => Forum::all()]);
});
Route::get('/forum/{fid}-{_}', 'ForumController@getForum');
Route::get('/thread/{tid}-{_}', 'ThreadController@getThread');
// Route for processing markdown to HTML.
Route::post('/ajax/markdown', 'MarkdownController@postParse');
Route::post('/ajax/markdown_inline', 'MarkdownController@postInlineParse');
// for parsing inline markdown
// Posting routes
Route::post('/ajax/new_post', 'PostController@newPost');
Route::post('/ajax/new_thread', 'ThreadController@newThread');
Route::get('/newthread/{forumid}', 'ThreadController@createThread')->middleware('auth');
// Registration
Route::get('/register', function () {
    return view('clearboard.pages.register');
});
Route::post('/ajax/register', 'LoginController@postRegister');
// Authentication routes
Route::group(array('prefix' => '/auth'), function () {
    Route::post('/login', 'LoginController@postLogin');
    Route::get('/logout', 'Auth\\AuthController@getLogout');
Esempio n. 9
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Project $project, Forum $forum, Request $request)
 {
     $forum->update($request->only('name', 'description'));
     return response()->json(['success' => true, 'message' => 'Forum Updated.', $request->only('description')]);
 }
Esempio n. 10
0
 private function CreateForum($name, $description, $priority, $category_id = 0)
 {
     return Forum::Create(['category_id' => $category_id, 'name' => $name, 'description' => $description, 'priority' => $priority]);
 }
Esempio n. 11
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $forum = Forum::find($id);
     $this->validate($request, ['name' => 'required|unique:forums,name,' . $forum->id . '|max:255', 'description' => 'required']);
     // Update forum
     $forum->name = $request->name;
     $forum->slug = str_slug($request->name, '-');
     $forum->description = $request->description;
     $forum->display_order = $request->display_order;
     if ($forum->save()) {
         Session::flash('alert-success', 'Forum updated.');
     }
     return redirect('dashboard');
 }
Esempio n. 12
0
 public function stestForumPosted()
 {
     $project = Project::create($this->projectdata);
     $user = User::firstOrFail();
     $forum = Forum::create($this->forumdata);
     //~ $user->forums()->save($forum);
     $forum->owner()->associate($user);
     $project->forums()->save($forum);
     event(new ForumPosted($user, $project, $forum));
     $this->assertEquals(1, $user->forums->count());
     $this->assertEquals(1, $project->forums->count());
     $this->assertEquals($user->id, $forum->owner->id);
     $this->assertEquals($project->id, $forum->project->id);
     $this->assertEquals(1, Feed::count());
     $this->assertEquals($forum->id, Feed::firstOrFail()->feedable->id);
     $this->assertEquals($project->id, Feed::firstOrFail()->project_id);
     $this->assertEquals(ForumPosted::class, $forum->feed->type);
 }
 /**
  * Create thread page
  * @param integer $forumid Forum ID
  * @return \Illuminate\View\View
  */
 public function createThread($forumid)
 {
     $forum = Forum::findOrFail($forumid);
     return view('clearboard.pages.newthread', ['forum' => Forum::find($forumid)]);
 }