<?php

namespace SCF\Core;

class AclManager {

    /**
     * @var mixed
     */
    private $_db;

    /**
     * @var
     */
    private $_userGroup;

    /**
     * @var
     */
    private $_acl;

    /**
     * AclManager constructor.
     * @param Database $db
     * @param $userGroupId
     */
    public function __construct(Database $db, $userGroupId)
    {
        $this->_db = $db;
        $this->_userGroup = $userGroupId;
        $this->getAcl();
    }

    /**
     *
     */
    private function getAcl()
    {
        $this->_db->query("SELECT * FROM system_usergroups WHERE guid = :groupId LIMIT 0,1");
        $this->_db->bind(':groupId', $this->_userGroup);
        $this->_acl = $this->_db->single();
    }

    /**
     * @param $value
     * @return string
     */
    public function acl($value)
    {
        if(isset($this->_acl[$value])) {
            return $this->_acl[$value];
        }
        else {
            return 'N/A';
        }
    }
}