protected function reset_password() { if (empty($_POST['user_id'])) { $this->setMsg(false, "Zadajte užívateľa"); return; } if (empty($this->users[$_POST['user_id']])) { $this->setMsg(false, "Zadaný užívateľ neexistuje"); return; } if (empty($_POST['login'])) { $this->setMsg(false, "Zadajte prihlasovacie meno užívateľa"); return; } if (strcmp($_POST['login'], $this->users[$_POST['user_id']]['login'])) { $this->setMsg(false, "Neoprávnená zmena údajov"); return; } $data = new DBQuery(CDatabaza::getInstance()); $data->setTable('Uzivatel'); $data->setRecord("uzivatel_id", $_POST['user_id'], true); $data->setField("heslo", $_POST['login'], true, true); if (!$data->queryDB('update')) { $this->setMsg(false, "Nepodarilo resetovať heslo."); return; } $this->setMsg(true, "Heslo úspešne zresetované."); }
protected function setTimeStamp() { $data = new DBQuery(CDatabaza::getInstance()); $data->setTable("Clanok"); $data->setField("casova_znamka", time()); $data->setRecord("clanok_id", $this->article['id']); if (!$data->queryDB("update")) { return false; } return true; }
private function removePost($post_id) { if (!$this->postEditable($post_id)) { return false; } $data = new DBQuery(CDatabaza::getInstance()); $data->setTable("Prispevok"); $data->setRecord("prispevok_id", $post_id); return $data->queryDB("delete"); }
protected function remove_theme() { if (empty($_POST['tema'])) { $this->setMsg(false, "Zadajte tému rubriky prosím."); return; } if (empty($this->themes[$_POST['tema']])) { $this->setMsg(false, "Zadaná téma sa v databáze nenachádza"); return; } foreach ($this->topics as $topic) { if ($topic['theme'] == $_POST['tema']) { $this->setMsg(false, "K danej téme sú priradené rubriky. Preraďte rubriky na inú tému a skúste znovu"); return; } } $query = new DBQuery(CDatabaza::getInstance()); $query->setTable('Tema'); $query->setRecord("tema_id", $_POST['tema'], true); if (!$query->queryDB("delete")) { $this->setMsg(false, "Nepodarilo sa vymazať tému"); return; } $this->setMsg(true, "Téma úspešne vymazaná"); }
private function initialize() { $data = new DBQuery(CDatabaza::getInstance()); $data->setTable("Uzivatel_info"); $data->setRecord("uzivatel_id", $_SESSION['user']); $query = $data->queryDB("select"); if ($query) { $usr_nfo = $query->fetch_array(); $this->user_info['name'] = $usr_nfo['meno']; $this->user_info['surname'] = $usr_nfo['priezvisko']; $this->user_info['class'] = $usr_nfo['trieda']; } }
protected function remove_article() { if (empty($_POST['id'])) { $this->setMsg(false, "Zadajte článok"); return; } $data = new DBQuery(CDatabaza::getInstance()); $data->setTable("Clanok_uzivatel"); $data->setRecord("clanok_id", $_POST['id']); if (!$data->queryDB("delete")) { $this->setMsg(false, "Nepodarilo sa vymazať prepojenia"); return; } $data->setTable("Clanok"); $data->setRecord("clanok_id", $_POST['id']); if (!$data->queryDB("delete")) { $this->setMsg(false, "Nepodarilo sa vymazať článok"); return; } //odstrani adresar a vsetko co sa v nom nachadza $dir = ProgramManager::getHomeDir() . "/../articles/" . $_POST['id']; $this->removeDir($dir); $this->setMsg(true, "Článok vymazaný"); }