Наследование: extends CI_Model
Пример #1
0
 function index()
 {
     // Init
     $data = array();
     $data['breadcrumb'] = set_crumbs(array(current_url() => 'General Settings'));
     $this->load->model('settings/settings_model');
     $this->load->model('users/groups_model');
     $this->load->model('content/entries_model');
     // Get Themes
     $data['themes'] = $this->template->get_themes();
     $data['layouts'] = $this->template->get_theme_layouts();
     // Get Groups
     $Groups = new Groups_model();
     $data['Groups'] = $Groups->where('type !=', 'super_admin')->order_by('name')->get();
     // Get All Entries
     $Entries = new Entries_model();
     $data['Entries'] = $Entries->order_by('title')->get();
     // Build object with current settings
     $Settings_table = $this->settings_model->get();
     $data['Settings'] = new stdClass();
     foreach ($Settings_table as $Setting) {
         $data['Settings']->{$Setting->slug} = new stdClass();
         $data['Settings']->{$Setting->slug}->value = $Setting->value;
         $data['Settings']->{$Setting->slug}->module = $Setting->module;
     }
     // Form Validation Rules
     $this->form_validation->set_rules('site_name', 'Site Name', 'trim|required');
     $this->form_validation->set_rules('notification_email', 'Notification Email', 'trim|required|valid_email');
     $this->form_validation->set_rules('content[site_homepage]', 'Site Homepage', 'trim|required');
     $this->form_validation->set_rules('content[custom_404]', 'Custom 404', 'trim|required');
     $this->form_validation->set_rules('enable_admin_toolbar', 'Admin Toolbar', 'trim|required');
     $this->form_validation->set_rules('suspend', 'Suspend Site', 'trim|required');
     $this->form_validation->set_rules('users[default_group]', 'Default User Group', 'trim|required');
     $this->form_validation->set_rules('users[enable_registration]', 'User Registration', 'trim|required');
     $this->form_validation->set_rules('users[email_activation]', 'Require Email Activation', 'trim|required');
     // Form Processing
     if ($this->form_validation->run() == TRUE) {
         foreach ($_POST as $slug => $value) {
             if (is_array($value)) {
                 // Value is an array so save it as a module setting
                 foreach ($value as $module_slug => $module_value) {
                     $Settings_m = new Settings_model();
                     $Settings_m->where('slug', $module_slug)->where('module', $slug)->update('value', $module_value);
                 }
             } else {
                 $Settings_m = new Settings_model();
                 $Settings_m->where('slug', $slug)->where('module IS NULL')->update('value', $value);
             }
             unset($Settings_m);
         }
         $this->load->library('cache');
         $this->cache->delete_all('settings');
         $this->session->set_flashdata('message', '<p class="success">Settings Saved.</p>');
         redirect(uri_string());
     }
     $this->template->view('admin/general_settings', $data);
 }
Пример #2
0
 /**
  * @throws Exception
  */
 public function up()
 {
     $json = [];
     $params = $_GET;
     foreach ($params as $key => $val) {
         $this->settings->set($key, $this->clearValue($val));
     }
     $this->settings->flush();
     $json['message'] = 'Настройки сохранены';
     echo json_encode($json);
 }
Пример #3
0
 function save_settings()
 {
     $settings_model = new Settings_model();
     $settings_service = new Settings_service();
     $slugs = $this->input->post('slug', TRUE);
     $res = 0;
     foreach ($slugs as $key => $slug) {
         $settings_model->set_slug($key);
         $settings_model->set_value($slug);
         $res = $settings_service->update_settings($settings_model);
     }
     echo $res;
 }
