Changeset 639 for trunk/app/controllers/messages_controller.php
- Timestamp:
- 07/10/08 18:56:32 (5 months ago)
- Files:
-
- 1 modified
-
trunk/app/controllers/messages_controller.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/controllers/messages_controller.php
r614 r639 13 13 14 14 public $components = array('Portal', 'Email', 'Session', 'Edublog'); 15 16 public $paginate = array('limit' => 20, 'page' => 1); 15 17 16 18 public function beforeFilter() … … 130 132 public function add() 131 133 { 132 $this->layout = 'ajax';133 134 if (!empty($this->data['Message']))135 { 134 $this->layout = 'ajax'; 135 136 if (!empty($this->data['Message'])): 137 136 138 $this->Sanitize = new Sanitize; 137 139 … … 146 148 $this->Message->create(); 147 149 148 if ($this->Message->save($this->data ['Message'])):150 if ($this->Message->save($this->data)): 149 151 $this->__sendMail($this->data['Message']['user_id']); 150 152 $this->render('sent','ajax'); … … 152 154 die('Error on database'); 153 155 endif; 154 }156 endif; 155 157 } 156 158 … … 231 233 public function admin_general() // send a general message to all commnunity 232 234 { 233 if ($this->Auth->user('group_id') != 1) 234 { 235 if ($this->Auth->user('group_id') != 1): 235 236 $this->redirect('/admin/messages/listing'); 236 }237 endif; 237 238 238 239 $this->layout = 'admin'; … … 246 247 $this->Sanitize->html($this->data['Message']["body"]); 247 248 248 $this->Message->User->unbindModel( 249 array( 250 "hasMany"=>array( 251 "Entry", "News", "Category", "Lesson", "Podcast", "Bookmark"))); 252 253 $conditions = array("active"=>1); 254 255 $fields = array("id"); 256 257 $data = $this->User->findAll($conditions, $fields); 249 $this->Message->User->unbindAll(); 250 251 $conditions = array("active"=>1); 252 253 $fields = array("id"); 254 255 $data = $this->User->findAll($conditions, $fields); 258 256 259 257 $j = 0; //counter … … 331 329 public function admin_listing() 332 330 { 333 $this->layout = 'admin'; 334 335 $this->pageTitle = 'Messages'; 336 337 $conditions = array("Message.user_id" => $this->Auth->user('id')); 338 $fields = array("Message.id", "Message.title", "Message.body", "Message.created", "Message.sender", "Message.status", "User.username"); 339 $order = "Message.id DESC"; 340 $limit = 20; 341 342 $this->set('data', $this->Message->findAll($conditions, $fields, $order, $limit)); 331 $this->layout = 'admin'; 332 333 $this->pageTitle = __('Messages', true); 334 335 $this->paginate['conditions'] = array('Message.user_id' => $this->Auth->user('id')); 336 $this->paginate['fields'] = array("Message.id", "Message.title", "Message.body", "Message.created", "Message.sender", "Message.status", "User.username"); 337 $this->paginate['order'] = 'Message.id DESC'; 338 $this->paginate['limit'] = 20; 339 340 $data = $this->paginate('Entry', $conditions); 341 342 $this->set(compact('data')); 343 343 } 344 344
