Changeset 471

Show
Ignore:
Timestamp:
05/09/08 23:13:21 (8 months ago)
Author:
aarkerio
Message:

Forums and topics improveds

Location:
trunk/app
Files:
6 modified

Legend:

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

    r422 r471  
    166166          $this->data["Message"]["user_id"] = $val["User"]["id"]; 
    167167           
    168           if ($this->Message->save($this->data["Message"])) 
    169       { 
    170              $j++; 
    171       } 
    172           else 
    173           { 
    174              exit('error on save'); 
    175           } 
     168          if ($this->Message->save($this->data["Message"])): 
     169                $j++; 
     170          else: 
     171               exit('error on save'); 
     172      endif; 
    176173        } 
    177174        $this->msgFlash($j . ' messages sent', '/admin/messages/listing'); 
    178175     } 
     176 } 
     177 
     178 /*  Send a message to all student on a group 
     179  * 
     180  * 
     181 */  
     182 
     183 public function admin_allclass($vclassroom_id) 
     184 { 
     185    $this->layout    = 'ajax';  
     186 
     187    $this->set('vclassroom_id', $vclassroom_id); 
     188 
     189    $this->render('admin_allclass', 'ajax'); 
     190 } 
     191 
     192 public function admin_send2class() 
     193 { 
     194  $this->layout  = 'ajax'; 
     195  //die(debug($this->data['Message']['vclassroom_id'])); 
     196  $messages      = (int) 0; 
     197 
     198  $this->data['Message']['sender'] = $this->Auth->user('id'); 
     199     
     200  $users = $this->Message->getUsers($this->data['Message']['vclassroom_id']); 
     201  //die(debug($users)); 
     202  foreach ($users as $u): 
     203 
     204    $this->data['Message']['user_id'] = $u['id']; 
     205 
     206    $this->Message->create(); 
     207  
     208    if ($this->Message->save($this->data['Message'])): 
     209        $this->sendMail($this->data['Message']['user_id'], $this->data['Message']['username'], $this->data['Message']['title']); 
     210        $messages++; 
     211    endif; 
     212  endforeach; 
     213     
     214  $this->set('messages', $messages); 
     215 
     216  $this->msgFlash($messages . ' sent to group','/admin/vclassroom/members/'.$this->data['Message']['vclassroom_id']);   
    179217 } 
    180218  
     
    202240      $this->set('data', $this->Message->findAll($conditions, $fields, $order, $limit)); 
    203241 } 
    204   
     242 
     243 /*  reply to all member  */  
    205244 public function admin_reply() 
    206245 { 
     
    277316        if ($this->Message->save($this->data['Message'])) 
    278317        { 
    279             $this->flash('Your virtual classroom has been updated.','/admin/messages/listing'); 
     318            $this->flash('Classroom has been updated.','/admin/messages/listing'); 
    280319        } 
    281320    } 
  • trunk/app/models/message.php

    r342 r471  
    1818      'sender_id' => VALID_NOT_EMPTY 
    1919      ); 
     20  /* return  
     21   * 
     22   */ 
     23 public function getUsers($vclassroom_id) 
     24 { 
     25    $users = array(); 
    2026 
     27    $conditions    = array('UsersVclassroom.vclassroom_id'=>$vclassroom_id); 
     28 
     29    $fields        = array('UsersVclassroom.user_id'); 
     30 
     31    $this->User->bindModel( 
     32                                    array('hasAndBelongsToMany'=> 
     33                         array('Vclassroom' => 
     34                              array('className'    => 'Vclassroom', 
     35                                    'joinTable'    => 'users_vclassrooms', 
     36                                     'foreignKey'   => 'user_id', 
     37                                     'associationForeignKey'=> 'vclassroom_id' 
     38                                 ) 
     39                          ) 
     40                      ) 
     41    ); 
     42 
     43    $Usersids   = $this->User->UsersVclassroom->findAll($conditions, $fields); 
     44    //die(debug($Usersids)); 
     45    foreach($Usersids as $u) 
     46    { 
     47      $conditions = array('User.id'=>$u['UsersVclassroom']['user_id']); 
     48       
     49      $fields = array('User.email', 'User.id');      
     50 
     51      $this->User->removeBinds(); 
     52 
     53      $tmp = $this->User->find($conditions, $fields); 
     54      //die(debug($tmp)); 
     55      array_push($users, $tmp['User']);         
     56    } 
     57     
     58    return $users;  
     59 } 
    2160} 
    2261?> 
  • trunk/app/models/user.php

    r467 r471  
    5151  ); 
    5252   
    53  public $notNow = array('hasMany'=>array('Entry', 'Category', 'Acquaintance', 'Faq', 'Glossary', 'Vclassroom', 'Lesson', 'Confirm')); 
     53 public $notNow = array('hasMany'=>array('Entry', 'Category', 'Acquaintance', 'Faq', 'Glossary', 'Vclassroom', 'Lesson', 'Confirm', 'Vclassroom')); 
    5454 
    5555 public $validate = array( 
     
    5959      'name' => VALID_NOT_EMPTY, 
    6060      'email'    => VALID_EMAIL 
    61    );  
     61   ); 
     62  
     63 /* 
     64  * excepts : model you need 
     65  * 
     66  */ 
     67  public function removeBinds($excepts = array()) 
     68  { 
     69    foreach ($excepts as $e) 
     70    { 
     71        if ( in_array($e, $this->notNow) ) 
     72    { 
     73           unset($this->notNow[$e]); // not unbind this model 
     74        } 
     75    } 
     76 
     77    $this->unbindModel($this->notNow); 
     78 
     79    return true; 
     80  } 
    6281} 
    6382?> 
  • trunk/app/models/vclassroom.php

    r470 r471  
    155155  $data  = $this->UsersVclassroom->findAll(array('UsersVclassroom.vclassroom_id'=>$vclassroom_id), array('user_id')); 
    156156 
    157   // die(debug($users));    
     157  //die(debug($data));    
    158158  foreach ($data as $u): 
    159159      
    160160     $user_id = $u['UsersVclassroom']['user_id']; 
    161       
     161 
     162     $conditions       = array('User.id'=>$user_id); 
     163     $fields           = array('User.name', 'User.email'); //null; 
     164     $records[$user_id] = $this->User->find($conditions, $fields); 
     165   
     166     // Test result      
    162167     $conditions        = array('Result.vclassroom_id'=>$vclassroom_id, 'Result.user_id'=>$user_id); 
    163168     $fields            = array('Result.percentage', 'Test.title');  //null; 
  • trunk/app/views/vclassrooms/admin_export.ctp

    r470 r471  
    55 
    66    $fpdf->newPage(); 
     7 
     8    $fpdf->setData('Student '.$u['User']['name'] . ' '.$u['User']['email']); 
    79 
    810    foreach ($u['tests'] as $te):   
  • trunk/app/views/vclassrooms/admin_members.ctp

    r470 r471  
    11<?php 
    22//die( debug($data)); 
    3 echo '<div style="padding:4px;margin:10px auto 10px;width:700px;text-align:center;">'; 
     3echo '<div style="padding:4px;margin:10px auto 10px;width:900px;text-align:center;">'; 
    44 
    55//popup window for tests 
     
    4949 echo '<div id="loading3" style="display: none;">'.$html->image("static/loading.gif", array("alt"=>"Loading")).'</div>'; 
    5050                         
    51  echo $ajax->div('qn', array("style"=>"padding:3px")) . $ajax->divEnd('qn'); 
    52                        
    53 echo '</div>'; 
     51 echo '</div>'; 
     52 
     53 echo $ajax->div('qn', array("style"=>"padding:0")) . $ajax->divEnd('qn'); 
    5454 
    5555echo $html->div('title_section', 'Students belonging to ' . $data['Vclassroom']['name']);