Пример #4
0
 /**
  * Constructor
  *
  */
 public function __construct()
 {
     parent::__construct();
     // Check the database settings
     if ($this->test_database_config() === FALSE) {
         redirect(base_url() . 'install/');
         die;
     }
     $this->load->database();
     if (!$this->db->db_select()) {
         $error =& load_class('Exceptions', 'core');
         echo $error->show_error('Database Error', 'Unable to connect to the specified database : ' . $this->db->database, 'error_db');
         exit;
     }
     // Models
     $this->load->model(array('base_model', 'settings_model'), '', TRUE);
     // Helpers
     $this->load->helper('file');
     $this->load->helper('trace');
     // Get all the website languages from DB and store them into config file "languages" key
     $languages = $this->settings_model->get_languages();
     Settings::set_languages($languages);
     // 	Settings : google analytics string, filemanager, etc.
     //	Each setting is accessible through Settings::get('setting_name');
     Settings::set_settings_from_list($this->settings_model->get_settings(), 'name', 'content');
     Settings::set_settings_from_list($this->settings_model->get_lang_settings(config_item('detected_lang_code')), 'name', 'content');
     if (Authority::can('access', 'admin') && Settings::get('display_front_offline_content') == 1) {
         Settings::set_all_languages_online();
     }
     // Try to find the installer class : No access if install folder is already there
     $installer = glob(BASEPATH . '../*/class/installer' . EXT);
     // If installer class is already here, avoid site access
     if (!empty($installer)) {
         // Get languages codes from available languages folder/translation file
         $languages = $this->settings_model->get_admin_langs();
         if (!in_array(config_item('detected_lang_code'), $languages)) {
             $this->config->set_item('detected_lang_code', config_item('default_admin_lang'));
         }
         $this->lang->load('admin', config_item('detected_lang_code'));
         Theme::set_theme('admin');
         // Set the view to output
         $this->output('system/delete_installer');
         // Display the view directly
         $this->output->_display();
         // Don't do anything more
         die;
     }
 }
Пример #5
0
 function admin_toolbar($content_type_id, $entry_id = null)
 {
     // Update the inline editing setting if user submitted setting
     if ($this->input->post('admin_toggle_inline_editing')) {
         $this->load->model('settings/settings_model');
         $Settings_model = new Settings_model();
         $Settings_model->where('slug', 'enable_inline_editing')->where('module IS NULL')->update('value', $this->settings->enable_inline_editing ? '0' : '1');
         // Clear the settings cache
         $this->load->library('cache');
         $this->cache->delete_all('settings');
         // Redirect to the current url so that it clears the post
         redirect(current_url());
     }
     // Show admin_toolbar on page
     if ($this->settings->enable_admin_toolbar && $this->secure->group_types(array(ADMINISTRATOR))->is_auth()) {
         $this->template->add_script("var ADMIN_URL = '" . site_url(ADMIN_PATH) . "';");
         $admin_toolbar = $this->load->view('admin/admin_toolbar', array('entry_id' => $entry_id, 'content_type_id' => $content_type_id), TRUE);
         $this->template->add_stylesheet('/application/modules/content/assets/css/admin_toolbar.css');
         $this->template->add_package(array('jquery', 'superfish'));
         $this->template->add_script("var jq_admin_toolbar = jQuery.noConflict(true); \n            jq_admin_toolbar(document).ready( function() {  \n                jq_admin_toolbar(document.body).prepend(" . json_encode($admin_toolbar) . "); \n                jq_admin_toolbar('#admin-toolbar > ul').superfish({\n                    hoverClass   : 'sfHover',\n                    pathClass    : 'overideThisToUse',\n                    delay        : 0,\n                    animation    : {height: 'show'},\n                    speed        : 'normal',\n                    autoArrows   : false,\n                    dropShadows  : false, \n                    disableHI    : false, /* set to true to disable hoverIntent detection */\n                    onInit       : function(){},\n                    onBeforeShow : function(){},\n                    onShow       : function(){},\n                    onHide       : function(){}\n                });\n\n                jq_admin_toolbar('#admin-toggle-inline-editing').click(function() {\n                    jq_admin_toolbar('<form method=\"post\"><input type=\"hidden\" name=\"admin_toggle_inline_editing\" value=\"1\" /></form>').appendTo('body').submit();\n                });\n            });");
         $this->_content_editable();
     }
 }
