Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function changeKategory(){
- $this->isAdmin();
- $db = new DB();
- //zmiana kolejnosci - tylko!
- if($this->post["CatNewNumber"]>$this->post["CatOldNumber"]){
- $db -> query("SELECT id,kolejnosc FROM forum_category WHERE kolejnosc > :CatOldNumber AND kolejnosc <= :CatNewNumber ORDER BY kolejnosc ASC");
- $db -> bind (':CatOldNumber', $this->post["CatOldNumber"]);
- $db -> bind (':CatNewNumber', $this->post["CatNewNumber"]);
- $wyniki = $db -> resultSet();
- foreach($wyniki as $kategoria){
- $kategoria['kolejnosc']--;
- $db -> query("UPDATE forum_category SET kolejnosc = :kolejnoscNowa WHERE id = :id");
- $db -> bind(':kolejnoscNowa', $kategoria['kolejnosc']);
- $db -> bind(':id', $kategoria['id']);
- $db->execute();
- }
- $db -> query("UPDATE forum_category SET name = :NewName, opis = :NewDesc, kolejnosc = :CatNewNumber WHERE id = :CatId");
- $db -> bind (':NewName', $this->post['CatNewName']);
- $db -> bind (':NewDesc', $this->post['CatNewDesc']);
- $db -> bind (':CatNewNumber', $this->post['CatNewNumber']);
- $db -> bind (':CatId', $this->post['CatId']);
- $db -> execute();
- }elseif($this->post["CatNewNumber"]<$this->post["CatOldNumber"]){
- $db -> query("SELECT id,kolejnosc FROM forum_category WHERE kolejnosc < :CatOldNumber AND kolejnosc >= :CatNewNumber ORDER BY kolejnosc DESC");
- $db -> bind (':CatOldNumber', $this->post["CatOldNumber"]);
- $db -> bind (':CatNewNumber', $this->post["CatNewNumber"]);
- $wyniki = $db -> resultSet();
- foreach($wyniki as $kategoria){
- $kategoria['kolejnosc']++;
- $db -> query("UPDATE forum_category SET kolejnosc = :kolejnoscNowa WHERE id = :id");
- $db -> bind(':kolejnoscNowa', $kategoria['kolejnosc']);
- $db -> bind(':id', $kategoria['id']);
- $db->execute();
- }
- $db -> query("UPDATE forum_category SET name = :NewName, opis = :NewDesc, kolejnosc = :CatNewNumber WHERE id = :CatId");
- $db -> bind (':NewName', $this->post['CatNewName']);
- $db -> bind (':NewDesc', $this->post['CatNewDesc']);
- $db -> bind (':CatNewNumber', $this->post['CatNewNumber']);
- $db -> bind (':CatId', $this->post['CatId']);
- $db -> execute();
- }else{
- $db -> query("UPDATE forum_category SET name = :NewName, opis = :NewDesc WHERE id = :CatId");
- $db -> bind (':NewName', $this->post['CatNewName']);
- $db -> bind (':NewDesc', $this->post['CatNewDesc']);
- $db -> bind (':CatId', $this->post['CatId']);
- $db -> execute();
- }
- Messages::setSuccess("Kategoria zmieniona");
- header("Location:http://".ROOT_APP_URL."/forum");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement