<?php 

class Permissions
{
	public function __construct($db,$us)
	{
		$this->db = $db;
		$this->us = $us;
	}
	public function hasPermision($permId,$userId = 0)
	{
		if(!$userId) $userId = $this->us->user_id;
		$sql = "SELECT * FROM _UserPermissions WHERE id_user = ".$userId." AND id_permission = ".$permId;
		$rs = $this->db->SQLexecute($sql);
		if( $this->db->fetchAssoc($rs) )
			return true;
		return false;
		
	}
	public function permWarning()
	{
		return "Ext.Msg.alert('Error','Access denied!')";
	}
}
?>