/html/AppCode/expressionengine/controllers/cp/design.php
PHP | 4632 lines | 3155 code | 906 blank | 571 comment | 575 complexity | 54567a43fef52bd10171d50df890d34b MD5 | raw file
Possible License(s): AGPL-3.0
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 ExpressionEngine Dev Team
- * @copyright Copyright (c) 2003 - 2010, EllisLab, Inc.
- * @license http://expressionengine.com/user_guide/license.html
- * @link http://expressionengine.com
- * @since Version 2.0
- * @filesource
- */
-
- // ------------------------------------------------------------------------
- /**
- * ExpressionEngine CP Home Page Class
- *
- * @package ExpressionEngine
- * @subpackage Control Panel
- * @category Control Panel
- * @author ExpressionEngine Dev Team
- * @link http://expressionengine.com
- */
- class Design extends Controller {
- var $sub_breadcrumbs = array();
- // Reserved Template names
- var $reserved_names = array('act', 'css');
-
- // Reserved Global Variable names
- var $reserved_vars = array(
- 'lang',
- 'charset',
- 'homepage',
- 'debug_mode',
- 'gzip_mode',
- 'version',
- 'elapsed_time',
- 'hits',
- 'total_queries',
- 'XID_HASH'
- );
- /**
- * Constructor
- *
- * @access public
- */
- function Design()
- {
- parent::Controller();
- if ( ! $this->cp->allowed_group('can_access_design'))
- {
- show_error($this->lang->line('unauthorized_access'));
- }
- $this->load->model('template_model');
- $this->lang->loadfile('design');
-
- $this->javascript->compile();
- if ($this->cp->allowed_group('can_admin_templates'))
- {
- $this->sub_breadcrumbs = array(
- 'global_variables' => BASE.AMP.'C=design'.AMP.'M=global_variables',
- 'snippets' => BASE.AMP.'C=design'.AMP.'M=snippets',
- 'sync_templates' => BASE.AMP.'C=design'.AMP.'M=sync_templates',
- 'global_template_preferences' => BASE.AMP.'C=design'.AMP.'M=global_template_preferences',
- 'template_preferences_manager' => BASE.AMP.'C=design'.AMP.'M=template_preferences_manager'
- );
- }
- $this->cp->set_variable('wiki_installed', (bool) $this->db->table_exists('wikis'));
- $this->cp->set_variable('forum_installed', (bool) $this->db->table_exists('forums'));
- }
-
- // --------------------------------------------------------------------
- /**
- * Index function
- *
- * @access public
- * @return void
- */
- function index()
- {
- if ( ! $this->cp->allowed_group('can_access_design'))
- {
- show_error($this->lang->line('unauthorized_access'));
- }
- $this->cp->set_variable('cp_page_title', $this->lang->line('design'));
-
- $this->javascript->output($this->javascript->slidedown("#adminTemplatesSubmenu"));
- $this->javascript->compile();
- $this->load->vars(array('controller'=>'design'));
- $this->load->view('_shared/overview');
- }
-
- // --------------------------------------------------------------------
-
- /**
- * New Template
- *
- * Create a new template
- *
- * @access public
- * @return type
- */
- function template_group_pick($edit = FALSE)
- {
- if ( ! $this->cp->allowed_group('can_access_design'))
- {
- show_error($this->lang->line('unauthorized_access'));
- }
- $group_id = $this->input->get_post('id');
- if ($group_id != '')
- {
- $this->new_template('', $group_id);
- }
- $this->load->model('template_model');
- $this->lang->loadfile('admin_content');
- $this->cp->set_variable('cp_page_title', $this->lang->line('new_template_form'));
- $this->javascript->compile();
- $template_groups_query = $this->template_model->get_template_groups();
- $vars['template_groups'] = $template_groups_query->result_array();
- $vars['link_to_method'] = ($edit) ? 'edit_template_group' : 'new_template';
- // if this isn't an admin, then unset any template
- // groups they aren't allowed to admin
- if ($this->session->userdata['group_id'] != 1)
- {
- foreach($vars['template_groups'] as $index=>$group)
- {
- if ( ! array_key_exists($group['group_id'], $this->session->userdata['assigned_template_groups']))
- {
- unset($vars['template_groups'][$index]);
- }
- }
- }
- $this->load->view('design/new_template_group_pick', $vars);
- }
- // --------------------------------------------------------------------
-
- /**
- * Delete Template Group
- *
- * Create a new template
- *
- * @access public
- * @return type
- */
- function delete_template_group_pick()
- {
- if ( ! $this->cp->allowed_group('can_access_design'))
- {
- show_error($this->lang->line('unauthorized_access'));
- }
-
- $group_id = $this->input->get_post('id');
- if ($group_id != '')
- {
- $this->manager();
- }
- $this->load->model('template_model');
- $this->lang->loadfile('admin_content');
- $this->cp->set_variable('cp_page_title', $this->lang->line('new_template_form'));
- $template_groups_query = $this->template_model->get_template_groups();
- $vars['template_groups'] = $template_groups_query->result_array();
- // if this isn't an admin, then unset any template
- // groups they aren't allowed to admin
- if ($this->session->userdata['group_id'] != 1)
- {
- foreach($vars['template_groups'] as $index=>$group)
- {
- if ( ! array_key_exists($group['group_id'], $this->session->userdata['assigned_template_groups']))
- {
- unset($vars['template_groups'][$index]);
- }
- }
- }
- $this->javascript->compile();
- $this->load->view('design/delete_template_group', $vars);
- }
- // --------------------------------------------------------------------
- /**
- * Template Delete Confirm
- */
- function template_group_delete_confirm()
- {
- if ( ! $this->cp->allowed_group('can_access_design') OR ! $this->cp->allowed_group('can_admin_templates'))
- {
- show_error($this->lang->line('unauthorized_access'));
- }
-
- $group_id = $this->input->get_post('group_id');
- if ($group_id == '')
- {
- $this->manager();
- }
- if ( ! is_numeric($group_id))
- {
- show_error('id_not_found');
- }
- $this->load->model('template_model');
- $this->load->helper('form');
- $query = $this->template_model->get_group_info($group_id);
- $group_id = $query->row('group_id') ;
- $vars['template_group_name'] = $query->row('group_name') ;
- if ( ! $this->cp->allowed_group('can_admin_templates'))
- {
- if ( ! $this->_template_access_privs(array('group_id' => $group_id)))
- {
- show_error($this->lang->line('unauthorized_access'));
- }
- }
-
- $vars['file_folder'] = FALSE;
-
- // Check for associated group folder
- if ($this->config->item('save_tmpl_files') == 'y' AND $this->config->item('tmpl_file_basepath') != '')
- {
- $basepath = $this->config->slash_item('tmpl_file_basepath');
- $basepath .= $this->config->item('site_short_name').'/'.$vars['template_group_name'].'.group/';
-
- $vars['file_folder'] = is_dir($basepath);
- }
- $vars['damned'] = array($group_id);
- $vars['cp_page_title'] = $this->lang->line('delete_template_group');
- $this->cp->set_breadcrumb(BASE.AMP.'C=design'.AMP.'M=manager'.AMP.'tgpref='.$group_id, $this->lang->line('template_manager'));
- $vars['form_hidden']['group_id'] = $group_id;
- $this->javascript->compile();
- $this->load->view('design/template_group_delete_confirm', $vars);
- }
- // --------------------------------------------------------------------
- /** -------------------------------
- /** Delete Template Group
- /** -------------------------------*/
- function template_group_delete()
- {
- if ( ! $this->cp->allowed_group('can_access_design') OR ! $this->cp->allowed_group('can_admin_templates'))
- {
- show_error($this->lang->line('unauthorized_access'));
- }
-
- // if the hidden group_id field is not set, they might be here by accident.
- if ( ! $this->input->post('group_id'))
- {
- show_error($this->lang->line('unauthorized_access'));
- }
- $group_id = $this->input->get_post('group_id');
- if ($group_id == '' OR ! is_numeric($group_id))
- {
- show_error($this->lang->line('unauthorized_access'));
- }
- // Delete the group folder if it exists
- if ($this->config->item('save_tmpl_files') == 'y' AND $this->config->item('tmpl_file_basepath') != '')
- {
- $this->db->select('group_name');
- $result = $this->db->get_where('template_groups', array('group_id' => $group_id));
- $basepath = $this->config->slash_item('tmpl_file_basepath');
- $basepath .= $this->config->item('site_short_name').'/'.$result->row('group_name').'.group/';
- $this->load->helper('file');
- delete_files($basepath, TRUE);
- @rmdir($basepath);
- }
- // We need to delete all the saved template data in the versioning table
- $this->db->select('template_id');
- $this->db->where('group_id', $group_id);
- $query = $this->db->get('templates');
-
- if ($query->num_rows() > 0)
- {
- $sql = "DELETE FROM exp_revision_tracker WHERE ";
- $sqlb = '';
-
- foreach ($query->result_array() as $row)
- {
- $sqlb .= " item_id = '".$row['template_id']."' OR";
- }
- $sqlb = substr($sqlb, 0, -2);
- $this->db->query($sql.$sqlb);
- $this->db->query("DELETE FROM exp_template_no_access WHERE ".str_replace('item_id', 'template_id', $sqlb));
- $this->db->query("DELETE FROM exp_templates WHERE group_id = '$group_id'");
- }
- $this->db->query("DELETE FROM exp_template_groups WHERE group_id = '$group_id'");
- $this->session->set_flashdata('message_success', $this->lang->line('template_group_deleted'));
- $this->functions->redirect(BASE.AMP.'C=design'.AMP.'M=manager');
- }
- // --------------------------------------------------------------------
- /**
- * New Template
- *
- * Create a new template
- *
- * @access public
- * @return type
- */
- function new_template($message = '', $group_id = '')
- {
- if ( ! $this->cp->allowed_group('can_access_design') OR ! $this->cp->allowed_group('can_admin_templates'))
- {
- show_error($this->lang->line('unauthorized_access'));
- }
- if ($group_id == '')
- {
- $group_id = $this->input->get_post('group_id');
- }
- // if its still blank, make them choose a template
- if ($group_id == '')
- {
- return $this->template_group_pick();
- }
- if ( ! $this->_template_access_privs(array('group_id' => $group_id)))
- {
- show_error($this->lang->line('unauthorized_access'));
- }
- $this->load->model('template_model');
- $this->load->helper('form');
- $this->load->library('table');
- $templates = $this->template_model->get_templates($this->config->item('site_id'));
- $vars['templates'] = array();
- foreach($templates->result() as $template)
- {
- $vars['templates'][$template->group_name][$template->template_id] = $template->template_name;
- }
- $vars['form_hidden']['group_id'] = $group_id;
- //create_new_template
- $this->cp->set_variable('cp_page_title', $this->lang->line('new_template_form'));
- $this->cp->set_breadcrumb(BASE.AMP.'C=design'.AMP.'M=manager'.AMP.'tgpref='.$group_id, $this->lang->line('template_manager'));
- $templates = $this->template_model->get_templates($this->config->item('site_id'));
- $vars['templates'] = array();
- foreach($templates->result() as $template)
- {
- $vars['templates'][$template->group_name][$template->template_id] = $template->template_name;
- }
- $this->javascript->compile();
- $this->load->view('design/new_template', $vars);
- }
- // --------------------------------------------------------------------
-
- /**
- * New Template Group
- *
- * Create a new template group
- *
- * @access public
- * @return type
- */
- function new_template_group()
- {
- if ( ! $this->cp->allowed_group('can_access_design') OR ! $this->cp->allowed_group('can_admin_templates'))
- {
- show_error($this->lang->line('unauthorized_access'));
- }
- $this->load->helper('form');
-
- $this->cp->set_variable('cp_page_title', $this->lang->line('create_new_template_group'));
- $this->cp->set_breadcrumb(BASE.AMP.'C=design'.AMP.'M=manager', $this->lang->line('template_manager'));
- $this->load->model('template_model');
- $this->lang->loadfile('admin_content');
- $this->load->library('form_validation');
- $this->load->library('table');
- $this->form_validation->set_rules('group_name', 'lang:group_name', 'required|callback__group_name_checks');
- $this->form_validation->set_rules('duplicate_group', 'lang:duplicate_group', '');
- $this->form_validation->set_rules('is_site_default', 'lang:is_site_default', '');
- $this->form_validation->set_error_delimiters('<br /><span class="notice">', '</span>');
- $template_groups_query = $this->template_model->get_template_groups();
- $template_groups = $template_groups_query->result_array();
- // if this isn't an admin, then unset any template
- // groups they aren't allowed to admin
- if ($this->session->userdata['group_id'] != 1)
- {
- foreach($template_groups as $index=>$group)
- {
- if ( ! array_key_exists($group['group_id'], $this->session->userdata['assigned_template_groups']))
- {
- unset($template_groups[$index]);
- }
- }
- }
- // now that the groups are filtered, built the group output
- $vars['template_groups'] = array('false'=>$this->lang->line('do_not_duplicate_group'));
- foreach($template_groups as $group)
- {
- $vars['template_groups'][$group['group_id']] = $group['group_name'];
- }
- if ($this->form_validation->run() === TRUE)
- {
- $this->update_template_group();
- }
- else
- {
- $this->javascript->compile();
- $this->load->view('design/new_template_group', $vars);
- }
- }
- // --------------------------------------------------------------------
-
- /**
- * Global Template Preferences
- *
- * @access public
- * @return type
- */
- function global_template_preferences()
- {
- if ( ! $this->cp->allowed_group('can_access_design') OR ! $this->cp->allowed_group('can_admin_templates'))
- {
- show_error($this->lang->line('unauthorized_access'));
- }
-
- $this->load->model('template_model');
- $this->load->model('admin_model');
- $this->load->helper('form');
- $this->load->library('table');
- $this->jquery->tablesorter('.mainTable', '{
- headers: {2: {sorter: false}},
- widgets: ["zebra"]
- }');
-
- $this->cp->set_variable('cp_page_title', $this->lang->line('global_template_preferences'));
- $this->cp->set_breadcrumb(BASE.AMP.'C=design'.AMP.'M=manager', $this->lang->line('template_manager'));
-
- $vars['template_data'] = array('' => lang('none'));
-
- $templates = $this->template_model->get_templates();
-
- foreach ($templates->result() as $template)
- {
- $group_name = $template->group_name.'/'.$template->template_name;
- $vars['template_data'][$group_name] = $group_name;
- }
- $f_data = $this->admin_model->get_config_fields('template_cfg');
- foreach ($f_data as $conf => $val)
- {
- $vars[$conf] = $this->config->item($conf);
- }
- $vars['save_tmpl_revisions_options'] = array(
- 'n' => lang('no'),
- 'y' => lang('yes')
- );
-
- $vars['save_tmpl_files_options'] = array(
- 'n' => lang('no'),
- 'y' => lang('yes')
- );
-
- $vars['save_tmpl_files_n'] = TRUE;
- $vars['save_tmpl_files_y'] = FALSE;
- $vars['save_tmpl_revisions_n'] = TRUE;
- $vars['save_tmpl_revisions_y'] = FALSE;
- $vars['strict_urls_options'] = array(
- 'n' => lang('no'),
- 'y' => lang('yes')
- );
-
- if ($vars['save_tmpl_files'] && $vars['save_tmpl_files'] == 'y')
- {
- $vars['save_tmpl_files_n'] = FALSE;
- $vars['save_tmpl_files_y'] = TRUE;
- }
- if ($vars['save_tmpl_revisions'] && $vars['save_tmpl_revisions'] == 'y')
- {
- $vars['save_tmpl_revisions_n'] = FALSE;
- $vars['save_tmpl_revisions_y'] = TRUE;
- }
- $this->javascript->compile();
- $this->load->view('design/global_template_preferences', $vars);
- }
-
- function update_global_template_prefs()
- {
- if ( ! $this->cp->allowed_group('can_access_design') OR ! $this->cp->allowed_group('can_admin_templates'))
- {
- show_error($this->lang->line('unauthorized_access'));
- }
- //Just to be careful, let's strip out everything not a template conf
- $this->load->model('admin_model');
- $template_vars = array_keys($this->admin_model->get_config_fields('template_cfg'));
- foreach ($_POST as $key => $val)
- {
- if ( ! in_array($key, $template_vars))
- {
- unset($_POST[$key]);
- }
- }
- $this->config->update_site_prefs($_POST);
-
- $this->session->set_flashdata('message_success', $this->lang->line('preferences_updated'));
- $this->functions->redirect(BASE.AMP.'C=design'.AMP.'M=global_template_preferences');
- }
- // --------------------------------------------------------------------
- /**
- * Snippets
- *
- * Early-parsed variables for dynamic content
- *
- * @access public
- * @param string
- * @return void
- */
- function snippets()
- {
- if ( ! $this->cp->allowed_group('can_access_design') OR ! $this->cp->allowed_group('can_admin_templates'))
- {
- show_error($this->lang->line('unauthorized_access'));
- }
- $this->load->model('template_model');
- $this->load->helper('form');
- $this->load->library('table');
- $this->jquery->tablesorter('.mainTable', '{
- headers: {2: {sorter: false}},
- widgets: ["zebra"]
- }');
- $this->cp->set_breadcrumb(BASE.AMP.'C=design'.AMP.'M=manager', $this->lang->line('template_manager'));
- $this->cp->set_variable('cp_page_title', $this->lang->line('snippets'));
- $vars['snippets'] = $this->template_model->get_snippets();
- $vars['snippets_count'] = $vars['snippets']->num_rows();
- $vars['message'] = ($this->input->get_post('delete') !== FALSE) ? lang('variable_deleted') : FALSE;
- $vars['message'] = ($this->input->get_post('update') !== FALSE) ? lang('snippet_updated') : FALSE;
- $this->javascript->compile();
- $this->cp->set_right_nav(array(
- 'create_new_snippet' => BASE.AMP.'C=design'.AMP.'M=snippets_edit')
- );
-
- $this->load->view('design/snippets', $vars);
- }
- // --------------------------------------------------------------------
- /**
- * Edit/Create Snippets
- *
- * Displays the form for the creation/editing of Snippets
- *
- * @access public
- * @return void
- */
- function snippets_edit()
- {
- if ( ! $this->cp->allowed_group('can_access_design') OR ! $this->cp->allowed_group('can_admin_templates'))
- {
- show_error($this->lang->line('unauthorized_access'));
- }
-
- $this->load->model('template_model');
- $this->load->helper('form');
-
- // form defaults
- $vars = array(
- 'msm' => FALSE,
- 'update' => ($this->input->get_post('update') == 1),
- 'site_id' => $this->config->item('site_id'),
- 'all_sites' => FALSE,
- 'snippet_id' => NULL,
- 'snippet_name' => '',
- 'snippet_contents' => '',
- 'create_edit' => $this->lang->line('snippet_create')
- );
- if ($this->config->item('multiple_sites_enabled') == 'y')
- {
- $vars['msm'] = TRUE;
- }
- if ($this->input->get_post('snippet') !== FALSE)
- {
- if (($snippet = $this->template_model->get_snippet($this->input->get_post('snippet'), TRUE)) !== FALSE)
- {
- $snippet['snippet_site_id'] = $snippet['site_id'];
- unset($snippet['site_id']);
-
- $vars = array_merge($vars, $snippet);
- $vars['orig_name'] = $vars['snippet_name'];
- $vars['create_edit'] = sprintf($this->lang->line('snippet_edit'), $vars['snippet_name']);
- $vars['all_sites'] = ($snippet['snippet_site_id'] == 0) ? TRUE : FALSE;
- }
- }
- $this->cp->set_variable('cp_page_title', $vars['create_edit']);
- $this->cp->set_breadcrumb(BASE.AMP.'C=design'.AMP.'M=manager', $this->lang->line('template_manager'));
- $this->cp->set_breadcrumb(BASE.AMP.'C=design'.AMP.'M=snippets', $this->lang->line('snippets'));
-
- $this->javascript->compile();
- $this->load->view('design/snippets_edit', $vars);
- }
- // --------------------------------------------------------------------
-
- /**
- * Snippets Update
- *
- * Handles creating/updating of Snippets
- *
- * @access public
- * @return void
- */
- function snippets_update()
- {
- if ( ! $this->cp->allowed_group('can_access_design') OR ! $this->cp->allowed_group('can_admin_templates'))
- {
- show_error($this->lang->line('unauthorized_access'));
- }
- $this->load->model('template_model');
- $this->load->library('api');
-
- foreach (array('snippet_id', 'site_id', 'snippet_name', 'snippet_contents') as $var)
- {
- ${$var} = $this->input->get_post($var);
- }
-
- $update = FALSE;
-
- // is this an update?
- if ($snippet_id !== FALSE && ($snippet = $this->template_model->get_snippet($snippet_id)) !== FALSE)
- {
- $update = TRUE;
- }
-
- // validate name and contents
- if ($snippet_name == '' OR $snippet_contents == '' OR $site_id === FALSE)
- {
- show_error($this->lang->line('all_fields_required'));
- }
- elseif ($this->api->is_url_safe($snippet_name) === FALSE)
- {
- show_error($this->lang->line('illegal_characters'));
- }
- elseif (in_array($snippet_name, $this->cp->invalid_custom_field_names()))
- {
- show_error($this->lang->line('reserved_name'));
- }
-
- // validate site_id
- if ($site_id != $this->config->item('site_id') AND $site_id != 0)
- {
- $site_id = $this->config->item('site_id');
- }
-
- // looks okay!
- $data = array(
- 'snippet_name' => $snippet_name,
- 'snippet_contents' => $snippet_contents,
- 'site_id' => $site_id
- );
-
- if ($update === TRUE)
- {
- // if the var name is changing, make sure it's unique
- if ($snippet['snippet_name'] != $data['snippet_name'] && $this->template_model->unique_snippet_name($data['snippet_name']) !== TRUE)
- {
- show_error($this->lang->line('duplicate_snippet_name'));
- }
-
- $this->db->update('snippets', $data, array('snippet_id' => $snippet_id));
- $cp_message = $this->lang->line('snippet_updated');
- }
- else
- {
- // double check for uniqueness please. Note that since a variable might change from being for
- // one site to all sites at any time, we have to have strict uniqueness for all variables at all times.
- if ($this->template_model->unique_snippet_name($data['snippet_name']) !== TRUE)
- {
- show_error($this->lang->line('duplicate_snippet_name'));
- }
- $this->db->insert('snippets', $data);
- $cp_message = $this->lang->line('snippet_created');
- }
-
- // Clear caches- db and template cache my result in update not being reflected
- $this->functions->clear_caching('all');
- $this->session->set_flashdata('message_success', $cp_message);
- if ($this->input->get_post('update_and_return') !== FALSE)
- {
- $this->functions->redirect(BASE.AMP.'C=design'.AMP.'M=snippets'.AMP.'update=1');
- }
- else
- {
- $this->functions->redirect(BASE.AMP.'C=design'.AMP.'M=snippets_edit'.AMP.'snippet='.$snippet_name.AMP.'update=1');
- }
- }
- // --------------------------------------------------------------------
- /**
- * Delete Snippets
- *
- * Delete Delete I Eat Meat
- *
- * @access public
- * @return void
- */
- function snippets_delete()
- {
- if ( ! $this->cp->allowed_group('can_access_design') OR ! $this->cp->allowed_group('can_admin_templates'))
- {
- show_error($this->lang->line('unauthorized_access'));
- }
- $this->load->model('template_model');
- $this->load->helper('form');
-
- if (($snippet_id = $this->input->get_post('snippet_id')) === FALSE)
- {
- show_error($this->lang->line('unauthorized_access'));
- }
- if (($snippet = $this->template_model->get_snippet($snippet_id)) === FALSE)
- {
- show_error($this->lang->line('unauthorized_access'));
- }
- // offer up confirmation first
- if ($this->input->get_post('delete_confirm') == TRUE)
- {
- $this->template_model->delete_snippet($snippet_id);
- $this->session->set_flashdata('message_success', $this->lang->line('snippet_deleted'));
- $this->functions->redirect(BASE.AMP.'C=design'.AMP.'M=snippets'.AMP.'delete=1');
- }
- else
- {
- $this->cp->set_breadcrumb(BASE.AMP.'C=design'.AMP.'M=manager', $this->lang->line('template_manager'));
- $this->cp->set_breadcrumb(BASE.AMP.'C=design'.AMP.'M=snippets', $this->lang->line('snippets'));
-
- $this->cp->set_variable('cp_page_title', $this->lang->line('delete_snippet'));
- $this->load->view('design/snippets_delete', $snippet);
- }
- }
- // --------------------------------------------------------------------
-
- /**
- * Global Variables
- *
- * @access public
- * @param string
- * @return type
- */
- function global_variables()
- {
- if ( ! $this->cp->allowed_group('can_access_design') OR ! $this->cp->allowed_group('can_admin_templates'))
- {
- show_error($this->lang->line('unauthorized_access'));
- }
- $this->load->model('template_model');
- $this->load->helper('form');
- $this->load->library('table');
-
- $this->cp->set_variable('cp_page_title', $this->lang->line('global_variables'));
- $this->cp->set_breadcrumb(BASE.AMP.'C=design'.AMP.'M=manager', $this->lang->line('template_manager'));
-
- $this->jquery->tablesorter('.mainTable', '{
- headers: {2: {sorter: false}},
- widgets: ["zebra"]
- }');
-
- $vars['global_variables'] = $this->template_model->get_global_variables();
- $vars['global_variables_count'] = $vars['global_variables']->num_rows();
- $this->javascript->compile();
-
- $this->cp->set_right_nav(array(
- 'create_new_global_variable' => BASE.AMP.'C=design'.AMP.'M=global_variables_create'
- ));
-
- $this->load->view('design/global_variables', $vars);
- }
- // --------------------------------------------------------------------
-
- /**
- * Update Global Variables
- *
- * Processes the updating of Global Variables
- *
- * @access public
- * @return type
- */
- function global_variables_update()
- {
- if ( ! $this->cp->allowed_group('can_access_design') OR ! $this->cp->allowed_group('can_admin_templates'))
- {
- show_error($this->lang->line('unauthorized_access'));
- }
-
- $this->load->model('template_model');
- $this->load->library('table');
- $variable_id = $this->input->get_post('variable_id');
- $variable_name = $this->input->get_post('variable_name');
- $variable_data = $this->input->get_post('variable_data');
- $this->cp->set_breadcrumb(BASE.AMP.'C=design'.AMP.'M=manager', $this->lang->line('template_manager'));
- $this->cp->set_breadcrumb(BASE.AMP.'C=design'.AMP.'M=global_variables', $this->lang->line('global_variables'));
-
- if ($variable_name != '')
- {
- if ($variable_name == '' OR $variable_data == '')
- {
- show_error($this->lang->line('all_fields_required'));
- }
-
- if ( ! preg_match("#^[a-zA-Z0-9_\-/]+$#i",$variable_name))
- {
- show_error($this->lang->line('illegal_characters'));
- }
-
- if (in_array($_POST['variable_name'], $this->reserved_vars))
- {
- show_error($this->lang->line('reserved_name'));
- }
- $this->template_model->update_global_variable($variable_id, $variable_name, $variable_data);
-
- // Clear caches- db and template cache my result in update not being reflected
- $this->functions->clear_caching('all');
- // Send success message and move user back to global vars page
- $this->session->set_flashdata('message_success', $this->lang->line('global_var_updated'));
- $this->functions->redirect(BASE.AMP.'C=design'.AMP.'M=global_variables');
- }
- else
- {
- $global_variable = $this->template_model->get_global_variable($variable_id);
- if ($global_variable->num_rows() < 1)
- {
- // They shouldn't be this far
- show_error('variable_does_not_exist');
- }
- $this->load->helper('form');
-
- $global_variable_info = $global_variable->row(); // PHP 5 can do this in one step...
-
- $vars['variable_id'] = $global_variable_info->variable_id;
- $vars['variable_name'] = $global_variable_info->variable_name;
- $vars['variable_data'] = $global_variable_info->variable_data;
- $this->cp->set_variable('cp_page_title', $this->lang->line('global_var_update'));
- $this->javascript->compile();
- $this->load->view('design/global_variables_update', $vars);
- }
- }
-
- // --------------------------------------------------------------------
- /**
- * Create Global Variables
- *
- * Processes the creation of Global Variables
- *
- * @access public
- * @return type
- */
- function global_variables_create()
- {
- if ( ! $this->cp->allowed_group('can_access_design') OR ! $this->cp->allowed_group('can_admin_templates'))
- {
- show_error($this->lang->line('unauthorized_access'));
- }
-
- $this->load->library('table');
- $variable_name = $this->input->get_post('variable_name');
- $variable_data = $this->input->get_post('variable_data');
-
- $this->cp->set_breadcrumb(BASE.AMP.'C=design'.AMP.'M=manager', $this->lang->line('template_manager'));
- $this->cp->set_breadcrumb(BASE.AMP.'C=design'.AMP.'M=global_variables', $this->lang->line('global_variables'));
-
- // Existing variables, will have an id
- if ($variable_name != '')
- {
- if ($variable_name == '' OR $variable_data == '')
- {
- show_error($this->lang->line('all_fields_required'));
- }
-
- if ( ! preg_match("#^[a-zA-Z0-9_\-/]+$#i",$variable_name))
- {
- show_error($this->lang->line('illegal_characters'));
- }
-
- if (in_array($variable_name, $this->reserved_vars))
- {
- show_error($this->lang->line('reserved_name'));
- }
-
- if ($this->template_model->check_duplicate_global_variable_name($variable_name) === FALSE)
- {
- show_error($this->lang->line('duplicate_var_name'));
- }
- $this->template_model->create_global_variable($variable_name, $variable_data);
-
- // Clear caches- db and template cache my result in update not being reflected
- $this->functions->clear_caching('all');
-
- // Send success message and move user back to global vars page
- $this->global_variables($this->lang->line('global_var_created'));
- }
- else
- {
- $this->load->helper('form');
-
- $this->cp->set_variable('cp_page_title', $this->lang->line('create_new_global_variable'));
- $this->javascript->compile();
- $this->load->view('design/global_variables_create');
- }
- }
-
- // --------------------------------------------------------------------
- /**
- * Delete Global Variables
- *
- * @access public
- * @return type
- */
- function global_variables_delete()
- {
- if ( ! $this->cp->allowed_group('can_access_design') OR ! $this->cp->allowed_group('can_admin_templates'))
- {
- show_error($this->lang->line('unauthorized_access'));
- }
- $this->cp->set_breadcrumb(BASE.AMP.'C=design'.AMP.'M=manager', $this->lang->line('template_manager'));
- $this->cp->set_breadcrumb(BASE.AMP.'C=design'.AMP.'M=global_variables', $this->lang->line('global_variables'));
-
- $this->load->helper('form');
-
- $variable_id = $this->input->get_post('variable_id');
- if ($variable_id == '')
- {
- // They shouldn't be this far
- show_error($this->lang->line('variable_does_not_exist'));
- }
- $global_variable = $this->template_model->get_global_variable($variable_id);
-
- if ($global_variable->num_rows() < 1)
- {
- // They shouldn't be this far
- show_error('variable_does_not_exist');
- }
- // offer up confirmation first
- // This is a hidden form value, and === isn't an appropriate check
- if ($this->input->get_post('delete_confirm') == TRUE)
- {
- $this->template_model->delete_global_variable($variable_id);
-
- // Send success message and move user back to global vars page
- $this->global_variables($this->lang->line('variable_deleted'));
- }
- else
- {
- $this->cp->set_variable('cp_page_title', $this->lang->line('delete_global_variable'));
- $global_variable_info = $global_variable->row(); // PHP 5 can do this in one step...
-
- $vars['variable_id'] = $global_variable_info->variable_id;
- $vars['variable_name'] = $global_variable_info->variable_name;
-
- $this->javascript->compile();
- $this->load->view('design/global_variables_delete', $vars);
- }
- }
- // --------------------------------------------------------------------
-
- /**
- * Template Preferences Manager
- *
- * @access public
- * @return type
- */
- function template_preferences_manager($message = '')
- {
- if ( ! $this->cp->allowed_group('can_access_design') OR ! $this->cp->allowed_group('can_admin_templates'))
- {
- show_error($this->lang->line('unauthorized_access'));
- }
- if ($this->input->get_post('id') !== '')
- {
- $group_id = $this->input->get_post('id');
- }
- $vars['message'] = $message;
- $vars['show_template_manager'] = TRUE; // in an error condition, this will go false
- if ($this->session->userdata['group_id'] != 1 && (count($this->session->userdata['assigned_template_groups']) == 0 OR $this->cp->allowed_group('can_admin_templates') == FALSE))
- {
- $vars['message'] = $this->lang->line('no_templates_assigned');
- $vars['show_template_manager'] = FALSE;
- return $this->load->view('design/template_preferences_manager', $vars);
- }
- $this->load->helper('form');
- $this->load->library('table');
-
- $this->javascript->output('
- // select all options for template access restrictions
- $("input.select_all").click(function(){
- $("input[class="+$(this).val()+"]").each(function() {
- this.checked = true;
- });
- });
-
- var the_templates = $(\'div[id^="template_group_div_"]\');
-
- $("#template_groups").change(function() {
- the_templates.hide();
- var openDivs = $(this).val().toString()
- var ids = new Array();
- ids = openDivs.split(",");
-
- for(i=0;i<ids.length;i++)
- {
- $("#template_group_div_"+ids[i]).show();
- }
-
- return false;
- });
- ');
-
- // Retrieve Valid Template Groups and Templates
- $this->db->from('template_groups tg, templates t');
- $this->db->select('tg.group_id, tg.group_name, t.template_id, t.template_name');
- $this->db->where('tg.group_id = t.group_id');
- $this->db->where('tg.site_id', $this->config->item('site_id'));
- if ($this->session->userdata['group_id'] != 1)
- {
- $this->db->where_in('t.group_id', array_keys($this->session->userdata['assigned_template_groups']));
- }
- $this->db->order_by('tg.group_order, t.group_id, t.template_name');
- $query = $this->db->get();
- if ($query->num_rows() == 0)
- {
- $vars['message'] = $this->lang->line('no_templates_available');
- $vars['show_template_manager'] = FALSE;
- return $this->load->view('design/template_preferences_manager', $vars);
- }
- // Create MultiSelect Lists
- $current_group = 0;
-
- $groups = array();
- $tmpl = array();
-
- $vars['templates'] = array();
- foreach ($query->result_array() as $i => $row)
- {
- if ($row['group_id'] != $current_group)
- {
- $groups[$row['group_id']] = form_prep($row['group_name']);
- if ($current_group != 0)
- {
- $vars['templates']['template_group_div_'.$current_group]['select'] = form_multiselect('template_group_'.$row['group_id'].'[]', $tmpl, '', "size='8' class='multiselect' style='width:45%'");
- $vars['templates']['template_group_div_'.$current_group]['active'] = ($current_group == $group_id) ? TRUE : FALSE;
- $tmpl = array();
- }
- }
- $tmpl[$row['template_id']] = form_prep($row['template_name']);
- $current_group = $row['group_id'];
- }
- $groups = form_multiselect('template_groups', $groups, $group_id, "id='template_groups' size='10' class='multiselect' style='width:160px'");
-
- $vars['templates']['template_group_div_'.$current_group]['select'] = form_multiselect('template_group_'.$row['group_id'].'[]', $tmpl, '', "size='8' class='multiselect' style='width:45%'");
- $vars['templates']['template_group_div_'.$current_group]['active'] = ($current_group == $group_id) ? TRUE : FALSE;
- $vars['groups'] = $groups;
- if ($this->input->get_post('U'))
- {
- $vars['message'] = $this->lang->line('preferences_updated');
- }
- // Template Preference Headings
- $headings = array(
- array('template_type', $this->lang->line('type')),
- array('cache', $this->lang->line('cache_enable')),
- array('refresh', $this->lang->line('refresh_interval').' <small>('.$this->lang->line('refresh_in_minutes').')</small>')
- );
- if ($this->session->userdata['group_id'] == 1)
- {
- $headings[] = array('allow_php', $this->lang->line('enable_php').' <span class="notice">*</span>');
- $headings[] = array('php_parse_location', $this->lang->line('parse_stage'));
- }
- if ($this->config->item('save_tmpl_files') == 'y' AND $this->config->item('tmpl_file_basepath') != '')
- {
- $headings[] = array('save_template_file', $this->lang->line('save_template_file'));
- }
- $headings[] = array('hits', $this->lang->line('hit_counter'));
- $vars['headings'] = $headings;
- // Template Preference Options
- $vars['template_prefs'] = array();
- $template_type_options = array(
- 'null' => $this->lang->line('do_not_change'),
- 'css' => $this->lang->line('css_stylesheet'),
- 'js' => $this->lang->line('js'),
- 'feed' => $this->lang->line('rss'),
- 'static' => $this->lang->line('static'),
- 'webpage' => $this->lang->line('webpage'),
- 'xml' => $this->lang->line('xml')
- );
- $vars['template_prefs']['template_type'] = form_dropdown('template_type', $template_type_options, 'null', 'id="template_type"');
- $yes_no_options = array(
- 'null' => $this->lang->line('do_not_change'),
- 'y' => $this->lang->line('yes'),
- 'n' => $this->lang->line('no')
- );
- $vars['template_prefs']['cache'] = form_dropdown('cache', $yes_no_options, 'null', 'id="cache"');
- $vars['template_prefs']['refresh'] = form_input(array('name'=>'refresh', 'value'=>'0', 'size'=>5));
- if ($this->session->userdata['group_id'] == 1)
- {
- $php_i_o_options = array(
- 'null' => $this->lang->line('do_not_change'),
- 'i' => $this->lang->line('input'),
- 'o' => $this->lang->line('output')
- );
- $vars['template_prefs']['allow_php'] = form_dropdown('allow_php', $yes_no_options, 'null', 'id="allow_php"');
- $vars['template_prefs']['php_parse_location'] = form_dropdown('php_parse_location', $php_i_o_options, 'null', 'id="php_parse_location"');
- }
- if ($this->config->item('save_tmpl_files') == 'y' AND $this->config->item('tmpl_file_basepath') != '')
- {
- $vars['template_prefs']['save_template_file'] = form_dropdown('save_template_file', $yes_no_options, 'null', 'id="save_template_file"');
- }
- $vars['template_prefs']['hits'] = form_input(array('name'=>'hits', 'value'=>'', 'size'=>5));
- // Template Access Restrictions
- $this->db->select('group_id, group_title');
- $this->db->where('site_id', $this->config->item('site_id'));
- $this->db->where('group_id !=', '1');
- $this->db->order_by('group_title');
- $query = $this->db->get('member_groups');
- $vars['template_access'] = array();
- foreach ($query->result() as $row)
- {
- $vars['template_access'][$row->group_id][] = $row->group_title;
- $radio_options = '';
- foreach ($yes_no_options as $key => $lang)
- {
- $radio_options .= '<label>'.form_radio('access_'.$row->group_id, $key, '', 'class="access_'.$key.'"').NBS.$lang.'</label>'.NBS.NBS.NBS.NBS.NBS.NBS.NBS;
- }
- $vars['template_access'][$row->group_id][] = $radio_options;
- }
- $vars['template_access']['select_all'][] = $this->lang->line('select_all');
- $select_all_radios = '<label>'.form_radio('select_all', 'access_null', '', 'class="select_all"').NBS.$this->lang->line('do_not_change').'</label>'.NBS.NBS.NBS.NBS.NBS.NBS.NBS;
- $select_all_radios .= '<label>'.form_radio('select_all', 'access_y', '', 'class="select_all"').NBS.$this->lang->line('yes').'</label>'.NBS.NBS.NBS.NBS.NBS.NBS.NBS;
- $select_all_radios .= '<label>'.form_radio('select_all', 'access_n', '', 'class="select_all"').NBS.$this->lang->line('no').'</label>';
- $vars['template_access']['select_all'][] = $select_all_radios;
- $this->db->select('template_groups.group_name, templates.template_name, templates.template_id');
- $this->db->where('template_groups.group_id = '.$this->db->dbprefix('templates.group_id'));
- $this->db->where('template_groups.site_id', $this->config->item('site_id'));
- $this->db->order_by('template_groups.group_name, templates.template_name');
-
- $query = $this->db->get(array('template_groups', 'templates'));
- $vars['no_auth_bounce_options']['null'] = $this->lang->line('do_not_change');
- foreach ($query->result() as $row)
- {
- $vars['no_auth_bounce_options'][$row->template_id] = $row->group_name.'/'.$row->template_name;
- }
- $vars['enable_http_auth_options'] = $yes_no_options;
- $this->cp->set_variable('cp_page_title', $this->lang->line('template_preferences_manager'));
- $this->cp->set_breadcrumb(BASE.AMP.'C=design'.AMP.'M=manager', $this->lang->line('template_manager'));
-
- $this->javascript->compile();
- $this->load->view('design/template_preferences_manager', $vars);
- }
- // --------------------------------------------------------------------
-
- /**
- * Update Preferences Manager
- *
- * @access public
- * @return type
- */
- function update_manager_prefs()
- {
- if ( ! $this->cp->allowed_group('can_access_design') OR ! $this->cp->allowed_group('can_admin_templates'))
- {
- show_error($this->lang->line('unauthorized_access'));
- }
- // Determine Valid Template Groups and Templates
- if ($this->session->userdata['group_id'] != 1 && (count($this->session->userdata['assigned_template_groups']) == 0 OR $this->cp->allowed_group('can_admin_templates') == FALSE))
- {
- show_error($this->lang->line('unauthorized_access'));
- }
- $this->db->from('template_groups tg, templates t');
- $this->db->select('t.template_id, t.group_id, tg.group_name');
- $this->db->where('tg.group_id = t.group_id');
- $this->db->where('tg.site_id', $this->config->item('site_id'));
- if ($this->session->userdata['group_id'] != 1)
- {
- $this->db->where_in('t.group_id', array_keys($this->session->userdata['assigned_template_groups']));
- }
- $query = $this->db->get();
- if ($query->num_rows() == 0)
- {
- show_error($this->lang->line('unauthorized_access'));
- }
-
- $delete = array();
-
- foreach ($query->result_array() as $row)
- {
- $delete[$row['template_id']] = $row['group_name'];
- }
- $templates = array();
- foreach($_POST as $key => $value)
- {
- if (substr($key, 0, strlen('template_group_')) == 'template_group_' && is_array($value))
- {
- foreach($value as $template)
- {
- $templates[] = $this->db->escape_str($template);
- }
- }
- }
- if (count($templates) == 0)
- {
- show_error($this->lang->line('no_templates_selected'));
- }
- // Template Preferences
- $data = array();
- if (in_array($_POST['template_type'], array('css', 'js', 'feed', 'static', 'webpage', 'xml')))
- {
- $data['template_type'] = $_POST['template_type'];
- }
- if ($_POST['cache'] == 'y' OR $_POST['cache'] == 'n')
- {
- $data['cache'] = $_POST['cache'];
- if ($_POST['refresh'] != '' && is_numeric($_POST['refresh']))
- {
- $data['refresh'] = $_POST['refresh'];
- }
- }
- if ($this->session->userdata['group_id'] == 1)
- {
- if ($_POST['allow_php'] == 'y' OR $_POST['allow_php'] == 'n')
- {
- $data['allow_php'] = $_POST['allow_php'];
- if ($_POST['php_parse_location'] == 'i' OR $_POST['php_parse_location'] == 'o')
- {
- $data['php_parse_location'] = $_POST['php_parse_location'];
- }
- }
- }
- if ($_POST['hits'] != '' && is_numeric($_POST['hits']))
- {
- $data['hits'] = $_POST['hits'];
- }
- if ($_POST['enable_http_auth'] == 'y' OR $_POST['enable_http_auth'] == 'n')
- {
- $data['enable_http_auth'] = $_POST['enable_http_auth'];
- }
- if ($_POST['no_auth_bounce'] != 'null')
- {
- $data['no_auth_bounce'] = $_POST['no_auth_bounce'];
- }
- if ($this->config->item('save_tmpl_files') == 'y' AND $this->config->item('tmpl_file_basepath') != '')
- {
- if ($this->input->post('save_template_file') != FALSE && $this->input->post('save_template_file') != 'null')
- {
- $data['save_template_file'] = $this->input->post('save_template_file');
- }
- }
- if (count($data) > 0)
- {
- // If we switched 'save' to no, we need to delete files.
- $short_name = $this->config->item('site_short_name');
-
- if ($this->input->post('save_template_file') == 'n')
- {
- $this->db->from('templates');
- $this->db->select('template_name, template_type, template_id');
- $this->db->where('save_template_file', 'y');
- $this->db->where_in('template_id', $templates);
-
- $query = $this->db->get();
-
- if ($query->num_rows() > 0)
- {
- foreach ($query->result_array() as $row)
- {
- $tdata = array(
- 'template_id' => $row['template_id'],
- 'site_short_name' => $short_name,
- 'template_group' => $delete[$row['template_id']],
- 'template_name' => $row['template_name'],
- 'template_type' => $row['template_type']
- );
-
- $this->_delete_template_file($tdata);
- }
- }
- }
- $this->db->query($this->db->update_string('exp_templates', $data, "template_id IN ('".implode("','", $templates)."')"));
- }
- // Template Access
-
- $yes = array();
- $no = array();
- $this->db->select('group_id');
- $this->db->where('site_id', $this->config->item('site_id'));
- $this->db->where('group_id !=', '1');
- $this->db->order_by('group_title');
-
- $query = $this->db->get('member_groups');
- if ($query->num_rows() > 0)
- {
- foreach($query->result_array() as $row)
- {
- if ( isset($_POST['access_'.$row['group_id']]))
- {
- if ($_POST['access_'.$row['group_id']] == 'y')
- {
- $yes[] = $row['group_id'];
- }
- elseif($_POST['access_'.$row['group_id']] == 'n')
- {
- $no[] = $row['group_id'];
- }
- }
- }
- }
- if ( ! empty($yes) OR ! empty($no))
- {
- $access = array();
- if (count($no) > 0)
- {
- foreach($templates as $template)
- {
- $access[$template] = $no;
- }
- }
- $this->db->where_in('template_id', $templates);
- $query = $this->db->get('template_no_access');
- if ($query->num_rows() > 0)
- {
- foreach($query->result_array() as $row)
- {
- if ( ! in_array($row['member_group'], $yes) && ! in_array($row['member_group'], $no))
- {
- $access[$row['template_id']][] = $row['member_group'];
- }
- }
- }
- $this->db->where_in('template_id', $templates);
- $this->db->delete('template_no_access');
- foreach($access as $template => $groups)
- {
- if ( empty($groups)) continue;
- foreach($groups as $group)
- {
- $this->db->query($this->db->insert_string('exp_template_no_access', array('template_id' => $template, 'member_group' => $group)));
- }
- }
- }
- $this->functions->redirect(BASE.AMP.'C=design'.AMP.'M=template_preferences_manager'.AMP.'U=1');
- }
- // --------------------------------------------------------------------
- /**
- * Create New Template
- *
- * @access public
- * @return type
- */
- function create_new_template()
- {
- if ( ! $this->cp->allowed_group('can_access_design'))
- {
- show_error($this->lang->line('unauthorized_access'));
- }
- $template_name = $this->input->post('template_name');
- $group_id = $this->input->post('group_id');
- if ($group_id == '')
- {
- show_error($this->lang->line('unauthorized_access'));
- }
- if ($template_name == '')
- {
- show_error($this->lang->line('you_must_submit_a_name'));
- }
- if ( ! $this->_template_access_privs(array('group_id' => $group_id)))
- {
- show_error($this->lang->line('unauthorized_access'));
- }
- if ( ! preg_match("#^[a-zA-Z0-9_\.-]+$#i", $template_name))
- {
- show_error($this->lang->line('illegal_characters'));
- }
-
- if (in_array($template_name, $this->reserved_names))
- {
- show_error($this->lang->line('reserved_name'));
- }
-
- $this->db->where('group_id', $_POST['group_id']);
- $this->db->where('template_name', $_POST['template_name']);
- if ($this->db->count_all_results('templates'))
- {
- show_error($this->lang->line('template_name_taken'));
- }
- $template_data = '';
- $template_type = $this->input->post('template_type');
- if ($_POST['template_data'] == 'existing_template')
- {
- $this->db->from('templates t, template_groups tg');
- $this->db->select('tg.group_name, template_name, template_data, template_type, template_notes, cache, refresh, no_auth_bounce, allow_php, php_parse_location, save_template_file');
- $this->db->where('t.template_id', $_POST['existing_template']);
- $this->db->where('tg.group_id = t.group_id');
-
- $query = $this->db->get();
- if ($this->config->item('save_tmpl_files') == 'y' && $this->config->item('tmpl_file_basepath') != '' && $query->row('save_template_file') == 'y')
- {
- $basepath = $this->config->item('tmpl_file_basepath');
-
- if (substr($basepath, -1) != '/')
- {
- $basepath .= '/';
- }
-
- $basepath .= $query->row('group_name') .'/'.$query->row('template_name') .'.php';
-
- if ($fp = @fopen($basepath, FOPEN_READ))
- {
- flock($fp, LOCK_SH);
-
- $query->set_row('template_data', (filesize($basepath) == 0) ? '' : fread($fp, filesize($basepath)));
-
- flock($fp, LOCK_UN);
- fclose($fp);
- }
- }
-
- $template_data = $query->row('template_data') ;
-
- if ($template_type != $query->row('template_type') )
- {
- $template_type = $query->row('template_type') ;
- }
- $data = array(
- 'group_id' => $_POST['group_id'],
- 'template_name' => $_POST['template_name'],
- 'template_notes' => $query->row('template_notes') ,
- 'cache' => $query->row('cache') ,
- 'refresh' => $query->row('refresh') ,
- 'no_auth_bounce' => $query->row('no_auth_bounce') ,
- 'php_parse_location' => $query->row('php_parse_location') ,
- 'allow_php' => ($this->session->userdata['group_id'] == 1) ? $query->row('allow_php') : 'n',
- 'template_type' => $template_type,
- 'template_data' => $template_data,
- 'edit_date' => $this->localize->now,
- 'site_id' => $this->config->item('site_id'),
- 'last_author_id' => 0
- );
- $template_id = $this->template_model->create_template($data);
- }
- else
- {
- $data = array(
- 'group_id' => $_POST['group_id'],
- 'template_name' => $_POST['template_name'],
- 'template_type' => $template_type,
- 'template_data' => '',
- 'edit_date' => $this->localize->now,
- 'site_id' => $this->config->item('site_id'),
- 'last_author_id' => $this->session->userdata['member_id']
- );
- $template_id = $this->template_model->create_template($data);
- }
- if (isset($_POST['create']))
- {
- $this->manager($this->lang->line('template_created'));
- }
- else
- {
- $this->edit_template($template_id…
Large files files are truncated, but you can click here to view the full file