<?php
/**
* @version 1.0.0
* @package RSEvents! 1.0.0
* @copyright (C) 2009 www.rsjoomla.com
* @license GPL, http://www.gnu.org/copyleft/gpl.html
*/

defined( '_JEXEC' ) or die( 'Restricted access' ); 
jimport( 'joomla.application.component.view');

class rseventsViewFiles extends JView
{
	function display($tpl = null)
	{
		$layout=JRequest::getVar('layout','','request');
		
		$Itemid = intval(JRequest::getVar('Itemid','','request'));
		$itemId = ($Itemid == '') ? '' : '&Itemid='.$Itemid;
		$this->assignRef('itemId',$itemId);
		$this->assignRef('Itemid',$Itemid);
		
		switch($layout)
		{
			
			default:
			{
			global $mainframe;
			$user = &JFactory::getUser();
			$owner = $this->get('Owner');
			
			if($user->usertype == 'Super Administrator' || $user->id == $owner )
			{
				$fileDetails=$this->get('FileData');
				
				if(empty($fileDetails->FilePermission))
				$fileDetails->FilePermission = '11111111';

				$filePermission[0] = ($fileDetails->FilePermission[0]==0 ? '' : 'checked="checked"');
				$filePermission[1] = ($fileDetails->FilePermission[1]==0 ? '' : 'checked="checked"');
				$filePermission[2] = ($fileDetails->FilePermission[2]==0 ? '' : 'checked="checked"');
				$filePermission[3] = ($fileDetails->FilePermission[3]==0 ? '' : 'checked="checked"');
				$filePermission[4] = ($fileDetails->FilePermission[4]==0 ? '' : 'checked="checked"');
				$filePermission[5] = ($fileDetails->FilePermission[5]==0 ? '' : 'checked="checked"');
				
				$this->assignRef('fileDetails',$fileDetails);
				$this->assignRef('filePermission' , $filePermission);
				
			} else $mainframe->redirect(html_entity_decode(JRoute::_('index.php?option=com_rsevents&view=events'.$itemId)),JText::_('RSE_ACCESS_DENIED'));
			} break;
			
		}
		
		
		parent::display($tpl);
	}
}