Exemplo n.º 1
0
 /** Spracovanie reistracneho formulara
  * @param Nette\Application\UI\Form $button Data formulara
  */
 public function userRegisterFormSubmitted($button)
 {
     // Inicializacia
     $values = $button->getForm()->getValues();
     //Nacitanie hodnot formulara
     // Over, ci dane username uz existuje. Ak ano vypis a skonc.
     if ($this->users->testUsername($values->username)) {
         $this->flashMessage($this->trLang('registracia_username_duble'), 'danger');
         return;
     }
     // Over, ci dany email uz existuje. Ak ano vypis a skonc.
     if ($this->users->testEmail($values->email)) {
         $this->flashMessage(sprintf($this->trLang('registracia_email_duble'), $values->email, $this->link('User:forgotPassword')), 'danger,n');
         return;
     }
     $new_password_key = $this->hasser->HashPassword($values->heslo . StrFTime("%Y-%m-%d %H:%M:%S", Time()));
     $uloz_data_user_profiles = ['meno' => $values->meno, 'priezvisko' => $values->priezvisko, 'pohl' => isset($values->pohl) ? $values->pohl : 'Z', 'modified' => StrFTime("%Y-%m-%d %H:%M:%S", Time()), 'created' => StrFTime("%Y-%m-%d %H:%M:%S", Time())];
     $uloz_data_users = ['username' => $values->username, 'password' => $this->hasser->HashPassword($values->heslo), 'email' => $values->email, 'activated' => 0];
     //Uloz info do tabulky users
     if (($uloz_users = $this->users->uloz($uloz_data_users)) !== FALSE) {
         //Ulozenie v poriadku
         $uloz_data_user_profiles['id_users'] = $uloz_users['id'];
         //nacitaj id ulozeneho clena
         $uloz_user_profiles = $this->user_profiles->uloz($uloz_data_user_profiles);
     }
     if ($uloz_user_profiles !== FALSE) {
         //Ulozenie v poriadku
         $this->flashMessage($this->trLang('base_save_ok'), 'success');
         $templ = new Latte\Engine();
         $params = ["site_name" => $this->nazov_stranky, "nadpis" => sprintf($this->trLang('email_activate_nadpis'), $this->nazov_stranky), "email_activate_txt" => $this->trLang('email_activate_txt'), "email_nefunkcny_odkaz" => $this->trLang('email_nefunkcny_odkaz'), "email_pozdrav" => $this->trLang('email_pozdrav'), "nazov" => $this->trLang('register_aktivacia'), "odkaz" => 'http://' . $this->nazov_stranky . $this->link("User:activateUser", $uloz_user_profiles['id'], $new_password_key)];
         $mail = new Message();
         $mail->setFrom($this->nazov_stranky . ' <' . $this->clen->users->email . '>')->addTo($values->email)->setSubject($this->trLang('register_aktivacia'))->setHtmlBody($templ->renderToString(__DIR__ . '/templates/User/email_activate-html.latte', $params));
         try {
             $sendmail = new SendmailMailer();
             $sendmail->send($mail);
             $this->users->find($uloz_users['id'])->update(['new_password_key' => $new_password_key]);
             $this->flashMessage($this->trLang('register_email_ok'), 'success');
         } catch (Exception $e) {
             $this->flashMessage($this->trLang('send_email_err') . $e->getMessage(), 'danger,n');
         }
         $this->redirect('Homepage:');
     } else {
         $this->flashMessage($this->trLang('register_save_err'), 'danger');
     }
     //Ulozenie sa nepodarilo
 }
Exemplo n.º 2
0
 public function actionActivateNewEmail($id, $new_email_key)
 {
     $users_data = $this->user_profiles->find($id);
     if ($new_email_key == $users_data->users->new_email_key) {
         //Aktivacia prebeha v poriadku
         try {
             $this->users->uloz(['email' => $users_data->users->new_email, 'new_email' => NULL, 'new_email_key' => NULL], $users_data->id_users);
             $this->user_profiles->uloz(['modified' => StrFTime("%Y-%m-%d %H:%M:%S", Time())], $id);
             $pomocny = $this->user->isLoggedIn() ? '' : $this->trLang('activate_mail_login');
             $this->flashMessage($this->trLang('activate_mail_ok') . $pomocny, 'success');
         } catch (Exception $e) {
             $this->flashMessage($this->trLang('activate_mail_err') . $e->getMessage(), 'danger,n');
         }
     } else {
         $this->flashMessage($this->trLang('activate_mail_err1'), 'danger');
     }
     //Neuspesna aktivacia
     $this->redirect('Homepage:');
 }
Exemplo n.º 3
0
      $uloz_users = $this->users->uloz(['username' => $values->username, 'password' => $hasser->HashPassword($values->heslo), 'email' => $values->email, 'activated' => 1]);
      if (!empty($uloz_users['id'])) {
          //Ulozenie v poriadku
          $uloz_user_profiles = $this->user_profiles->uloz(['id_users' => $uloz_users['id'], 'meno' => $values->meno, 'priezvisko' => $values->priezvisko, 'id_registracia' => $values->id_registracia, 'pohl' => isset($values->pohl) ? $values->pohl : 'Z', 'modified' => StrFTime("%Y-%m-%d %H:%M:%S", Time()), 'created' => StrFTime("%Y-%m-%d %H:%M:%S", Time())]);
      }
      if (!empty($uloz_user_profiles['id'])) {
          //Ulozenie v poriadku
          $this->flashRedirect('User:'******'Nový užívateľ uložený v poriadku!', 'success');
      } else {
          $this->flashMessage('Uloženie sa nepodarilo!', 'danger');
      }
      //Ulozenie sa nepodarilo
  }
  /**
 * Edit user form component factory. Tovarnicka na formular pre editaciu clena
 * @return \Nette\Application\UI\Form
 */
  protected function createComponentEditUserForm()
  {
      $form = $this->editUserForm->create($this->users, $this->id_reg, $this->urovneReg, $this->user_view_fields);
      $form['uloz']->onClick[] = [$this, 'editUserFormSubmitted'];
      $form['cancel']->onClick[] = [$this, 'formCancelled'];
Exemplo n.º 4
0
            $this->setView('notFound');
        } elseif ($id) {
            $this["editCategoriForm"]->setDefaults($categ);
        }
    }
    /** Formular pre pridanie uzivatela.
	 * @return Nette\Application\UI\Form
	 */
    protected function createComponentAddUserForm()
    {
        $form = $this->addUserForm->create($this->users, $this->urovneReg, $this->user_view_fields["pohl"]);
        $form['uloz']->onClick[] = [$this, 'addUserFormSubmitted'];
        $form['cancel']->onClick[] = function () {
            $this->redirect('User:');
        };
        return $this->_vzhladForm($form);
    }
    /** Spracovanie formulara pre pridanie uzivatela
   * @param Nette\Forms\Controls\SubmitButton $button Data formulara
   */
    public function addUserFormSubmitted($button)
    {
        // Inicializacia
        $values = $button->getForm()->getValues();