public function create_review() { $this->form_validation->set_rules('comment', lang_key('comment'), 'required'); if ($this->form_validation->run() == FALSE) { $this->load_review_form($this->input->post('post_id')); } else { $post_id = $this->input->post('post_id'); $data = array(); $data['comment'] = $this->input->post('comment'); $data['post_id'] = $post_id; $data['rating'] = $this->input->post('rating'); $data['created_by'] = get_id_by_username($this->session->userdata('user_name')); $time = time(); $data['status'] = 1; $data['create_time'] = $time; $review_id = $this->review_model->insert_review($data); $average_rating = get_post_average_rating($post_id); $this->review_model->update_post_average_rating($post_id, $average_rating); echo '<div class="alert alert-success">' . lang_key('review_submitted') . '</div>'; $this->load_review_form($post_id); // $this->single_review_view($review_id); } }
public function addcategory() { $this->form_validation->set_rules('title', 'Title', 'required'); $this->form_validation->set_rules('parent', 'Parent', 'required'); if ($this->form_validation->run() == FALSE) { $this->newcategory(); } else { $this->load->helper('date'); $format = 'DATE_RFC822'; $time = time(); $data = array(); $data['title'] = $this->input->post('title'); $data['parent'] = $this->input->post('parent'); $data['create_time'] = standard_date($format, $time); $data['created_by'] = get_id_by_username($this->session->userdata('user_name')); $data['status'] = 1; if (constant("ENVIRONMENT") == 'demo') { $this->session->set_flashdata('msg', '<div class="alert alert-success">Data updated.[NOT AVAILABLE ON DEMO]</div>'); } else { $this->category_model->insert_category($data); $this->session->set_flashdata('msg', '<div class="alert alert-success">Data inserted</div>'); } redirect(site_url('admin/category/newcategory')); } }
function delete_preferred_reviewees($user) { $user = sanitize($user); $id = get_id_by_username($user); $batch = get_running1_batch_id(); mysql_query("DELETE FROM preferred_poll WHERE User = {$id} AND Reviewer = {$id} AND Batch = {$batch}"); }
public function create_ad() { $state_active = get_settings('classified_settings', 'show_state_province', 'yes'); // $this->form_validation->set_rules('purpose', lang_key('purpose'), 'required'); $this->form_validation->set_rules('category', lang_key('category'), 'required'); $this->form_validation->set_rules('sub_category', lang_key('Sub category'), 'required'); $this->form_validation->set_rules('manufacturer', lang_key('Manufacturer'), 'required'); $this->form_validation->set_rules('email', lang_key('email'), 'required'); $this->form_validation->set_rules('phone_no', lang_key('phone_no'), 'required'); $this->form_validation->set_rules('manufacturing_year', lang_key('Manufacturing Year'), 'required'); $this->form_validation->set_rules('contact_for_price', lang_key('contact_for_price'), 'xss_clean'); if ($this->input->post('contact_for_price') == '') { $this->form_validation->set_rules('price', lang_key('price'), 'required'); } $this->form_validation->set_rules('country', lang_key('country'), 'required'); if ($state_active == 'yes') { $this->form_validation->set_rules('state', lang_key('state'), 'required'); } $this->form_validation->set_rules('selected_city', lang_key('city'), 'xss_clean'); $this->form_validation->set_rules('city', lang_key('city'), 'required'); $this->form_validation->set_rules('zip_code', lang_key('zip_code'), 'xss_clean'); $this->form_validation->set_rules('latitude', lang_key('latitude'), 'required'); $this->form_validation->set_rules('longitude', lang_key('longitude'), 'required'); $this->form_validation->set_rules('title_' . default_lang(), lang_key('title'), 'required'); $this->form_validation->set_rules('description', lang_key('description'), 'required'); $this->form_validation->set_rules('featured_img', lang_key('featured_img'), 'required'); $this->create_post_validation(); if ($this->form_validation->run() == FALSE) { $msg = '<div class="alert alert-danger form-error">' . lang_key('ad_creation_error') . '</div>'; $this->new_ad($msg); } else { $meta_search_text = ''; //meta information for simple searching $this->load->helper('date'); $format = 'DATE_RFC822'; $time = time(); $data = array(); $data['unique_id'] = uniqid(); $data['purpose'] = 'sell'; // $meta_search_text .= $data['purpose'].' '; $data['category'] = $this->input->post('category'); $meta_search_text .= get_category_title_by_id($data['category']) . ' '; $data['parent_category'] = get_category_parent_by_id($data['category']); $meta_search_text .= get_category_title_by_id($data['parent_category']) . ' '; $data['contact_for_price'] = $this->input->post('contact_for_price'); $data['price'] = $this->input->post('price'); $data['phone_no'] = $this->input->post('phone_no'); $data['country'] = $this->input->post('country'); $meta_search_text .= get_location_name_by_id($data['country']) . ' '; $data['state'] = $state_active == 'yes' ? $this->input->post('state') : 0; $meta_search_text .= get_location_name_by_id($data['state']) . ' '; $selected_city = $this->input->post('selected_city'); $city = $this->input->post('city'); if ($selected_city == '') { $new_city_id = $this->post_model->get_location_id_by_name($city, 'city', $data['state'], $data['country']); } else { $new_city_id = $selected_city; } $data['city'] = $new_city_id; $meta_search_text .= get_location_name_by_id($data['city']) . ' '; $data['zip_code'] = $this->input->post('zip_code'); $meta_search_text .= $data['zip_code'] . ' '; $data['address'] = $this->input->post('address'); $meta_search_text .= $data['address'] . ' '; $data['latitude'] = $this->input->post('latitude'); $data['longitude'] = $this->input->post('longitude'); $this->load->model('admin/system_model'); $langs = $this->system_model->get_all_langs(); $titles = array(); $descriptions = array(); foreach ($langs as $lang => $long_name) { $titles[$lang] = $this->input->post('title_' . $lang); $meta_search_text .= $titles[$lang] . ' '; $descriptions[$lang] = $this->input->post('description_' . $lang); } $data['title'] = json_encode($titles); $data['description'] = json_encode($descriptions); $data['tags'] = $this->input->post('tags'); $meta_search_text .= $data['tags'] . ' '; $data['featured_img'] = $this->input->post('featured_img'); $data['gallery'] = $this->input->post('gallery') != false ? json_encode($this->input->post('gallery')) : '[]'; $data['created_by'] = get_id_by_username($this->session->userdata('user_name')); $data['create_time'] = $time; $data['publish_time'] = $time; $data['last_update_time'] = $time; $publish_directly = get_settings('classified_settings', 'publish_directly', 'Yes'); $enable_pricing = get_settings('package_settings', 'enable_pricing', 'Yes'); /************************** status=0: post is deleted status=1: post is active status=2: post requires admin approval status=3: post requires payment status=4: post is expired **************************/ if ($enable_pricing == 'Yes') { $data['status'] = 3; } else { $data['status'] = $publish_directly == 'Yes' ? 1 : 2; // 2 = pending } $data['featured'] = 0; $data['report'] = 0; $data['total_view'] = 0; $data['total_view'] = 0; $data['search_meta'] = $meta_search_text; $this->before_post_creation(); if (constant("ENVIRONMENT") == 'demo') { $this->session->set_flashdata('msg', '<div class="alert alert-success">Data updated.[NOT AVAILABLE ON DEMO]</div>'); } else { $post_id = $this->post_model->insert_post($data); $this->after_post_creation($post_id); $this->session->set_flashdata('msg', '<div class="alert alert-success">' . lang_key('ad_created') . '</div>'); } redirect(site_url('post-ad')); } }