Changeset 753 for trunk/app

Show
Ignore:
Timestamp:
09/03/08 21:34:40 (3 months ago)
Author:
aarkerio
Message:

New layout

Location:
trunk/app
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/config/sql/postgresql/chats.sql

    r738 r753  
    11CREATE TABLE chats (  -- chats on vgroups 
    22   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 
    45   vclassroom_id int NOT NULL REFERENCES vclassrooms(id) ON DELETE CASCADE, 
     6   message varchar(100) NOT NULL, 
    57   "created" timestamp(0) with time zone DEFAULT now() NOT NULL 
    68); 
  • trunk/app/controllers/vclassrooms_controller.php

    r745 r753  
    4343 } 
    4444   
    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  } 
    5445 public function chat($user_id, $vclassroom_id)  
    5546 { 
     
    7667 
    7768   $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');  
    7970   $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; 
    8096 } 
    8197 
     
    103119 public function show($user_id, $vclassroom_id)  
    104120 { 
    105    $this->pageTitle = 'Virtual Group'; 
     121   $this->pageTitle = __('Virtual Class', true); 
    106122   $this->layout    = $this->Edublog->layout($user_id); 
    107123   $this->Edublog->blog($user_id); 
     
    116132   $this->set('data', $this->Vclassroom->classElements($vclassroom_id)); 
    117133 } 
    118  
     134  
    119135 public function participation() 
    120136 { 
     
    227243 public function admin_linktest() 
    228244 { 
    229    if (!empty($this->data["TestsVclassroom"])): 
     245   if (!empty($this->data['TestsVclassroom'])): 
    230246        $this->Sanitize = new Sanitize; 
    231247         
    232         $this->Sanitize->clean($this->data["TestsVclassroom"]);  
    233          
    234         $this->Vclassroom->TestsVclassroom->create(); 
     248        $this->Sanitize->clean($this->data['TestsVclassroom']);  
    235249         
    236250        unset($this->Vclassroom->TestsVclassroom->id); 
    237251 
    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"]); 
    240254    endif; 
    241255    endif; 
  • trunk/app/locale/spa/LC_MESSAGES/default.po

    r747 r753  
    44msgid  "Yes" 
    55msgstr "Si" 
     6 
     7msgid  "Virtual Class" 
     8msgstr "Clase Virtual" 
    69 
    710msgid  "You already answered this Scavenger Hunt" 
  • trunk/app/models/chat.php

    r738 r753  
    1313                             'User' => array( 
    1414                                            'className'    => 'User', 
    15                                             'foreignKey'   => 'user_id'  # teacher id in facts 
     15                                            'foreignKey'   => 'student_id' 
    1616                                            ), 
    1717                             'Vclassroom' => array( 
     
    2222   
    2323  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, 
    2627                           ); 
    2728} 
  • trunk/app/models/vclassroom.php

    r746 r753  
    4646                 'limit'         => null, 
    4747                 'foreignKey'    => 'vclassroom_id' 
     48                 ), 
     49                      'Chat' => 
     50               array('className'     => 'Chat', 
     51                 'conditions'    => null, 
     52                 'order'         => null, 
     53                 'limit'         => null, 
     54                 'foreignKey'    => 'vclassroom_id' 
    4855                 ) 
     56 
    4957               ); 
    5058               
  • trunk/app/views/vclassrooms/chat.ctp

    r739 r753  
    11<?php 
    2 //debug($data); 
     2// debug($data); 
    33 
    44if ( $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'); 
    1115 
    1216 echo $ajax->form(); 
    1317 echo $form->hidden('Chat.vclassroom_id', array('value'=>$data['Vclassroom']['id'])); 
    1418 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()", 
    1924                                         "loading" => "Element.show('charging');Element.hide('updater')", 
    20                                          "complete" => "Element.hide('charging');Effect.Appear('updater')" 
     25                     "complete"=> "Element.hide('charging');Effect.Appear('updater')") 
    2126        ); 
    2227endif; 
    2328?> 
     29<script type="text/javascript"> 
     30//<![CDATA[ 
     31function clean() 
     32{ 
     33  var message = document.getElementById('ChatMessage'); 
     34  message.value = ''; 
     35  return true; 
     36} 
     37 
     38function 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  
    1919   $t="javascript:window.open('/vclassrooms/chat/".$blog['User']['id']."/".$data['Vclassroom']['id']."', 'blank', 'toolbar=no, scrollbars=yes,width=700,height=400')";  
    2020      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') 
    2222     ), '#', array("onclick"=>$t), null, null, false); 
    2323