Example #1
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);
     }
 }