Example #1
0
File: rule.php Project: trk/ionize
 /**
  * Creation Form
  * Return rules array as JSON
  *
  */
 public function get_all()
 {
     $type = $this->input->post('type');
     if (!$type) {
         $type = NULL;
     }
     $rules = $this->rule_model->get_from_type($type);
     if ($this->is_xhr()) {
         $data = array('rules' => $rules);
         $this->xhr_output($data);
     }
 }
Example #2
0
 public function get_options($rel)
 {
     // IDs
     $rel = explode(".", $rel);
     $id_page = !empty($rel[1]) ? $rel[0] : '0';
     $id_article = !empty($rel[1]) ? $rel[1] : NULL;
     $resource = $this->_get_resource_name('backend', 'article', $id_article);
     if (Authority::can('edit', $resource, NULL, TRUE)) {
         // Edit article if ID exists
         if (!is_null($id_article)) {
             $article = $this->article_model->get_by_id($id_article);
             if (!empty($article)) {
                 $this->load_modules_addons($article);
                 // Page context of the current edited article
                 $article['id_page'] = $id_page;
                 // Merge article's data with template
                 $this->template = array_merge($this->template, $article);
                 $this->article_model->feed_lang_template($id_article, $this->template);
                 // Add article types to template
                 $data = $this->article_type_model->get_types_select();
                 if (!empty($data)) {
                     $data = array('' => lang('ionize_select_no_type')) + $data;
                     $this->template['all_article_types'] = $data;
                 } else {
                     $this->template['all_article_types'] = NULL;
                 }
                 $this->template['article_type_current'] = $article['id_type'];
                 // Linked pages list
                 $this->template['pages_list'] = $this->article_model->get_pages_list($id_article);
                 // Categories
                 $categories = $this->category_model->get_categories_select();
                 $current_categories = $this->category_model->get_current_categories('article', $id_article);
                 $this->template['categories'] = form_dropdown('categories[]', $categories, $current_categories, 'class="select w100p" multiple="multiple"');
                 // Permissions
                 $frontend_roles_resources = $this->resource_model->get_element_roles_resources('article', $id_article, self::$_AUTHORITY_FRONTEND_ACTIONS, 'frontend');
                 $this->template['frontend_roles_resources'] = $frontend_roles_resources;
                 $backend_roles_resources = $this->resource_model->get_element_roles_resources('article', $id_article, self::$_AUTHORITY_BACKEND_ACTIONS, 'backend');
                 $this->template['backend_roles_resources'] = $backend_roles_resources;
                 // Default Deny Action
                 if (empty($article['deny_code'])) {
                     $this->template['deny_code'] = '404';
                 }
                 // Roles which have permission set for this page
                 $this->template['frontend_role_ids'] = $this->rule_model->get_element_role_ids('article', $id_article);
                 $this->template['backend_role_ids'] = $this->rule_model->get_element_role_ids('article', $id_article, 'backend');
                 // Output
                 $this->output('article/options');
             } else {
                 // Article not found
                 $this->error(lang('ionize_message_article_not_exist'));
             }
         } else {
             // Article not found
             $this->error(lang('ionize_message_article_not_exist'));
         }
     } else {
         $this->output(self::$_DENY_DEFAULT_VIEW);
     }
 }
Example #3
0
File: menu.php Project: trk/ionize
 /**
  * Update one menu
  *
  */
 public function update()
 {
     $id_menu = $this->input->post('id_menu');
     if ($id_menu) {
         $this->menu_model->update($id_menu, $this->input->post());
         if (Authority::can('access', 'admin/menu/permissions/backend')) {
             $resource = 'backend/menu/' . $id_menu;
             $this->rule_model->save_element_roles_rules($resource, $this->input->post('backend_rule'));
         }
     }
     // UI update panels
     $this->_update_panels();
     $this->success(lang('ionize_message_menu_updated'));
 }
Example #4
0
File: page.php Project: trk/ionize
 /**
  * Saves the page's options.
  * If no page ID is given by $_POST
  *
  * @param int	Page ID
  */
 public function save_options()
 {
     $id_page = $this->input->post('id_page');
     // Do stuff
     if ($id_page) {
         // Prepare data before save
         $this->_prepare_options_data();
         // Event Data
         $event_data = array('base' => $this->data, 'lang' => $this->lang_data, 'post' => $this->input->post());
         Event::fire('Page.options.save.before', $event_data);
         // Save Page
         $this->page_model->save($this->data, $this->lang_data);
         // Save the Urls
         $this->page_model->save_urls($id_page);
         // Save Home page
         if ($this->data['home'] == '1') {
             $this->page_model->update_home_page($id_page);
         }
         $page = array_merge($this->lang_data[Settings::get_lang('default')], $this->page_model->get_by_id($id_page));
         $page['menu'] = $this->menu_model->get($page['id_menu']);
         // Saves linked categories
         $this->base_model->join_items_keys_to('category', $this->input->post('categories'), 'page', $id_page);
         // Saves Tags
         $this->tag_model->save_element_tags($this->input->post('tags'), 'page', $id_page);
         // Rules
         if (Authority::can('access', 'admin/page/permissions/backend')) {
             $resource = $this->_get_resource_name('backend', 'page', $id_page);
             $this->rule_model->save_element_roles_rules($resource, $this->input->post('backend_rule'));
         }
         if (Authority::can('access', 'admin/page/permissions/frontend')) {
             $resource = $this->_get_resource_name('frontend', 'page', $id_page);
             $this->rule_model->save_element_roles_rules($resource, $this->input->post('frontend_rule'));
         }
         Event::fire('Page.options.save.success', $event_data);
         // Remove HTML tags from returned array
         strip_html($page);
     }
     // Reloads the page edition panel
     $this->_reload_panel($id_page);
     // Answer
     $this->success(lang('ionize_message_page_saved'));
 }