$cats = $db->get_rows('SELECT * FROM ' . PERCH_DB_PREFIX . 'blog_categories'); if (PerchUtil::count($cats)) { foreach ($cats as $cat) { $dynfields = '[]'; if ($cat['categoryDynamicFields']) { $dynfields = $cat['categoryDynamicFields']; } $NewCat = $Core_Categories->create(array('setID' => $Set->id(), 'catParentID' => 0, 'catTitle' => $cat['categoryTitle'], 'catSlug' => $cat['categorySlug'], 'catPath' => '/blog/' . $cat['categorySlug'] . '/', 'catDynamicFields' => $dynfields)); if (is_object($NewCat)) { $db->update(PERCH_DB_PREFIX . 'blog_categories', array('categoryCoreID' => $NewCat->id()), 'categoryID', $cat['categoryID']); } } } } } $Posts = new PerchBlog_Posts($API); $posts = $Posts->all($Paging); if (PerchUtil::count($posts)) { foreach ($posts as $Post) { $Post->import_legacy_categories(); $Post->index(); } } if ($Paging->is_last_page()) { $Sections = new PerchBlog_Sections($API); $Sections->update_post_counts(); $Posts->update_category_counts(); $Authors = new PerchBlog_Authors($API); $Authors->update_post_counts(); $Settings->set('perch_blog_update', '5.0'); }
$Blog = new PerchBlog_Posts($API); $Authors = new PerchBlog_Authors($API); $HTML = $API->get('HTML'); $Form = $API->get('Form'); $message = false; if (!$CurrentUser->has_priv('perch_blog.post.delete')) { PerchUtil::redirect($API->app_path()); } if (isset($_GET['id']) && $_GET['id'] != '') { $Post = $Blog->find($_GET['id'], true); } if (!is_object($Post)) { PerchUtil::redirect($API->app_path()); } $Form->set_name('delete'); if ($Form->submitted()) { if (is_object($Post)) { $Post->delete(); $Blog->update_category_counts(); $Authors->update_post_counts(); if ($Form->submitted_via_ajax) { echo $API->app_path() . '/'; exit; } else { PerchUtil::redirect($API->app_path() . '/'); } } else { $message = $HTML->failure_message('Sorry, that post could not be deleted.'); } } $details = $Post->to_array();