private function recursiveMarkCategoryRead($CategoryModel, $UnprocessedCategories, $ParentIDs)
{
$CurrentUnprocessedCategories = array();
$CurrentParentIDs = $ParentIDs;
foreach ($UnprocessedCategories as $Category) {
if (in_array($Category["ParentCategoryID"], $ParentIDs)) {
$this->markCategoryRead($CategoryModel, $Category["CategoryID"]);
// Don't add duplicate ParentIDs
if (!in_array($Category["CategoryID"], $CurrentParentIDs)) {
$CurrentParentIDs[] = $Category["CategoryID"];
}
} else {
// This keeps track of categories that we still need to check on recurse
$CurrentUnprocessedCategories[] = $Category;
}
}
// Base case: if we have not found any new parent ids, we don't need to recurse
if (count($ParentIDs) != count($CurrentParentIDs)) {
$this->recursiveMarkCategoryRead($CategoryModel, $CurrentUnprocessedCategories, $CurrentParentIDs);
}
}