- Timestamp:
- 09/03/08 21:34:40 (3 months ago)
- Location:
- trunk/app
- Files:
-
- 7 modified
-
config/sql/postgresql/chats.sql (modified) (1 diff)
-
controllers/vclassrooms_controller.php (modified) (5 diffs)
-
locale/spa/LC_MESSAGES/default.po (modified) (1 diff)
-
models/chat.php (modified) (2 diffs)
-
models/vclassroom.php (modified) (1 diff)
-
views/vclassrooms/chat.ctp (modified) (1 diff)
-
views/vclassrooms/show.ctp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/config/sql/postgresql/chats.sql
r738 r753 1 1 CREATE TABLE chats ( -- chats on vgroups 2 2 id serial NOT NULL PRIMARY KEY, 3 user_id int NOT NULL REFERENCES users(id), -- teacher id in fact 3 student_id int NOT NULL REFERENCES users(id), -- student id in fact 4 teacher_id int NOT NULL REFERENCES users(id), -- student id in fact 4 5 vclassroom_id int NOT NULL REFERENCES vclassrooms(id) ON DELETE CASCADE, 6 message varchar(100) NOT NULL, 5 7 "created" timestamp(0) with time zone DEFAULT now() NOT NULL 6 8 ); -
trunk/app/controllers/vclassrooms_controller.php
r745 r753 43 43 } 44 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 45 public function chat($user_id, $vclassroom_id) 55 46 { … … 76 67 77 68 $conditions = array('Vclassroom.id'=>$vclassroom_id, 'Vclassroom.user_id'=>$user_id, 'Vclassroom.status'=>1); 78 $fields = array('id', 'name', 'user_id'); 69 $fields = array('id', 'name', 'user_id'); 79 70 $this->set('data', $this->Vclassroom->find($conditions, $fields)); 71 72 $conditions = array('Chat.vclassroom_id'=>$vclassroom_id); 73 $fields = array('Chat.message', 'Chat.created', 'User.username');; 74 $order = 'Chat.id DESC'; 75 $limit = 15; 76 $this->set('msgs', $this->Vclassroom->Chat->findAll($conditions, $fields, $order, $limit)); 77 } 78 public function savemessage() 79 { 80 $this->layout = 'ajax'; 81 82 if ( !empty($this->data['Chat'])): 83 $this->Sanitize = new Sanitize; 84 $this->Sanitize->clean($this->data['Chat']); 85 86 $this->Vclassroom->Chat->save($this->data); 87 88 $conditions = array('Chat.vclassroom_id'=>$this->data['Chat']['vclassroom_id']); 89 $fields = array('Chat.message', 'Chat.created', 'User.username');; 90 $order = 'Chat.id DESC'; 91 $limit = 15; 92 93 $this->set('data', $this->Vclassroom->Chat->findAll($conditions, $fields, $order, $limit)); 94 $this->render('messages', 'ajax'); 95 endif; 80 96 } 81 97 … … 103 119 public function show($user_id, $vclassroom_id) 104 120 { 105 $this->pageTitle = 'Virtual Group';121 $this->pageTitle = __('Virtual Class', true); 106 122 $this->layout = $this->Edublog->layout($user_id); 107 123 $this->Edublog->blog($user_id); … … 116 132 $this->set('data', $this->Vclassroom->classElements($vclassroom_id)); 117 133 } 118 134 119 135 public function participation() 120 136 { … … 227 243 public function admin_linktest() 228 244 { 229 if (!empty($this->data[ "TestsVclassroom"])):245 if (!empty($this->data['TestsVclassroom'])): 230 246 $this->Sanitize = new Sanitize; 231 247 232 $this->Sanitize->clean($this->data["TestsVclassroom"]); 233 234 $this->Vclassroom->TestsVclassroom->create(); 248 $this->Sanitize->clean($this->data['TestsVclassroom']); 235 249 236 250 unset($this->Vclassroom->TestsVclassroom->id); 237 251 238 if ( $this->Vclassroom->TestsVclassroom->save($this->data[ "TestsVclassroom"])):239 $this->msgFlash( 'Test linked', '/admin/vclassrooms/tests/'.$this->data["TestsVclassroom"]["vclassroom_id"]);252 if ( $this->Vclassroom->TestsVclassroom->save($this->data['TestsVclassroom'])): 253 $this->msgFlash(__('Test linked', true), '/admin/vclassrooms/tests/'.$this->data["TestsVclassroom"]["vclassroom_id"]); 240 254 endif; 241 255 endif; -
trunk/app/locale/spa/LC_MESSAGES/default.po
r747 r753 4 4 msgid "Yes" 5 5 msgstr "Si" 6 7 msgid "Virtual Class" 8 msgstr "Clase Virtual" 6 9 7 10 msgid "You already answered this Scavenger Hunt" -
trunk/app/models/chat.php
r738 r753 13 13 'User' => array( 14 14 'className' => 'User', 15 'foreignKey' => ' user_id' # teacher id in facts15 'foreignKey' => 'student_id' 16 16 ), 17 17 'Vclassroom' => array( … … 22 22 23 23 public $validate = array( 24 'user_id' => VALID_NOT_EMPTY, 25 'vclassroom_id' => VALID_NOT_EMPTY 24 'student_id' => VALID_NOT_EMPTY, 25 'vclassroom_id' => VALID_NOT_EMPTY, 26 'message' => VALID_NOT_EMPTY, 26 27 ); 27 28 } -
trunk/app/models/vclassroom.php
r746 r753 46 46 'limit' => null, 47 47 'foreignKey' => 'vclassroom_id' 48 ), 49 'Chat' => 50 array('className' => 'Chat', 51 'conditions' => null, 52 'order' => null, 53 'limit' => null, 54 'foreignKey' => 'vclassroom_id' 48 55 ) 56 49 57 ); 50 58 -
trunk/app/views/vclassrooms/chat.ctp
r739 r753 1 1 <?php 2 // debug($data);2 // debug($data); 3 3 4 4 if ( $belongs === true ): 5 6 echo $ajax->div('updater') . $ajax->divEnd('updater'); 7 echo $html->para(null, $session->read('Auth.User.username')); 8 echo $ajax->div('charging', array('style'=>'display:none')); 9 echo $html->image('static/loading.gif', array('alt'=>'Loading')); 10 echo $ajax->divEnd('charging'); 5 echo $html->div(null, 'Chat Room '. $data['Vclassroom']['name'], array('style'=>'font-size:12pt;')); 6 echo $ajax->div('updater'); 7 $M = array_reverse($msgs); 8 //foreach ($M as $m): 9 //e($html->div(null, 10 // '<span style="color:orange;font-size:6pt;">'.$m['Chat']['created']. ' '.$m['User']['username'].'</span>: '.$m['Chat']['message'], array('style'=>'font-size:8pt;'))); 11 //endforeach; 12 echo $ajax->divEnd('updater'); 13 echo $html->div(null, $session->read('Auth.User.username') .' '. __('writes', true)); 14 echo $ajax->div('charging',array('style'=>'display:none')).$html->image('static/loading.gif', array('alt'=>'Loading')).$ajax->divEnd('charging'); 11 15 12 16 echo $ajax->form(); 13 17 echo $form->hidden('Chat.vclassroom_id', array('value'=>$data['Vclassroom']['id'])); 14 18 echo $form->hidden('Chat.teacher_id', array('value'=>$blog['User']['id'])); 15 echo $form->hidden('Chat.sender_id', array('value'=>$session->read('Auth.User.username'))); 16 echo $form->input('Chat.message', array('size' => 60, 'maxlength'=>60, 'title'=>__('Message', true), 'between'=>': ')); 17 echo $ajax->submit(__('Send', true)), array("url" => "/vclassrooms/savemessage/", 18 "update"=>"updater", 19 echo $form->hidden('Chat.student_id', array('value'=>$session->read('Auth.User.id'))); 20 echo $form->input('Chat.message', array('size' => 60, 'maxlength'=>95, 'title'=>__('Message', true), 'between'=>':<br /> ', 'value'=>'')); 21 echo $ajax->submit(__('Send', true), array("url" => "/vclassrooms/savemessage/", 22 "update" => "updater", 23 "after" => "clean()", 19 24 "loading" => "Element.show('charging');Element.hide('updater')", 20 "complete" => "Element.hide('charging');Effect.Appear('updater')" 25 "complete"=> "Element.hide('charging');Effect.Appear('updater')") 21 26 ); 22 27 endif; 23 28 ?> 29 <script type="text/javascript"> 30 //<![CDATA[ 31 function clean() 32 { 33 var message = document.getElementById('ChatMessage'); 34 message.value = ''; 35 return true; 36 } 37 38 function ping() { 39 // Send ping, to let the server know I'm still here 40 var url = base_url + 'ping.php'; 41 var pars = creds(); 42 43 var ajax = new Ajax.Request(url, {method: 'post', parameters: pars, onComplete: handle_ping}); 44 45 Logger.info("Sent Ping: " + pars); 46 } 47 //]]> 48 </script> -
trunk/app/views/vclassrooms/show.ctp
r739 r753 19 19 $t="javascript:window.open('/vclassrooms/chat/".$blog['User']['id']."/".$data['Vclassroom']['id']."', 'blank', 'toolbar=no, scrollbars=yes,width=700,height=400')"; 20 20 echo $html->link( 21 $html->image('static/ icon_webquest.jpg', array('alt'=>'Chat','title'=>'Chat','style'=>'margin-right:12px')21 $html->image('static/feature_chatroom.jpg', array('alt'=>'Chatroom','title'=>'Chatroom','style'=>'margin-right:12px') 22 22 ), '#', array("onclick"=>$t), null, null, false); 23 23
