<?php 

include_once('../libs/main.php');

$adminObj = new admin();

if(!isset($_SESSION['admin_user']) || $_SESSION['admin_user']==''){
	header('location:admin-login.php');
	exit;
}

$admin_filename=basename($_SERVER['SCRIPT_FILENAME']);

$modules = $adminObj->GetPageModule($admin_filename);

if($_SESSION['admin_user']!= ''){	

	if($_SESSION['admin_access']!='Full'){
		
		
		$admin_access = explode(',',$_SESSION['admin_access']);
		
		if(isset($modules) && !empty($modules)){
			if(!in_array($modules->module_id,$admin_access)){				
				header("Location: access_denied.php");
				exit;
			}
		}
	}
	
	$adminD = $adminObj->fromId($_SESSION['admin_id']);
	$event_access = unserialize($adminD->access_event);

	$ADD_ACCESS = false;
	$EDIT_ACCESS = false;
	$DELETE_ACCESS = false;
	
	$module_access = (isset($modules->id) && $event_access[$modules->id]) ? $event_access[$modules->id] : array();

	if(in_array('add',$module_access)){
		$ADD_ACCESS = true;
	}
	if(in_array('edit',$module_access)){
		$EDIT_ACCESS = true;
	}
	if(in_array('delete',$module_access)){
		$DELETE_ACCESS = true;
	}
if($_SESSION['admin_access'] == 'Full'){
	$ADD_ACCESS = true;
	$EDIT_ACCESS = true;
	$DELETE_ACCESS = true;
	}
	
}else {	
	header("Location: index.php");
	exit;
}

?>