Пример #6
0
 function index()
 {
     // Init
     $data = array();
     $data['breadcrumb'] = set_crumbs(array(current_url() => 'General Settings'));
     $this->load->model('settings/settings_model');
     $this->load->model('users/groups_model');
     $this->load->model('content/entries_model');
     // Get Themes
     $data['themes'] = $this->template->get_themes();
     $data['layouts'] = $this->template->get_theme_layouts();
     // Get Groups
     $Groups = new Groups_model();
     $data['Groups'] = $Groups->where('type !=', 'super_admin')->order_by('name')->get();
     // Get All Entries
     $Entries = new Entries_model();
     $data['Entries'] = $Entries->order_by('title')->get();
     // Build object with current settings
     $Settings_table = $this->settings_model->get();
     $data['Settings'] = new stdClass();
     foreach ($Settings_table as $Setting) {
         $data['Settings']->{$Setting->slug} = new stdClass();
         $data['Settings']->{$Setting->slug}->value = $Setting->value;
         $data['Settings']->{$Setting->slug}->module = $Setting->module;
     }
     // Form Validation Rules
     $this->form_validation->set_rules('site_name', 'Site Name', 'trim|required');
     $this->form_validation->set_rules('notification_email', 'Notification Email', 'trim|required|valid_email');
     $this->form_validation->set_rules('content[site_homepage]', 'Site Homepage', 'trim|required');
     $this->form_validation->set_rules('content[custom_404]', 'Custom 404', 'trim|required');
     // $this->form_validation->set_rules('enable_admin_toolbar', 'Admin Toolbar', 'trim|required');
     $this->form_validation->set_rules('suspend', 'Suspend Site', 'trim|required');
     $this->form_validation->set_rules('pagination_count', 'Pagination Count', 'trim|required|integer');
     $this->form_validation->set_rules('points_earned_trivia_question', 'Point Earned In Correct Answer', 'trim|required|decimal');
     $this->form_validation->set_rules('amount_earned_trivia_correct_answer', 'Amount Earned In One Point', 'trim|required|decimal');
     // $this->form_validation->set_rules('users[default_group]', 'Default User Group', 'trim|required');
     //$this->form_validation->set_rules('users[enable_registration]', 'User Registration', 'trim|required');
     // $this->form_validation->set_rules('users[email_activation]', 'Require Email Activation', 'trim|required');
     $this->form_validation->set_rules('bronze_points_per_referrals', 'Bronze(Points Per Referrals)', 'trim|required|decimal');
     $this->form_validation->set_rules('silver_points_per_referrals', 'Silver(Points Per Referrals)', 'trim|required|decimal');
     $this->form_validation->set_rules('gold_points_per_referrals', 'Gold(Points Per Referrals)', 'trim|required|decimal');
     $this->form_validation->set_rules('bronze_club_quote_point', 'Points Per Quote', 'trim|decimal');
     $this->form_validation->set_rules('silver_club_quote_point', 'Points Per Quote', 'trim|decimal');
     $this->form_validation->set_rules('gold_club_quote_point', 'Points Per Quote', 'trim|decimal');
     $this->form_validation->set_rules('bronze_no_referrals_trailing_months', 'Bronze Referrals In Trailing Months', 'trim|decimal');
     $this->form_validation->set_rules('bronze_club_binder_point', 'Points Per Binder', 'trim|decimal');
     $this->form_validation->set_rules('silver_club_binder_point', 'Points Per Binder', 'trim|decimal');
     $this->form_validation->set_rules('gold_club_binder_point', 'Points Per Binder', 'trim|decimal');
     $this->form_validation->set_rules('trialing_months', 'Trialing Months', 'trim|required|integer');
     $this->form_validation->set_rules('registration_point', 'Points On Registration', 'trim|required|integer');
     $this->form_validation->set_rules('allow_point_auto_registration', 'Allow Points On Auto Registration', 'trim|required');
     $this->form_validation->set_rules('send_user_on_icontact', 'Send user on Icontact', 'trim|required');
     $this->form_validation->set_rules('resubmit_survey_counter', 'Resubmit Survey Link After (How Many Requests)', 'trim|required|integer');
     $this->form_validation->set_rules('survey_link', 'Survey Link', 'trim|required');
     $this->form_validation->set_rules('min_amount_redeem', 'Minimum Amount For Redeem Points', 'trim|required|integer');
     $this->form_validation->set_rules('flash_message', 'Flash Message', 'trim|required');
     // Form Processing
     if ($this->form_validation->run() == TRUE) {
         foreach ($_POST as $slug => $value) {
             //                print_r($_POST);exit;
             if (is_array($value)) {
                 // Value is an array so save it as a module setting
                 foreach ($value as $module_slug => $module_value) {
                     $Settings_m = new Settings_model();
                     $Settings_m->where('slug', $module_slug)->where('module', $slug)->update('value', $module_value);
                 }
             } else {
                 $Settings_m = new Settings_model();
                 $Settings_m->where('slug', $slug)->where('module IS NULL')->update('value', $value);
             }
             unset($Settings_m);
         }
         $this->load->library('cache');
         $this->cache->delete_all('settings');
         $this->session->set_flashdata('message', '<p class="success">Settings Saved.</p>');
         redirect(uri_string());
     }
     $this->template->view('admin/general_settings', $data);
 }