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:"); }
protected function createComponentUserEditor() { $form = new Form(); $form->addText('username', 'Uživatelské jméno')->setRequired('Zadejte uživatelské jméno'); $form->addText('realname', 'Skutečné jméno'); $form->addSelect('role', 'Role', $this->perms->getRoles())->setPrompt('Vyberte roli')->setRequired('Musíte vybrat roli uživatele'); $form->addText('email', 'Email')->addCondition(Form::FILLED)->addRule(Form::EMAIL, 'Zadejte platnnou emailovou adresu'); $form->addPassword('password', 'Heslo')->addCondition(Form::FILLED)->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->addText('twitter_acc', 'Twitter'); $form->addText('www', 'Homepage (WWW)')->addCondition(Form::FILLED)->addRule(Form::URL, 'Zadejte platnou URL'); $form->addTextArea('about', 'Krátce o uživateli'); $form->addHidden('id')->setRequired('Vyžadován identifikátor'); $form->onSuccess[] = function (Form $f) { $val = $f->values; if (empty($val->password)) { unset($val->password); } else { $this->users->changePassword($val->id, $val->password); unset($val->password); } $this->users->update($val->id, $val); $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('this'); }; $form->addSubmit('send', 'Uložit'); return $form; }