Show
Ignore:
Timestamp:
07/10/08 18:56:32 (5 months ago)
Author:
aarkerio
Message:

Litle changes

Files:
1 modified

Legend:

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

    r614 r639  
    1313  
    1414 public $components    = array('Portal', 'Email', 'Session', 'Edublog'); 
     15 
     16 public $paginate = array('limit' => 20, 'page' => 1); 
    1517  
    1618 public function beforeFilter()  
     
    130132 public function add() 
    131133 {     
    132    $this->layout    = 'ajax'; 
    133          
    134    if (!empty($this->data['Message'])) 
    135    { 
     134  $this->layout    = 'ajax'; 
     135         
     136  if (!empty($this->data['Message'])): 
     137 
    136138     $this->Sanitize = new Sanitize; 
    137139           
     
    146148     $this->Message->create(); 
    147149           
    148      if ($this->Message->save($this->data['Message'])): 
     150     if ($this->Message->save($this->data)): 
    149151            $this->__sendMail($this->data['Message']['user_id']); 
    150152            $this->render('sent','ajax'); 
     
    152154           die('Error on database'); 
    153155     endif; 
    154    } 
     156  endif; 
    155157 } 
    156158 
     
    231233 public function admin_general()  // send a general message to all commnunity 
    232234 { 
    233    if ($this->Auth->user('group_id') != 1) 
    234    { 
     235   if ($this->Auth->user('group_id') != 1): 
    235236        $this->redirect('/admin/messages/listing'); 
    236    } 
     237   endif; 
    237238     
    238239   $this->layout = 'admin'; 
     
    246247     $this->Sanitize->html($this->data['Message']["body"]); 
    247248         
    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); 
    258256         
    259257        $j = 0; //counter 
     
    331329 public function admin_listing() 
    332330 { 
    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')); 
    343343 } 
    344344