Exemplo n.º 1
0
 public function getUserSettings()
 {
     $data = ['users' => User::with('roles')->paginate(20)->setPath(route('getUserSettings')), 'roles' => Role::all()];
     return view('admin.users')->with($data);
 }
Exemplo n.º 2
0
 public function add()
 {
     $user_model = new User();
     $album_model = new Album();
     $role_model = new Role();
     $status_model = new Status();
     $this->data['title'] = 'Add Artist';
     if (isset($_POST) && !empty($_POST)) {
         $artistArray = array('user_firstname' => $_POST['firstname'], 'user_stagename' => $_POST['stagename'], 'user_bio' => $_POST['bio'], 'twitter_handle' => $_POST['twitter_handle'], 'user_status_id' => Status::id('active'), 'user_role_id' => Role::id('artist'), 'user_created' => time());
         $artistArray = Gump::xss_clean($artistArray);
         $artistArray = Gump::sanitize($artistArray);
         $artist_id = $user_model->create($artistArray);
         if ($artist_id > 0) {
             $this->data['success'] = 'Artist Added!';
             $slug = Url::generateSafeSlug($_POST['stagename'] . $artist_id);
             $user_model->updateId(array('user_slug' => $slug), $artist_id);
         } else {
             $this->data['error'] = 'Operation Fails!';
         }
         //UPLOAD ATTACHMENT
         if ($_FILES["image"]["tmp_name"] != '') {
             //upload image into uploads folder
             Upload::setName($slug . uniqid());
             Upload::resizeUpload($_FILES["image"], UPLOAD_PATH, '450px');
             $update_data = array('user_image' => Upload::getFileName('images'));
             $this->user_model->updateId($update_data, $artist_id);
         }
         //GET INSERTED ID
         $this->data['user_data'] = $user_model->find($insert_id);
         Url::redirect('artist');
     }
     View::rendertemplate('header', $this->data);
     View::rendertemplate('sidebar', $this->data);
     View::render('artist/artist.add', $this->data);
     View::rendertemplate('footer', $this->data);
 }
Exemplo n.º 3
0
 public function signup($slug = null)
 {
     $this->data['title'] = 'Join Us';
     $statusModel = new Status();
     $roleModel = new Role();
     $userModel = new User();
     if (isset($_POST['email']) && !empty($_POST['email'])) {
         $firstname = $_POST['firstname'];
         $email = $_POST['email'];
         if ($_POST['password'] == $_POST['password2']) {
             $encrypted = md5($_POST['password']);
             $row_count = $userModel->getColRow('user_email', $email);
             if (!is_bool($row_count)) {
                 Session::set('error', 'Email exists in our records, please use a different email');
             } else {
                 $userArray = array('user_firstname' => $firstname, 'user_email' => $email, 'user_password' => $encrypted, 'user_role_id' => Role::id('user'), 'user_status_id' => Status::id('active'));
                 $userArray = Gump::xss_clean($userArray);
                 $userArray = Gump::sanitize($userArray);
                 $is_valid = Gump::is_valid($userArray, array('user_firstname' => 'required|max_len,200|min_len,1', 'user_email' => 'required|max_len,200|min_len,1', 'user_password' => 'required|max_len,200|min_len,1'));
                 if ($is_valid === true) {
                     $user_id = $userModel->create($userArray);
                     if ($user_id > 0) {
                         $slug = Url::generateSafeSlug($firstname . $user_id);
                         //send email
                         $subject = 'Welcome to GbeduMobile';
                         $content .= "You just opened a new account with us, Get login details below<br><br>";
                         $content .= "Username: "******"<br>";
                         $content .= "Password: "******"<br>";
                         if (ENVIRONMENT == 'production') {
                             $mail = new Mail();
                             $mail->general($email, $subject, $firstname, $content);
                         }
                         Session::set('success', 'Login details has been sent to your email, Congrats!');
                         Url::redirect('home');
                     } else {
                         Session::set('error', 'Operation Fails, Please contact admin');
                     }
                 } else {
                     Session::set('error', $is_valid);
                 }
             }
         } else {
             Session::set('error', 'Password does not match!');
         }
     }
     View::rendertemplate('header', $this->data);
     View::render('account/signup', $this->data);
     View::rendertemplate('footer', $this->data);
 }
Exemplo n.º 4
0
 private static function insert(Role $model)
 {
     $db = Database::getInstance('app');
     $query = "INSERT INTO roles (role) VALUES (:role);";
     $result = $db->prepare($query);
     $result->execute([':role' => $model->getRole()]);
     $model->setId($db->lastId());
 }
Exemplo n.º 5
0
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     DB::table('user')->truncate();
     DB::table('role')->truncate();
     DB::table('role_user')->truncate();
     DB::table('event')->truncate();
     DB::table('exp_level')->truncate();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
     $faker = Factory::create();
     $uQ = new User();
     $uQ->login = '******';
     $uQ->pseudo = 'QsAnakrose';
     $uQ->password = Hash::make('quentin');
     $uQ->email = '*****@*****.**';
     $uQ->streaming = 1;
     $uQ->twitch_channel = 'riotgames';
     $uQ->save();
     $data = [];
     for ($i = 0; $i < 110; $i++) {
         $username = $faker->unique()->username;
         $data[] = ['login' => $username, 'pseudo' => $username, 'email' => $faker->unique()->freeEmail, 'password' => Hash::make($username)];
     }
     User::insert($data);
     $this->command->info('Users created');
     $admin = new Role();
     $admin->title = 'admin';
     $admin->save();
     $streamer = new Role();
     $streamer->title = 'streamer';
     $streamer->save();
     $this->command->info('Roles created');
     $uQ->becomeAdmin();
     $uQ->becomeStreamer();
     for ($i = 2; $i < 13; $i++) {
         $u = User::find($i);
         $u->becomeStreamer();
         $u->twitch_channel = $i;
         $u->description = $u->login . 'lorem ipsum dolor. Lol.';
         $rand = rand(0, 2);
         if ($rand == 0) {
             $u->streaming = 1;
         } else {
             $u->streaming = 0;
         }
         /*
         $avatarManager = new AvatarManager();
         $intervManager = $avatarManager->getImgManager();
         $width = $avatarManager->getAvatarWidth();
         $color = substr(md5(rand()), 0, 6);
         $intervManager->canvas($width, $width, $color);
         */
         $u->save();
     }
     $su = new StreamingUserService();
     $su->update();
     $this->command->info('Roles attached');
     $event = new Event();
     $event->title = 'Hugo';
     $event->start = '2015-06-26T12:30:00+02:00';
     $event->end = '2015-06-26T15:30:00+02:00';
     $event->allDay = 'false';
     $event->color = '#FF0000';
     $event->timezone = '+02:00';
     $event->save();
     $this->command->info('Test event created');
     $expManager = new ExperienceManager();
     $data = $expManager->generateExperienceSystem();
     ExpLevel::insert($data);
     $this->command->info('Experience system initialized');
 }