public function update($id, $params) { $status = Response::STATUS_BAD_REQUEST; $data = array(); unset($params['news_id']); $lang_code = $this->_safeGet($params, 'lang_code', DEFAULT_LANGUAGE); $new_id = fn_update_news($id, $params, $lang_code); if ($new_id) { $status = Response::STATUS_OK; $data = array('new_id' => $new_id); } return array('status' => $status, 'data' => $data); }
// // Manage news // if ($mode == 'm_update') { if (!empty($_REQUEST['news'])) { foreach ($_REQUEST['news'] as $k => $v) { fn_update_news($k, $v, DESCR_SL); } } $suffix = ".manage"; } // // Add/update news // if ($mode == 'update') { $news_id = fn_update_news($_REQUEST['news_id'], $_REQUEST['news_data'], DESCR_SL); if (empty($news_id)) { $suffix = ".manage"; } else { $suffix = ".update?news_id={$news_id}" . (!empty($_REQUEST['news_data']['block_id']) ? "&selected_block_id=" . $_REQUEST['news_data']['block_id'] : ""); } } return array(CONTROLLER_STATUS_OK, "news{$suffix}"); } if ($mode == 'add') { fn_add_breadcrumb(fn_get_lang_var('news'), "news.manage"); // [Page sections] Registry::set('navigation.tabs', array('detailed' => array('title' => fn_get_lang_var('general'), 'js' => true), 'addons' => array('title' => fn_get_lang_var('addons'), 'js' => true))); // [/Page sections] } elseif ($mode == 'update') { fn_add_breadcrumb(fn_get_lang_var('news'), "news.manage");
function importNews($deleteOldNews) { ini_set('max_execution_time', 0); if ($deleteOldNews) { require DIR_ROOT . "/addons/news_and_emails/controllers/admin/news.php"; //Delete news $destLink = mysqli_connect($this->config['db_host'], $this->config['db_user'], $this->config['db_password']) or die('Database connection error. ' . mysqli_error($this->link)); $this->useDatabase($this->destinationDB, $destLink); $oldNews = db_get_fields("SELECT news_id FROM cscart_news"); foreach ($oldNews as $newsToDelete) { fn_delete_news($newsToDelete); } } $this->useDatabase($this->sourceDB); //main link used for selecting news $query = "SELECT * FROM news ORDER BY id DESC"; $result = mysqli_query($this->link, $query) or die('Failed to select items: ' . mysqli_error($this->link)); //Destination link $destLink = mysqli_connect($this->config['db_host'], $this->config['db_user'], $this->config['db_password']) or die('Database connection error. ' . mysqli_error($this->link)); $this->useDatabase($this->destinationDB, $destLink); while ($news = mysqli_fetch_array($result, MYSQL_ASSOC)) { //import $newsData = array(); $newsData['news'] = $news['theme']; $newsData['description'] = $news['post']; $newsData['date'] = date('d/m/Y', $news['date']); $newsData['status'] = 'A'; fn_update_news("", $newsData, DESCR_SL); } }