Changeset 471 for trunk/app/models

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

Forums and topics improveds

Location:
trunk/app/models
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • 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;