Esempio n. 1
0
      $form->addSubmit('cancel', 'Cancel')->setAttribute('class', 'btn btn-default')->setValidationScope([]);
      return $form;
  }
  /** Vlastná validácia pre AddUserForm
 * @param Nette\Application\UI\Form $button
 */
  public function validateAddUserForm($button)
  {
      $values = $button->getForm()->getValues();
      if ($button->isSubmitted()->name == 'uloz') {
          // Over, ci dane username uz existuje.
          if ($this->users->findBy(['username' => $values->username])->count() > 0) {
              $button->addError(sprintf('Zadané užívateľské meno %s už existuje! Zvolte prosím iné!', $values->username));
          }
          // Over, ci dany email uz existuje.
Esempio n. 2
0
 function confirmedDelete($id, $nazov)
 {
     if (!$this->user_view_fields['delete']) {
         $this->flashRedirect("User:"******"danger");
         return;
     }
     $path = $this->context->parameters['wwwDir'] . "/files/" . $id;
     if (is_dir($path)) {
         //Vymazanie adresaru s avatarom
         foreach (glob("{$path}*.{jpg,jpeg,gif,png}", GLOB_BRACE) as $file) {
             @unlink($file);
         }
         rmdir($path);
     }
     $clen_id_up = $this->user_profiles->findOneBy(['id_users' => $id])->id;
     try {
         $this->getUser()->logout();
         $this->user_profiles->delUser($clen_id_up);
         $this->user_profiles->oprav($clen_id_up, ['id_users' => 1]);
         $this->users->zmaz($id);
         $this->user_profiles->zmaz($clen_id_up);
         $this->flashMessage(sprintf($this->trLang('delete_user_ok'), $nazov), 'success');
     } catch (Exception $e) {
         $this->flashMessage($this->trLang('delete_user_err') . $e->getMessage(), 'danger');
     }
     if (!$this->isAjax()) {
         $this->redirect('User:');
     }
 }
Esempio n. 3
0
      unset($values->id, $values->id_users);
      //Uloz info do tabulky users
      $uloz_users = $this->users->uloz(['username' => $values->username, 'email' => $values->email], $id_users);
      if (!empty($uloz_users['id'])) {
          unset($values->username, $values->email);
          $uloz = $this->user_profiles->uloz($values, $id_user_profiles);
      }
      if (!empty($uloz['id'])) {
          //Ulozenie v poriadku
          $this->flashRedirect('User:'******'Údaje boli uložené!', 'success');
      } else {
          //Ulozenie sa nepodarilo
          $this->flashMessage('Došlo k chybe a údaje sa neuložili. Skúste neskôr znovu...', 'danger');
      }
  }
  /** Filtre pre sablonu
 * @param type $class
 * @return type
 */
  protected function createTemplate($class = NULL)
  {
      $template = parent::createTemplate($class);
      //Helper clenclass - vyber classu podla poctu prihlaseni
      $template->addFilter('clenclass', function ($pocet, $max) {
          $pok = 100 * $pocet / $max;
          return "vyb" . ($pok > 70 ? 1 : ($pok > 45 ? 2 : ($pok > 30 ? 3 : ($pok > 0 ? 4 : 5))));
      });
      return $template;
Esempio n. 4
0
          $form->addText('rok', 'Rok narodenia:', 4, 5)->addRule(Form::RANGE, 'Rok narodenia musí byť v rozsahu od %d do %d', [1900, StrFTime("%Y", Time())]);
      }
      if ($user_view_fields["telefon"]) {
          $form->addText('telefon', 'Telefón:', 20, 20);
      }
      if ($user_view_fields["poznamka"]) {
          $form->addText('poznamka', 'Poznámka:', 50, 250);
      }
      if ($user_view_fields["pohl"]) {
          $form->addSelect('pohl', 'Pohlavie:', ['M' => 'Muž', 'Z' => 'Žena']);
      }
      $form->onValidate[] = [$this, 'validateEditUserForm'];
      $form->addSubmit('uloz', 'Ulož')->setAttribute('class', 'btn btn-success')->onClick[] = [$this, 'editUserFormSubmitted'];
      $form->addSubmit('cancel', 'Cancel')->setAttribute('class', 'btn btn-default')->setValidationScope(FALSE);
      return $form;
  }
  /** Vlastná validácia
 * @param Nette\Application\UI\Form $button
Esempio n. 5
0
 public function userPasswordResetFormSubmitted($form)
 {
     $values = $form->getValues();
     //Nacitanie hodnot formulara
     if ($values->new_heslo != $values->new_heslo2) {
         $this->flashRedirect('this', $this->trLang('reset_pass_hesla_err'), 'danger');
     }
     //Vygeneruj kluc pre zmenu hesla
     $new_password = $this->hasser->HashPassword($values->new_heslo);
     $values->new_heslo = 'xxxxx';
     //Len pre istotu
     $values->new_heslo2 = 'xxxxx';
     //Len pre istotu
     try {
         $this->users->find($values->id)->update(['password' => $new_password, 'new_password_key' => NULL, 'new_password_requested' => NULL]);
         $this->flashRedirect('User:'******'reset_pass_ok'), 'success');
     } catch (Exception $e) {
         $this->flashRedirect('Homepage:', $this->trLang('reset_pass_err') . $e->getMessage(), 'danger,n');
     }
 }