Beispiel #1
0
 public function action_get_users()
 {
     $course_id = $this->request->post('course_id');
     $batch_id = $this->request->post('batch_id');
     $course_users = Model_Course::get_students($course_id)->as_array(NULL, 'id');
     $batch_users = Model_Batch::get_students($batch_id)->as_array(NULL, 'id');
     $user_ids = array_unique(array_merge($course_users, $batch_users));
     if ($user_ids) {
         $data = ORM::factory('user')->where('id', 'IN', $user_ids)->find_all();
         $count = ORM::factory('user')->where('id', 'IN', $user_ids)->count_all();
     } else {
         $data = ORM::factory('user')->where('id', '=', 0)->find_all();
         $count = ORM::factory('user')->where('id', '=', 0)->count_all();
     }
     $cacheimage = CacheImage::instance();
     $view = View::factory('course/assign')->bind('data', $data)->bind('count', $count)->bind('cacheimage', $cacheimage)->bind('user_ids', $course_users);
     $response = $this->response->body($view)->body();
     echo json_encode(array('response' => $response));
 }