summaryrefslogblamecommitdiffstats
path: root/application/modules/dev/controllers/BootisoController.php
blob: 901c9015a1dcd6780c5324d6e87ad803db6b4d3d (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13

     
                                                          









                                                               


                                                                     
                                                                
        
                                                              

                                           

                                                       
                                                                                                                           



                                                                                                                                                                                           
     





                                                            
                                                                        
                                                                        
 
                                                                                    


                                                                                                                                          
                                                                                                      

                                                   
                



                                                              
                                                      
                                                                             
                                                
                        
     




        


                                         
                                                                   
                                                                       
        
                                                     
                                                                                                                                                            

                        
                                                                                                                                                                   








                                                                               
                                
                                                           
        





                                                                                      
                                                                         








                                                                
                                                           

                                                               



                                                                    
                                                                 




                                                                          
                                                                                                                                                           


                                                                    
                                                                                                                                                               
















                                                                                
                                                                 










                                                                    
                                                         





                                                                          
                                         










     
<?php

class dev_BootisoController extends Zend_Controller_Action
{

    public function init()
    {
   		$db = Zend_Db_Table::getDefaultAdapter();
    }

    public function indexAction()
    {
    	$bootisomapper = new Application_Model_BootIsoMapper();
    	$groupmapper = new Application_Model_GroupMapper();
    	$membershipmapper = new Application_Model_MembershipMapper();
    	$personmapper = new Application_Model_PersonMapper();
    	$prebootmapper = new Application_Model_PreBootMapper(); 
    	
    	$this->view->bootisolist = $bootisomapper->fetchAll();
    	$this->view->prebootlist = array();
    	
    	    
    	foreach ($this->view->bootisolist as $bootiso){
    		  $this->view->prebootlist[$bootiso->getID()] = $prebootmapper->find($bootiso->getPrebootID())->getTitle();
    		  $bootiso->setGroupID("[".$bootiso->getGroupID()."] ".$groupmapper->find($bootiso->getGroupID())->getTitle());
    		  $bootiso->setMembershipID("[".$bootiso->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootiso->getMembershipID())->getPersonID())->getFirstname());
    	}
    
    }
    
    public function downloadbootisoAction()
    {
    	$this->_helper->layout->disableLayout();
		$this->_helper->viewRenderer->setNoRender();
		
    	$prebootID = $this->_request->getParam('prebootID');    	
    	$serialnumber = $this->_request->getParam('serialnumber');    	

    	if(is_dir("../resources/bootmedium/$prebootID/") && is_numeric($prebootID)){
			 
			header('Content-Type: application/x-gzip');
			$content_disp = ( ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']) == 'IE') ? 'inline' : 'attachment';
			header('Content-Disposition:  ' . $content_disp . '; filename="preboot.zip"');
			header('Pragma: no-cache');
			header('Expires: 0');
		
			$fp = fopen("bootisoSerial.txt", "w");
        	fputs ($fp, $serialnumber);
        	fclose ($fp);
			
			// create the gzipped tarfile.
			chdir("../resources/bootmedium/$prebootID/preboot/");
			passthru("zip -r - ./");
			
    }
    	
    	

    
    }

    public function createbootisoAction()
    {
    		$groupmapper = new Application_Model_GroupMapper();
    		$prebootmapper = new Application_Model_PreBootMapper();
    	
           	if (!isset($_POST["createbootiso"])){
    	        $createbootisoForm = new dev_Form_BootisoCreate(array('grouplist' => $groupmapper->fetchAll(),'prebootlist' => $prebootmapper->fetchAll()));
    		} else {
    			
    	        $createbootisoForm = new dev_Form_BootisoCreate(array('grouplist' => $groupmapper->fetchAll(),'prebootlist' => $prebootmapper->fetchAll()),$_POST);
    			    			
    		    if ($createbootisoForm->isValid($_POST)) {

    		    	$bootiso = new Application_Model_BootIso($_POST);
    		    	$bootiso->setMembershipID('1');
    		        $bootisomapper = new Application_Model_BootIsoMapper();
    		        $bootiso->setCreated(time()); 
    		        
    		    	try {  
    		    		
    		            $bootisomapper->save($bootiso);
	
    		        }catch(Zend_Exception $e)
    		        {
    		            echo "Caught exception: " . get_class($e) . "<br/>";
    					echo "Message: " . $e->getMessage() . "<br/>";
    					
    		        }
					$this->_redirect('/dev/bootiso');
    		     }
    		}
    
            $this->view->createbootisoForm = $createbootisoForm;
    }

    public function editbootisoAction()
    {
    	$bootisoID = $this->_request->getParam('bootisoID');
    	$groupmapper = new Application_Model_GroupMapper();
    	$prebootmapper = new Application_Model_PreBootMapper();
    	
    	
    	if (!isset($_POST["editbootiso"])){
    		$bootisoID = $this->_request->getParam('bootisoID');
     		if (!isset($bootisoID) || !is_numeric($bootisoID)){
   				$this->_redirect('/dev/bootiso');
    		} else {
    		   $bootiso = new Application_Model_BootIso();
    		   $bootisomapper = new Application_Model_BootIsoMapper();
    		   $bootisomapper->find($bootisoID, $bootiso);
    		   
    		   $editbootisoForm = new dev_Form_BootisoEdit(array('grouplist' => $groupmapper->fetchAll(),'prebootlist' => $prebootmapper->fetchAll()));
    		   $editbootisoForm->populate($bootiso->toArray()); 
    		}
    	}else{
    		$editbootisoForm = new dev_Form_BootisoEdit(array('grouplist' => $groupmapper->fetchAll(),'prebootlist' => $prebootmapper->fetchAll()),$_POST);
    			    			
    		if ($editbootisoForm->isValid($_POST)) {

    			$bootiso = new Application_Model_BootIso($_POST);
    			$bootiso->setMembershipID('1');
    		    $bootisomapper = new Application_Model_BootIsoMapper();
    		    $bootiso->setCreated(time());
    		    $bootiso->setID($bootisoID);
    		        
    		   	try {  
    		       	$bootisomapper->save($bootiso);
    		    }catch(Zend_Exception $e)
    		    {
    		    	echo "Caught exception: " . get_class($e) . "<br/>";
    				echo "Message: " . $e->getMessage() . "<br/>";	
    		    }
    		    
				$this->_redirect('/dev/bootiso');
    		}
    			
    	}
    	
    	$this->view->editbootisoForm = $editbootisoForm;
    }

    public function deletebootisoAction()
    {
   		$bootisoID = $this->_request->getParam('bootisoID');
     	if (!isset($bootisoID)){
   			$this->_redirect('/dev/bootiso');
    	} else {
    		   $bootiso = new Application_Model_BootIso();
    		   $bootiso->setID($bootisoID);
    		   $bootisomapper = new Application_Model_BootIsoMapper();
    		   $bootisomapper->delete($bootiso);
    	}
    	$this->_redirect('/dev/bootiso');
    }


}