Changeset 471
- Timestamp:
- 05/09/08 23:13:21 (8 months ago)
- Location:
- trunk/app
- Files:
-
- 6 modified
-
controllers/messages_controller.php (modified) (3 diffs)
-
models/message.php (modified) (1 diff)
-
models/user.php (modified) (2 diffs)
-
models/vclassroom.php (modified) (1 diff)
-
views/vclassrooms/admin_export.ctp (modified) (1 diff)
-
views/vclassrooms/admin_members.ctp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/controllers/messages_controller.php
r422 r471 166 166 $this->data["Message"]["user_id"] = $val["User"]["id"]; 167 167 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; 176 173 } 177 174 $this->msgFlash($j . ' messages sent', '/admin/messages/listing'); 178 175 } 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']); 179 217 } 180 218 … … 202 240 $this->set('data', $this->Message->findAll($conditions, $fields, $order, $limit)); 203 241 } 204 242 243 /* reply to all member */ 205 244 public function admin_reply() 206 245 { … … 277 316 if ($this->Message->save($this->data['Message'])) 278 317 { 279 $this->flash(' Your virtual classroom has been updated.','/admin/messages/listing');318 $this->flash('Classroom has been updated.','/admin/messages/listing'); 280 319 } 281 320 } -
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; -
trunk/app/views/vclassrooms/admin_export.ctp
r470 r471 5 5 6 6 $fpdf->newPage(); 7 8 $fpdf->setData('Student '.$u['User']['name'] . ' '.$u['User']['email']); 7 9 8 10 foreach ($u['tests'] as $te): -
trunk/app/views/vclassrooms/admin_members.ctp
r470 r471 1 1 <?php 2 2 //die( debug($data)); 3 echo '<div style="padding:4px;margin:10px auto 10px;width: 700px;text-align:center;">';3 echo '<div style="padding:4px;margin:10px auto 10px;width:900px;text-align:center;">'; 4 4 5 5 //popup window for tests … … 49 49 echo '<div id="loading3" style="display: none;">'.$html->image("static/loading.gif", array("alt"=>"Loading")).'</div>'; 50 50 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'); 54 54 55 55 echo $html->div('title_section', 'Students belonging to ' . $data['Vclassroom']['name']);
