Location: PHPKode > projects > Blackwolf CMF > projectBlackWolf/lib/Module/Mission/Cmd/Get/CurrentVisibleTeamMission.class.php
<?php

/* Please see the README and LICENSE files. */

/**
 * Gets the current mission that is visible for this team and user
 */
class Module_Mission_Cmd_Get_CurrentVisibleTeamMission implements Command {

    public function run($module) {        
        $controller = Data_Storage_DatabaseController::get_default();
        
        if(!$controller->connect(NULL,NULL,NULL,NULL,false,true)){return false;} // Return false connection on failure. Move to get_default()?
        
        $name = $controller->translate_location(array("module","mission"),"mission"); // Move this to controller?
        
        $sql = "
            SELECT * 
            FROM `".$name."` 
            WHERE `missionId` = ?
            ORDER BY `missionId` DESC
            LIMIT 0,1;";
        
        $controller->query($sql,array("i",1));
        
        $results = $controller->get_result();
        
        if($results == false){
            return false;
        }
        
        $model = new Module_Mission_Model_Mission();
        $model->add_attribute(new Module_Attribute("missionId",$results[0]->missionId));
        $model->add_attribute(new Module_Attribute("title",$results[0]->title));
        $model->add_attribute(new Module_Attribute("text",$results[0]->text));
        $model->add_attribute(new Module_Attribute("mission",$results[0]->mission));
        $model->add_attribute(new Module_Attribute("team",$results[0]->team));
        
        $module->add_model($model);
        return $module;
    }

}

?>
Return current item: Blackwolf CMF