/** * * * @param string $where Where filter to apply * @return array */ public function find($where, $orderby = '', $limit = null) { $table_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); $table = $this->get_table(); $tool = $this->get_tool(); $sql = "SELECT n.*, \n prop.id AS property_id, \n prop.tool, \n prop.insert_user_id,\n prop.insert_date,\n prop.lastedit_date,\n prop.ref,\n prop.lastedit_type,\n prop.lastedit_user_id,\n prop.to_group_id, \n prop.to_user_id, \n prop.visibility, \n prop.start_visible, \n prop.end_visible, \n prop.id_session\n FROM \n {$table} AS n, \n {$table_item_property} AS prop\n WHERE \n (n.notebook_id = prop.ref AND\n n.c_id = prop.c_id AND\n prop.tool = '{$tool}')"; $sql .= $where ? "AND ({$where})" : ''; $sql .= ' ORDER BY '; $sql .= $orderby ? $orderby : 'creation_date ASC'; if ($limit) { $from = (int) $limit->from; $count = (int) $limit->count; $sql .= " LIMIT {$from}, {$count}"; } $rs = Database::query($sql); while ($data = Database::fetch_object($rs)) { $result[] = Notebook::create($data); } return $result; }
public function find_by_id() { $c_id = Request::get_c_id(); $id = Request::get_id(); $item = Notebook::repository()->find_one_by_id($c_id, $id); $data = (object) array(); if ($item) { $data->title = $item->title; $data->description = $item->description; } $this->response($success, '', $data); }
public function export_csv() { $course = Request::get_course_key(); $items = Notebook::repository()->find_by_course($course); $writer = CsvWriter::create(); $writer->add($items); $path = $writer->get_path(); \DocumentManager::file_send_for_download($path, true, get_lang('Notebook') . '.csv'); }