public static function GetCategoryBlogsByState($categoryid, $state) { $retval = array(); //get posts by category $posts = PostFactory::GetBlogsByCategory($categoryid); //then filter foreach ($posts as $post) { if ($state == 'notpublished') { array_push($retval, $post); } else { if ($state == 'unpublished') { array_push($retval, $post); } else { if ($state == 'outdated') { array_push($retval, $post); } else { if ($state == 'canpublish') { //it is ready to publish if array_push($retval, $post); } } } } } return $retval; }
require_once 'post.php'; require_once 'posttype.php'; require_once 'userresponse.php'; require_once 'userreply.php'; require_once 'userresponse.php'; require_once 'userreply.php'; $GLOBALS['mysqli'] = MySQLConnection::Open(); //we're changed this around //first get the blog that we should be publishing right now - readyforpublish $blogsToPublish = array(); if ($categoryid == -1) { $blogsToPublish = PostFactory::GetAllPublishableBlogs(); } else { $blogs = null; if (is_numeric($categoryid)) { $blogs = PostFactory::GetBlogsByCategory($categoryid); } else { $blogs = PostFactory::GetBlogsByState($categoryid); } foreach ($blogs as $post) { if ($post->CanPublish && $post->ReadyForPublish) { array_push($blogsToPublish, $post); } } } $numberofblogspublished = 0; //go ahead only if at least there is at least one blog to publish - else NOTHING has changed if (sizeof($blogsToPublish) > 0) { //we're going to create an array of categories that we want to publish //these are categories of blogs that we are publishing right now $categoriesToPublish = array();