Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Testimonials extends CI_Controller
- {
- public $data = array();
- /*============*/
- // constructor
- /*============*/
- function __construct()
- {
- parent::__construct();
- //load libraries
- $this->load->library('pagination');
- //load required models
- $this->load->model('admin/admin_model');
- $this->load->model('admin/testimonials_model');
- $this->load->model('admin/testimonials_config_model');
- if(!$this->admin_model->validate_session())
- {
- die('you do not have permission');
- }
- else {
- //initialize variables
- $this->data['change_settings'] = FALSE;
- $this->data['atleast_one_required_field'] = TRUE;
- $this->data['testimonials_p_p_error'] = FALSE;
- }
- }
- /*=============*/
- // index
- /*=============*/
- public function index()
- {
- $this->load->view('admin/testimonials_view',$this->data);
- }
- /*================*/
- // change_settings
- /*================*/
- public function change_settings()
- {
- $testimonial_required_fields_setting = 0;
- $testimonial_required_fields_setting = $this->input->post('tc_require_phone') === 'true' ? $testimonial_required_fields_setting+1 : $testimonial_required_fields_setting;
- $testimonial_required_fields_setting = $this->input->post('tc_require_email') === 'true' ? $testimonial_required_fields_setting+1 : $testimonial_required_fields_setting;
- $testimonial_required_fields_setting = $this->input->post('tc_require_website') === 'true' ? $testimonial_required_fields_setting+1 : $testimonial_required_fields_setting;
- if($testimonial_required_fields_setting > 0)
- {
- $this->testimonials_config_model->update_required_fields();
- $this->data['atleast_one_required_field'] = TRUE;
- $this->data['change_settings'] = TRUE; }
- else {
- $this->data['atleast_one_required_field'] = FALSE;
- $this->data['change_settings'] = FALSE; }
- //check testimonials per page setting
- if( ($this->input->post('tc_testimonials_per_page') > 15) || ($this->input->post('tc_testimonials_per_page') <= 4))
- {
- $this->data['testimonials_p_p_error'] = TRUE;
- }else{
- $this->testimonials_config_model->set_config_value_plain('displayed_per_page',$this->input->post('tc_testimonials_per_page'));
- }
- $this->index();
- }
- /*==========*/
- // approve
- /*==========*/
- public function approve($option = null, $id = null) {
- $this->data['approved']= false;
- $this->data['deleted']=false;
- if(strcasecmp($option, 'yes')==0)
- {
- $approve = array('testimonial_approved'=>1);
- $this->db->where('id',$id);
- $this->db->update('nv_cms_testimonials',$approve);
- $this->data['approved']=true;
- }
- elseif(strcasecmp($option, 'no') == 0)
- {
- $this->db->delete('nv_cms_testimonials',array('id'=>$id));
- $this->data['deleted']=true;
- }
- $this->data['new_testimonials'] = $this->testimonials_model->get_new_testimonials();
- $this->load->view('admin/testimonials_approve_view.php',$this->data);
- }
- /*=========*/
- // manage
- /*=========*/
- public function manage($action = null, $id = null) {
- $this->load->model('admin/testimonials_model');
- $this->data['deleted'] = false;
- if(strcasecmp($action, 'delete') == 0 )
- {
- $this->db->delete('nv_cms_testimonials',array('id'=>$id));
- $this->data['deleted']=true;
- $this->data['testimonials'] = $this->testimonials_model->get_all_testimonials_with_pagination('5',$this->uri->segment(4));
- //pagination
- $config['base_url'] = base_url().'admin/testimonials/manage';
- $config['total_rows'] = $this->testimonials_model->get_all_testimonials();
- $config['per_page'] = 5;
- $config['uri_segment'] = 4;
- $this->pagination->initialize($config);
- $this->data['pagination_links'] = $this->pagination->create_links();
- $this->load->view('admin/testimonials_manage_view',$this->data);
- }
- elseif(strcasecmp($action, 'edit')==0)
- {
- $this->data['testimonial'] = $this->testimonials_model->get_testimonial_by_id($id);
- $this->load->view('admin/testimonials_edit_view',$this->data);
- }
- elseif(strcasecmp($action, 'update')==0)
- {
- $this->testimonials_model->update_testimonial($id);
- }else{
- /*============================*/
- /*LINE 145 HACK FOR ERROR HERE*/
- $CI =& get_instance();
- /*============================*/
- //NOTICE the i call $CI->testimonials_model.. instead of $this->testimonials_mode..
- $this->data['testimonials'] = $CI->testimonials_model->get_all_testimonials_with_pagination('5',$this->uri->segment(4));
- //pagination
- $config['base_url'] = base_url().'admin/testimonials/manage';
- $config['total_rows'] = $this->testimonials_model->get_all_testimonials();
- $config['per_page'] = 5;
- $config['uri_segment'] = 4;
- $this->pagination->initialize($config);
- $this->data['pagination_links'] = $this->pagination->create_links();
- $this->load->view('admin/testimonials_manage_view',$this->data);
- }
- }//manage
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement