/** * Elimina un artículo de la base de datos */ function deletePost() { global $xoopsSecurity; $posts = rmc_server_var($_POST, 'posts', array()); if (empty($posts)) { redirectMsg('posts.php', __('Select one post at least!', 'mywords'), 1); die; } if (!$xoopsSecurity->check()) { redirectMsg('posts.php', __('Session token expired!', 'mywords'), 1); die; } $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT * FROM " . $db->prefix("mod_mywords_posts") . " WHERE id_post IN (" . implode(",", $posts) . ")"; $result = $db->query($sql); while ($row = $db->fetchArray($result)) { $post = new MWPost(); $post->assignVars($row); if (!$post->delete()) { showMessage(sprintf(__('Errors ocurred while deleting "%s"', 'mw_categories'), $post->getVar('title')), 1); } RMFunctions::delete_comments('mywords', urlencode('post=' . $post->id())); } redirectMsg('posts.php', __('Database updated!', 'mw_categories'), 0); }