Changeset 528 for trunk/app/controllers/entries_controller.php
- Timestamp:
- 05/19/08 23:51:04 (8 months ago)
- Files:
-
- 1 modified
-
trunk/app/controllers/entries_controller.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/controllers/entries_controller.php
r527 r528 11 11 12 12 uses('sanitize'); 13 uses('l10n'); 13 14 14 15 class EntriesController extends AppController { … … 26 27 public function isAuthorized() 27 28 { 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; 35 34 return false; // go away !! 36 35 } … … 72 71 $this->set('subjects', Set::combine($this->Entry->Subject->find('all', array('order' => 'title')), "{n}.Subject.id","{n}.Subject.title")); 73 72 74 if ( !empty($this->data[ "Entry"]) )73 if ( !empty($this->data['Entry']) ) 75 74 { 76 75 $this->Sanitize = new Sanitize; … … 84 83 $this->Entry->create(); 85 84 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 90 87 $this->msgFlash('Story has been added', '/admin/entries/listing'); 91 }92 else//edition continue93 {$id = $this->Entry->getLastInsertID();88 89 else: //edition continue 90 $id = $this->Entry->getLastInsertID(); 94 91 $this->msgFlash('Story has been added', '/admin/entries/edit/'.$id); 95 }96 } 92 endif; 93 endif; 97 94 } 98 95 } … … 102 99 $this->layout = 'admin'; 103 100 104 if ( !$this->Auth->user())105 {106 $this->redirect('/users/login'); // Get Out!!!107 }108 109 101 $this->pageTitle = 'Welcome! '. $this->Auth->user('username'); 110 102 } … … 141 133 $this->Sanitize->html($this->data['Entry']['body']); 142 134 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 ): 147 137 $this->redirect('/admin/entries/listing'); 148 } 149 else 150 { 138 else: 151 139 $this->msgFlash('Entry has been updated','/admin/entries/edit/'.$this->data['Entry']['id']); 152 } 153 } 140 endif; 141 endif; 154 142 } 155 143 } … … 161 149 $this->data['Entry']['id'] = $entry_id; 162 150 163 if ($this->Entry->save($this->data['Entry'])) 164 { 151 if ($this->Entry->save($this->data['Entry'])): 165 152 $this->msgFlash('Entry status changed', '/admin/entries/listing'); 166 }153 endif; 167 154 } 168 155 169 156 public function admin_delete($id) 170 157 { 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; 174 161 } 175 162 }
