protected function edit() { // ladowanie klasy $item = new ClassTrainingCenter(ClassTools::getValue('id_training_centre')); // sprawdza czy klasa zostala poprawnie zaladowana if (!$item->load_class) { $this->alerts['danger'] = "Centrum szkolenia nie istnieje."; return; } $active = ClassTools::getValue('form_active'); $item->name = ClassTools::getValue('form_name'); $item->location = ClassTools::getValue('form_location'); $item->id_user = ClassAuth::getCurrentUserId(); $item->active = $active && $active == '1' ? '1' : '0'; // komunikaty bledu if (!$item->update()) { $this->alerts['danger'] = $item->errors; return; } // komunikat $this->alerts['success'] = "Poprawnie zaktualizowano centrum szkolenia: <b>{$item->name}</b>"; // czyszczeie zmiennych wyswietlania $this->tpl_values = ''; $_POST = array(); return; }
public function sqlUpdatePassword($new_password, $id_user_new_password = false) { global $DB; // dodawanie logu if (!($user = $this->sqlGetUser($this->id, true))) { $this->errors[] = "LOG: Błąd podczas pobierania rekordu z bazy."; return false; } $data_log = array('id_user' => $user['id_user'], 'login' => $user['login'], 'mail' => $user['mail'], 'password' => $user['password'], 'id_permission' => $user['id_permission'], 'id_military' => $user['id_military'], 'active' => $user['active'], 'guard' => $user['guard'], 'name' => $user['name'], 'surname' => $user['surname'], 'phone' => $user['phone'], 'date_update' => date('Y-m-d H:i:s'), 'id_user_update' => ClassAuth::getCurrentUserId()); if (!$DB->insert('log_users', $data_log)) { $this->errors[] = "LOG: Błąd podczas zapisywania rekordu w tabeli z logami."; return false; } $where = "`id_user` = '{$this->id}'"; if (!$DB->update('sew_users', array('password' => ClassAuth::generatePassword($new_password)), $where)) { return false; } if ($id_user_new_password) { $where = "`id_user_new_password` = '{$id_user_new_password}'"; if (!$DB->update('sew_user_new_password', array('generated' => '1'), $where)) { return false; } } return true; }
protected function add() { $item = new ClassSoldierRank(); $item->name = ClassTools::getValue('form_name'); $item->date_add_rank = ClassTools::getValue('form_date'); $item->id_soldier = ClassTools::getValue('id_soldier'); $item->id_user = ClassAuth::getCurrentUserId(); // komunikaty bledu if (!$item->add()) { $this->alerts['danger'] = $item->errors; return; } // komunikat sukcesu $this->alerts['success'] = "Poprawnie dodano nowy stopień wojskowy."; // czyszczeie zmiennych wyswietlania $this->tpl_values = ''; $_POST = array(); return; }
protected function trainingReturn() { // ladowanie klasy $item = new ClassSoldier2Training(ClassTools::getValue('id_soldier2trainings')); // sprawdza czy klasa zostala poprawnie zaladowana if (!$item->load_class) { $this->alerts['danger'] = "Szkolenie żołnierza nie istnieje."; return; } $item->id_soldier = ClassTools::getValue('id_soldier'); $item->id_training = ClassTools::getValue('id_training'); $item->description_return = ClassTools::getValue('form_description_return'); $item->date_training_return = ClassTools::getValue('form_date'); $item->id_user = ClassAuth::getCurrentUserId(); // komunikaty bledu if (!$item->trainingReturn()) { $this->alerts['danger'] = $item->errors; return; } // komunikat $this->alerts['success'] = "Poprawnie odesłano żołnierza ze szkolenia."; // czyszczeie zmiennych wyswietlania $this->tpl_values = ''; $_POST = array(); return; }
protected function receive() { // ladowanie klasy $item = new ClassSoldier2Badge(ClassTools::getValue('id_soldier2badges')); // sprawdza czy klasa zostala poprawnie zaladowana if (!$item->load_class) { $this->alerts['danger'] = "Odznaczenie żołnierza nie istnieje."; return; } $item->description_receive = ClassTools::getValue('form_description_receive'); $item->id_badge = ClassTools::getValue('id_badge'); $item->id_soldier = ClassTools::getValue('id_soldier'); $item->date_receive = ClassTools::getValue('form_date'); $item->id_user = ClassAuth::getCurrentUserId(); // komunikaty bledu if (!$item->receive()) { $this->alerts['danger'] = $item->errors; return; } // komunikat $this->alerts['success'] = "Poprawnie odebrano odznaczenie żołnierza: <b>{$item->badge_name}</b>"; // czyszczeie zmiennych wyswietlania $this->tpl_values = ''; $_POST = array(); return; }
protected function edit() { // ladowanie klasy $item = new ClassSoldierSchool(ClassTools::getValue('id_school')); // sprawdza czy klasa zostala poprawnie zaladowana if (!$item->load_class) { $this->alerts['danger'] = "Szkoła żołnierza nie istnieje."; return; } $item->name = ClassTools::getValue('form_name'); $item->address = ClassTools::getValue('form_address'); $item->specialization = ClassTools::getValue('form_specialization'); $item->id_academic_degree = ClassTools::getValue('form_academic_degree'); $item->date_start = ClassTools::getValue('form_date_start'); $item->date_end = ClassTools::getValue('form_date_end'); $item->id_soldier = ClassTools::getValue('id_soldier'); $item->id_user = ClassAuth::getCurrentUserId(); // komunikaty bledu if (!$item->update()) { $this->alerts['danger'] = $item->errors; return; } // komunikat $this->alerts['success'] = "Poprawnie zaktualizowano szkolę żołnierza: <b>{$item->name}</b>"; // czyszczeie zmiennych wyswietlania $this->tpl_values = ''; $_POST = array(); return; }
protected function sqlDeleteOnColumn($table, $id_item) { global $DB; $table_name = (static::$use_prefix ? static::$prefix : '') . $table; $where = static::$definition['primary'] . ' = ' . $id_item; if (static::$is_log) { $table_name_log = static::$prefix_log . $table; if (!($item_to_log = self::sqlGetItem($id_item))) { $this->errors[] = "LOG: Błąd podczas pobierania rekordu z bazy."; return false; } if (!$DB->insert($table_name_log, $item_to_log)) { $this->errors[] = "LOG: Błąd podczas zapisywania rekordu w tabeli z logami."; return false; } } $data = array(); $data['id_user'] = ClassAuth::getCurrentUserId(); $data['deleted'] = '1'; if (property_exists($this, 'date_update')) { $data['date_update'] = $this->date_update; } if (property_exists($this, 'active')) { $data['active'] = '0'; } return $DB->update($table_name, $data, $where); }
protected function add() { $item = new ClassSoldierDriveLicense(); $item->id_drive_category = ClassTools::getValue('form_drive_category'); $item->date_start = ClassTools::getValue('form_date_start'); $item->date_end = ClassTools::getValue('form_date_end'); $item->id_soldier = ClassTools::getValue('id_soldier'); $item->id_user = ClassAuth::getCurrentUserId(); // komunikaty bledu if (!$item->add()) { $this->alerts['danger'] = $item->errors; return; } // komunikat sukcesu $this->alerts['success'] = "Poprawnie dodano nową kategorię jazdy."; // czyszczeie zmiennych wyswietlania $this->tpl_values = ''; $_POST = array(); return; }
protected function editPassword() { global $login; // sprawdza czy uzytkownik nie zmienil sb id podczas edycji if (ClassTools::getValue('id_user') != $login->auth_user['id_user']) { $this->alerts['danger'] = 'Niepoprawny użytkownik'; return false; } $item = new ClassUser(ClassTools::getValue('id_user')); $item->id_user = ClassAuth::getCurrentUserId(); // komunikaty bledu if (!$item->myAccountEditPassword(ClassTools::getValue('form_new_password'), ClassTools::getValue('form_new_password_repeat'))) { $this->alerts['danger'] = $item->errors; return; } // komunikat sukcesu $this->alerts['success'] = "Poprawnie zmieniono hasło."; // czyszczeie zmiennych wyswietlania $this->tpl_values = ''; $_POST = array(); return; }
protected function login() { $login = new ClassLogin(); $login->login = ClassTools::getValue('form_login'); $login->password = ClassTools::getValue('form_password'); // komunikaty bledu if (!($user = $login->login())) { $this->alerts['danger'] = $login->errors; return; } $guard = $user['guard'] == '1' ? true : false; if (!($auth = ClassAuth::userLogin($user['id_user'], $guard))) { $this->alerts['danger'] = 'Błąd podczas zapisu sesji logowania do bazy.'; return; } // przypisanie klucza logowania do sesji $_SESSION['user']['auth_key'] = $auth['auth_key']; if ($auth['guard_key']) { if ($auth['guard_key'] !== true) { // wysylanie maila z kluczem do guarda $this->sendMailGuardKey($user['mail'], $auth['guard_key'], $_SERVER['REMOTE_ADDR']); } // przejscie na strone z formularzem do wpisania klucza ClassTools::redirect('guard'); exit; } // przejscie na strone glowna po poprawnym logowaniu ClassTools::redirect(''); exit; return; }
public function sendNewPasswordLink() { $empty = false; $this->login = trim($this->login); // sprawdzanie czy login jest pusty if ($this->login == '' || empty($this->login)) { $this->errors[] = "<b>Użytkownik</b>: Pole jest puste."; return false; } // sprawdzanie czy login sie waliduje if (!ClassModel::validIsNormalChars($this->login)) { $this->errors = "<b>Login</b>: Niepoprawny format."; return false; } // sprawdzanie czy uzytkownik istnieje if (!($user = $this->sqlGetUserAndPassword($this->login))) { $this->errors = "Użytkownik nie istnieje."; return false; } // sprawdzanie czy uzytkownik jest aktywny if ($user['active'] != '1') { $this->errors = "Użytkownik nie jest aktywny."; return false; } // sprawdzanie kiedy ostatnio zostal wyslany link do zmiany hasla if ($last_send = $this->sqlGetWhenPasswordSend($user['id_user'])) { $date_password_send = new DateTime($last_send['date_send']); $date_now = new DateTime("now"); $date_now->sub(new DateInterval('PT' . ClassAuth::$password_mail_time . 'M')); if ($date_password_send > $date_now) { $this->errors = "Nowe hasło można wysyłać raz na " . ClassAuth::$password_mail_time . " minut."; return false; } } // generowanie klucza linka // $password_key = ClassTools::generateRandomPasswd(60, array('1', '2', '3')); $password_key = ClassAuth::generateRandomPasswordLinkKey(); if ($last_send) { $this->sqlUpdateNewPasswordRequest($password_key, $last_send['id_user_new_password']); } else { $this->sqlAddNewPasswordRequest($password_key, $user['id_user']); } $this->auth_user = $user; return $password_key; }
protected function equipmentReturn() { // ladowanie klasy $item = new ClassSoldier2Equipment(ClassTools::getValue('id_soldier2equipments')); // sprawdza czy klasa zostala poprawnie zaladowana if (!$item->load_class) { $this->alerts['danger'] = "Wyposażenie żołnierza nie istnieje."; return; } $item->id_soldier = ClassTools::getValue('id_soldier'); $item->id_equipment = ClassTools::getValue('id_equipment'); $item->description_return = ClassTools::getValue('form_description_return'); $item->date_return = ClassTools::getValue('form_date'); $item->id_user = ClassAuth::getCurrentUserId(); // komunikaty bledu if (!$item->equipmentReturn()) { $this->alerts['danger'] = $item->errors; return; } // komunikat $this->alerts['success'] = "Poprawnie zwrócono wyposazenie żołnierza."; // czyszczeie zmiennych wyswietlania $this->tpl_values = ''; $_POST = array(); return; }
protected function edit() { // ladowanie klasy $military = new ClassMilitary(ClassTools::getValue('id_military')); // sprawdza czy klasa zostala poprawnie zaladowana if (!$military->load_class) { $this->alerts['danger'] = "Jednostka nie istnieje."; } $active = ClassTools::getValue('form_active'); $military->id_military_type = ClassTools::getValue('form_group'); $military->number = ClassTools::getValue('form_number'); $military->name = ClassTools::getValue('form_name'); $military->location = ClassTools::getValue('form_location'); $military->id_user = ClassAuth::getCurrentUserId(); $military->active = $active && $active == '1' ? '1' : '0'; // komunikaty bledu if (!$military->update()) { $this->alerts['danger'] = $military->errors; return; } // komunikat $this->alerts['success'] = "Poprawnie zaktualizowano jednostkę: <b>{$military->name}</b>"; // czyszczeie zmiennych wyswietlania $this->tpl_values = ''; $_POST = array(); return; }
protected function edit() { // ladowanie klasy $item = new ClassSoldierAddress(ClassTools::getValue('id_address')); // sprawdza czy klasa zostala poprawnie zaladowana if (!$item->load_class) { $this->alerts['danger'] = "Szkoła żołnierza nie istnieje."; } $item->street = ClassTools::getValue('form_street'); $item->postcode = ClassTools::getValue('form_postcode'); $item->city = ClassTools::getValue('form_city'); $item->country = ClassTools::getValue('form_country'); $item->id_address_types = ClassTools::getValue('form_type'); $item->id_soldier = ClassTools::getValue('id_soldier'); $item->id_user = ClassAuth::getCurrentUserId(); // komunikaty bledu if (!$item->update()) { $this->alerts['danger'] = $item->errors; return; } // komunikat $this->alerts['success'] = "Poprawnie zaktualizowano adres żołnierza."; // czyszczeie zmiennych wyswietlania $this->tpl_values = ''; $_POST = array(); return; }
protected function edit() { // ladowanie klasy $item = new ClassMilitaryType(ClassTools::getValue('id_military_type')); // sprawdza czy klasa zostala poprawnie zaladowana if (!$item->load_class) { $this->alerts['danger'] = 'Rodzaj jednoski wojskowej nie istnieje'; return; } $active = ClassTools::getValue('form_active'); $item->name = ClassTools::getValue('form_name'); $item->id_user = ClassAuth::getCurrentUserId(); $item->active = $active && $active == '1' ? '1' : '0'; // komunikaty bledu if (!$item->update()) { $this->alerts['danger'] = $item->errors; return; } // komunikat $this->alerts['success'] = "Poprawnie zaktualizowano rodzaj jednoski wojskowej: <b>" . htmlspecialchars($item->name) . "</b>"; // czyszczeie zmiennych wyswietlania $this->tpl_values = ''; $_POST = array(); return; }
protected function edit() { // ladowanie klasy $item = new ClassMission(ClassTools::getValue('id_mission')); // sprawdza czy klasa zostala poprawnie zaladowana if (!$item->load_class) { $this->alerts['danger'] = "Misja nie istnieje."; return; } $active = ClassTools::getValue('form_active'); $form_date_end = ClassTools::getValue('form_date_end'); $item->name = ClassTools::getValue('form_name'); $item->id_mission_type = ClassTools::getValue('form_type'); $item->location = ClassTools::getValue('form_location'); $item->description = ClassTools::getValue('form_description'); $item->date_start = ClassTools::getValue('form_date_start'); $item->date_end = $form_date_end != '' ? $form_date_end : NULL; $item->id_user = ClassAuth::getCurrentUserId(); $item->active = $active && $active == '1' ? '1' : '0'; // komunikaty bledu if (!$item->update()) { $this->alerts['danger'] = $item->errors; return; } // komunikat $this->alerts['success'] = "Poprawnie zaktualizowano misję: <b>{$item->name}</b>"; // czyszczeie zmiennych wyswietlania $this->tpl_values = ''; $_POST = array(); return; }
protected function edit() { // ladowanie klasy $item = new ClassSoldier(ClassTools::getValue('id_soldier')); // sprawdza czy klasa zostala poprawnie zaladowana if (!$item->load_class) { $this->alerts['danger'] = "Żołnierz nie istnieje."; } $form_height = ClassTools::getValue('form_height'); $form_weight = ClassTools::getValue('form_weight'); $form_shoe_number = ClassTools::getValue('form_shoe_number'); $item->sex = ClassTools::getValue('form_sex'); $item->name = ClassTools::getValue('form_name'); $item->second_name = ClassTools::getValue('form_second_name'); $item->surname = ClassTools::getValue('form_surname'); $item->date_birthday = ClassTools::getValue('form_date_birthday'); $item->place_birthday = ClassTools::getValue('form_place_birthday'); $item->citizenship = ClassTools::getValue('form_citizenship'); $item->nationality = ClassTools::getValue('form_nationality'); $item->pesel = ClassTools::getValue('form_pesel'); $item->identity_document = ClassTools::getValue('form_identity_document'); $item->mail = ClassTools::getValue('form_mail'); $item->phone = ClassTools::getValue('form_phone'); $item->height = $form_height != '' && $form_height != '0' ? $form_height : NULL; $item->weight = $form_weight != '' && $form_weight != '0' ? $form_weight : NULL; $item->shoe_number = $form_shoe_number != '' && $form_shoe_number != '0' ? $form_shoe_number : NULL; $item->blood_group = ClassTools::getValue('form_blood_group'); $item->name_mother = ClassTools::getValue('form_name_mother'); $item->surname_mother = ClassTools::getValue('form_surname_mother'); $item->name_father = ClassTools::getValue('form_name_father'); $item->surname_father = ClassTools::getValue('form_surname_father'); $item->name_partner = ClassTools::getValue('form_name_partner'); $item->surname_partner = ClassTools::getValue('form_surname_partner'); $item->id_education_type = ClassTools::getValue('form_education_type'); $item->wku = ClassTools::getValue('form_wku'); $item->health_category = ClassTools::getValue('form_health_category'); $item->id_military = ClassTools::getValue('form_military'); $item->injuries = ClassTools::getValue('form_injuries'); $item->id_status = ClassTools::getValue('form_status'); $item->id_user = ClassAuth::getCurrentUserId(); // komunikaty bledu if (!$item->update()) { $this->alerts['danger'] = $item->errors; return; } // komunikat $this->alerts['success'] = "Poprawnie zaktualizowano żołnierza: <b>{$item->name} {$item->surname}</b>"; // czyszczeie zmiennych wyswietlania $this->tpl_values = ''; $_POST = array(); return; }
protected function edit() { // ladowanie klasy $badge = new ClassBadge(ClassTools::getValue('id_badge')); // sprawdza czy klasa zostala poprawnie zaladowana if (!$badge->load_class) { $this->alerts['danger'] = "Odznaczenie nie istnieje."; return; } $active = ClassTools::getValue('form_active'); $badge->id_badge_type = ClassTools::getValue('form_rank'); $badge->name = ClassTools::getValue('form_name'); $badge->id_user = ClassAuth::getCurrentUserId(); $badge->active = $active && $active == '1' ? '1' : '0'; // komunikaty bledu if (!$badge->update()) { $this->alerts['danger'] = $badge->errors; return; } // komunikat $this->alerts['success'] = "Poprawnie zaktualizowano odznaczenie: <b>{$badge->name}</b>"; // czyszczeie zmiennych wyswietlania $this->tpl_values = ''; $_POST = array(); return; }
protected function edit() { // ladowanie klasy $item = new ClassMissionType(ClassTools::getValue('id_mission_type')); // sprawdza czy klasa zostala poprawnie zaladowana if (!$item->load_class) { $this->alerts['danger'] = "Rodzaj misji nie istnieje."; return; } $active = ClassTools::getValue('form_active'); $form_parent = ClassTools::getValue('form_parent'); $item->name = ClassTools::getValue('form_name'); $item->id_parent = $form_parent != '' && is_numeric($form_parent) ? $form_parent : NULL; $item->id_user = ClassAuth::getCurrentUserId(); $item->active = $active && $active == '1' ? '1' : '0'; // komunikaty bledu if (!$item->update()) { $this->alerts['danger'] = $item->errors; return; } // komunikat $this->alerts['success'] = "Poprawnie zaktualizowano rodzaj misji: <b>{$item->name}</b>"; // czyszczeie zmiennych wyswietlania $this->tpl_values = ''; $_POST = array(); return; }
protected function add() { $item = new ClassSoldierLanguage(); $item->name = ClassTools::getValue('form_name'); $item->id_language_level = ClassTools::getValue('form_language_level'); $item->id_soldier = ClassTools::getValue('id_soldier'); $item->id_user = ClassAuth::getCurrentUserId(); // komunikaty bledu if (!$item->add()) { $this->alerts['danger'] = $item->errors; return; } // komunikat sukcesu $this->alerts['success'] = "Poprawnie dodano nowy język: <b>{$item->name}</b>"; // czyszczeie zmiennych wyswietlania $this->tpl_values = ''; $_POST = array(); return; }
protected function detach() { // ladowanie klasy $item = new ClassSoldier2Mission(ClassTools::getValue('id_soldier2missions')); // sprawdza czy klasa zostala poprawnie zaladowana if (!$item->load_class) { $this->alerts['danger'] = "Misja żołnierza nie istnieje."; return; } $item->id_soldier = ClassTools::getValue('id_soldier'); $item->id_mission = ClassTools::getValue('id_mission'); $item->description_detach = ClassTools::getValue('form_description_detach'); $item->date_mission_detach = ClassTools::getValue('form_date'); $item->id_user = ClassAuth::getCurrentUserId(); // komunikaty bledu if (!$item->detach()) { $this->alerts['danger'] = $item->errors; return; } // komunikat $this->alerts['success'] = "Poprawnie oddelegowano żołnierza z misji."; // czyszczeie zmiennych wyswietlania $this->tpl_values = ''; $_POST = array(); return; }
protected function edit() { // ladowanie klasy i uzytkownika $user = new ClassUser(ClassTools::getValue('id_user')); // sprawdza czy klasa zostala poprawnie zaladowana if (!$user->load_class) { $this->alerts['danger'] = $user->errors; return; } $active = ClassTools::getValue('form_active'); $military = ClassTools::getValue('form_military'); $guard = ClassTools::getValue('form_guard'); $user->login = ClassTools::getValue('form_login'); $user->mail = ClassTools::getValue('form_mail'); $user->id_permission = ClassTools::getValue('form_permission'); $user->id_military = !$military || $military == '0' || $military == '' ? NULL : $military; $user->active = $active && $active == '1' ? '1' : '0'; $user->guard = $guard && $guard == '1' ? '1' : '0'; $user->name = ClassTools::getValue('form_name'); $user->surname = ClassTools::getValue('form_surname'); $user->phone = ClassTools::getValue('form_phone'); $user->id_user_edit = ClassAuth::getCurrentUserId(); $user->id_user_update = ClassAuth::getCurrentUserId(); // komunikaty if (!$user->update()) { $this->alerts['danger'] = $user->errors; return; } // komunikat $this->alerts['success'] = "Poprawnie zaktualizowano użytkownika: <b>{$user->name} {$user->surname}</b>"; // czyszczeie zmiennych wyswietlania // $this->tpl_values = ''; $_POST = array(); return; }