AllViewedPlugin::recursiveMarkCategoryRead PHP Method

recursiveMarkCategoryRead() private method

Helper function to recursively mark categories as read based on a Category's ParentID.
Since: 2.0
private recursiveMarkCategoryRead ( CategoryModel $CategoryModel, array $UnprocessedCategories, array $ParentIDs )
$CategoryModel CategoryModel
$UnprocessedCategories array
$ParentIDs array
    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);
        }
    }