Changeset 471 for trunk/app/models
- Timestamp:
- 05/09/08 23:13:21 (7 months ago)
- Location:
- trunk/app/models
- Files:
-
- 3 modified
-
message.php (modified) (1 diff)
-
user.php (modified) (2 diffs)
-
vclassroom.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/models/message.php
r342 r471 18 18 'sender_id' => VALID_NOT_EMPTY 19 19 ); 20 /* return 21 * 22 */ 23 public function getUsers($vclassroom_id) 24 { 25 $users = array(); 20 26 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 } 21 60 } 22 61 ?> -
trunk/app/models/user.php
r467 r471 51 51 ); 52 52 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')); 54 54 55 55 public $validate = array( … … 59 59 'name' => VALID_NOT_EMPTY, 60 60 '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 } 62 81 } 63 82 ?> -
trunk/app/models/vclassroom.php
r470 r471 155 155 $data = $this->UsersVclassroom->findAll(array('UsersVclassroom.vclassroom_id'=>$vclassroom_id), array('user_id')); 156 156 157 // die(debug($users));157 //die(debug($data)); 158 158 foreach ($data as $u): 159 159 160 160 $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 162 167 $conditions = array('Result.vclassroom_id'=>$vclassroom_id, 'Result.user_id'=>$user_id); 163 168 $fields = array('Result.percentage', 'Test.title'); //null;
