コード例 #1
0
 public function store()
 {
     if (Request::hasFile('cover_file') !== true) {
         abort(422);
     }
     $topic = null;
     if (presence(Request::input('topic_id')) !== null) {
         $topic = Topic::findOrFail(Request::input('topic_id'));
         priv_check('ForumTopicEdit', $topic)->ensureCan();
         if ($topic->cover !== null) {
             abort(422);
         }
     }
     try {
         $cover = TopicCover::upload(Request::file('cover_file')->getRealPath(), Auth::user(), $topic);
     } catch (ImageProcessorException $e) {
         return error_popup($e->getMessage());
     }
     return json_item($cover, new TopicCoverTransformer());
 }
コード例 #2
0
 public function store()
 {
     if (Request::hasFile('cover_file') !== true) {
         abort(422);
     }
     $topic = null;
     if (presence(Request::input('topic_id')) !== null) {
         $topic = Topic::findOrFail(Request::input('topic_id'));
         $this->authorizePost($topic->forum, $topic);
         if ($topic->canBeEditedBy(Auth::user()) !== true) {
             abort(403);
         }
         if ($topic->cover !== null) {
             abort(422);
         }
     }
     try {
         $cover = TopicCover::upload(Request::file('cover_file')->getRealPath(), Auth::user(), $topic);
     } catch (ImageProcessorException $e) {
         return error_popup($e->getMessage());
     }
     return fractal_item_array($cover, new TopicCoverTransformer());
 }
コード例 #3
0
ファイル: TopicsController.php プロジェクト: Hughp135/osu-web
 public function lock($id)
 {
     // FIXME: should be moderator check?
     // And maybe even its own controller or something.
     if (Auth::user()->isAdmin() !== true) {
         abort(403);
     }
     $topic = Topic::findOrFail($id);
     $lock = Request::input('lock') !== '0';
     $topic->lock($lock);
     return ['message' => trans('forum.topics.lock.locked-' . ($lock === true ? '1' : '0'))];
 }
コード例 #4
0
 public function watch($id)
 {
     $topic = Topic::findOrFail($id);
     $state = get_bool(Request::input('watch'));
     $privName = 'ForumTopicWatch' . ($state ? 'Add' : 'Remove');
     $type = 'watch';
     priv_check($privName, $topic)->ensureCan();
     TopicWatch::toggle($topic, Auth::user(), $state);
     switch (Request::input('page')) {
         case 'manage':
             $topics = Topic::watchedByUser(Auth::user())->get();
             $topicReadStatus = TopicTrack::readStatus(Auth::user(), $topics);
             // there's currently only destroy action from watch index
             return js_view('forum.topic_watches.destroy', compact('topic', 'topics', 'topicReadStatus'));
         default:
             return js_view('forum.topics.replace_button', compact('topic', 'type', 'state'));
     }
 }
コード例 #5
0
ファイル: TopicsController.php プロジェクト: echojc/osu-web
 public function reply(HttpRequest $request, $id)
 {
     $topic = Topic::findOrFail($id);
     $this->authorizePost($topic->forum, $topic);
     $this->validate($request, ['body' => 'required']);
     if ($topic->addPost(Auth::user(), Request::input('body'), false)) {
         $posts = Post::where('post_id', $topic->topic_last_post_id)->get();
         $postsPosition = $topic->postsPosition($posts);
         Event::fire(new TopicWasReplied($topic, $posts->last(), Auth::user()));
         return view('forum.topics._posts', compact('posts', 'postsPosition', 'topic'));
     }
 }
コード例 #6
0
 public function reply(HttpRequest $request, $id)
 {
     $topic = Topic::findOrFail($id);
     $this->authorizePost($topic->forum, $topic);
     $this->validate($request, ["body" => "required"]);
     if ($topic->addPost(Auth::user(), Request::input("body"), false)) {
         $posts = Post::where("post_id", $topic->topic_last_post_id)->get();
         $postsPosition = $topic->postsPosition($posts);
         Event::fire(new TopicWasReplied($topic, $posts->last(), Auth::user()));
         return view("forum.topics._posts", compact("posts", "postsPosition", "topic"));
     }
 }