Esempio n. 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);
 }
Esempio n. 2
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);
 }
Esempio n. 3
0
 function name_check($name, $group_id)
 {
     $this->load->model('groups_model');
     $Group = new Groups_model();
     $Group->where("name = '{$name}'")->get();
     if ($Group->exists() && $Group->id != $group_id) {
         $this->form_validation->set_message('name_check', "This group name already exists.");
         return FALSE;
     } else {
         return TRUE;
     }
 }
Esempio n. 4
0
 function add()
 {
     // Init
     $data = array();
     $data['breadcrumb'] = set_crumbs(array('content/types' => 'Content Types', current_url() => 'Add Content Type'));
     $this->load->model('content_types_model');
     $this->load->model('content_types_admin_groups_model');
     $this->load->model('content_fields_model');
     $this->load->model('users/groups_model');
     $this->load->model('category_groups_model');
     // Get theme layouts for theme layout dropdown
     $data['theme_layouts'] = $this->template->get_theme_layouts($this->settings->theme, TRUE);
     // Get all admin groups for admin group access
     $data['Admin_groups'] = $this->groups_model->where('type', ADMINISTRATOR)->order_by('name')->get();
     // Get all user groups except super admin for group access
     $Groups = new Groups_model();
     $data['Groups'] = $Groups->where('type !=', SUPER_ADMIN)->order_by('name')->get();
     // Get all category groups for dropdown
     $data['category_groups'] = option_array_value($this->category_groups_model->order_by('title')->get(), 'id', 'title', array('' => ''));
     // Form Validation
     $this->form_validation->set_rules('title', 'Title', 'trim|required');
     $this->form_validation->set_rules('short_name', 'Short Name', 'trim|required|alpha_dash|max_length[50]|is_unique[content_types.short_name]');
     $this->form_validation->set_rules('enable_dynamic_routing', 'Enable Dynamic Routing', 'trim');
     $this->form_validation->set_rules('enable_versioning', 'Enable Versioning', 'trim|required');
     $this->form_validation->set_rules('max_revisions', 'Max Revisions', 'trim|required|integer|less_than[26]');
     $this->form_validation->set_rules('category_group_id', 'Category Group', 'trim');
     $this->form_validation->set_rules('restrict_admin_access', 'Restrict Admin Access', 'trim|required');
     $this->form_validation->set_rules('selected_admin_groups[]', 'Administrative Access', 'trim');
     $this->form_validation->set_rules('access', 'Access', 'trim|required');
     $this->form_validation->set_rules('restrict_to[]', 'Group Access', 'trim');
     $this->form_validation->set_rules('entries_allowed', 'Number of Entries Allowed', 'trim|integer');
     // Add dynamic route validation if enable dynamic routing checkbox selected
     if ($this->input->post('enable_dynamic_routing') == 1) {
         $this->form_validation->set_rules('dynamic_route', 'Dynamic Route', 'trim|required|max_length[255]|callback_unique_dynamic_route');
     }
     if ($this->form_validation->run() == TRUE) {
         // Save new content type
         $Content_type = new Content_types_model();
         $Content_type->from_array($this->input->post());
         $Content_type->dynamic_route = $this->input->post('dynamic_route') != '' && $this->input->post('enable_dynamic_routing') ? $this->input->post('dynamic_route') : NULL;
         $Content_type->restrict_to = $this->input->post('access') == 2 ? serialize($this->input->post('restrict_to')) : NULL;
         $Content_type->category_group_id = $this->input->post('category_group_id') != '' ? $this->input->post('category_group_id') : NULL;
         $Content_type->theme_layout = $this->input->post('theme_layout') != '' ? $this->input->post('theme_layout') : NULL;
         $Content_type->entries_allowed = $this->input->post('entries_allowed') != '' ? $this->input->post('entries_allowed') : NULL;
         $Content_type->save();
         $Content_type->add_revision();
         // Assign admin groups to this content type
         // if restrict admin access is enabled
         if ($Content_type->restrict_admin_access && is_array($this->input->post('selected_admin_groups'))) {
             $selected_admin_groups = $this->input->post('selected_admin_groups');
             foreach ($selected_admin_groups as $admin_group) {
                 $Content_types_admin_groups = new Content_types_admin_groups_model();
                 $Content_types_admin_groups->content_type_id = $Content_type->id;
                 $Content_types_admin_groups->group_id = $admin_group;
                 $Content_types_admin_groups->save();
             }
         }
         // Clear cache
         $this->load->library('cache');
         $this->cache->delete_all('entries');
         $this->cache->delete_all('content_types');
         redirect(ADMIN_PATH . "/content/types/edit/{$Content_type->id}");
     }
     $this->template->view('admin/types/add', $data);
 }