Changeset 701 for trunk/app/controllers

Show
Ignore:
Timestamp:
08/08/08 16:03:49 (4 months ago)
Author:
aarkerio
Message:

New validates

Location:
trunk/app/controllers
Files:
4 modified

Legend:

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

    r700 r701  
    109109 } 
    110110 
    111 public function admin_edit($catglossary_id=null) 
    112 { 
    113  $this->layout    = 'admin'; 
     111 public function admin_edit($catglossary_id=null) 
     112 { 
     113  $this->layout    = 'admin'; 
    114114      
    115115  if ( empty( $this->data['Catglossary'] ) ):        
  • trunk/app/controllers/entries_controller.php

    r696 r701  
    123123   $this->layout = 'admin'; 
    124124 
    125    $this->set('subjects', Set::combine($this->Entry->Subject->find('all', array('order' => 'title')), "{n}.Subject.id","{n}.Subject.title")); 
    126        
    127     if ( !empty($this->data['Entry']) )   
    128     { 
     125   $this->set('subjects',Set::combine($this->Entry->Subject->find('all', array('order'=>'title')),"{n}.Subject.id","{n}.Subject.title")); 
     126       
     127   if ( !empty($this->data['Entry']) ): 
     128     
    129129        $this->Sanitize = new Sanitize; 
    130130       
     
    134134 
    135135        $this->data['Entry']['user_id'] = $this->Auth->user('id'); 
    136  
    137     $this->Entry->create(); 
    138136       
    139137        if ($this->Entry->save($this->data)):  
     
    146144           endif; 
    147145        endif; 
    148     } 
     146    endif; 
    149147 } 
    150148  
  • trunk/app/controllers/lessons_controller.php

    r697 r701  
    3131         
    3232    $this->layout      = $this->Edublog->layout($user_id); 
    33          
     33     
    3434    $this->Edublog->blog($user_id); // blogger elements 
    3535         
    36     $this->LessonTitle = __('Lesson', true); 
     36    $this->LessonTitle = $username .' '. __('Lessons', true); 
    3737         
    3838    $conditions        = array('Lesson.id'=>$id, 'Lesson.status'=>1); 
  • trunk/app/controllers/news_controller.php

    r696 r701  
    114114   
    115115  /*** ======ADMIN METHODS === *****/ 
    116    public function admin_listing($page=1)  
     116   public function admin_listing()  
    117117   { 
    118118      $this->pageTitle = 'News manager'; 
     
    147147    $this->set('themes', Set::combine($this->News->Theme->find('all', array('order'=>'theme')),"{n}.Theme.id","{n}.Theme.theme")); 
    148148     
    149     if (!empty($this->data["News"])) 
    150     { 
     149    if (!empty($this->data['News'])): 
    151150         $this->Sanitize = new Sanitize; 
    152151          
    153          $this->Sanitize->paranoid($this->data["News"]["title"]); 
    154           
    155          $this->Sanitize->paranoid($this->data["News"]["reference"]); 
    156  
    157          $this->Sanitize->html($this->data["News"]["body"]);  
    158          
    159          $this->data["News"]["user_id"] = $this->Auth->user('id'); 
     152         $this->Sanitize->paranoid($this->data['News']['title']); 
     153          
     154         $this->Sanitize->paranoid($this->data['News']['reference']); 
     155 
     156         $this->Sanitize->html($this->data['News']['body']);  
     157         
     158         $this->data['News']['user_id'] = $this->Auth->user('id'); 
    160159 
    161160     $this->News->create(); 
    162161          
    163      if ($this->News->save($this->data["News"])) 
    164          { 
    165              if ( $this->data["News"]["end"] == 1 ) 
    166              { 
    167                          $this->msgFlash('Story added!','/admin/news/listing'); 
    168              }  
    169              else  
    170              { 
    171                          $id = $this->News->getLastInsertID(); 
    172                          $this->msgFlash('Story added','/admin/news/edit/'.$id); 
    173              } 
    174          } 
    175     } 
    176  } 
    177   
    178  public function admin_edit($id=null) 
    179   { 
    180      $this->layout    = 'admin'; 
    181       
    182      if ( empty( $this->data["News"] ) ) 
    183      { 
    184          $this->News->id  = $id; 
    185           
    186          $this->data      = $this->News->read(); 
    187  
    188          $this->set('themes', Set::combine($this->News->Theme->find('all', array('order'=>'theme')),"{n}.Theme.id","{n}.Theme.theme")); 
    189      } 
    190      else 
    191      {    
     162     if ($this->News->save($this->data)): 
     163         if ( $this->data['News']['end'] == 1 ): 
     164                   $this->msgFlash(__('Data saved', true),'/admin/news/listing'); 
     165             else: 
     166                   $id = $this->News->getLastInsertID(); 
     167                   $this->msgFlash(__('Data saved', true),'/admin/news/edit/'.$id); 
     168             endif; 
     169     endif; 
     170    endif; 
     171 } 
     172  
     173 public function admin_edit($news_id=null) 
     174 { 
     175  $this->layout    = 'admin'; 
     176 
     177  $this->set('themes', Set::combine($this->News->Theme->find('all', array('order'=>'theme')),"{n}.Theme.id","{n}.Theme.theme")); 
     178  
     179  if ( empty($this->data['News']) ): 
     180         $this->data      = $this->News->read(null, $news_id); 
     181  else:    
    192182         $this->Sanitize = new Sanitize; 
    193           
     183   
    194184         $this->Sanitize->paranoid($this->data['News']['title']); 
    195185          
     
    198188         $this->Sanitize->html($this->data['News']['body']); 
    199189          
    200          if ($this->News->save($this->data['News'])) 
    201          {    
    202              if ( $this->data["News"]["end"] == 1 ) 
    203              { 
    204                     $this->msgFlash('Story saved', '/admin/news/listing'); 
    205              }  
    206              else  
    207              { 
    208                     $this->msgFlash('Story saved', '/admin/news/edit/'.$this->data["News"]["id"]); 
    209              } 
    210         } 
    211      } 
    212   } 
    213    
    214   public function admin_delete($id)  
     190         if ($this->News->save($this->data)): 
     191         if ( $this->data['News']['end'] == 1 ): 
     192                    $this->msgFlash(__('Data saved', true), '/admin/news/listing'); 
     193             else:  
     194                    $this->msgFlash(__('Data saved', true), '/admin/news/edit/'.$this->data['News']['id']); 
     195         endif; 
     196     endif; 
     197     endif; 
     198  } 
     199   
     200  public function admin_delete($news_id)  
    215201  {    
    216       if ( $this->News->del($id) ) 
    217       { 
    218             $this->msgFlash('New deleted', '/admin/news/listing'); 
    219       }  
    220       else  
    221       { 
    222             $this->flash('Database error!', '/admin/news/listing'); 
    223       } 
     202   if ( $this->News->del($news_id) ): 
     203         $this->msgFlash(__('Data removed', true), '/admin/news/listing/'); 
     204   endif;  
    224205  } 
    225206}