コード例 #1
0
ファイル: article.php プロジェクト: rockylo/ionize
 public function save_duplicate()
 {
     if ($this->input->post('dup_url') != '' && $this->input->post('dup_id_page') > 0) {
         // No name change : exit
         if (url_title($this->input->post('dup_url')) === $this->input->post('name')) {
             $this->error(lang('ionize_message_article_duplicate_no_name_change'));
         }
         /* New article data :
          * - The updater is set to nobody
          * - The author become the current connected user
          *
          */
         $user = User()->get_user();
         $data = array('name' => url_title($this->input->post('dup_url')), 'id_page' => $this->input->post('dup_id_page'), 'view' => $this->input->post('view'), 'id_type' => $this->input->post('id_type'), 'updater' => $user['username'], 'author' => $user['username']);
         // Duplicate the article base data and get the new ID
         $id_new_article = $this->article_model->duplicate($this->input->post('id_article'), $data, $this->input->post('ordering_select'));
         if ($id_new_article !== FALSE) {
             Cache()->clear_cache();
             // Update URLs
             $this->article_model->save_urls($id_new_article);
             // Update the content structure tree
             // The data var is merged to the default lang data_lang var,
             // in order to send the lang values to the browser without making another SQL request
             $menu = $this->menu_model->get_from_page($this->input->post('dup_id_page'));
             $article = array_shift($this->article_model->get_linked_lang_items('page', 'article', array('id_article' => $id_new_article), Settings::get_lang('default')));
             $this->data = $article;
             $this->data['title'] = htmlspecialchars_decode($article['title'], ENT_QUOTES);
             $this->data['id_article'] = $id_new_article;
             $this->data['id_page'] = $this->input->post('dup_id_page');
             $this->data['element'] = 'article';
             $this->data['menu'] = $menu;
             $this->data['online'] = 0;
             // Used by JS Tree to detect if article in inserted in tree or not
             $this->data['inserted'] = TRUE;
             // Panels Update
             $this->_reload_panel($this->data['id_page'], $id_new_article);
             $this->callback[] = array('fn' => $menu['name'] . 'Tree.insertElement', 'args' => array($this->data, 'article'));
             // Answer send
             $this->success(lang('ionize_message_article_duplicated'));
         } else {
             $this->error(lang('ionize_message_article_not_duplicated'));
         }
     } else {
         $this->error(lang('ionize_message_article_not_duplicated'));
     }
 }