public function update_field() { $field = $this->input->post('field'); $id_article = $this->input->post('id_article'); $type = $this->input->post('type'); if ($id_article && $field) { $value = $this->input->post('value'); // Check the type of data, for special process if ($type === 'date') { $value = $value ? getMysqlDatetime($value) : '0000-00-00 00:00:00'; } // Update $result = $this->article_model->update(array('id_article' => $id_article), array($field => $value)); if ($result) { $this->update_contexts($id_article); $this->success(lang('ionize_message_article_saved')); } else { $this->response(); } } }
/** * Register article's time window * * @access private * @param array $_post _POST array * @return void */ private function setting_date($_post) { $msg = null; // check permissions $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], 'articles', $_post['id'], 2); if (is_null($msg)) { // handle _post $post = array('date_in' => strtotime($_post['date_in']), 'date_out' => empty($_post['date_out']) ? 0 : strtotime($_post['date_out'])); // do action $mod = new Article_model(); $obj = $mod->get_by_id($_post['id'], 'articles', 'id_area, lang, bid'); $result = $mod->update($_post['id'], $post); // set message $msg = AdmUtils_helper::set_msg($result); // set what update if ($result[1]) { $msg->update[] = array('element' => 'topic', 'url' => BASE_URL . 'articles/history/' . $obj->id_area . '/' . $obj->lang . '/' . $obj->bid, 'title' => null); } } $this->response($msg); }