Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function GetAllSectionsUserHasAccess($sectionID) {
- $tempSection = new SectionChildrenAll($sectionID);
- return $tempSection->getChildSectionsAll();
- }
- class SectionChildrenAll {
- public function __construct($sectionID) {
- $this->id = $sectionID;
- }
- public function getChildSectionsAll() {
- global $main_conn;
- global $userdata;
- $returnedChildren = [];
- // Finds out what section is being requested
- $childSQL_t = ('SELECT id FROM sections WHERE parent = :thisid ORDER BY `list`');
- $childSQL = $main_conn->prepare($childSQL_t);
- $childSQL->bindParam(':thisid', $this->id);
- $childSQL->execute();
- if($childSQL->rowCount()) {
- while($childSectionRow = $childSQL->fetch(PDO::FETCH_ASSOC)) {
- // We need to checks
- $CheckSubPerms = CheckGroupPermissions($childSectionRow['id'], $userdata['user_id']);
- if ($CheckSubPerms[0] == 1 OR $CheckSubPerms[1] == 1) {
- array_push($returnedChildren, $childSectionRow['id']);
- $newChild = new SectionChildrenAll($childSectionRow['id']);
- foreach($newChild->getChildSectionsAll() as $anotherChild) {
- array_push($returnedChildren, $anotherChild);
- }
- }
- }
- }
- return $returnedChildren;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment