admin_blocks_model.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. class admin_blocks_model extends Model {
  3. public function getBoxes() {
  4. $result = $this->query("select * from azonics_blocks where box_status<>'0';");
  5. return $result;
  6. }
  7. public function loadBox() {
  8. $box_id = $this->escapeString($_REQUEST['id']);
  9. $row = $this->query("select * from azonics_blocks where box_id='".$box_id."';");
  10. return $row[0];
  11. }
  12. public function saveBox() {
  13. $data = $this->escapeArray($_REQUEST);
  14. if ($data['box_id']!='') {
  15. $this->execute("update azonics_blocks set "
  16. . "box_title='".$data['box_title']."', "
  17. . "box_subtitle='".$data['box_subtitle']."', "
  18. . "box_slug='".$data['box_slug']."' "
  19. . "where box_id='".$data['box_id']."';");
  20. return true;
  21. }
  22. else {
  23. $this->execute("insert into azonics_blocks set "
  24. . "box_title='".$data['box_title']."', "
  25. . "box_subtitle='".$data['box_subtitle']."', "
  26. . "box_slug='".$data['box_slug']."', "
  27. . "box_status='1', "
  28. . "box_user='".$_SESSION['admin_user']->admin_id."';");
  29. return true;
  30. }
  31. }
  32. public function deleteBox() {
  33. $box_id = $this->escapeString($_REQUEST['id']);
  34. $this->execute("update azonics_blocks set box_status='0' where box_id='".$box_id."';");
  35. return true;
  36. }
  37. }