Check User Page Permission with PageID

I am populating content on a page in concrete5 8.2.1 from it's child pages using $page->getCollectionChildrenArray(true), but the issue is that it outputs pages that the user doesn't have permission to see. I want to add in a check to stop it outputting the content if the logged in user doesn't have permission to view that page. I found the documentation on the Checking Permissions Against Other Users or Groups but I can't seem to work out how to get it to work for my case. I have the pageID as in example code so if I can use that will be helpful.

Example code

<?php $curriculums = $page->getCollectionChildrenArray(true);
 if(count($curriculums) > 0 ) { ?>
<section class="display-box">
    <?php for ($x = 0; count($curriculums) > $x; $x++) {
            $curriculum = Page::getByID($curriculums[$x]); ?>
    <?php echo "<article><header><h2>".$curriculum->getCollectionName()."</h2></header>";
        $desc = $curriculum->getCollectionDescription();
        if ($desc){ ?>
        <?php } echo "<a class='box-link' href='".$curriculum->getCollectionPath()."'>View ".$curriculum->getCollectionName()."  <i class='fa fa-arrow-circle-right' aria-hidden='true'></i></a>";
            echo "</article>";
        } ?>
<?php } else {echo '<p class="no-message">There are no modules available for this curriculum at this time.</p>';} ?>

I'm new to concrete5, so any help would be appreciated.

View Replies:
pvernaglia replied on at Permalink Reply
I think I would use a page list to do that rather than getCollectionChildrenArray, it will honor user permissions.
dpdesignz replied on at Permalink Reply
Thanks but unfortunately how what I'm outputting I don't think that will work.

I found code that worked though finally :)

$curriculum = Page::getByID($curriculums[$x]);
$curp = new Permissions($curriculum);
if($curp->canViewPage()) {}