Пример #1
0
 public function profileCreateSuccess(Form $form)
 {
     $val = $form->getValues(true);
     if (!$this->checkPermissions("ucp", "save")) {
         $this->redirect("homepage:");
     }
     if ($this->twitter->isTwitterUser()) {
         $info = $this->twitter->verifyCredentials();
         $val["avatar"] = $info->profile_image_url;
     }
     $val["first_login"] = false;
     $this->usrmgr->update($this->user->id, $val);
     $this->redirect("Homepage:");
 }
Пример #2
0
 protected function createComponentUserAdd()
 {
     $form = new Form();
     $form->addText('username', 'Uživatelské jméno')->setRequired('Zadejte uživatelské jméno');
     $form->addText('email', 'Email')->setRequired('Zadejte platnou emailovou adresu')->addRule(Form::EMAIL, 'Zadaná emailová adresa je neplatná');
     $form->addPassword('password', 'Heslo')->setRequired('Zadejte heslo')->addRule(Form::MIN_LENGTH, 'Heslo musí mít minimálně %s znaků', 6);
     $form->addPassword('password_verify', 'Ověření hesla')->setOmitted()->addConditionOn($form['password'], Form::FILLED)->addRule(Form::EQUAL, 'Hesla se neshodují', $form['password']);
     $form->addSubmit('send', 'Vytvořit účet');
     $form->onSuccess[] = function (Form $f) {
         try {
             $val = $f->values;
             $r = $this->users->add($val->username, $val->password, $val->email);
             $this->logger->log('User', 'edit', "%user% editoval(a) profil uživatele {$val->username}");
             $msg = $this->flashMessage("Profil uživatele '{$val->username}' upraven.", 'success');
             $msg->title = 'A je tam!';
             $msg->icon = 'check';
             $this->redirect('editor', [$r->id]);
         } catch (\App\UserManagerException $e) {
             $msg = $this->flashMessage($e->getMessage(), 'danger');
             $msg->title = 'Oh shit!';
             $msg->icon = 'warning';
         }
     };
     return $form;
 }
Пример #3
0
 private function redirectAfterLogin()
 {
     if ($this->usrmgr->getUser($this->user->id)->first_login) {
         $this->redirect("Profile:create");
     }
     //First login
     $this->redirect('Homepage:');
 }
Пример #4
0
 public static function hasRoles(array $roles)
 {
     $loginUser = \Auth::user();
     $user = MeSelf::where('email', '=', $loginUser->email)->first();
     foreach ($roles as $role) {
         if (in_array($role, $user->roles->lists('name')->toArray())) {
             return true;
         }
     }
     return false;
 }
Пример #5
0
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     if ($this->method() === 'POST') {
         return ['name' => 'max:255', 'email' => 'required|email|max:255|unique:users,email', 'role' => 'required', 'password' => 'required|confirmed|min:' . config('entrance.password_length') . '|max:255'];
     } elseif ($this->method() === 'PUT' || $this->method() === 'PATCH') {
         $id = $this->route()->users;
         $user = UserManager::findOrFail($id);
         if (!$this->get('password')) {
             return ['name' => 'max:255', 'email' => 'required|email|max:255|unique:users,email,' . $user->id, 'role' => 'required', 'password' => 'min:' . config('entrance.password_length') . '|max:255|confirmed'];
         } else {
             return ['name' => 'max:255', 'email' => 'required|email|max:255|unique:users,email,' . $user->id, 'role' => 'required', 'password' => 'required|min:' . config('entrance.password_length') . '|max:255|confirmed'];
         }
     }
 }
Пример #6
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function permanentlyDestroy($id)
 {
     $user = User::onlyTrashed()->findOrFail($id);
     $user->forceDelete();
     return redirect()->route('user.manager.index');
 }
