protected function run() { $id = $this->get('id'); $post = $this->conversations->findPostById($id); $page = $this->conversations->getPageOfPost($post, User::current()->dispPosts()); return ['post' => $post, 'page' => $page]; }
public function get_index() { // TODO: Get list of forums and topics with new posts since last visit & get all topics that were marked as read // Fetch the categories and forums $categories = Category::allForGroup(User::current()->group_id); $view = \View::make('fluxbb::index'); $view['categories'] = $categories; return $view; }
protected function run() { $pid = $this->get('id'); $post = Post::with('author', 'topic')->findOrFail($pid); $creator = User::current(); $post->fill(['message' => $this->get('message'), 'edited' => Carbon::now(), 'edited_by' => $creator->username]); $post->save(); $this->raise(new PostWasEdited($post, $creator)); return ['post' => $post]; }
protected function run() { $id = $this->get('id'); $conversation = $this->conversations->findById($id); $creator = User::current(); $post = new Post(['poster' => $creator->username, 'poster_id' => $creator->id, 'message' => $this->get('message'), 'posted' => Carbon::now()]); $this->conversations->addReply($conversation, $post); $this->raise(new UserHasPosted($creator, $post)); return ['post' => $post]; }
/** * Run the action and return a response for the user. * * @throws Exception\ValidationException * @return void */ protected function run() { $creator = User::current(); $this->post->fill(['message' => $this->message, 'edited' => Carbon::now(), 'edited_by' => $creator->username]); if (!$this->validator->isValid($this->post)) { throw new ValidationException(); } $this->post->save(); $this->trigger('post.edited', [$this->post, $creator]); }
protected function run() { $tid = $this->get('id'); $topic = Topic::findOrFail($tid); $user = User::current(); if (!$topic->subscribers->contains($user)) { $topic->subscribers()->attach($user); $this->raise(new UserSubscribed($topic, $user)); } }
protected function handleRequest(Request $request) { $pid = \Route::input('id'); // If a post ID is specified we determine topic ID and page number so we can show the correct message $this->post = Post::findOrFail($pid); // Determine on which page the post is located $numPosts = Post::where('topic_id', '=', $this->post->topic_id)->where('posted', '<', $this->post->posted)->count('id') + 1; $dispPosts = User::current()->dispPosts(); $this->page = ceil($numPosts / $dispPosts); }
/** * Run the action and return a response for the user. * * @return array */ protected function run() { $slug = $this->get('slug'); $category = $this->categories->findBySlug($slug); $creator = User::current(); $now = Carbon::now(); $conversation = (object) ['poster' => $creator->username, 'title' => $this->get('subject'), 'posted' => $now, 'last_post' => $now, 'last_poster' => $creator->username, 'category_slug' => $category->slug]; $post = new Post(['poster' => $creator->username, 'poster_id' => $creator->id, 'message' => $this->get('message'), 'posted' => $now]); $this->categories->addNewTopic($category, $conversation, $post->toArray()); $this->raise(new UserHasPosted($creator, $post)); }
/** * Run the action and return a response for the user. * * @throws Exception\ValidationException * @return void */ protected function run() { $creator = User::current(); $this->post = new Post(['poster' => $creator->username, 'poster_id' => $creator->id, 'message' => $this->message, 'posted' => Carbon::now()]); if (!$this->validator->isValid($this->post)) { throw new ValidationException(); } $this->topic->addReply($this->post); $this->post->save(); $this->trigger('user.posted', [$creator, $this->post]); }
public function subscribe($subscribe = true) { // To subscribe or not to subscribe, that ... if (!Config::enabled('o_topic_subscriptions') || !Auth::check()) { return false; } if ($subscribe && !$this->isUserSubscribed()) { $this->subscription()->insert(array('user_id' => User::current()->id)); } elseif (!$subscribe && $this->isUserSubscribed()) { $this->subscription()->delete(); } }
public function put_topic($fid) { $forum = Forum::with(array('perms'))->where('id', '=', $fid)->first(); if ($forum === NULL) { return \Event::first('404'); } // TODO: Flood protection $rules = array('req_subject' => 'required|max:70', 'req_message' => 'required'); // TODO: More validation if (\Auth::isGuest()) { if (Config::enabled('p_force_guest_email') || \Input::get('email') != '') { $rules['req_email'] = 'required|email'; } // TODO: banned email } $validation = $this->make_validator(Input::all(), $rules); if ($validation->fails()) { return \Redirect::to_action('fluxbb::posting@topic', array($fid))->with_input()->with_errors($validation); } $topic_data = array('poster' => User::current()->username, 'subject' => \Input::get('req_subject'), 'posted' => \Request::time(), 'last_post' => \Request::time(), 'last_poster' => User::current()->username, 'sticky' => \Input::get('stick_topic') ? '1' : '0', 'forum_id' => $fid); if (\Auth::isGuest()) { $topic_data['poster'] = $topic_data['last_poster'] = \Input::get('req_username'); } // Create the topic $topic = Topic::create($topic_data); // To subscribe or not to subscribe $topic->subscribe(\Input::get('subscribe')); $post_data = array('poster' => User::current()->username, 'poster_id' => User::current()->id, 'poster_ip' => \Request::ip(), 'message' => \Input::get('req_message'), 'hide_smilies' => \Input::get('hide_smilies') ? '1' : '0', 'posted' => \Request::time(), 'topic_id' => $topic->id); if (\Auth::isGuest()) { $post_data['poster'] = \Input::get('req_username'); $post_data['poster_email'] = Config::enabled('p_force_guest_email') ? \Input::get('req_email') : \Input::get('email'); } // Create the post ("topic post") $post = Post::create($post_data); // Update the topic with last_post_id $topic->last_post_id = $topic->first_post_id = $post->id; $topic->save(); // Update forum (maybe $forum->update_forum() ?) $forum->num_posts += 1; $forum->num_topics += 1; $forum->last_post = $topic->last_post; $forum->last_post_id = $topic->last_post_id; $forum->last_poster = $topic->last_poster; $forum->save(); // TODO: update_search_index(); // If the posting user is logged in, increment his/her post count $user = User::current(); if (\Auth::isAuthed()) { $user->num_posts += 1; $user->last_post = \Request::time(); $user->save(); // TODO: Promote this user to a new group if enabled } else { $user->online()->update(array('last_post' => \Request::time())); } return \Redirect::to_action('fluxbb::topic', array($topic->id))->with('message', trans('fluxbb::topic.topic_added')); }
public function put_profile($id, $action = 'essentials') { $user = u::find($id); // TODO: Add validation. This can probably wait until we restructure the profile. if ($action == 'essentials') { $user->username = \Input::get('username', $user->username); $user->email = \Input::get('email', $user->email); $user->timezone = \Input::get('timezone', $user->timezone); $user->dst = \Input::get('dst', $user->dst); $user->time_format = \Input::get('time_format'); $user->date_format = \Input::get('date_format'); $user->admin_note = \Input::get('admin_note', $user->admin_note); } else { if ($action == 'messaging') { $user->jabber = \Input::get('jabber'); $user->icq = \Input::get('icq'); $user->msn = \Input::get('msn'); $user->aim = \Input::get('aim'); $user->yahoo = \Input::get('yahoo'); } else { if ($action == 'personal') { $user->realname = \Input::get('realname'); $user->title = \Input::get('title'); $user->location = \Input::get('location'); $user->url = \Input::get('url'); } else { if ($action == 'personality') { $user->signature = \Input::get('signature'); } else { if ($action == 'display') { //This will give an error if not everything is set -> need to set defaults in database! $user->style = \Input::get('style'); $user->show_smilies = \Input::get('show_smilies'); $user->show_sig = \Input::get('show_sig'); $user->show_avatars = \Input::get('show_avatars'); $user->show_img = \Input::get('show_img'); $user->disp_topics = \Input::get('disp_topics', $user->disp_topics); $user->disp_posts = \Input::get('disp_posts', $user->disp_posts); } else { //TODO } } } } } $user->save(); return \View::make('fluxbb::user.profile.' . $action)->with('user', $user)->with('admin', u::current()->isAdmin()); }
protected function user() { return User::current(); }
public function user() { return User::current(); }
/** * Delete all expired sessions from persistent storage. * * @param int $expiration * @return void */ public function sweep($expiration) { $expiration = Request::time() - Config::get('o_timeout_online'); // Fetch all sessions that are older than o_timeout_online $result = $this->table()->where('user_id', '!=', 1)->where('last_visit', '<', $expiration)->get(); $delete_ids = array(); foreach ($result as $cur_session) { $delete_ids[] = $cur_session->id; $result = $this->connection->table('users')->where_id($cur_session->user_id)->update(array('last_visit' => $cur_session->last_visit)); } // Make sure logged-in users have no more than ten sessions alive if (Auth::check()) { $uid = User::current()->id; $session_ids = $this->table()->where_user_id($uid)->order_by('last_visit', 'desc')->lists('id'); $prune_ids = array_slice($session_ids, 10); $delete_ids = array_merge($delete_ids, $prune_ids); } if (!empty($delete_ids)) { $this->table()->where_in('id', $delete_ids)->or_where('last_visit', '<', $expiration)->delete(); } }
protected function handleRequest(Request $request) { $group_id = User::current()->group_id; $categories = Category::allForGroup($group_id); $this->data['categories'] = $categories; }