Show
Ignore:
Timestamp:
03/25/08 01:03:27 (8 months ago)
Author:
aarkerio
Message:

eCourses fixes

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/controllers/ecourses_controller.php

    r340 r342  
    3636       $this->layout = 'admin'; 
    3737        
    38              
    3938       $conditions   =  array("user_id"=>$this->Auth->user('id')); 
    4039       $fields       =  array('id', 'title', 'access',  'status', 'description'); 
    4140       $order        =  "Ecourse.title DESC"; 
    42              
     41        
    4342       $this->set('data', $this->Ecourse->findAll($conditions, $fields, $order)); 
    4443  } 
     
    6766        $this->set('data', $this->Ecourse->find($conditions, $fields)); 
    6867  } 
    69   
    70   public function admin_add()  
    71   {    
    72     $this->layout    = 'admin';  
    73      
    74     if (!empty($this->data['Ecourse'])) 
    75     { 
    76         $this->Sanitize = new Sanitize; 
    77          
    78         $this->Sanitize->clean($this->data["Ecourse"]); 
    79    
    80         $this->data['Ecourse']['user_id'] = $this->Auth->user('id'); 
    81  
    82         $this->Ecourse->create(); 
    83     
    84         if ($this->Ecourse->save($this->data['Ecourse'])) 
    85         { 
    86                 $this->msgFlash('Course saved', '/admin/ecourses/listing'); 
    87         } 
    88     } 
    89     else 
    90     { 
    91   
    92      $this->set('subjects', Set::combine($this->Ecourse->Subject->find('all', array('order' => 'title')), "{n}.Subject.id","{n}.Subject.title")); 
    93  
    94      $this->set('langs', Set::combine($this->Ecourse->Lang->find('all', array('order' => 'lang')), "{n}.Lang.id","{n}.Lang.lang")); 
    95  
    96     } 
    97   } 
    9868   
    9969  public function admin_change($id, $status) 
     
    11282        } 
    11383    } 
     84  public function admin_add()  
     85  {    
     86    $this->layout    = 'admin';  
     87     
     88    $this->set('subjects', Set::combine($this->Ecourse->Subject->find('all', array('order' => 'title')), "{n}.Subject.id","{n}.Subject.title")); 
     89     
     90    $this->set('langs', Set::combine($this->Ecourse->Lang->find('all', array('order' => 'lang')), "{n}.Lang.id","{n}.Lang.lang")); 
     91     
     92    if (!empty($this->data['Ecourse'])) 
     93    { 
     94        $this->Sanitize = new Sanitize; 
     95         
     96        $this->Sanitize->clean($this->data["Ecourse"]); 
     97         
     98        $this->data['Ecourse']['user_id'] = $this->Auth->user('id'); 
     99         
     100        $this->Ecourse->create(); 
     101         
     102        if ($this->Ecourse->save($this->data['Ecourse'])) 
     103        { 
     104                $this->msgFlash('Course saved', '/admin/ecourses/listing'); 
     105        } 
     106    } 
     107  } 
    114108   
    115109  public function admin_edit($id = null) 
    116110  { 
    117       
    118     if (empty($this->data['Ecourse'])) 
     111    $this->set('subjects', Set::combine($this->Ecourse->Subject->find('all', array('order' => 'title')), "{n}.Subject.id","{n}.Subject.title")); 
     112     
     113    $this->set('langs', Set::combine($this->Ecourse->Lang->find('all', array('order' => 'lang')), "{n}.Lang.id","{n}.Lang.lang")); 
     114     
     115    if ( empty($this->data['Ecourse']) ) 
    119116    { 
    120117        $this->layout = 'admin'; 
     
    124121        $this->Subject     = new Subject; 
    125122         
    126         $this->set('subjects', $this->Ecourse->Subject->generateList(null, 'title'));        
    127      
    128         $this->set('langs', $this->Ecourse->Lang->generateList(null, 'lang', null, '{n}.Lang.id', '{n}.Lang.lang')); 
    129          
    130123        $this->data = $this->Ecourse->read(); 
     124         
    131125    } 
    132126    else 
     
    135129         
    136130        $this->Sanitize->html($this->data["Ecourse"]['description']); 
    137  
     131         
    138132        if ($this->Ecourse->save($this->data['Ecourse'])) 
    139133        {