Example #1
0
 public function admin($arguments = array())
 {
     if (count($arguments) != 3) {
         throw new BadMethodCallException('Exactly three arguments expected.');
     }
     $username = $arguments[0];
     $password = $arguments[1];
     $email = $arguments[2];
     // Create admin user
     $admin_user = User::create(array('username' => $username, 'password' => $password, 'email' => $email, 'language' => Laravel\Config::get('application.language'), 'style' => 'Air', 'last_post' => Request::time(), 'registered' => Request::time(), 'registration_ip' => Request::ip(), 'last_visit' => Request::time()));
     $admin_group = Group::find(Group::ADMIN);
     if (is_null($admin_group)) {
         throw new LogicException('Could not find admin group.');
     }
     $admin_group->users()->insert($admin_user);
 }
Example #2
0
 public function post_register()
 {
     $rules = array('user' => 'Required|Between:2,25|username_not_guest|no_ip|username_not_reserved|no_bbcode|not_censored|Unique:users,username|username_not_banned');
     // If email confirmation is enabled
     if (Config::enabled('o_regs_verify')) {
         $rules['email'] = 'Required|Email|Confirmed|unique:users,email|email_not_banned';
     } else {
         $rules['password'] = 'Required|Min:4|Confirmed';
         $rules['email'] = 'Required|Email|Unique:users,email';
     }
     // Agree to forum rules
     if (Config::enabled('o_rules')) {
         $rules['rules'] = 'Accepted';
     }
     $validation = $this->make_validator(\Input::all(), $rules);
     if ($validation->fails()) {
         return \Redirect::route('register')->withInput(\Input::all())->with('errors', $validation->getMessages());
     }
     $user_data = array('username' => \Input::get('user'), 'group_id' => Config::enabled('o_regs_verify') ? Group::UNVERIFIED : Config::get('o_default_user_group'), 'password' => \Input::get('password'), 'email' => \Input::get('email'), 'email_setting' => Config::get('o_default_email_setting'), 'timezone' => Config::get('o_default_timezone'), 'dst' => Config::get('o_default_dst'), 'language' => Config::get('o_default_lang'), 'style' => Config::get('o_default_style'), 'registered' => \Request::time(), 'registration_ip' => \Request::ip(), 'last_visit' => \Request::time());
     $user = User::create($user_data);
     return \Redirect::action('fluxbb::home@index')->with('message', trans('fluxbb::register.reg_complete'));
 }
Example #3
0
 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'));
 }