Changeset 528

Show
Ignore:
Timestamp:
05/19/08 23:51:04 (7 months ago)
Author:
aarkerio
Message:

Contrller fixed

Files:
1 modified

Legend:

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

    r527 r528  
    1111 
    1212uses('sanitize'); 
     13uses('l10n'); 
    1314 
    1415class EntriesController extends AppController { 
     
    2627 public function isAuthorized()  
    2728 {       
    28     if (isset( $this->params[Configure::read('Routing.admin')] ))  
    29     { 
    30         if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2 )  // admin and teachers 
    31         { 
    32         return true; 
    33         }  
    34     }  
     29    if (isset( $this->params[Configure::read('Routing.admin')] )): 
     30        if ($this->Auth->user('group_id') == 1 || $this->Auth->user('group_id') == 2 ):  // admin and teachers 
     31         return true; 
     32        endif; 
     33    endif; 
    3534    return false;  // go away !! 
    3635 } 
     
    7271   $this->set('subjects', Set::combine($this->Entry->Subject->find('all', array('order' => 'title')), "{n}.Subject.id","{n}.Subject.title")); 
    7372       
    74     if ( !empty($this->data["Entry"]) )   
     73    if ( !empty($this->data['Entry']) )   
    7574    { 
    7675        $this->Sanitize = new Sanitize; 
     
    8483    $this->Entry->create(); 
    8584       
    86         if ($this->Entry->save($this->data["Entry"])) 
    87         {  
    88           if ( $this->data["Entry"]["end"] == 1 )  // edition ends 
    89           { 
     85        if ($this->Entry->save($this->data["Entry"])):  
     86           if ( $this->data["Entry"]["end"] == 1 ):     // edition ends 
    9087                     $this->msgFlash('Story has been added', '/admin/entries/listing'); 
    91           } 
    92           else           //edition continue 
    93           {          $id = $this->Entry->getLastInsertID(); 
     88    
     89           else:           //edition continue 
     90                     $id = $this->Entry->getLastInsertID(); 
    9491                     $this->msgFlash('Story has been added', '/admin/entries/edit/'.$id); 
    95           } 
    96     }  
     92           endif; 
     93        endif; 
    9794    } 
    9895 } 
     
    10299     $this->layout = 'admin'; 
    103100 
    104      if ( !$this->Auth->user()) 
    105      { 
    106             $this->redirect('/users/login'); // Get Out!!! 
    107      } 
    108          
    109101     $this->pageTitle = 'Welcome! '. $this->Auth->user('username'); 
    110102 } 
     
    141133         $this->Sanitize->html($this->data['Entry']['body']); 
    142134 
    143          if ($this->Entry->save($this->data['Entry'])) 
    144          { 
    145              if ( $this->data["Entry"]["end"] == 1 ) 
    146              { 
     135         if ($this->Entry->save($this->data['Entry'])): 
     136         if ( $this->data["Entry"]["end"] == 1 ): 
    147137                     $this->redirect('/admin/entries/listing'); 
    148              } 
    149              else 
    150              { 
     138             else: 
    151139                     $this->msgFlash('Entry has been updated','/admin/entries/edit/'.$this->data['Entry']['id']); 
    152              } 
    153          } 
     140         endif; 
     141     endif; 
    154142     } 
    155143  } 
     
    161149    $this->data['Entry']['id']     = $entry_id; 
    162150      
    163     if ($this->Entry->save($this->data['Entry'])) 
    164       { 
     151    if ($this->Entry->save($this->data['Entry'])): 
    165152    $this->msgFlash('Entry status changed', '/admin/entries/listing'); 
    166       } 
     153    endif; 
    167154 } 
    168155 
    169156 public function admin_delete($id) 
    170157 { 
    171     $this->Entry->del($id); 
    172      
    173     $this->msgFlash('The entry has been deleted.', '/admin/entries/listing'); 
     158   if ( $this->Entry->del($id)): 
     159             $this->msgFlash('The entry has been deleted.', '/admin/entries/listing'); 
     160   endif; 
    174161  } 
    175162}