SHOW:
|
|
- or go back to the newest paste.
| 1 | <?php | |
| 2 | class Testimonials extends CI_Controller | |
| 3 | {
| |
| 4 | ||
| 5 | public $data = array(); | |
| 6 | /*============*/ | |
| 7 | // constructor | |
| 8 | /*============*/ | |
| 9 | function __construct() | |
| 10 | {
| |
| 11 | parent::__construct(); | |
| 12 | ||
| 13 | //load libraries | |
| 14 | $this->load->library('pagination');
| |
| 15 | //load required models | |
| 16 | $this->load->model('admin/admin_model');
| |
| 17 | $this->load->model('admin/testimonials_model');
| |
| 18 | $this->load->model('admin/testimonials_config_model');
| |
| 19 | ||
| 20 | ||
| 21 | if(!$this->admin_model->validate_session()) | |
| 22 | {
| |
| 23 | die('you do not have permission');
| |
| 24 | } | |
| 25 | - | //load required models |
| 25 | + | |
| 26 | ||
| 27 | ||
| 28 | ||
| 29 | //initialize variables | |
| 30 | $this->data['change_settings'] = FALSE; | |
| 31 | $this->data['atleast_one_required_field'] = TRUE; | |
| 32 | $this->data['testimonials_p_p_error'] = FALSE; | |
| 33 | } | |
| 34 | ||
| 35 | ||
| 36 | ||
| 37 | } | |
| 38 | ||
| 39 | /*=============*/ | |
| 40 | // index | |
| 41 | /*=============*/ | |
| 42 | public function index() | |
| 43 | {
| |
| 44 | ||
| 45 | $this->load->view('admin/testimonials_view',$this->data);
| |
| 46 | } | |
| 47 | ||
| 48 | /*================*/ | |
| 49 | // change_settings | |
| 50 | /*================*/ | |
| 51 | public function change_settings() | |
| 52 | {
| |
| 53 | ||
| 54 | $testimonial_required_fields_setting = 0; | |
| 55 | $testimonial_required_fields_setting = $this->input->post('tc_require_phone') === 'true' ? $testimonial_required_fields_setting+1 : $testimonial_required_fields_setting;
| |
| 56 | $testimonial_required_fields_setting = $this->input->post('tc_require_email') === 'true' ? $testimonial_required_fields_setting+1 : $testimonial_required_fields_setting;
| |
| 57 | $testimonial_required_fields_setting = $this->input->post('tc_require_website') === 'true' ? $testimonial_required_fields_setting+1 : $testimonial_required_fields_setting;
| |
| 58 | ||
| 59 | if($testimonial_required_fields_setting > 0) | |
| 60 | {
| |
| 61 | $this->testimonials_config_model->update_required_fields(); | |
| 62 | $this->data['atleast_one_required_field'] = TRUE; | |
| 63 | $this->data['change_settings'] = TRUE; } | |
| 64 | else {
| |
| 65 | $this->data['atleast_one_required_field'] = FALSE; | |
| 66 | $this->data['change_settings'] = FALSE; } | |
| 67 | ||
| 68 | //check testimonials per page setting | |
| 69 | if( ($this->input->post('tc_testimonials_per_page') > 15) || ($this->input->post('tc_testimonials_per_page') <= 4))
| |
| 70 | {
| |
| 71 | $this->data['testimonials_p_p_error'] = TRUE; | |
| 72 | }else{
| |
| 73 | $this->testimonials_config_model->set_config_value_plain('displayed_per_page',$this->input->post('tc_testimonials_per_page'));
| |
| 74 | } | |
| 75 | $this->index(); | |
| 76 | } | |
| 77 | ||
| 78 | /*==========*/ | |
| 79 | // approve | |
| 80 | /*==========*/ | |
| 81 | public function approve($option = null, $id = null) {
| |
| 82 | ||
| 83 | $this->data['approved']= false; | |
| 84 | $this->data['deleted']=false; | |
| 85 | ||
| 86 | if(strcasecmp($option, 'yes')==0) | |
| 87 | {
| |
| 88 | $approve = array('testimonial_approved'=>1);
| |
| 89 | $this->db->where('id',$id);
| |
| 90 | $this->db->update('nv_cms_testimonials',$approve);
| |
| 91 | $this->data['approved']=true; | |
| 92 | } | |
| 93 | elseif(strcasecmp($option, 'no') == 0) | |
| 94 | {
| |
| 95 | $this->db->delete('nv_cms_testimonials',array('id'=>$id));
| |
| 96 | $this->data['deleted']=true; | |
| 97 | ||
| 98 | } | |
| 99 | $this->data['new_testimonials'] = $this->testimonials_model->get_new_testimonials(); | |
| 100 | $this->load->view('admin/testimonials_approve_view.php',$this->data);
| |
| 101 | } | |
| 102 | ||
| 103 | /*=========*/ | |
| 104 | // manage | |
| 105 | /*=========*/ | |
| 106 | public function manage($action = null, $id = null) {
| |
| 107 | ||
| 108 | ||
| 109 | $this->load->model('admin/testimonials_model');
| |
| 110 | ||
| 111 | ||
| 112 | $this->data['deleted'] = false; | |
| 113 | ||
| 114 | if(strcasecmp($action, 'delete') == 0 ) | |
| 115 | {
| |
| 116 | $this->db->delete('nv_cms_testimonials',array('id'=>$id));
| |
| 117 | $this->data['deleted']=true; | |
| 118 | ||
| 119 | $this->data['testimonials'] = $this->testimonials_model->get_all_testimonials_with_pagination('5',$this->uri->segment(4));
| |
| 120 | ||
| 121 | //pagination | |
| 122 | $config['base_url'] = base_url().'admin/testimonials/manage'; | |
| 123 | $config['total_rows'] = $this->testimonials_model->get_all_testimonials(); | |
| 124 | $config['per_page'] = 5; | |
| 125 | $config['uri_segment'] = 4; | |
| 126 | $this->pagination->initialize($config); | |
| 127 | ||
| 128 | $this->data['pagination_links'] = $this->pagination->create_links(); | |
| 129 | $this->load->view('admin/testimonials_manage_view',$this->data);
| |
| 130 | ||
| 131 | } | |
| 132 | elseif(strcasecmp($action, 'edit')==0) | |
| 133 | {
| |
| 134 | ||
| 135 | ||
| 136 | $this->data['testimonial'] = $this->testimonials_model->get_testimonial_by_id($id); | |
| 137 | $this->load->view('admin/testimonials_edit_view',$this->data);
| |
| 138 | } | |
| 139 | elseif(strcasecmp($action, 'update')==0) | |
| 140 | {
| |
| 141 | $this->testimonials_model->update_testimonial($id); | |
| 142 | ||
| 143 | }else{
| |
| 144 | - | $CI =& get_instance(); |
| 144 | + | /*============================*/ |
| 145 | /*LINE 145 HACK FOR ERROR HERE*/ | |
| 146 | $CI =& get_instance(); | |
| 147 | /*============================*/ | |
| 148 | ||
| 149 | //NOTICE the i call $CI->testimonials_model.. instead of $this->testimonials_mode.. | |
| 150 | $this->data['testimonials'] = $CI->testimonials_model->get_all_testimonials_with_pagination('5',$this->uri->segment(4));
| |
| 151 | ||
| 152 | //pagination | |
| 153 | $config['base_url'] = base_url().'admin/testimonials/manage'; | |
| 154 | $config['total_rows'] = $this->testimonials_model->get_all_testimonials(); | |
| 155 | $config['per_page'] = 5; | |
| 156 | $config['uri_segment'] = 4; | |
| 157 | $this->pagination->initialize($config); | |
| 158 | ||
| 159 | $this->data['pagination_links'] = $this->pagination->create_links(); | |
| 160 | $this->load->view('admin/testimonials_manage_view',$this->data);
| |
| 161 | } | |
| 162 | ||
| 163 | }//manage | |
| 164 | ||
| 165 | } |