Guest User

Untitled

a guest
Mar 6th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.23 KB | None | 0 0
  1.     function GetAllSectionsUserHasAccess($sectionID) {
  2.         $tempSection = new SectionChildrenAll($sectionID);
  3.  
  4.         return $tempSection->getChildSectionsAll();
  5.     }
  6.     class SectionChildrenAll {
  7.         public function __construct($sectionID) {
  8.             $this->id = $sectionID;
  9.         }
  10.  
  11.         public function getChildSectionsAll() {
  12.             global $main_conn;
  13.             global $userdata;
  14.             $returnedChildren = [];
  15.  
  16.             // Finds out what section is being requested
  17.             $childSQL_t = ('SELECT id FROM sections WHERE parent = :thisid ORDER BY `list`');
  18.             $childSQL = $main_conn->prepare($childSQL_t);
  19.             $childSQL->bindParam(':thisid', $this->id);
  20.             $childSQL->execute();
  21.  
  22.             if($childSQL->rowCount()) {
  23.                 while($childSectionRow = $childSQL->fetch(PDO::FETCH_ASSOC)) {
  24.                     // We need to checks
  25.                    
  26.                     $CheckSubPerms = CheckGroupPermissions($childSectionRow['id'], $userdata['user_id']);
  27.  
  28.                     if ($CheckSubPerms[0] == 1 OR $CheckSubPerms[1] == 1) {
  29.                         array_push($returnedChildren, $childSectionRow['id']);
  30.  
  31.                         $newChild = new SectionChildrenAll($childSectionRow['id']);
  32.                         foreach($newChild->getChildSectionsAll() as $anotherChild) {
  33.                             array_push($returnedChildren, $anotherChild);
  34.                         }
  35.                     }
  36.                 }
  37.             }
  38.  
  39.             return $returnedChildren;
  40.         }
  41.     }
Advertisement
Add Comment
Please, Sign In to add comment