Changeset 739 for trunk/app/controllers

Show
Ignore:
Timestamp:
08/26/08 00:41:38 (3 months ago)
Author:
aarkerio
Message:

CHate

Files:
1 modified

Legend:

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

    r730 r739  
    2121 { 
    2222   parent::beforeFilter(); 
    23    $this->Auth->allow(array('show', 'jointoclass', 'aboutme', 'display', 'participation', 'upload', 'description')); 
     23   $this->Auth->allow(array('show', 'jointoclass', 'aboutme', 'display', 'participation', 'upload', 'description', 'chat', 'savemessage')); 
    2424 } 
    2525 
     
    4141           $this->Edublog->setSession($user_id); 
    4242      endif; 
     43 } 
     44   
     45 public function savemessage()  
     46 { 
     47  if ($this->data['Chat']): 
     48    $this->Sanitize = new Sanitize; 
     49    $this->Sanitize->clear($this->data['Chat']); 
     50    $this->save($this->data); 
     51    $this->render('oldmessages', 'ajax'); 
     52  endif;  
     53 } 
     54 public function chat($user_id, $vclassroom_id)  
     55 { 
     56   $this->pageTitle = 'Virtual Group Chat'; 
     57   $this->layout    = 'popup'; 
     58   $this->Edublog->blog($user_id); 
     59    
     60   // student belongs to this class? 
     61   if ( $this->Auth->user()): 
     62             $this->set('belongs', $this->Vclassroom->belongs($this->Auth->user('id'), $vclassroom_id)); 
     63   else: 
     64             $this->set('belongs', false); 
     65   endif; 
     66   $this->Vclassroom->unbindAll(); 
     67 
     68   $this->Vclassroom->bindModel(array('hasMany'=>array( 
     69                              'Chat' => 
     70               array('className'     => 'Chat', 
     71                 'conditions'    => null, 
     72                 'order'         => null, 
     73                 'limit'         => 15, 
     74                 'foreignKey'    => 'vclassroom_id' 
     75                 )))); 
     76 
     77   $conditions = array('Vclassroom.id'=>$vclassroom_id, 'Vclassroom.user_id'=>$user_id, 'Vclassroom.status'=>1); 
     78   $fields     = array('id', 'name', 'user_id');    
     79   $this->set('data', $this->Vclassroom->find($conditions, $fields)); 
    4380 } 
    4481 
     
    329366    endif; 
    330367 } 
     368 
     369 public function admin_chat($vclassroom_id, $chat) 
     370 { 
     371    $this->data['Vclassroom']['chat']   = ($chat == 0 ) ? 1 : 0; 
     372    
     373    $this->data['Vclassroom']['id']     = (int) $vclassroom_id; 
     374      
     375    if ($this->Vclassroom->save($this->data, array('validate'=>false))): 
     376          $this->msgFlash(__('Status modified', true), '/admin/vclassrooms/members/'.$vclassroom_id); 
     377    endif; 
     378 } 
    331379  
    332380 public function admin_delete($vclassroom_id, $ecourse_id)