Example #1
0
 public function getMaterialsByTeacher($pagination, $teacher_id = NULL, $node_id = NULL, $filter = NULL)
 {
     $cat = new Model_Category();
     $qry = DB::select('materials.*', array('users.name', 'name'))->join('users', 'left')->on('users.id', '=', 'materials.teacher_id')->from('materials');
     if ($teacher_id) {
         $qry->where('teacher_id', '=', $teacher_id);
     }
     if ($node_id) {
         $qry->where('node_id', '=', $node_id);
     }
     if (isset($filter['FIO']) && $filter['FIO'] != '') {
         $qry->where('name', 'like', '%' . $filter['FIO'] . '%');
     }
     if (!$teacher_id) {
         $qry->order_by('users.name', 'asc');
     }
     if ($pagination) {
         $data = $qry->order_by('subjectName', 'asc')->order_by('ctime', 'asc')->limit($pagination->items_per_page)->offset($pagination->offset)->execute()->as_array();
     } else {
         $data = $qry->order_by('subjectName', 'asc')->order_by('ctime', 'asc')->execute()->as_array();
     }
     foreach ($data as $key => $item) {
         $data[$key]['path'] = $cat->getPath($item['node_id']);
         $data[$key]['isLeaf'] = $cat->isLeaf($item['node_id']);
         $data[$key]['link'] = $this->getLink($item);
     }
     return $data;
 }
Example #2
0
 public function action_shownode()
 {
     //Приведение к целому чеслу, если передайотся float то abs() убрать!
     $node_id = abs((int) $this->request->param('id', NULL));
     $teacher_id = abs((int) $this->request->param('id2', NULL));
     $data = array();
     //Настройки навигации
     $count = ORM::factory('material')->count_all();
     $pagination = Pagination::factory(array('total_items' => $count))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action()));
     //Выбор
     $material = ORM::factory('material')->limit($pagination->items_per_page)->offset($pagination->offset)->find_all();
     $cat = new Model_Category();
     $data['path'] = $cat->getPath($node_id);
     $data['materials'] = $material->getMaterialsByTeacher('', $teacher_id, $node_id);
     $data['teachername'] = ORM::factory('user', $teacher_id)->name;
     //Вывод в шаблон
     $content = View::factory('materials/shownode', array('data' => $data, 'pagination' => $pagination));
     $this->tpl->content = array($content);
 }