public static function update(post_model $post, $category_id, $tags) { $post->save(); if ($category_id != $post->category_id) { category_model::dec_by_id(array('post_count' => 1), $category_id); category_model::inc_by_id(array('post_count' => 1), $post->category_id); } self::delete_tags_for_post($post); self::create_tags_for_post($post, $tags); }
public static function delete($category_id) { $category = category_model::get_by_id($category_id); if ($category !== null) { if (!$category->can_be_deleted()) { return false; } category_model::del_by_id($category_id); if ($category->has_posts()) { post_model::set(array('category_id' => category_model::default_id), array('category_id' => $category_id)); category_model::inc_by_id(array('post_count' => $category->post_count), category_model::default_id); } } return true; }