View Single Post
  #1  
Old 07-05-2013, 08:18 AM
Infernette Infernette is offline
CODE CODE CODE CODE CODE
 
Join Date: Jan 2013
Location: Where I live? I live home.
Posts: 164
Gender: Female
Credits: 33,059
Infernette is on a distinguished road
Default

Okay I got everything else to work but now the page isn't recognizing the adopt like the other pages I made. This is going to be hard >.<

Here's all the code in case it matters (duplicated/modified the daycare page)
  Spoiler: code 
Code:
<?php

class CrecheController extends AppController{

    const PARAM = "aid";
    const PARAM2 = "confirm";
    private $view;
	private $subController;
	private $adopt;
	private $image;

    public function __construct(){
        parent::__construct();
		$mysidia = Registry::get("mysidia");
		if($mysidia->input->action() == "click" or $mysidia->input->action() == "siggy") $this->adopt = new OwnedAdoptable($mysidia->input->get("aid"));
		if($mysidia->user instanceof Member){
		    $status = $mysidia->user->getstatus();   
			if($status->canlevel == "no") throw new InvalidActionException($mysidia->lang->banned);
		}	
    }
	
	public function view(){
		$mysidia = Registry::get("mysidia");
		$document = $mysidia->frame->getDocument();
        $document->setTitle($mysidia->lang->daycare_title);
        $document->addLangvar($mysidia->lang->daycare, TRUE);

		try{
		    $daycare = new Daycare;
			$adopts = $daycare->getForadopts();
		}
		catch(DaycareException $dae){
		    $message = $dae->getmessage();
		    $document->addLangvar($mysidia->lang->{$message});
			return;
		}
		
		$daycareTable = new Table("daycare", "", FALSE);
		$daycareTable->setBordered(FALSE);
		$total = $daycare->getTotalAdopts();
        $index = 0;

		for($row = 0; $row < $daycare->getTotalRows(); $row++){
	        $daycareRow = new TRow("row{$row}");
            for($column = 0; $column < $daycare->getTotalColumns(); $column++){
			    $adopt = new OwnedAdoptable($adopts[$index]);
				$image = new Link("creche/adopt/{$adopt->getAdoptID()}", $adopt->getImage("gui"), TRUE);
				      $level = $mysidia->db->select("levels", array("primaryimage", "alternateimage","description"), "adoptiename='{$this->adopt->lvltype}' AND thisislevel='{$adopt->currentlevel}'")->fetchObject(); 

				$stats = new Comment("{$level->description}");
				$daycareCell = new TCell(new ArrayObject(array($image, $stats)), "cell{$index}");
                $daycareCell->setAlign(new Align("center", "center"));
				$daycareRow->add($daycareCell);
				$index++;
				if($index == $total) break;
            }
            $daycareTable->add($daycareRow);			
		}
		
        $document->add($daycareTable);
		if($pagination = $daycare->getPagination()) $document->addLangvar($pagination->showPage());
	}
	public function creATEaBunchOFeggsens(){
		$mysidia = Registry::get("mysidia");
		$document = $mysidia->frame->getDocument();
		
$mysidia->db->delete("owned_adoptables", "owner = 'none'");  
			$document->setTitle("Delete Successful!");
			$document->addLangvar($message);
			$document->add(new Link("myadopts/manage/nothin", "Deleted"));
			return;
}
	public function alladoptsdeletedgoodbye3231281ye721(){
		$mysidia = Registry::get("mysidia");
		$document = $mysidia->frame->getDocument();
		
$mysidia->db->delete("owned_adoptables", "owner = 'none'");  
			$document->setTitle("Delete Successful!");
			$document->addLangvar($message);
			$document->add(new Link("myadopts/manage/nothin", "Deleted"));
			return;
}
	public function adopt(){
		$mysidia = Registry::get("mysidia");
		$document = $mysidia->frame->getDocument();
if($this->adopt->owner= "None"){
$n = count($mysidia->db->select("owned_adoptables", array("aid"), " owner='{$mysdia->user->username}' AND currentlevel < 6")->fetchAll()); 
				 $row = $mysidia->db->select("users", array(), constant("PREFIX")."users.username='{$mysidia->user->username}' ")->fetchObject();
				 			$document->setTitle("Adoption Successful!");
		 $slotsleft = $row->slots - $n;
		 if($slotsleft >= 1){
            $mysidia->db->update("owned_adoptables", array("owner" => $mysidia->user->username), "breedcode = '{$adopt->getAdoptID()}'");
			$document->setTitle("Adoption Successful!");
			$message = "<br>You have adopted this pet! You can now manage it in your ";
			$document->addLangvar($message);
			$document->add(new Link("myadopts/", "Holding Area."));
			}
elseif($slotsleft < 1){
			$document->setTitle("Error");
						$message = "<br>You have too many eggs to adopt this pet, you need to hatch one before getting another.";
			$document->addLangvar($message);
}
return;
}
else{
$document->setTitle("Cheating");
			$message = "<br>Not supported in the forest, please upgrade your account to BANNED.";
			$document->addLangvar($message);
}
}
}
?>
__________________
No, I have no idea what I'm doing. But it works. Barely.

Last edited by Infernette; 07-05-2013 at 09:26 AM.
Reply With Quote