<?php
    class AccessControl {
        private $data;
        public function __construct(Database $db, $user_group = 0) {
            $this->db = $db;
            $this->user_group = $user_group;

            $this->load($this->user_group);
        }
        
        public function get($key) {
            return (in_array($key, $this->data) ? true : false);
        }
        
        public function all() {
            return $this->data;
        }
        
        public function load($user_group) {
            $_ = array();

            $stmt = $this->db->query("SELECT directory FROM {$this->db->prefix}user_group_permissions WHERE user_group=:user_group", array(':user_group'=>$user_group));
            if($stmt->num_rows > 0){
                foreach($stmt->rows as $row) {
                    $_[] = $row['directory'];
                }
            }
            $this->data = $_;
            return $this->data;
        }
    }