示例#1
0
 public function render()
 {
     $user = ORM::factory('user', $this->actor_id);
     $batch = ORM::factory('batch', $this->respective_id);
     if ($this->check_deleted($batch)) {
         return View::factory('feed/unavaliable')->render();
     }
     $count_user = Model_Batch::get_users_count($this->respective_id, 'student');
     $span = Date::fuzzy_span($this->time);
     $feed_id = $this->id;
     $comment = ORM::factory('feedcomment');
     $comment->where('feed_id', '=', $feed_id)->order_by('date', 'DESC');
     $comments = $comment->find_all();
     $curr_user = Auth::instance()->get_user();
     $role = $curr_user->role()->name;
     $url = Url::site('profile/view/id/');
     $view = View::factory('feed/' . $this->type . '_' . $this->action)->bind('user', $user)->bind('count_user', $count_user)->bind('batch', $batch)->bind('span', $span)->bind('role', $role)->bind('feed_id', $feed_id)->bind('comments', $comments)->bind('url', $url);
     return $view->render();
 }
示例#2
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));
 }