public function delete($id) { $data = array(); $status = Response::STATUS_BAD_REQUEST; if (fn_delete_news($id)) { $status = Response::STATUS_OK; $data['message'] = 'Ok'; $data['status'] = $status; } return array('status' => $status, 'data' => $data); }
$view->assign('selected_block', fn_get_selected_block_data($_REQUEST, $blocks, $_REQUEST['news_id'], 'news')); $view->assign('block_properties', fn_get_block_properties()); } // [/Block manager] // [Page sections] Registry::set('navigation.tabs', array('detailed' => array('title' => fn_get_lang_var('general'), 'js' => true), 'blocks' => array('title' => fn_get_lang_var('blocks'), 'js' => true), 'addons' => array('title' => fn_get_lang_var('addons'), 'js' => true))); // [/Page sections] $view->assign('news_data', $news_data); } elseif ($mode == 'manage' || $mode == 'picker') { $params = $_REQUEST; $params['paginate'] = true; list($news, ) = fn_get_news($params, DESCR_SL); $view->assign('news', $news); } elseif ($mode == 'delete') { if (!empty($_REQUEST['news_id'])) { fn_delete_news($_REQUEST['news_id']); } return array(CONTROLLER_STATUS_REDIRECT, "news.manage"); } // // News picker // if ($mode == 'picker') { $view->display('addons/news_and_emails/pickers/news_picker_contents.tpl'); exit; } function fn_delete_news($news_id) { // Log news deletion fn_log_event('news', 'delete', array('news_id' => $news_id)); fn_clean_block_items('news', $news_id);
/** * POST hook when deleting company * * @param int $company_id Company identifier */ function fn_news_and_emails_delete_company($company_id) { $news_ids = db_get_fields('SELECT news_id FROM ?:news WHERE company_id = ?i', $company_id); foreach ($news_ids as $news_id) { fn_delete_news($news_id); } }
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); } }