Ejemplo n.º 1
0
  /**
 * @param DbTable\Users $users
 * @param DbTable\User_profiles $users_profiles
 * @param DbTable\Registracia $registracia
 * @param \App\AdminModule\Presenters\Forms\User\User $user */
  public function __construct(DbTable\Users $users, DbTable\User_profiles $users_profiles, DbTable\Registracia $registracia, User $user)
  {
      $this->users = $users;
      $this->users_profiles = $users_profiles;
      $this->id_reg = $user->isLoggedIn() ? $user->getIdentity()->id_registracia : 0;
      $this->urovneReg = $registracia->hladaj_urovne(0, $this->id_reg)->fetchPairs('id', 'nazov');
      //Hodnoty id=>nazov pre formulare z tabulky registracia
  }
  /**
 * Edit hlavne menu form component factory.
 * @return Nette\Application\UI\Form
 */
  public function create($user_view_fields)
  {
      $form = new Form();
      $form->addProtection();
      $form->addHidden('id');
      $form->addHidden('id_users');
      $form->addHidden('created');
      $form->addHidden('modified');
      $form->addText('meno', 'Meno:', 50, 80)->addRule(Form::MIN_LENGTH, 'Meno musí mať spoň %d znakov!', 3)->setRequired('Meno musí byť zadané!');
      $form->addText('priezvisko', 'Priezvisko:', 50, 80)->addRule(Form::MIN_LENGTH, 'Priezvisko musí mať spoň %d znakov!', 3)->setRequired('Priezvisko musí byť zadané!');
      $form->addText('username', 'Užívateľské meno', 50, 50)->addRule(Form::MIN_LENGTH, 'Užívateľské meno musí mať aspoň %s znakov', 3)->setRequired('Užívateľské meno musí byť zadané!');
      $form->addText('email', 'E-mailová adresa', 50, 50)->setType('email')->addRule(Form::EMAIL, 'Musí byť zadaná korektná e-mailová adresa(napr. janko@hrasko.sk)')->setRequired('E-mailová adresa musí byť zadaná!');
      if ($this->id_reg > 2) {
          $form->addSelect('id_registracia', 'Úroveň registrácie člena:', $this->urovneReg);
      }
      if ($user_view_fields["rok"]) {
Ejemplo n.º 2
0
function date_picker($name, $startyear = NULL, $endyear = NULL)
{
    if ($startyear == NULL) {
        $startyear = date("Y") - 10;
    }
    if ($endyear == NULL) {
        $endyear = date("Y") + 5;
    }
    $cday = StrFTime("%d", Time());
    $cmonth = StrFTime("%m", Time());
    $cyear = StrFTime("%Y", Time());
    $months = array('', 'Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen', 'Červenec', 'Srpen', 'Září', 'Říjen', 'Listopad', 'Prosinec');
    // roletka dnů
    $html = "<select class=\"day\" name=\"" . $name . "day\">";
    for ($i = 1; $i <= 31; $i++) {
        $html .= "<option value='{$i}'" . ($i == $cday ? 'selected="selected"' : '') . ">{$i}</option>";
    }
    $html .= "</select> ";
    // roletka měsíců
    $html .= "<select class=\"month\" name=\"" . $name . "month\">";
    for ($i = 1; $i <= 12; $i++) {
        $html .= "<option value='{$i}'" . ($i == $cmonth ? 'selected="selected"' : '') . ">{$months[$i]}</option>";
    }
    $html .= "</select> ";
    // roletka let
    $html .= "<select class=\"year\" name=\"" . $name . "year\">";
    for ($i = $startyear; $i <= $endyear; $i++) {
        $html .= "<option value='{$i}'" . ($i == $cyear ? 'selected="selected"' : '') . ">{$i}</option>";
    }
    $html .= "</select> ";
    return $html;
}
Ejemplo n.º 3
0
 /** Vypisanie vsetkych oznamov aj s priznakom aktualnosti
  * @param boolean $usporiadanie Urcuje usporiadane podla datumu platnosti
  * @return array
  */
 public function vsetky($usporiadanie = FALSE)
 {
     $oznamy = $this->findAll()->order('datum_platnosti ' . ($usporiadanie ? 'ASC' : 'DESC'));
     $out = [];
     foreach ($oznamy as $o) {
         $temp = ["oznam" => $o, "aktualny" => $o->datum_platnosti >= StrFTime("%Y-%m-%d", strtotime("0 day"))];
         $out[] = $temp;
     }
     return $out;
 }
Ejemplo n.º 4
0
 /** Akcia pre editaciu oznamu
  * @param int $id Id oznamu
  */
 public function actionEdit($id)
 {
     if (($oznam = $this->oznam->hladaj_id($id, $this->id_reg)) === FALSE) {
         $this->setView('notFound');
     } else {
         //Ak je vsetko OK priprav premenne
         $this["oznamEditForm"]->setDefaults($oznam);
         $this["oznamEditForm"]->setDefaults(['datum_zadania' => StrFTime("%Y-%m-%d %H:%M:%S", Time()), 'posli_news' => 0]);
         $this->template->h2 = sprintf('Editácia oznamu: %s', $oznam->nazov);
     }
 }
Ejemplo n.º 5
0
 /**
  * RSS feed of news.
  * @return void
  */
 public function rss()
 {
     // Special view for rss
     $this->template = new View('rss');
     $this->template->time = StrFTime("%a, %d %b %Y %H:%M:%S %z", Time());
     // time of generation
     $this->template->description = Kohana::lang('news.rss_description');
     $this->set_title(Kohana::lang('news.news'));
     $this->template->lang = '';
     $this->template->address = url::base();
     $this->template->items = $this->news->get(1, self::PER_PAGE);
 }
Ejemplo n.º 6
0
 /**
  * Performs an authentication
  * @param  array
  * @return Nette\Security\Identity
  * @throws Nette\Security\AuthenticationException
  */
 public function authenticate(array $credentials)
 {
     list($username, $password) = $credentials;
     $row = $this->database->table('users')->where('username', $username)->fetch();
     if (!$row) {
         //Ak sa nenajde username skus hladat email
         $row = $this->database->table('users')->where('email', $username)->fetch();
     }
     if (!$row) {
         throw new Nette\Security\AuthenticationException("User '{$username}' not found. Užívateľ '{$username}' sa nenašiel v databáze!", self::IDENTITY_NOT_FOUND);
     }
     if (!$row->activated) {
         throw new Nette\Security\AuthenticationException("User '{$username}' not activated. Užívateľ '{$username}' ešte nie je aktivovaný!", self::FAILURE);
     }
     //Nasledujuca podmnienka je docasna a je len pre echo-msz a rodinapp
     if ($row->password == 'chyba') {
         if (md5($password) != $row->password) {
             throw new Nette\Security\AuthenticationException("Invalid login name or password. Chybné meno alebo heslo.", self::INVALID_CREDENTIAL);
         } else {
             $this->PasswordHash(8, FALSE);
             //Nastavenie
             $new_password = $this->HashPassword($row->password);
             $this->database->table('users')->get($row->id)->update(array('password' => $new_password, 'old_pass' => NULL, 'last_ip' => $this->context->httpRequest->getRemoteAddress()));
         }
     } else {
         if (!$this->CheckPassword($password, $row->password)) {
             throw new Nette\Security\AuthenticationException("Invalid login name or password. Chybné meno alebo heslo.", self::INVALID_CREDENTIAL);
         }
     }
     //data z tabulky user_profiles
     $prof1 = $this->database->table('user_profiles')->where(array('id_users' => $row->id))->limit(1)->fetch();
     //login ok
     $this->database->table('user_prihlasenie')->insert(array('id_user_profiles' => $prof1->id, 'prihlasenie_datum' => StrFTime("%Y-%m-%d %H:%M:%S", Time())));
     //		unset($row->password);
     $uzivatel = $row->toArray();
     //data z tabulky users
     $prof = $prof1->toArray();
     unset($prof['id'], $prof['id_users']);
     unset($uzivatel['id'], $uzivatel["password"]);
     $uzivatel = array_merge($prof, $uzivatel);
     // Zlucenie users a user_profiles
     $nastav = array('pocet_pr' => $prof1->pocet_pr + 1, 'prihlas_teraz' => StrFTime("%Y-%m-%d %H:%M:%S", Time()), 'prihlas_predtym' => $prof1->prihlas_teraz);
     //Docasne riadky
     if (isset($row->created) && $prof1->created == NULL) {
         $nastav['created'] = $row->created;
     }
     if (isset($row->modified) && $prof1->modified == NULL) {
         $nastav['modified'] = $row->modified;
     }
     //Koniec Docasne riadky
     $this->database->table('user_profiles')->get($prof1->id)->update($nastav);
     return new Nette\Security\Identity($row->id, $prof1->registracia->role, $uzivatel);
 }
class EditPokladnickaFormFactory
{
    /** @var DbTable\Pokladnicka */
    private $pokladnicka;
    /**
   * @param DbTable\Pokladnicka $pokladnicka
   * @param DbTable\User_profiles $user_profiles */
    public function __construct(DbTable\Pokladnicka $pokladnicka)
    {
        $this->pokladnicka = $pokladnicka;
    }
    /**
   * Formular pre pridanie a aditaciu poloziek pokladnicky.
   * @param int $id Id polozky
   * @return Nette\Application\UI\Form */
    public function create($id = 0)
    {
        $form = new Form();
        $form->addProtection();
        $form->addHidden("id");
Ejemplo n.º 8
0
 * @return Form  */
  public function create($upload_size, $prilohy_adresar, $prilohy_images)
  {
      $this->prilohy_adresar = $prilohy_adresar;
      $this->prilohy_images = $prilohy_images;
      $form = new Form();
      $form->addProtection();
      $form->addHidden("id");
      $form->addHidden("id_hlavne_menu");
      $form->addHidden("id_registracia");
      $form->addUpload('priloha', 'Pridaj prílohu')->setOption('description', sprintf('Max veľkosť prílohy v bytoch %s kB', $upload_size / 1024))->addCondition(Form::FILLED)->addRule(Form::MAX_FILE_SIZE, 'Max veľkosť obrázka v bytoch %d B', $upload_size);
      $form->addText('nazov', 'Nadpis prílohy:', 55, 255)->setOption('description', sprintf('Nadpis by mal mať aspoň %s znakov. Inak nebude akceptovaný a bude použitý názov súboru!', 2));
      $form->addText('popis', 'Podrobnejší popis prílohy:', 55, 255)->setOption('description', sprintf('Popis by mal mať aspoň %s znakov. Inak nebude akceptovaný!', 2));
      $form->addSubmit('uloz', 'Ulož')->setAttribute('class', 'btn btn-success')->onClick[] = [$this, 'editPrilohaFormSubmitted'];
      $form->addSubmit('cancel', 'Cancel')->setAttribute('class', 'btn btn-default')->setAttribute('data-dismiss', 'modal')->setAttribute('aria-label', 'Close')->setValidationScope(FALSE);
      return $form;
  }
  /** 
 * Spracovanie formulara pre pridanie a editaciu prilohy polozky.
 * @param Nette\Forms\Controls\SubmitButton $button Data formulara 
 * @throws Database\DriverException   */
  public function editPrilohaFormSubmitted($button)
Ejemplo n.º 9
0
    {
        if (($this->clen = $this->user_profiles->find($id)) === FALSE) {
            $this->setView('notFound');
        } else {
            $this->template->h2 = 'Editácia profilu';
            $this["editUserForm"]->setDefaults($this->clen);
            $this["editUserForm"]->setDefaults(['created' => $this->clen->created < '2000-01-02' ? StrFTime("%Y-%m-%d %H:%M:%S", Time()) : $this->clen->created, 'modified' => StrFTime("%Y-%m-%d %H:%M:%S", Time()), 'username' => $this->clen->user->username, 'email' => $this->clen->user->email]);
        }
    }
    /** 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[] = [$this, 'formCancelled'];
        return $this->_vzhladForm($form);
    }
    /** Spracovanie formulara pre pridanie uzivatela
   * @param Nette\Forms\Controls\SubmitButton $button Data formulara
   */
    public function addUserFormSubmitted($button)
    {
Ejemplo n.º 10
0
 /** Vychodzie nestavenia */
 protected function startup()
 {
     parent::startup();
     //Len na to aby som vedel zobraziť odkaz na aktuality
     $this->template->aktuality = $this->hlavne_menu->findBy(["datum_platnosti >= '" . StrFTime("%Y-%m-%d", strtotime("0 day")) . "'", "id_registracia <= " . ($this->user->isLoggedIn() ? $this->user->getIdentity()->id_registracia : 0), "id_nadradenej = " . ($this->template->id_nadradeny_aktuality = 1)]);
 }
Ejemplo n.º 11
0
 * @license
 * @link       http://petak23.echo-msz.eu
 * @version 1.0.3a
  */
class PokladnickaPresenter extends \App\AdminModule\Presenters\BasePresenter
Ejemplo n.º 12
0
 public function forgotPasswordFormSubmitted($button)
 {
     //Inicializacia
     $values = $button->getForm()->getValues();
     //Nacitanie hodnot formulara
     $clen = $this->users->findOneBy(['email' => $values->email]);
     $new_password_requested = StrFTime("%Y-%m-%d %H:%M:%S", Time());
     $new_password_key = $this->hasser->HashPassword($values->email . $new_password_requested);
     if (isset($clen->email) && $clen->email == $values->email) {
         //Taky clen existuje
         $templ = new Latte\Engine();
         $params = ["site_name" => $this->nazov_stranky, "nadpis" => sprintf($this->trLang('email_reset_nadpis'), $this->nazov_stranky), "email_reset_txt" => $this->trLang('email_reset_txt'), "email_nefunkcny_odkaz" => $this->trLang('email_nefunkcny_odkaz'), "email_pozdrav" => $this->trLang('email_pozdrav'), "nazov" => $this->trLang('forgot_pass'), "odkaz" => 'http://' . $this->nazov_stranky . $this->link("User:resetPassword", $clen->id, $new_password_key)];
         $mail = new Message();
         $mail->setFrom($this->nazov_stranky . ' <' . $this->clen->users->email . '>')->addTo($values->email)->setSubject($this->trLang('forgot_pass'))->setHtmlBody($templ->renderToString(__DIR__ . '/templates/User/forgot_password-html.latte', $params));
         try {
             $sendmail = new SendmailMailer();
             $sendmail->send($mail);
             $this->users->find($clen->id)->update(['new_password_key' => $new_password_key, 'new_password_requested' => $new_password_requested]);
             $this->flashMessage($this->trLang('forgot_pass_email_ok'), 'success');
         } catch (Exception $e) {
             $this->flashMessage($this->trLang('send_email_err') . $e->getMessage(), 'danger,n');
         }
         $this->redirect('Homepage:');
     } else {
         //Taky clen neexzistuje
         $this->flashMessage(sprintf($this->trLang('forgot_pass_user_err'), $values->email), 'danger');
     }
 }
Ejemplo n.º 13
0
        $f = false;
    }
    if ($result['pWood'] > 0 || $result['pVine'] > 0 || $result['pRock'] > 0 || $result['pGlass'] > 0 || $result['pSira'] > 0) {
        $p = true;
    } else {
        $p = false;
    }
    if ($result['pWood'] < 0 || $result['pVine'] < 0 || $result['pRock'] < 0 || $result['pGlass'] < 0 || $result['pSira'] < 0) {
        $pf = true;
    } else {
        $pf = false;
    }
    echo '<tr' . ($f ? ' class="f"' : ($pf ? ' class="pf"' : ($p ? ' class="p"' : ''))) . '><td>' . $result['id'] . '</td><td>' . $result['is_x'] . ':' . $result['is_y'] . '</td>
          <td>' . $result['name'] . '</td>
          <td>' . round($result['wood'] / 1000) . 'k+' . $result['pWood'] . '/hod</td>
          <td>' . round($result['vine'] / 1000) . 'k+' . $result['pVine'] . '/hod</td>
          <td>' . round($result['rock'] / 1000) . 'k+' . $result['pRock'] . '/hod</td>
          <td>' . round($result['glass'] / 1000) . 'k+' . $result['pGlass'] . '/hod</td>
          <td>' . round($result['sira'] / 1000) . 'k+' . $result['pSira'] . '/hod</td>
          <td>' . $result['dist'] . '</td>
          <td' . (time() - $result['lastedit'] > 24 * 60 * 60 ? ' class="f"' : '') . '>' . StrFTime("%d/%m %H:%M:%S", $result['lastedit']) . '</td>';
}
echo '</table>';
?>
     <br />    
    <a href="show.php">back</a>
    <br>      
    <a href="calc.php">kalkulacka</a>
    <br>        
  </body>
</html>
Ejemplo n.º 14
0
 public function userPasswordChangeFormSubmitted($button)
 {
     $values = $button->getForm()->getValues();
     //Nacitanie hodnot formulara
     if ($values->new_heslo != $values->new_heslo2) {
         $this->flashRedirect('this', $this->trLang('PasswordChangeForm_new_heslo2_ar'), 'danger');
     }
     $this->clen = $this->user_profiles->find($values->id);
     //Najdenie clena
     if (!$this->hasser->CheckPassword($values->heslo, $this->clen->users->password)) {
         $this->flashRedirect('this', $this->trLang('pass_incorect'), '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($this->clen->id_users)->update(['password' => $new_password]);
         $this->user_profiles->uloz(['modified' => StrFTime("%Y-%m-%d %H:%M:%S", Time())], $values->id);
         $this->flashMessage($this->trLang('pass_change_ok'), 'success');
     } catch (Exception $e) {
         $this->flashMessage($this->trLang('pass_change_err') . $e->getMessage(), 'danger,n');
     }
     $this->redirect('UserLog:');
 }
Ejemplo n.º 15
0
class AktualneClankyControl extends Nette\Application\UI\Control
{
    /** @var Nette\Database\Table\Selection $aktualne_clanky Data zobrazovaneho clanku */
    private $aktualne_clanky;
    /** @var string $avatar_path  Cesta k titulnemu obrazku clanku */
    private $avatar_path = "";
    /** @var array $texts */