| 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')); |
| | 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)); |