You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
3.1 KiB
109 lines
3.1 KiB
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
class Faqs extends MY_Controller {
|
|
|
|
public function __construct()
|
|
{
|
|
//parent::__construct();
|
|
$this->my_parent_controller();
|
|
$this->load_language_backoffice();
|
|
$this->load->model('frontoffice_faq_model');
|
|
}
|
|
public function compare()
|
|
{
|
|
$keyword = $this->input->post('keyword');
|
|
$res = $this->frontoffice_faq_model->compares($keyword);
|
|
|
|
|
|
$items = array();
|
|
foreach($res as $key => $value){
|
|
$q = $value['question'];
|
|
$link = base_url('faq?page=reply&question_id='.$value['q_id'].'&reply_id='.$value['reply_id'].'&cat_id='.$value['subject_id']);
|
|
$x = array('question'=>$q, 'link'=>$link);
|
|
$items[]=$x;
|
|
}
|
|
// print_r($items);
|
|
return output_to_json($this,$items);
|
|
|
|
|
|
}
|
|
public function suggestion()
|
|
{
|
|
$res = $this->frontoffice_faq_model->suggestions();
|
|
|
|
$items = array();
|
|
foreach($res as $key => $value){
|
|
$q = $value['question'];
|
|
$catID = $value['subject_id'];
|
|
$qID=$value['q_id'];
|
|
$link = base_url('faq?page=reply&question_id='.$value['q_id'].'&reply_id='.$value['reply_id'].'&cat_id='.$value['subject_id']);
|
|
$x = array('question'=>$q, 'question_link'=>$link, 'category'=>$catID, 'questionID'=>$qID);
|
|
$items[]=$x;
|
|
}
|
|
// print_r($items);
|
|
return output_to_json($this,$items);
|
|
|
|
}
|
|
|
|
public function add_question(){
|
|
$q = $this->input->post('question');
|
|
$s = $this->input->post('subject');
|
|
$a = $this->input->post('answer');
|
|
$res = $this->frontoffice_faq_model->addQuestion($q,$s,$a, $this->data['logged_in']['user_id']);
|
|
// echo $res;
|
|
return output_to_json($this,$res);
|
|
}
|
|
|
|
public function get_question(){
|
|
$q = $this->input->post('question');
|
|
$res = $this->frontoffice_faq_model->getQuestion($q);
|
|
output_to_json($this,$res);
|
|
}
|
|
|
|
public function delete_question(){
|
|
$q = $this->input->post('question');
|
|
$res = $this->frontoffice_faq_model->deleteQuestion($q);
|
|
output_to_json($this,$res);
|
|
}
|
|
|
|
public function edit_question(){
|
|
|
|
$q = $this->input->post('question');
|
|
$s = $this->input->post('subject');
|
|
$a = $this->input->post('answer');
|
|
$qid=$this->input->post('qid');
|
|
$res = $this->frontoffice_faq_model->editQuestion($qid,$q,$s,$a);
|
|
|
|
output_to_json($this,$res);
|
|
}
|
|
|
|
public function helpful_yes(){
|
|
$q = $this->input->post('question');
|
|
$a = $this->input->post('answer');
|
|
$this->checkResponseAnswer($q,$a);
|
|
$res = $this->frontoffice_faq_model->helpfulYes($q,$a);
|
|
return output_to_json($this,$res);
|
|
}
|
|
|
|
public function helpful_no(){
|
|
$q = $this->input->post('question');
|
|
$a = $this->input->post('answer');
|
|
$this->checkResponseAnswer($q,$a);
|
|
$res = $this->frontoffice_faq_model->helpfulNo($q,$a);
|
|
return output_to_json($this,$res);
|
|
}
|
|
|
|
/**
|
|
* Check if post parameters for faqs are properly set or die if no post are present
|
|
* @param int|null $question = question ID
|
|
* @param string $answer = answer(yes/no)
|
|
* @return void
|
|
* access private member
|
|
*/
|
|
private function checkResponseAnswer($question = null, $answer = null) {
|
|
if(!isset($question) || !isset($answer)){
|
|
show_404();
|
|
exit();
|
|
}
|
|
}
|
|
}
|