Advertisement
Guest User

Health/Mood Problem for Myadopts.php

a guest
Jul 16th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.21 KB | None | 0 0
  1. <?php
  2.  
  3. use Resource\Native\Integer;
  4. use Resource\Native\String;
  5.  
  6. class MyadoptsController extends AppController{
  7.  
  8. const PARAM = "aid";
  9. const PARAM2 = "confirm";
  10. private $adopt;
  11. private $image;
  12.  
  13. public function __construct(){
  14. parent::__construct("member");
  15. $mysidia = Registry::get("mysidia");
  16. if($this->action != "index"){
  17. try{
  18. $this->adopt = new OwnedAdoptable($mysidia->input->get("aid"));
  19. if($this->adopt->getOwner() != $mysidia->user->username) throw new NoPermissionException("permission");
  20. $this->image = $this->adopt->getImage("gui");
  21. }
  22. catch(AdoptNotfoundException $pne){
  23. $this->setFlags("nonexist_title", "nonexist");
  24. }
  25. }
  26. }
  27.  
  28. public function index(){
  29. $mysidia = Registry::get("mysidia");
  30. $total = $mysidia->db->select("owned_adoptables", array("aid"), "owner = '{$mysidia->user->username}'")->rowCount();
  31. $pagination = new Pagination($total, 10, "myadopts");
  32. $pagination->setPage($mysidia->input->get("page"));
  33. $stmt = $mysidia->db->select("owned_adoptables", array("aid"), "owner = '{$mysidia->user->username}' ORDER BY totalclicks LIMIT {$pagination->getLimit()},{$pagination->getRowsperPage()}");
  34. $this->setField("pagination", $pagination);
  35. $this->setField("stmt", new DatabaseStatement($stmt));
  36. }
  37.  
  38. public function manage(){
  39. $health = $adopt->getHealth();
  40. $mood = $adopt->getMood();
  41. $addHealth = $adopt->getHealth() + 10;
  42. $addMood = $adopt->getMood() + 10;
  43. $subtractHealth = $adopt->getHealth() - 10;
  44. $subtractMood = $adopt->getMood() - 10;
  45. $this->setField("aid", new Integer($this->adopt->getAdoptID()));
  46. $this->setField("name", new String($this->adopt->getName()));
  47. $this->setField("image", $this->image);
  48. }
  49.  
  50. public function stats(){
  51. $mysidia = Registry::get("mysidia");
  52. $stmt = $mysidia->db->select("vote_voters", array(), "adoptableid='{$this->adopt->getAdoptID()}' ORDER BY date DESC LIMIT 10");
  53. $this->setField("adopt", $this->adopt);
  54. $this->setField("image", $this->image);
  55. $this->setField("stmt", new DatabaseStatement($stmt));
  56. $document->add(new Comment ("Health: <progress max='100' value='{$health}'></progress> <br></br>Mood: <progress max='100' value='{$mood}'></progress>"));
  57. }
  58.  
  59. public function bbcode(){
  60. $this->setField("adopt", $this->adopt);
  61. }
  62.  
  63. public function rename(){
  64. $mysidia = Registry::get("mysidia");
  65. if($mysidia->input->post("submit")){
  66. $poundsettings = getpoundsettings();
  67. $poundpet = $mysidia->db->select("pounds", array(), "aid='{$this->adopt->getAdoptID()}'")->fetchObject();
  68. if($poundpet and $poundsettings->rename->active == "yes"){
  69. if(!empty($poundpet->firstowner) and $mysidia->user->username != $poundpet->firstowner){
  70. $this->setFlags("rename_error", "rename_owner");
  71. return;
  72. }
  73. }
  74. $this->adopt->setName($mysidia->input->post("adoptname"), "update");
  75. }
  76. $this->setField("adopt", $this->adopt);
  77. $this->setField("image", $this->image);
  78. }
  79.  
  80. public function trade(){
  81. $mysidia = Registry::get("mysidia");
  82. if($mysidia->input->get("confirm") == "confirm"){
  83. switch($this->adopt->getTradeStatus()){
  84. case "fortrade":
  85. $this->adopt->setTradeStatus("notfortrade", "update");
  86. $message = $mysidia->lang->trade_disallow;
  87. break;
  88. case "notfortrade":
  89. $this->adopt->setTradeStatus("fortrade", "update");
  90. $message = $mysidia->lang->trade_allow;
  91. break;
  92. default:
  93. throw new InvalidActionException("global_action");
  94. }
  95. }
  96. else{
  97. $message = "Are you sure you wish to change the trade status of this Magna?
  98. <center><b><a href='{$this->adopt->getAdoptID()}/confirm'>Yes I'd like to change its trade status</a></b><br /><br />
  99. <b><a href='../../myadopts'>Nope I change my mind! Go back to the previous page.</a></b></center><br />";
  100. }
  101. $this->setField("aid", new Integer($this->adopt->getAdoptID()));
  102. $this->setField("image", $this->image);
  103. $this->setField("message", new String($message));
  104. }
  105.  
  106. public function freeze(){
  107. $mysidia = Registry::get("mysidia");
  108. if($mysidia->input->get("confirm") == "confirm"){
  109. switch($this->adopt->isFrozen()){
  110. case "no":
  111. $frozen = "yes";
  112. $message = $this->adopt->getName().$mysidia->lang->freeze_success;
  113. break;
  114. case "yes":
  115. $frozen = "no";
  116. $message = $this->adopt->getName().$mysidia->lang->freeze_reverse;
  117. break;
  118. default:
  119. throw new InvalidActionException("global_action");
  120. }
  121. $this->adopt->setFrozen($frozen, "update");
  122. $message .= "<br>You may now manage {$this->adopt->getName()} on the ";
  123. }
  124. $this->setField("adopt", $this->adopt);
  125. $this->setField("image", $this->image);
  126. $this->setField("message", new String($message));
  127. }
  128. }
  129. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement