public function find_by_id() { $c_id = Request::get_c_id(); $id = Request::get_id(); $item = Glossary::repository()->find_one_by_id($c_id, $id); $data = (object) array(); if ($item) { $data->name = $item->name; $data->description = $item->description; } $this->response($success, '', $data); }
public function import_csv() { if (!$this->is_allowed_to_edit()) { $this->forbidden(); return; } $action = $this->url(self::ACTION_IMPORT_CSV); $form = UploadFileForm::create($action); $form->init(); if ($form->validate()) { $delete_all = $form->get_delete_all(); if ($delete_all) { $course = Request::get_course_key(); $repo = Glossary::repository(); $repo->remove_by_course($course); } $file = $form->get_file(); $path = $file->tmp_name; $reader = new CsvReader($path); $items = $reader->get_items(); $course = Request::get_course_key(); $import = new CourseImport($course); $import->add($items); $home = $this->url(self::ACTION_DEFAULT); Redirect::go($home); } $data = (object) array(); $data->form = $form; $this->render('upload', $data); }