View Single Post
  #5  
Old 08-13-2014, 03:05 PM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 151,253
Abronsyth is on a distinguished road
Default

I have it right here. I can see where I need to change it, but I'm still uneasy about PHP, so I don't want to break it, haha.
PHP Code:
<?php

class AdoptController extends AppController{

    private 
$view;
    private 
$subController;

    public function 
__construct(){
        
parent::__construct("member");
        
$mysidia Registry::get("mysidia");
        if(
$mysidia->usergroup->getpermission("canadopt") != "yes"){
            throw new 
NoPermissionException("It appears that you are either not logged in, or do not have permission to adopt.");
        }    
    }
    
    public function 
index(){
        
$mysidia Registry::get("mysidia");
        
$document $mysidia->frame->getDocument();
        
        if(
$mysidia->input->post("submit")){
            
$this->flag "member";
            
$this->handleAccess();
            if(
$mysidia->session->fetch("adopt") != or !is_numeric($mysidia->input->post("id"))) throw new InvalidIDException($mysidia->lang->global_id);
            
            
$adopt = new Adoptable($mysidia->input->post("id"));                
            
$conditions $adopt->getConditions();
            if(!
$conditions->checkConditions()) throw new NoPermissionException("It appears that you do not meet the condition to acquire this adoptable.");
            
            
$name = (!$mysidia->input->post("name"))?$adopt->getType():$mysidia->input->post("name");
            
$alts $adopt->getAltStatus();
            
$code $adopt->getCode();
            
$gender $adopt->getGender();
            
$mysidia->db->insert("owned_adoptables", array("aid" => NULL"type" => $adopt->getType(), "name" => $name"owner" => $mysidia->user->username"currentlevel" => 0"totalclicks" => 0"code" => $code
                                                        
"imageurl" => NULL"usealternates" => $alts"tradestatus" => 'fortrade'"isfrozen" => 'no'"gender" => $gender"lastbred" => 0));
                        
            
$aid $mysidia->db->select("owned_adoptables", array("aid"), "code='{$code}' and owner='{$mysidia->user->username}'")->fetchColumn();
            
$document->setTitle("{$name} adopted successfully");
            
            
$image = new Image($adopt->getEggImage());
            
$image->setLineBreak(TRUE);
            
            
$document->add($image);
            
$document->addLangvar("Congratulations!  You just adopted {$name}.  You can now manage {$name} on the ");
            
$document->add(new Link("myadopts""Myadopts Page."));
            
$document->add(new Comment(""));
            
$document->add(new Link("myadopts/manage/{$aid}""Click Here to Manage {$name}"));
            
$document->add(new Comment(""));
            
$document->add(new Link("myadopts/bbcode/{$aid}""Click Here to get BBCodes/HTML Codes for {$name}"));
            
$document->add(new Comment(""));
            
$document->addLangvar("Be sure and");
            
$document->add(new Link("levelup/{$aid}""feed "));
            
$document->addLangvar("{$name} with clicks so that they grow!");
            return;
        }
        
        
$mysidia->session->assign("adopt"1TRUE);
        
$default = (!$mysidia->user->isloggedin)?$mysidia->lang->guest:$mysidia->lang->member;
        
$document->setTitle($mysidia->lang->title);
        
$document->addLangvar($default);  
        
$ids $mysidia->db->select("adoptables", array("id"), "shop='none'")->fetchAll(PDO::FETCH_COLUMN);

        
$adoptForm = new Form("form""adopt""post");
        
$adoptTitle = new Comment("Available Adoptables");
        
$adoptTitle->setHeading(3);
        
$adoptForm->add($adoptTitle);
        
$adoptTable = new Table("table"""FALSE);
 
        foreach(
$ids as $id){
            
$adopt = new Adoptable($id);
            
$conditions $adopt->getConditions();
            
            if(
$conditions->checkConditions()){
                
$row = new TRow;
                
$idCell = new TCell(new RadioButton("""id"$id));                
                
$imageCell = new TCell(new Image($adopt->getEggImage(), $adopt->getType()));
                
$imageCell->setAlign(new Align("center"));
                
                
$type = new Comment($adopt->getType());
                
$type->setBold();
                
$description = new Comment($adopt->getDescription(), FALSE);
                
$typeCell = new TCell;
                
$typeCell->add($type);
                
$typeCell->add($description);            

                
$row->add($idCell);
                
$row->add($imageCell);
                
$row->add($typeCell);
                
$adoptTable->add($row);
            }
        }
        if(!
$ids$adoptForm->add(new Comment("There is not an adoptable available at this point, please come back later."));
        else 
$adoptForm->add($adoptTable);
        
        
$adoptSubtitle = new Comment("Adopt");
        
$adoptSubtitle->setHeading(3);
        
$adoptForm->add($adoptSubtitle);
        
$adoptForm->add(new Comment("Adoptable Name: "FALSE));
        
$adoptForm->add(new TextField("name"));
        
$adoptForm->add(new Comment(""));
        
$adoptForm->add(new Button("Adopt Me""submit""submit"));
        
$document->add($adoptForm);    
    }
}
?>
Reply With Quote