Пример #7
0
 protected function createComponentSongEditor()
 {
     $form = new Form();
     $form->addText('name', 'Song')->setRequired('Zadejte název songu');
     $form->addText('interpret_name', 'Interpret')->setRequired('Zadejte jméno interpreta');
     $form->addSelect('interpret_id', 'Asociovat s', $this->interpreti->findAll()->fetchPairs('id', 'nazev'))->setPrompt('Vyberte asociaci');
     $form->addSelect('zanr_id', 'Žánr', $this->zanry->findAll()->fetchPairs('id', 'name'))->setPrompt('Vyberte žánr')->setRequired('Vyberte žánr songu');
     $form->addSelect('status', 'Status', ['waiting' => 'Čeká na schválení', 'approved' => 'Schválen', 'rejected' => 'Zamítnut'])->setRequired('Zadejte stav songu');
     $form->addSelect('reason_code', 'Kód zamítnutí', \Rejections::$reasons)->setPrompt('Vyberte kód zamítnutí')->addConditionOn($form['status'], Form::EQUAL, 'rejected')->addRule(Form::FILLED, 'Musíte udat kód zamítnutí');
     $form->addText('zadatel', 'Přezdívka žadatele')->addCondition(Form::FILLED)->addRule(Form::MIN_LENGTH, 'Přezdívka žadatele musí mít minimálně %s znaků', 3);
     $form->addSelect('user_id', 'Účet žadatele', $this->users->getUsers()->fetchPairs('id', 'username'))->setPrompt('Vyberte uživatele');
     $form->addCheckboxList('flags', 'Flagy', ['pecka' => 'Pecka', 'instro' => 'Má instro', 'remix' => 'Remix', 'wishlist_only' => 'Pouze na přání']);
     $form->addText('link', 'URL k poslechu')->addCondition(Form::FILLED)->addRule(Form::URL, 'URL není v platném formátu');
     $form->addTextArea('note', 'Poznámka DJe');
     $form->addTextArea('vzkaz', 'Vzkaz pro DJe');
     $form->addCheckbox('private_vzkaz', 'Vzkaz je soukromý');
     $form->addHidden('id');
     $form->addSubmit('send', 'Přidat');
     $form->onSuccess[] = function (Form $f) {
         $val = $f->getValues(true);
         foreach ($val['flags'] as $flag) {
             $val[$flag] = true;
         }
         unset($val['flags']);
         //clear bordel
         //If requester not filled => assign to you
         if (!$val['zadatel'] && !$val['user_id']) {
             $val['zadatel'] = $this->user->identity->username;
             $val['user_id'] = $this->user->id;
         }
         //If requester not filled BUT USER ID engaged => fetch username for requester name
         if (!$val['zadatel'] && $val['user_id']) {
             $val['zadatel'] = $this->users->getUser($val['user_id'])->username;
         }
         try {
             if ($val['id']) {
                 $original = $this->songy->find($val['id']);
                 if ($original->status != $val['status']) {
                     $val['revisor'] = $this->user->id;
                 }
                 $original->update($val);
                 $this->logger->log('Song', 'edit', "%user% upravila(a) song {$original->name}");
                 $msg = $this->flashMessage("Song '{$val['interpret_name']} - {$val['name']}' upraven.", 'success');
                 $msg->title = 'A je tam!';
                 $msg->icon = 'check';
             } else {
                 $val['image'] = json_encode($this->lfm->getTrackImage($val['interpret_name'], $val['name'])) ?: '';
                 $val['revisor'] = $this->user->id;
                 $song = $this->songy->add($val);
                 $this->logger->log('Song', 'create', "%user% vytvořila(a) song {$song->name}");
                 $msg = $this->flashMessage("Song '{$val['interpret_name']} - {$val['name']}' přidán.", 'success');
                 $msg->title = 'A je tam!';
                 $msg->icon = 'check';
             }
         } catch (\UnexpectedValueException $e) {
             $msg = $this->flashMessage($e->getMessage(), 'danger');
             $msg->title = 'Oh shit!';
             $msg->icon = 'exclamation';
         }
         $this->redirect('this');
     };
     return $form;
 }
Пример #8
0
 public function register($info)
 {
     $user = $this->usermgr->addViaTwitter($info["screen_name"], $info["user_id"]);
     return $user;
 }