Пример #1
0
 public function save_options()
 {
     $rel = $this->input->post('rel');
     // IDs
     $rel = explode(".", $rel);
     $id_page = $this->data['id_page'] = !empty($rel[1]) ? $rel[0] : '0';
     // $id_article = $this->input->post('id_article');
     $this->_prepare_options_data();
     // Event : On before save
     $event_data = array('base' => $this->data, 'lang' => $this->lang_data, 'post' => $this->input->post());
     Event::fire('Article.options.save.before', $event_data);
     // Saves article to DB and get the saved ID
     $id_article = $this->article_model->save($this->data, $this->lang_data);
     // Saves linked categories
     $this->base_model->join_items_keys_to('category', $this->input->post('categories'), 'article', $id_article);
     // Saves Tags
     $this->tag_model->save_element_tags($this->input->post('tags'), 'article', $id_article);
     // Rules
     if (Authority::can('access', 'admin/article/permissions/backend')) {
         $resource = $this->_get_resource_name('backend', 'article', $id_article);
         $this->rule_model->save_element_roles_rules($resource, $this->input->post('backend_rule'));
     }
     if (Authority::can('access', 'admin/article/permissions/frontend')) {
         $resource = $this->_get_resource_name('frontend', 'article', $id_article);
         $this->rule_model->save_element_roles_rules($resource, $this->input->post('frontend_rule'));
     }
     // Event : On after save
     Event::fire('Article.options.save.success', $event_data);
     // Context update
     $this->update_contexts($id_article);
     // Reloads the edition panel
     $this->_reload_panel($id_page, $id_article);
     // Answer
     $this->success(lang('ionize_message_article_saved'));
 }