/system/expressionengine/controllers/cp/admin_content.php
PHP | 5283 lines | 3493 code | 1083 blank | 707 comment | 503 complexity | 201607107bf2c54da47ee90b7cc3fdb1 MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
- /**
- * ExpressionEngine - by EllisLab
- *
- * @package ExpressionEngine
- * @author EllisLab Dev Team
- * @copyright Copyright (c) 2003 - 2012, EllisLab, Inc.
- * @license http://ellislab.com/expressionengine/user-guide/license.html
- * @link http://ellislab.com
- * @since Version 2.0
- * @filesource
- */
- // ------------------------------------------------------------------------
- /**
- * ExpressionEngine CP Home Page Class
- *
- * @package ExpressionEngine
- * @subpackage Control Panel
- * @category Control Panel
- * @author EllisLab Dev Team
- * @link http://ellislab.com
- */
- class Admin_content extends CI_Controller {
- var $reserved = array(
- 'random', 'date', 'title', 'url_title', 'edit_date',
- 'comment_total', 'username', 'screen_name',
- 'most_recent_comment', 'expiration_date');
- // Category arrays
- var $categories = array();
- var $cat_update = array();
- var $temp;
- /**
- * Constructor
- */
- function __construct()
- {
- parent::__construct();
- $this->lang->loadfile('admin');
- $this->cp->set_breadcrumb(BASE.AMP.'C=admin_content', lang('admin_content'));
-
- // Note- no access check here to allow the publish page access to categories
- }
- // --------------------------------------------------------------------
- /**
- * Index function
- *
- * @access public
- * @return void
- */
- function index()
- {
- if ( ! $this->cp->allowed_group('can_access_admin', 'can_access_content_prefs'))
- {
- show_error(lang('unauthorized_access'));
- }
- $this->cp->set_variable('cp_page_title', lang('admin'));
- $this->javascript->compile();
- $this->cp->set_variable('cp_page_title', lang('admin_content'));
- $this->load->vars(array('controller'=>'admin'));
-
- $this->load->view('_shared/overview');
- }
- // --------------------------------------------------------------------
- /**
- * Channel Overview
- *
- * Displays the Channel Management page
- *
- * @access public
- * @return void
- */
- function channel_management()
- {
- $this->_restrict_prefs_access();
- $this->cp->set_right_nav(array('create_new_channel' => BASE.AMP.'C=admin_content'.AMP.'M=channel_add'));
- $this->load->library('table');
- $this->lang->loadfile('admin_content');
- $this->load->model('channel_model');
- $this->cp->set_variable('cp_page_title', lang('channels'));
- $this->jquery->tablesorter('.mainTable', '{
- headers: {2: {sorter: false}, 3: {sorter: false}, 4: {sorter: false}},
- widgets: ["zebra"]
- }');
- $this->javascript->compile();
-
- $vars['channel_data'] = $this->channel_model->get_channels();
- $this->load->view('admin/channel_management', $vars);
- }
- // --------------------------------------------------------------------
- /**
- * Add Channel
- *
- * Displays the Channel Preferences form
- *
- * @access public
- * @return void
- */
- function channel_add()
- {
- $this->_restrict_prefs_access();
-
- $this->_channel_validation_rules();
- if ($this->form_validation->run() !== FALSE)
- {
- return $this->channel_update();
- }
- $this->lang->loadfile('admin_content');
- $this->load->helper('snippets');
- $this->load->model('channel_model');
- $this->load->model('category_model');
- $this->cp->add_js_script('plugin', 'ee_url_title');
- $this->javascript->output('
- $("#edit_group_prefs").hide();
- $("#channel_title").bind("keyup keydown", function() {
- $(this).ee_url_title("#channel_name");
- });
- ');
- $this->javascript->click("#edit_group_prefs_y", '$("#edit_group_prefs").show();', FALSE);
- $this->javascript->click("#edit_group_prefs_n", '$("#edit_group_prefs").hide();', FALSE);
- $this->cp->set_variable('cp_page_title', lang('create_new_channel'));
- $channels = $this->channel_model->get_channels($this->config->item('site_id'), array('channel_id', 'channel_title'));
- $vars['duplicate_channel_prefs_options'][''] = lang('do_not_duplicate');
- if ($channels != FALSE && $channels->num_rows() > 0)
- {
- foreach($channels->result() as $channel)
- {
- $vars['duplicate_channel_prefs_options'][$channel->channel_id] = $channel->channel_title;
- }
- }
- $vars['cat_group_options'][''] = lang('none');
- $groups = $this->category_model->get_categories('', $this->config->item('site_id'));
- if ($groups->num_rows() > 0)
- {
- foreach ($groups->result() as $group)
- {
- $vars['cat_group_options'][$group->group_id] = $group->group_name;
- }
- }
- $vars['status_group_options'][''] = lang('none');
- $this->db->select('group_id, group_name');
- $this->db->where('site_id', $this->config->item('site_id'));
- $this->db->order_by('group_name');
-
- $groups = $this->db->get('status_groups');
- if ($groups->num_rows() > 0)
- {
- foreach ($groups->result() as $group)
- {
- $vars['status_group_options'][$group->group_id] = $group->group_name;
- }
- }
- $vars['field_group_options'][''] = lang('none');
- $this->db->select('group_id, group_name');
- $this->db->where('site_id', $this->config->item('site_id'));
- $this->db->order_by('group_name');
-
- $groups = $this->db->get('field_groups');
- if ($groups->num_rows() > 0)
- {
- foreach ($groups->result() as $group)
- {
- $vars['field_group_options'][$group->group_id] = $group->group_name;
- }
- }
- // New themes may contain more than one group, thus naming collisions will happen
- // unless this is revamped.
- $vars['themes'] = array();
- $this->db->select('group_id, group_name, s.site_label');
- $this->db->from('template_groups tg, sites s');
- $this->db->where('tg.site_id = s.site_id', NULL, FALSE);
- if ($this->config->item('multiple_sites_enabled') !== 'y')
- {
- $this->db->where('tg.site_id', '1');
- }
- $this->db->order_by('tg.group_name');
- $query = $this->db->get();
- $vars['old_group_id'] = array();
- foreach ($query->result_array() as $row)
- {
- $vars['old_group_id'][$row['group_id']] = ($this->config->item('multiple_sites_enabled') == 'y') ? $row['site_label'].NBS.'-'.NBS.$row['group_name'] : $row['group_name'];
- }
- $this->cp->set_breadcrumb(BASE.AMP.'C=admin_content'.AMP.'M=channel_management', lang('channels'));
- $this->javascript->compile();
- $this->load->view('admin/channel_add', $vars);
- }
- // --------------------------------------------------------------------
- /**
- * Edit Channel
- *
- * Displays the Channel Preferences form
- *
- * @access public
- * @return void
- */
- function channel_edit()
- {
- $this->_restrict_prefs_access();
-
- // Get modules that are installed
- $this->cp->get_installed_modules();
- $this->lang->loadfile('admin_content');
- $this->load->library('table');
- $this->load->helper('snippets');
- $this->load->model('channel_model');
- $this->load->model('template_model');
- $this->load->model('status_model');
- $this->load->model('field_model');
- $this->load->model('admin_model');
- $channel_id = $this->input->get_post('channel_id');
- // If we don't have the $channel_id variable, bail out.
- if ($channel_id == '' OR ! is_numeric($channel_id))
- {
- show_error(lang('not_authorized'));
- }
-
- $this->_channel_validation_rules();
- $this->form_validation->set_old_value('channel_id', $channel_id);
- if ($this->form_validation->run() !== FALSE)
- {
- $this->form_validation->set_old_value('channel_id', $channel_id);
- return $this->channel_update();
- }
- $query = $this->channel_model->get_channel_info($channel_id);
- foreach ($query->row_array() as $key => $val)
- {
- $vars[$key] = $val;
- }
- $vars['form_hidden']['channel_id'] = $channel_id;
- // live_look_template
- $query = $this->template_model->get_templates();
- $vars['live_look_template_options'][0] = lang('no_live_look_template');
- if ($query->num_rows() > 0)
- {
- foreach ($query->result() as $template)
- {
- $vars['live_look_template_options'][$template->template_id] = $template->group_name.'/'.$template->template_name;
- }
- }
- // Default status menu
- $query = $this->status_model->get_statuses($vars['status_group']);
- $vars['deft_status_options']['open'] = lang('open');
- $vars['deft_status_options']['closed'] = lang('closed');
- if ($query->num_rows() > 0)
- {
- foreach ($query->result() as $row)
- {
- $status_name = ($row->status == 'open' OR $row->status == 'closed') ? lang($row->status) : $row->status;
- $vars['deft_status_options'][$row->status] = $status_name;
- }
- }
-
- $vars['deft_category_options'][''] = lang('none');
-
- $cats = $vars['cat_group'] ? explode('|', $vars['cat_group']) : array();
- // Needz moar felineness!
- if (count($cats))
- {
- $this->db->select('CONCAT('.$this->db->dbprefix('category_groups').'.group_name, ": ", '.$this->db->dbprefix('categories').'.cat_name) as display_name', FALSE);
- $this->db->select('categories.cat_id, categories.cat_name, category_groups.group_name');
- $this->db->from('categories, '.$this->db->dbprefix('category_groups'));
- $this->db->where($this->db->dbprefix('category_groups').'.group_id = '.$this->db->dbprefix('categories').'.group_id', NULL, FALSE);
- $this->db->where_in('categories.group_id', $cats);
- $this->db->order_by('display_name');
-
- $query = $this->db->get();
-
- if ($query->num_rows() > 0)
- {
- foreach ($query->result() as $row)
- {
- $vars['deft_category_options'][$row->cat_id] = $row->display_name;
- }
- }
- }
-
- // Default field for search excerpt
- $this->db->select('field_id, field_label');
- $this->db->where('group_id', $vars['field_group']);
- $query = $this->db->get('channel_fields');
- $vars['search_excerpt_options'] = array();
- if ($query->num_rows() > 0)
- {
- foreach ($query->result() as $row)
- {
- $vars['search_excerpt_options'][$row->field_id] = $row->field_label;
- }
- }
- // HTML formatting
- $vars['channel_html_formatting_options'] = array(
- 'none' => lang('convert_to_entities'),
- 'safe' => lang('allow_safe_html'),
- 'all' => lang('allow_all_html')
- );
- if (isset($this->cp->installed_modules['comment']))
- {
- // Default comment text formatting
- $vars['comment_text_formatting_options'] = array(
- 'none' => lang('none'),
- 'xhtml' => lang('xhtml'),
- 'br' => lang('auto_br')
- );
- // Comment HTML formatting
- $vars['comment_html_formatting_options'] = array(
- 'none' => lang('convert_to_entities'),
- 'safe' => lang('allow_safe_html'),
- 'all' => lang('allow_all_html_not_recommended')
- );
- }
-
- $vars['languages'] = $this->admin_model->get_xml_encodings();
- $this->javascript->compile();
- $this->cp->set_variable('cp_page_title', lang('channel_prefs').': '.$vars['channel_title']);
- $this->cp->set_breadcrumb(BASE.AMP.'C=admin_content'.AMP.'M=channel_management', lang('channels'));
- $this->load->view('admin/channel_edit', $vars);
- }
-
- // --------------------------------------------------------------------
- /**
- * Channel preference submission validation
- *
- * Sets the channel validation rules
- *
- * @access public
- * @return void
- */
- function _channel_validation_rules()
- {
- $this->load->library('form_validation');
-
- $this->form_validation->set_rules('channel_title', 'lang:channel_title', 'required');
- $this->form_validation->set_rules('channel_name', 'lang:channel_name', 'required|callback__valid_channel_name');
- $this->form_validation->set_rules('url_title_prefix', 'lang:url_title_prefix', 'strtolower|strip_tags|callback__valid_prefix');
- $this->form_validation->set_rules('comment_expiration', 'lang:comment_expiration', 'numeric');
-
- $this->form_validation->set_error_delimiters('<p class="notice">', '</p>');
- }
-
- function _valid_prefix($str)
- {
- if ($str == '')
- {
- return TRUE;
- }
- $this->form_validation->set_message('_valid_prefix', lang('invalid_url_title_prefix'));
- return preg_match('/^[\w\-]+$/', $str) ? TRUE : FALSE;
- }
-
- function _valid_channel_name($str)
- {
- // Check short name characters
- if (preg_match('/[^a-z0-9\-\_]/i', $str))
- {
- $this->form_validation->set_message('_valid_channel_name', lang('invalid_short_name'));
- return FALSE;
- }
-
- // Check for duplicates
- $this->db->where('site_id', $this->config->item('site_id'));
- $this->db->where('channel_name', $str);
-
- if ($this->form_validation->old_value('channel_id'))
- {
- $this->db->where('channel_id != ', $this->form_validation->old_value('channel_id'));
- }
- if ($this->db->count_all_results('channels') > 0)
- {
- $this->form_validation->set_message('_valid_channel_name', lang('taken_channel_name'));
- return FALSE;
- }
-
- return TRUE;
- }
- // --------------------------------------------------------------------
- /**
- * Channel preference submission handler
- *
- * This function receives the submitted channel preferences
- * and stores them in the database.
- *
- * @access public
- * @return void
- */
- function channel_update()
- {
- $this->_restrict_prefs_access();
- $this->lang->loadfile('admin_content');
- unset($_POST['channel_prefs_submit']); // submit button
- // If the $channel_id variable is present we are editing an
- // existing channel, otherwise we are creating a new one
- $edit = (isset($_POST['channel_id'])) ? TRUE : FALSE;
- // Load the layout Library & update the layouts
- $this->load->library('layout');
- $add_rss = (isset($_POST['add_rss'])) ? TRUE : FALSE;
- unset($_POST['add_rss']);
- $return = ($this->input->get_post('return')) ? TRUE : FALSE;
- unset($_POST['return']);
- $edit_group_prefs = TRUE;
-
- if ($this->input->get_post('edit_group_prefs') !== 'y')
- {
- unset($_POST['cat_group']);
- unset($_POST['status_group']);
- unset($_POST['field_group']);
- $edit_group_prefs = FALSE;
- }
- unset($_POST['edit_group_prefs']);
- $dupe_id = $this->input->get_post('duplicate_channel_prefs');
- unset($_POST['duplicate_channel_prefs']);
- // Check for required fields
- $error = array();
- if (isset($_POST['comment_expiration']) && $_POST['comment_expiration'] == '')
- {
- $_POST['comment_expiration'] = 0;
- }
- // Template Error Trapping
- if ($edit == FALSE)
- {
- $create_templates = ($this->input->get_post('create_templates') == FALSE OR $this->input->get_post('create_templates') == 'no') ? 'no' : $this->input->get_post('create_templates');
- $old_group_id = $this->input->get_post('old_group_id');
- $group_name = $this->input->post('group_name');
- $template_theme = $this->security->sanitize_filename($this->input->get_post('template_theme'));
- unset($_POST['create_templates']);
- unset($_POST['old_group_id']);
- unset($_POST['group_name']);
- unset($_POST['template_theme']);
- if ($create_templates != 'no')
- {
- $this->lang->loadfile('design');
- if ( ! $this->cp->allowed_group('can_admin_templates'))
- {
- show_error(lang('unauthorized_access'));
- }
- if ( ! $group_name)
- {
- show_error(lang('group_required'));
- }
- if ( ! preg_match("#^[a-zA-Z0-9_\-/]+$#i", $group_name))
- {
- show_error(lang('illegal_characters'));
- }
- $reserved[] = 'act';
- if ($this->config->item("forum_is_installed") == 'y' AND $this->config->item("forum_trigger") != '')
- {
- $reserved[] = $this->config->item("forum_trigger");
- }
- if (in_array($group_name, $reserved))
- {
- show_error(lang('reserved_name'));
- }
- $this->db->where('site_id', $this->config->item('site_id'));
- $this->db->where('group_name', $group_name);
-
- $count = $this->db->count_all_results('template_groups');
- if ($count > 0)
- {
- show_error(lang('template_group_taken'));
- }
- }
- }
- if ($this->input->post('apply_comment_enabled_to_existing'))
- {
- if ($this->input->post('comment_system_enabled') == 'y')
- {
- $this->channel_model->update_comments_allowed($_POST['channel_id'], 'y');
- }
- elseif ($this->input->post('comment_system_enabled') == 'n')
- {
- $this->channel_model->update_comments_allowed($_POST['channel_id'], 'n');
- }
- }
- unset($_POST['apply_comment_enabled_to_existing']);
- if (isset($_POST['apply_expiration_to_existing']))
- {
- if ($this->input->post('comment_expiration') == 0)
- {
- $this->channel_model->update_comment_expiration($_POST['channel_id'], $_POST['comment_expiration'], TRUE);
- }
- else
- {
- $this->channel_model->update_comment_expiration($_POST['channel_id'], $_POST['comment_expiration'] * 86400);
- }
- }
- unset($_POST['apply_expiration_to_existing']);
- if (isset($_POST['cat_group']) && is_array($_POST['cat_group']))
- {
- foreach($_POST['cat_group'] as $key => $value)
- {
- unset($_POST['cat_group_'.$key]);
- }
- $_POST['cat_group'] = implode('|', $_POST['cat_group']);
- }
- // Create Channel
- // Construct the query based on whether we are updating or inserting
- if ($edit == FALSE)
- {
- unset($_POST['channel_id']);
- unset($_POST['clear_versioning_data']);
- $_POST['channel_url'] = $this->functions->fetch_site_index();
- $_POST['channel_lang'] = $this->config->item('xml_lang');
- // Assign field group if there is only one
- if ($dupe_id != '' && ( ! isset($_POST['field_group']) OR (isset($_POST['field_group']) && ! is_numeric($_POST['field_group']))))
- {
- $this->db->select('group_id');
- $this->db->where('site_id', $this->config->item('site_id'));
- $query = $this->db->get('field_groups');
-
- if ($query->num_rows() == 1)
- {
- $_POST['field_group'] = $query->row('group_id') ;
- }
- }
- // Insert data
- $_POST['site_id'] = $this->config->item('site_id');
- $_POST['status_group'] = ($this->input->post('status_group') !== FALSE &&
- $this->input->post('status_group') != '')
- ? $this->input->post('status_group') : NULL;
- $_POST['field_group'] = ($this->input->post('field_group') !== FALSE &&
- $this->input->post('field_group') != '')
- ? $this->input->post('field_group') : NULL;
- // duplicating preferences?
- if ($dupe_id !== FALSE AND is_numeric($dupe_id))
- {
- $this->db->where('channel_id', $dupe_id);
- $wquery = $this->db->get('channels');
-
- if ($wquery->num_rows() == 1)
- {
- $exceptions = array('channel_id', 'site_id', 'channel_name', 'channel_title', 'total_entries',
- 'total_comments', 'last_entry_date', 'last_comment_date');
- foreach($wquery->row_array() as $key => $val)
- {
- // don't duplicate fields that are unique to each channel
- if ( ! in_array($key, $exceptions))
- {
- switch ($key)
- {
- // category, field, and status fields should only be duped
- // if both channels are assigned to the same group of each
- case 'cat_group':
- // allow to implicitly set category group to "None"
- if ( ! isset($_POST[$key]))
- {
- $_POST[$key] = $val;
- }
- break;
- case 'status_group':
- case 'field_group':
- if ( ! isset($_POST[$key]))
- {
- $_POST[$key] = $val;
- }
- elseif ($_POST[$key] == '')
- {
- $_POST[$key] = NULL;
- }
- break;
- case 'deft_status':
- case 'deft_status':
- if ( ! isset($_POST['status_group']) OR $_POST['status_group'] == $wquery->row('status_group') )
- {
- $_POST[$key] = $val;
- }
- break;
- case 'search_excerpt':
- if ( ! isset($_POST['field_group']) OR $_POST['field_group'] == $wquery->row('field_group') )
- {
- $_POST[$key] = $val;
- }
- break;
- case 'deft_category':
- if ( ! isset($_POST['cat_group']) OR count(array_diff(explode('|', $_POST['cat_group']), explode('|', $wquery->row('cat_group') ))) == 0)
- {
- $_POST[$key] = $val;
- }
- break;
- case 'blog_url':
- case 'comment_url':
- case 'search_results_url':
- case 'ping_return_url':
- case 'rss_url':
- if ($create_templates != 'no')
- {
- if ( ! isset($old_group_name))
- {
- $this->db->select('group_name');
- $this->db->where('group_id', $old_group_id);
- $gquery = $this->db->get('template_groups');
- $old_group_name = $gquery->row('group_name');
- }
- $_POST[$key] = str_replace("/{$old_group_name}/", "/{$group_name}/", $val);
- }
- else
- {
- $_POST[$key] = $val;
- }
- break;
- default :
- $_POST[$key] = $val;
- break;
- }
- }
- }
- }
- }
- $_POST['default_entry_title'] = ( ! isset( $_POST['default_entry_title'])) ? '' : $_POST['default_entry_title'];
- $_POST['url_title_prefix'] = ( ! isset( $_POST['url_title_prefix'])) ? '' : $_POST['url_title_prefix'];
-
- $this->db->insert('channels', $_POST);
-
- $insert_id = $this->db->insert_id();
- $channel_id = $insert_id;
-
- // If they made the channel? Give access to that channel to the member group?
- if ($dupe_id !== FALSE AND is_numeric($dupe_id) && $edit_group_prefs == FALSE)
- {
- // Duplicate layouts
- $this->layout->duplicate_layout($dupe_id, $channel_id);
- }
-
- // If member group has ability to create the channel, they should be
- // able to access it as well
- if ($this->session->userdata('group_id') != 1)
- {
- $data = array(
- 'group_id' => $this->session->userdata('group_id'),
- 'channel_id' => $channel_id
- );
-
- $this->db->insert('channel_member_groups', $data);
- }
- $success_msg = lang('channel_created');
- $this->logger->log_action($success_msg.NBS.NBS.$_POST['channel_title']);
- }
- else
- {
- if (isset($_POST['clear_versioning_data']))
- {
- $this->db->delete('entry_versioning', array('channel_id' => $_POST['channel_id']));
-
- unset($_POST['clear_versioning_data']);
- }
-
- // Only one possible is revisions- enabled or disabled.
- // We treat as installed/not and delete the whole tab.
-
- $this->layout->sync_layout($_POST, $_POST['channel_id']);
- $sql = $this->db->update_string('exp_channels', $_POST, 'channel_id='.$this->db->escape_str($_POST['channel_id']));
- $this->db->query($sql);
- $channel_id = $this->db->escape_str($_POST['channel_id']);
- $success_msg = lang('channel_updated');
- }
-
- /** -----------------------------------------
- /** Create Templates
- /** -----------------------------------------*/
- if ($edit == FALSE)
- {
- if ($create_templates != 'no')
- {
- $query = $this->db->query("SELECT COUNT(*) AS count FROM exp_template_groups");
- $group_order = $query->row('count') +1;
- $this->db->insert('template_groups', array(
- 'group_name' => $group_name,
- 'group_order' => $group_order,
- 'is_site_default' => 'n',
- 'site_id' => $this->config->item('site_id')
- ));
- $group_id = $this->db->insert_id();
- if ($create_templates == 'duplicate')
- {
- $this->db->select('group_name');
- $this->db->where('group_id', $old_group_id);
- $query = $this->db->get('template_groups');
- $old_group_name = $query->row('group_name') ;
- $this->db->select('template_name, template_data, template_type,
- template_notes, cache, refresh, no_auth_bounce,
- allow_php, php_parse_location');
- $this->db->where('group_id', $old_group_id);
- $query = $this->db->get('templates');
- if ($query->num_rows() == 0)
- {
- $this->db->insert('templates', array(
- 'group_id' => $group_id,
- 'template_name' => 'index',
- 'edit_date' => $this->localize->now,
- 'site_id' => $this->config->item('site_id')
- ));
- }
- else
- {
- $old_channel_name = '';
- foreach ($query->result_array() as $row)
- {
- if ($old_channel_name == '')
- {
- if (preg_match_all("/channel=[\"'](.+?)[\"']/", $row['template_data'], $matches))
- {
- for ($i = 0; $i < count($matches['1']); $i++)
- {
- if (substr($matches['1'][$i], 0, 1) != '{')
- {
- $old_channel_name = $matches['1'][$i];
- break;
- }
- }
- }
- }
- $temp = str_replace('channel="'.$old_channel_name.'"', 'channel="'.$_POST['channel_name'].'"', $row['template_data']);
- $temp = str_replace("channel='".$old_channel_name."'", 'channel="'.$_POST['channel_name'].'"', $temp);
- $temp = preg_replace("/{stylesheet=.+?\/(.+?)}/", "{stylesheet=".$group_name."/\\1}", $temp);
- $temp = preg_replace("#preload_replace:master_channel_name=\".+?\"#", 'preload_replace:master_channel_name="'.$_POST['channel_name'].'"', $temp);
- $temp = preg_replace("#preload_replace:master_channel_name=\'.+?\'#", "preload_replace:master_channel_name='".$_POST['channel_name']."'", $temp);
- $temp = preg_replace('#preload_replace:my_template_group=(\042|\047)([^\\1]*?)\\1#', "preload_replace:my_template_group=\\1{$group_name}\\1", $temp);
- $temp = preg_replace("#".$old_group_name."/(.+?)#", $group_name."/\\1", $temp);
- $data = array(
- 'group_id' => $group_id,
- 'template_name' => $row['template_name'],
- 'template_notes' => $row['template_notes'],
- 'cache' => $row['cache'],
- 'refresh' => $row['refresh'],
- 'no_auth_bounce' => $row['no_auth_bounce'],
- 'php_parse_location' => $row['php_parse_location'],
- 'allow_php' => ($this->session->userdata['group_id'] == 1) ? $row['allow_php'] : 'n',
- 'template_type' => $row['template_type'],
- 'template_data' => $temp,
- 'edit_date' => $this->localize->now,
- 'last_author_id' => 0,
- 'site_id' => $this->config->item('site_id')
- );
- $this->db->insert('templates', $data);
- }
- }
- }
- else
- {
- $type = 'core';
- if ($fp = @opendir(PATH_MOD))
- {
- while (FALSE !== ($file = readdir($fp)))
- {
- if (strpos($file, '.') === FALSE)
- {
- if ($file == 'mailinglist')
- {
- $type = 'full';
- break;
- }
- }
- }
- closedir($fp);
- }
- require PATH_THEMES.'site_themes/'.$template_theme.'/'.$template_theme.'.php';
- foreach ($template_matrix as $tmpl)
- {
- $Q[] = array($tmpl['0'](), "INSERT INTO exp_templates(group_id, template_name, template_type, template_data, edit_date, site_id)
- VALUES ('$group_id', '".$this->db->escape_str($tmpl['0'])."', '".$this->db->escape_str($tmpl['1'])."', '{template}', '".$this->localize->now."', '".$this->db->escape_str($this->config->item('site_id'))."')");
- }
- if ($add_rss == TRUE)
- {
- require PATH_THEMES.'site_themes/rss/rss.php';
- $Q[] = array(rss_2(), "INSERT INTO exp_templates(group_id, template_name, template_type, template_data, edit_date, site_id)
- VALUES ('$group_id', 'rss_2.0', 'feed', '{template}', '".$this->db->escape_str($this->localize->now)."', '".$this->db->escape_str($this->config->item('site_id'))."')");
- $Q[] = array(atom(), "INSERT INTO exp_templates(group_id, template_name, template_type, template_data, edit_date, site_id)
- VALUES ('$group_id', 'atom', 'feed', '{template}', '".$this->db->escape_str($this->localize->now)."', '".$this->db->escape_str($this->config->item('site_id'))."')");
- }
- foreach ($Q as $val)
- {
- $temp = $val['0'];
- $temp = str_replace('channel="channel1"', 'channel="'.$_POST['channel_name'].'"', $temp);
- $temp = str_replace("channel='channel1'", 'channel="'.$_POST['channel_name'].'"', $temp);
- $temp = str_replace('my_channel="channel1"', 'my_channel="'.$_POST['channel_name'].'"', $temp);
- $temp = str_replace("my_channel='channel1'", 'my_channel="'.$_POST['channel_name'].'"', $temp);
- $temp = str_replace('channel="default_site"', 'channel="'.$_POST['channel_name'].'"', $temp);
- $temp = str_replace("channel='default_site'", 'channel="'.$_POST['channel_name'].'"', $temp);
- $temp = str_replace('my_channel="default_site"', 'my_channel="'.$_POST['channel_name'].'"', $temp);
- $temp = str_replace("my_channel='default_site'", 'my_channel="'.$_POST['channel_name'].'"', $temp);
- $temp = str_replace('my_template_group="site"', 'my_template_group="'.$group_name.'"', $temp);
- $temp = str_replace("my_template_group='site'", 'my_template_group="'.$group_name.'"', $temp);
- $temp = str_replace("{stylesheet=channel/channel_css}", "{stylesheet=".$group_name."/site_css}", $temp);
- $temp = str_replace("{stylesheet=site/site_css}", "{stylesheet=".$group_name."/site_css}", $temp);
- $temp = str_replace('preload_replace:master_channel_name="channel1"', 'preload_replace:master_channel_name="'.$_POST['channel_name'].'"', $temp);
- $temp = preg_replace("#channel/(.+?)#", $group_name."/\\1", $temp);
- $temp = addslashes($temp);
- $sql = str_replace('{template}', $temp, $val['1']);
- $this->db->query($sql);
- }
- }
- }
- }
- $cp_message = $success_msg.NBS.NBS.$_POST['channel_title'];
- $this->session->set_flashdata('message_success', $cp_message);
- if ($edit == FALSE OR $return === TRUE)
- {
- $this->functions->redirect(BASE.AMP.'C=admin_content'.AMP.'M=channel_management');
- }
- else
- {
- $this->functions->redirect(BASE.AMP.'C=admin_content'.AMP.'M=channel_edit&channel_id='.$channel_id);
- }
- }
- // --------------------------------------------------------------------
- /**
- * Channel Update Group Assignments
- *
- * This function processes changes to the channel's
- * assigned groups
- *
- * @access public
- * @return void
- */
- function channel_update_group_assignments()
- {
- $this->_restrict_prefs_access();
- $update_fields = FALSE;
- $channel_id = $this->input->post('channel_id');
- $data['field_group'] = ($this->input->post('field_group') != FALSE && $this->input->post('field_group') != '') ? $this->input->post('field_group') : NULL;
- $data['status_group'] = ($this->input->post('status_group') != FALSE && $this->input->post('status_group') != '') ? $this->input->post('status_group') : NULL;
- $this->lang->loadfile('admin_content');
- if (isset($_POST['cat_group']) && is_array($_POST['cat_group']))
- {
- $data['cat_group'] = ltrim(implode('|', $_POST['cat_group']), '|');
- }
-
- if ( ! isset($data['cat_group']) OR $data['cat_group'] == '')
- {
- $data['cat_group'] = '';
- }
-
- // Find the old custom fields so we can remove them
- // Have the field assignments changed
- $this->db->select('cat_group, status_group, field_group');
- $this->db->where('channel_id', $channel_id);
- $query = $this->db->get('channels');
- if ($query->num_rows() == 1)
- {
- $old_cat = $query->row('cat_group');
- $old_status = $query->row('status_group');
- $old_field = $query->row('field_group');
- }
- if ($old_field != $data['field_group'] && ! is_null($old_field))
- {
- $update_fields = TRUE;
-
- $this->db->select('field_id');
- $this->db->where('group_id', $old_field);
- $query = $this->db->get('channel_fields');
-
- if ($query->num_rows() > 0)
- {
- foreach($query->result() as $row)
- {
- $tabs[] = $row->field_id;
- }
-
- $this->load->library('layout');
- $this->layout->delete_layout_fields($tabs, $channel_id);
- unset($tabs);
- }
- }
-
- $this->db->where('channel_id', $channel_id);
- $this->db->update('channels', $data);
- // Updated saved layouts if field group changed
- if ($update_fields == TRUE && ! is_null($data['field_group']))
- {
- $this->db->select('field_id');
- $this->db->where('group_id', $data['field_group']);
- $query = $this->db->get('channel_fields');
- if ($query->num_rows() > 0)
- {
- foreach($query->result() as $row)
- {
- $tabs['publish'][$row->field_id] = array(
- 'visible' => 'true',
- 'collapse' => 'false',
- 'htmlbuttons' => 'true',
- 'width' => '100%'
- );
-
- }
-
- $this->load->library('layout');
- $this->layout->add_layout_fields($tabs, $channel_id);
- }
- }
- $success_msg = lang('channel_updated');
- $cp_message = $success_msg.NBS.NBS.$_POST['channel_title'];
- $this->session->set_flashdata('message_success', $cp_message);
- $this->functions->redirect(BASE.AMP.'C=admin_content'.AMP.'M=channel_management');
- }
- // --------------------------------------------------------------------
- /**
- * Edit Channel
- *
- * This function displays the form used to edit the various
- * preferences and group assignments for a given channel
- *
- * @access public
- * @return void
- */
- function channel_edit_group_assignments()
- {
- $this->_restrict_prefs_access();
- // If we don't have the $channel_id variable, bail out.
- $channel_id = $this->input->get_post('channel_id');
- if ($channel_id == '' OR ! is_numeric($channel_id))
- {
- show_error(lang('not_authorized'));
- }
- $this->lang->loadfile('admin_content');
- $this->load->model(array(
- 'channel_model', 'category_model', 'status_model', 'field_model'
- ));
- $query = $this->channel_model->get_channel_info($channel_id);
- foreach ($query->row_array() as $key => $val)
- {
- if ($key == 'cat_group')
- {
- $val = explode('|', $val);
- }
-
- $vars[$key] = $val;
- }
-
- $vars['form_hidden'] = array(
- 'channel_id' => $channel_id,
- 'channel_name' => $vars['channel_name'],
- 'channel_title' => $vars['channel_title'],
- 'return' => 1
- );
- // Category Select List
- $query = $this->category_model->get_category_groups('', FALSE, 2);
- $vars['cat_group_options'][''] = lang('none');
- if ($query->num_rows() > 0)
- {
- foreach ($query->result() as $row)
- {
- $vars['cat_group_options'][$row->group_id] = $row->group_name;
- }
- }
- // Status group select list
- $this->db->select('group_id, group_name');
- $this->db->where('site_id', $this->config->item('site_id'));
- $this->db->order_by('group_name');
-
- $query = $this->db->get('status_groups');
- $vars['status_group_options'][''] = lang('none');
- if ($query->num_rows() > 0)
- {
- foreach ($query->result() as $row)
- {
- $vars['status_group_options'][$row->group_id] = $row->group_name;
- }
- }
- // Field group select list
- $this->db->select('group_id, group_name');
- $this->db->where('site_id', $this->config->item('site_id'));
- $this->db->order_by('group_name');
-
- $query = $this->db->get('field_groups');
- $vars['field_group_options'][''] = lang('none');
- if ($query->num_rows() > 0)
- {
- foreach ($query->result() as $row)
- {
- $vars['field_group_options'][$row->group_id] = $row->group_name;
- }
- }
- $this->javascript->compile();
- $this->cp->set_variable('cp_page_title', lang('edit_group_assignments'));
- $this->cp->set_breadcrumb(BASE.AMP.'C=admin_content'.AMP.'M=channel_management', lang('channels'));
- $this->load->view('admin/channel_edit_group_assignments', $vars);
- }
- // --------------------------------------------------------------------
- /**
- * Delete channel confirm
- *
- * @access public
- * @return void
- */
- function channel_delete_confirm()
- {
- $this->_restrict_prefs_access();
- $channel_id = $this->input->get_post('channel_id');
- if ($channel_id == '' OR ! is_numeric($channel_id))
- {
- show_error(lang('not_authorized'));
- }
- $this->lang->loadfile('admin_content');
- $this->load->model('channel_model');
- $this->cp->set_variable('cp_page_title', lang('delete_channel'));
- $this->cp->set_breadcrumb(BASE.AMP.'C=admin_content'.AMP.'M=channel_management', lang('channels'));
- $vars['form_action'] = 'C=admin_content'.AMP.'M=channel_delete';
- $vars['form_extra'] = '';
- $vars['form_hidden']['channel_id'] = $channel_id;
- $vars['message'] = lang('delete_channel_confirmation');
- // Grab category_groups locations with this id
- $items = $this->channel_model->get_channel_info($channel_id);
- $vars['items'] = array();
- foreach($items->result() as $item)
- {
- $vars['items'][] = $item->channel_title;
- }
- $this->javascript->compile();
- $this->load->view('admin/preference_delete_confirm', $vars);
- }
- // --------------------------------------------------------------------
- /**
- * Delete channel
- *
- * This function deletes a given channel
- *
- * @access public
- * @return void
- */
- function channel_delete()
- {
- $this->_restrict_prefs_access();
- $channel_id = $this->input->get_post('channel_id');
- if ($channel_id == '' OR ! is_numeric($channel_id))
- {
- show_error(lang('not_authorized'));
- }
- $this->lang->loadfile('admin_content');
- $this->load->model('channel_model');
- $query = $this->channel_model->get_channel_info($channel_id);
- if ($query->num_rows() == 0)
- {
- $this->functions->redirect(BASE.AMP.'C=admin_content'.AMP.'M=channel_management');
- }
- $channel_title = $query->row('channel_title') ;
- $this->logger->log_action(lang('channel_deleted').NBS.NBS.$channel_title);
- $this->db->select('entry_id, author_id');
- $this->db->where('channel_id', $channel_id);
- $query = $this->db->get('channel_titles');
- $entries = array();
- $authors = array();
- if ($query->num_rows() > 0)
- {
- foreach ($query->result() as $row)
- {
- $entries[] = $row->entry_id;
- $authors[] = $row->author_id;
- }
- }
- $authors = array_unique($authors);
- $this->channel_model->delete_channel($channel_id, $entries, $authors);
-
- // Clear saved layouts
- $this->load->library('layout');
- $this->layout->delete_channel_layouts($channel_id);
- $this->session->set_flashdata('message_success', lang('channel_deleted').NBS.$channel_title);
- $this->functions->redirect(BASE.AMP.'C=admin_content'.AMP.'M=channel_management');
- }
- // --------------------------------------------------------------------
- /**
- * Category Management
- *
- * Creates the Category Management main page
- *
- * @access public
- * @return void
- */
- function category_management()
- {
- if (AJAX_REQUEST)
- {
- if ( ! $this->cp->allowed_group('can_edit_categories'))
- {
- show_error(lang('unauthorized_access'));
- }
- }
- else
- {
- $this->_restrict_prefs_access();
- }
- $this->load->library('table');
- $this->load->model('category_model');
- $this->lang->loadfile('admin_content');
- $this->cp->set_variable('cp_page_title', lang('categories'));
- $this->jquery->tablesorter('.mainTable', '{
- headers: {2: {sorter: false}, 3: {sorter: false}, 4: {sorter: false}, 5: {sorter: false}},
- widgets: ["zebra"]
- }');
- $this->javascript->compile();
- // Fetch count of custom fields per group
- $cfcount = array();
-
- $this->db->select('COUNT(*) AS count, group_id');
- $this->db->group_by('group_id');
- $cfq = $this->db->get('category_fields');
-
- if ($cfq->num_rows() > 0)
- {
- foreach ($cfq->result() as $row)
- {
- $cfcount[$row->group_id] = $row->count;
- }
- }
- $cat_count = 1;
- $vars['categories'] = array();
- $categories = $this->category_model->get_categories('', FALSE);
- foreach($categories->result() as $row)
- {
- $this->db->where('group_id', $row->group_id);
- $category_count = $this->db->count_all_results('categories');
-
- $vars['categories'][$cat_count]['group_id'] = $row->group_id;
- $vars['categories'][$cat_count]['group_name'] = $row->group_name;
- $vars['categories'][$cat_count]['category_count'] = $category_count;
- $vars['categories'][$cat_count]['custom_field_count'] = ((isset($cfcount[$row->group_id])) ? $cfcount[$row->group_id] : '0');
- $cat_count++;
- }
- $this->cp->set_right_nav(array('create_new_category_group' => BASE.AMP.'C=admin_content'.AMP.'M=edit_category_group'));
- $this->load->view('admin/category_management', $vars);
- }
- // --------------------------------------------------------------------
- /**
- * Edit Category Group
- *
- * This function shows the form used to define a new category
- * group or edit an existing one
- *
- * @access public
- * @return mixed
- */
- function edit_category_group()
- {
- $this->_restrict_prefs_access();
- $this->load->model('admin_model');
- $this->load->model('category_model');
- $this->lang->loadfile('admin_content');
- $this->load->library('table');
- $this->cp->set_breadcrumb(BASE.AMP.'C=admin_content'.AMP.'M=category_management', lang('categories'));
- // Set default values
- $vars['cp_page_title'] = lang('create_new_category_group');
- $vars['submit_lang_key'] = 'submit';
- $vars['form_hidden'] = array(); // nothing needs to be passed into a new cat group
- $vars['group_name'] = '';
- $vars['field_html_formatting'] = 'all';
- $vars['can_edit'] = array();
- $vars['can_delete'] = array();
- $vars['can_edit_selected'] = array();
- $vars['can_delete_selected'] = array();
- $vars['formatting_options'] = array(
- 'none' => lang('convert_to_entities'),
- 'safe' => lang('allow_safe_html'),
- 'all' => lang('allow_all_html')
- );
- $can_edit_selected = array();
- $can_delete_selected = array();
- $vars['can_edit_categories'] = '';
- $vars['can_delete_categories'] = '';
- $group_id = $this->input->get_post('group_id');
- // If we have the group_id variable, it's an edit request, so fetch the category data
- if ($group_id != '')
- {
- if ( ! is_numeric($group_id))
- {
- show_error();
- }
- // some defaults to overwrite if we're editing
- $vars['cp_page_title'] = lang('edit_category_group');
- $vars['submit_lang_key'] = 'update';
- $vars['form_hidden']['group_id'] = $group_id;
- $this->db->where('group_id', $group_id);
- $this->db->where('site_id', $this->config->item('site_id'));
- $this->db->from('category_groups');
- $this->db->order_by('group_name');
- $query = $this->db->get();
- // there's only 1 possible category
- foreach ($query->row_array() as $key => $val)
- {
- $vars[$key] = $val;
- }
- // convert our | separated list of privileges into an array
- $can_edit_selected = explode('|', rtrim($vars['can_edit_categories'], '|'));
- $can_delete_selected = explode('|', rtrim($vars['can_delete_categories'], '|'));
- }
- // Grab member groups with potential privs
- $this->db->select('group_id, group_title, can_edit_categories, can_delete_categories');
- $this->db->where_not_in('group_id', array(1,2,3,4));
- $this->db->where('site_id', $this->config->item('site_id'));
- $query = $this->db->get('member_groups');
- $vars['can_edit_checks'] = array();
- $vars['can_delete_checks'] = array();
- // Can Edit/Delete Categories selected
- foreach ($query->result_array() as $row)
- {
- if ($row['can_edit_categories'] == 'y')
- {
- $vars['can_edit_checks'][$row['group_id']]['id'] = $row['group_id'];
- $vars['can_edit_checks'][$row['group_id']]['value'] = $row['group_title'];
- $vars['can_edit_checks'][$row['group_id']]['checked'] = (in_array($row['group_id'], $can_edit_selected)) ? TRUE : FALSE;
- $vars['can_edit'][$row['group_id']] = $row['group_title'];
- }
- if ($row['can_delete_categories'] == 'y')
- {
- $vars['can_delete_checks'][$row['group_id']]['id'] = $row['group_id'];
- $vars['can_delete_checks'][$row['group_id']]['value'] = $row['group_title'];
- $vars['can_delete_checks'][$row['group_id']]['checked'] = (in_array($row['group_id'], $can_delete_selected)) ? TRUE : FALSE;
- $vars['can_delete'][$row['group_id']] = $row['group_title'];
- }
- }
-
- // Get the selected 'excluded' group
- $vars['exclude_selected'] = (isset($vars['exclude_group'])) ? $vars['exclude_group'] : FALSE;
-
- $this->javascript->compile();
- $this->load->view('admin/edit_category_group', $vars);
- }
- // --------------------------------------------------------------------
- /**
- * Update Category Group
- *
- * This function receives the submission from the group
- * form and stores it in the database
- *
- * @access public
- * @return void
- */
- function update_category_group()
- {
- $this->_restrict_prefs_access();
- // If the $group_id variable is present we are editing an
- // existing group, otherwise we are creating a new one
- $edit = ($this->input->post('group_id') != '') ? TRUE : FALSE;
- if ($this->input->post('group_name') == '')
- {
- $this->functions->redirect(BASE.AMP.'C=admin_content'.AMP.'M=category_management');
- }
- // this should never happen, but protect ourselves!
- if ( ! isset($_POST['field_html_formatting']) OR ! in_array($_POST['field_html_formatting'], array('all', 'none', 'safe')))
- {
- $this->functions->redirect(BASE.AMP.'C=admin_content'.AMP.'M=category_management');
- }
- $this->lang->loadfile('admin_content');
- // check for bad characters in group name
- if ( ! preg_match("#^[a-zA-Z0-9_\-/\s]+$#i", $_POST['group_name']))
- {
- show_error(lang('illegal_characters'));
- }
- $this->load->model('category_model');
- // Is the group name taken?
- if ($this->category_model->is_duplicate_category_group($this->input->post('group_name'), $this->input->post('group_id')))
- {
- show_error(lang('taken_category_group_name'));
- }
- // make data array of variables from our POST data
- $data = array();
- foreach ($_POST as $key => $val)
- {
- // we can ignore some unwanted keys before INSERTing / UPDATEing
- if (strpos($key, 'can_edit_categories_') !== FALSE OR strpos($key, 'can_delete_categories_') !== FALSE OR strpos($key, 'submit') !== FALSE)
- {
- continue;
- }
- $data[$key] = $val;
- }
- // Set our pipe delimited privileges for edit / delete
- if (isset($data['can_edit_categories']) and is_array($data['can_edit_categories']))
- {
- $data['can_edit_categories'] = implode('|', $data['can_edit_categories']);
- }
- else
- {
- $data['can_edit_categories'] = '';
- }
- if (isset($data['can_delete_categories']) and is_array($data['can_delete_categories']))
- {
- $data['can_delete_categories'] = implode('|', $data['can_delete_categories']);
- }
- else
- {
- $data['can_delete_categories'] = '';
- }
- // Construct the query based on whether we are updating or inserting
- if ($edit == FALSE)
- {
- $this->category_model->insert_category_group($data);
- $cp_message = lang('category_group_created').' '.$data['group_name'];
- $this->logger->log_action(lang('category_group_created').NBS.NBS.$data['group_name']);
- $this->db->select('channel_id');
- $this->db->where('site_id', $this->config->item('site_id'));
- $query = $this->db->get('channels');
- if ($query->num_rows() > 0)
- {
- $cp_message .= '<br />'.lang('assign_group_to_channel');
- if ($query->num_rows() == 1)
- {
- $link = 'C=admin_content'.AMP.'M=channel_edit_group_assignments'.AMP.'channel_id='.$query->row('channel_id') ;
- }
- else
- {
- $link = 'C=admin_content'.AMP.'M=channel_management';
- }
-
- $cp_message .= '<br /><a href="'.BASE.AMP.$link.'">'. lang('click_to_assign_group').'</a>';
- }
- }
- else
- {
- $this->category_model->update_category_group($data['group_id'], $data);
- $cp_message = lang('category_group_updated').NBS.$data['group_name'];
- }
- $this->session->set_flashdata('message_success', $cp_message);
- $this->functions->redirect(BASE.AMP.'C=admin_content'.AMP.'M=category_management');
- }
- // --------------------------------------------------------------------
- /**
- * Delete category group confirm
- *
- * Warning message if you try to delete a category group
- *
- * @access public
- * @return mixed
- */
- function category_group_delete_conf()
- {
- $this->_restrict_prefs_access();
- $group_id = $this->input->get_post('group_id');
- if ($group_id == '' OR ! is_numeric($group_id))
- {
- show_error(lang('not_authorized'));
- }
- $this->lang->loadfile('admin_content');
- $this->load->model('category_model');
- $this->cp->set_variable('cp_page_title', lang('delete_group'));
- $this->cp->set_breadcrumb(BASE.AMP.'C=admin_content'.AMP.'M=category_management', lang('categories'));
- $vars['form_action'] = 'C=admin_content'.AMP.'M=category_group_delete';
- $vars['form_extra'] = '';
- $vars['form_hidden']['group_id'] = $group_id;
- $vars['message'] = lang('delete_cat_group_confirmation');
- // Grab category_groups locations with this id
- $items = $this->category_model->get_category_group_name($group_id);
- $vars['items'] = array();
- foreach($items->result() as $item)
- {
- $vars['items'][] = $item->group_name;
- }
- $this->javascript->compile();
- $this->load->view('admin/preference_delete_confirm', $vars);
- }
- // --------------------------------------------------------------------
- /**
- * Delete category group
- *
- * This function deletes the category group and all associated categories
- *
- * @access public
- * @return void
- */
- function category_group_delete()
- {
- $this->_restrict_prefs_access();
- $group_id = $this->input->get_post('group_id');
- if ($group_id == '' OR ! is_numeric($group_id))
- {
- show_error(lang('not_authorized'));
- }
- $this->lang->loadfile('admin_content');
- $this->load->model('category_model');
- $category = $this->category_model->get_category_group_name($group_id);
- if ($category->num_rows() == 0)
- {
- show_error(lang('not_authorized'));
- }
- $name = $category->row('group_name');
- // Delete from exp_category_posts
- $this->category_model->delete_category_group($group_id);
- $this->logger->log_action(lang('category_group_deleted').NBS.NBS.$name);
- $this->functions->clear_caching('all', '', TRUE);
- $this->session->set_flashdata('message_success', lang('category_group_deleted').NBS.NBS.$name);
- $this->functions->redirect(BASE.AMP.'C=admin_content'.AMP.'M=category_management');
- }
- // --------------------------------------------------------------------
- /**
- * Category management page
- *
- * This function shows the list of current categories, as
- * well as the form used to submit a new category
- *
- * @access public
- * @return void
- */
- function category_editor($group_id = '', $update = FALSE)
- {
- if (AJAX_REQUEST)
- {
- $vars['EE_view_disable'] = TRUE;
-
- if ( ! $this->cp->allowed_group('can_edit_categories'))
- {
- show_error(lang('unauthorized_access'));
- }
- }
- else
- {
- $this->_restrict_prefs_access();
- }
- $this->lang->loadfile('admin_content');
- $this->load->model('category_model');
- $this->load->library('table');
- $this->load->library('api');
-
- $this->api->instantiate('channel_categories');
-
- $this->cp->set_breadcrumb(BASE.AMP.'C=admin_content'.AMP.'M=category_m…
Large files files are truncated, but you can click here to view the full file