Example #1
0
 /**
  * Add new keyword
  * @return json
  * @author Ruslan Ushakov
  */
 function addKeyword()
 {
     $keyword = $this->input->post('keyword');
     $group = (int) $this->input->post('group');
     $res = array();
     $keyword_arr = explode(',', $keyword);
     if (!empty($keyword_arr)) {
         $this->load->model('ranking_model');
         if ($group == -1) {
             $group = $this->ranking_model->selectOrIKeywordGroup('Dont show');
             $this->ranking_model->deleteSearchTermsByGroupId($group);
             $this->ranking_model->addKeywordGroupCronJob($group, $this->ranking_model->CRON_PERIOD_DAY);
         }
         foreach ($keyword_arr as &$kword) {
             $kword = trim($kword);
             if ($kword) {
                 $res[] = $this->ranking_model->selectOrInsertIdSearchTerms($kword, $group);
             }
         }
     }
     $this->output->set_content_type('application/json')->set_output(json_encode(array('status' => 'ok', 'k_ids' => $res, 'group' => $group)));
 }