Esempio n. 1
0
 function save($object = '', $related_field = '')
 {
     if (!$this->exists()) {
         $o = new newscatalogue();
         $o->select_max('position');
         $o->get();
         if (count($o->all) != 0) {
             $max = $o->position + 1;
             $this->position = $max;
         } else {
             $this->postion = 1;
         }
     }
     return parent::save($object, $related_field);
 }
Esempio n. 2
0
 /**
  * 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);
 }
Esempio n. 3
0
 function delete()
 {
     $id = $this->uri->segment(4);
     $newscatalogue = new newscatalogue($id);
     //delete city
     if (count($newscatalogue->child->all) > 0) {
         flash_message('error', 'không thể xóa menu gốc, vui lòng xóa menu con trước');
     } else {
         $newscatalogue->delete();
     }
     //redirect to city
     redirect($this->admin . 'newscatalogues/list_all/');
 }