function edit($id = 0) { $newscatalogue = new newscatalogue($id); if ($_SERVER['REQUEST_METHOD'] == "GET") { } else { $newscatalogue->name_vietnamese = $this->input->post('name_vietnamese'); $newscatalogue->name_english = $this->input->post('name_english'); $newscatalogue->name_japanese = $this->input->post('name_japanese'); $parentcat = new newscatalogue(trim($this->input->post('parentcat'))); $newscatalogue->title_bar = $this->input->post('title_bar'); $newscatalogue->slogan = $this->input->post('slogan'); $newscatalogue->keyword = $this->input->post('keyword'); $newscatalogue->group = $this->input->post('group'); if ($this->logged_in_user->adminrole->id == 1) { $newscatalogue->navigation = $this->input->post('navigation'); $newscatalogue->menu_active = $this->input->post('menu_active'); } $this->load->helper('remove_vn_helper'); $newscatalogue->name_none = remove_vn($newscatalogue->name_vietnamese); if ($newscatalogue->save(array('parentcat' => $parentcat))) { redirect($this->admin . 'newscatalogues/list_all/'); } } $parentcat = new newscatalogue(); $parentcat->where('parentcat_id', NULL); if ($newscatalogue->exists()) { $parentcat->where('id !=', $newscatalogue->id); } $parentcat->order_by('position', 'asc'); $parentcat->get(); $sitelanguage = new Sitelanguage(); $sitelanguage->get()->all; $dis['sitelanguage'] = $sitelanguage; $dis['base_url'] = base_url(); $dis['parentcat'] = $parentcat; $dis['title'] = "Thêm/ Sửa danh mục tin tức"; $dis['menu_active'] = "Danh mục tin tức"; $dis['view'] = "newscatalogue/edit"; $dis['object'] = $newscatalogue; $dis['nav_menu'] = array(array("type" => "back", "text" => "Back", "link" => "{$this->admin_url}newscatalogues/", "onclick" => "")); $this->viewadmin($dis); }
function down_position() { $min = new newscatalogue(); $min->select_min('position'); $min->where('position >', $this->position); $min->where('parentcat_id', $this->parentcat->id); $min->get(); $o = new newscatalogue(); $o->where('position', $min->position); $o->where('parentcat_id', $this->parentcat->id); $o->get(); if ($o->result_count() > 0) { $tg = $this->position; $this->position = $o->position; $o->position = $tg; $o->save(); $this->save(); return true; } else { return false; } }
/** * Cnews::copy_2_cat() * * @param mixed $id * @return */ function copy_2_cat($id) { $this->load->helper('remove_vn_helper'); $news = new article($id); if (!$news->exists()) { show_404(); } $cat_id = $news->newscatalogue_id; $copy_newscatalogue = $this->input->post('copy_newscatalogue'); $copy_type = $this->input->post('copy_type'); $copy_amount = $this->input->post('copy_amount'); $flag_error = false; if ($copy_newscatalogue == 0) { $newscatalogue = new newscatalogue(); $newscatalogue->where('id !=', $news->newscatalogue_id); $newscatalogue->get(); $vb = new article(); $vb->hot = 0; $vb->home_hot = 0; foreach ($newscatalogue as $row) { for ($i = 0; $i < $copy_amount; $i++) { $vb = $news->get_copy(); $vb->code = ""; if (!$vb->save(array($row))) { foreach ($vb->error->all as $r) { flash_message('error', $r); $flag_error = true; } } else { $vb->title_vietnamese = $vb->code . ": " . $vb->title_vietnamese; $vb->title_none = remove_vn($vb->title_vietnamese) . "-" . md5($vb->id); $vb->save(); } $vb->clear(); } } } else { $newscatalogue = new newscatalogue($copy_newscatalogue); $vb = new article(); $vb->hot = 0; $vb->home_hot = 0; for ($i = 0; $i < $copy_amount; $i++) { $vb = $news->get_copy(); $vb->code = ""; if (!$vb->save(array($newscatalogue))) { foreach ($vb->error->all as $r) { flash_message('error', $r); $flag_error = true; } } else { $vb->title_vietnamese = $vb->code . ": " . $vb->title_vietnamese; $vb->title_none = remove_vn($vb->title_vietnamese) . "-" . md5($vb->id); $vb->save(); } $vb->clear(); } } if ($copy_type == "move") { $news->delete(); } if ($flag_error == false) { flash_message('success', "Thực hiện thành công xong copy/move"); } else { flash_message('info', "Có 1 vài lỗi trên"); } redirect($this->admin . 'cnews/edit/' . $cat_id . '/' . $id); }