<?php
/**
* @version 1.0.0
* @package RSFiles! 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.controller');

class rsfilesController extends JController
{

	var $_db;
	function __construct()
	{
		global $mainframe;
		parent::__construct();
		$this->_db=& JFactory::getDBO();
	}
	
	function saveRegistration()
	{
		$post = JRequest::get('post');
		$rsfilesConfig = $post['rsfilesConfig'];
		if (!isset($rsfilesConfig['license_code'])) $rsfilesConfig['license_code']='';

		if($rsfilesConfig['license_code']=='')
		{
			$msg=JText::_('RSFL_REGISTRATION_CODE');
			$this->setRedirect('index.php?option=com_rsfiles',$msg);
			return;
		}

		$this->_db->setQuery("UPDATE `#__rsfiles_config` SET ConfigValue = '". trim( $rsfilesConfig['license_code'] ). "' WHERE ConfigName = 'license_code'");
		$this->_db->query();

		$msg=JText::_('RSFL_REGISTRATION_SAVED');
		$this->setRedirect('index.php?option=com_rsfiles&task=updates',$msg);
	}
	
	/* GENERAL TASKS */
	
	function rsfiles()
	{
		JRequest::setVar('view','rsfiles');
		JRequest::setVar('layout','default');
		parent::display();
	}

	function updates()
	{
		JRequest::setVar('view','rsfiles');
		JRequest::setVar('layout','updates');
		parent::display();
	}

	function settings()
	{
		JRequest::setVar('view','rsfiles');
		JRequest::setVar('layout','settings');
		parent::display();
	}
	
	function dldlocation()
	{
		JRequest::setVar('view','rsfiles');
		JRequest::setVar('layout','downloadfolder');
		parent::display();
	}

	/* FILE TASKS */
	
	function files()
	{
		JRequest::setVar('view','files');
		JRequest::setVar('layout','default');
		parent::display();
	}

	function showfiles()
	{
		JRequest::setVar('view','files');
		JRequest::setVar('layout','show');
		parent::display();
	}

	function editfile()
	{
		JRequest::setVar('view','files');
		JRequest::setVar('layout','edit');
		parent::display();
	}
	
	function editmirror()
	{
		JRequest::setVar('view','files');
		JRequest::setVar('layout','mirrors');
		parent::display();
	}
	
	/* LICENSES TASKS */
	
	
	function licenses()
	{
		JRequest::setVar('view','licenses');
		JRequest::setVar('layout','default');
		parent::display();
	}
	
	function editlicense()
	{
		JRequest::setVar('view','licenses');
		JRequest::setVar('layout','edit');
		parent::display();
	}
	
	
	/* GROUP TASKS */
	
	function groups()
	{
		JRequest::setVar('view','groups');
		JRequest::setVar('layout','default');
		parent::display();
	}
	
	
	function editgroup()
	{
		JRequest::setVar('view','groups');
		JRequest::setVar('layout','edit');
		parent::display();
	}
	
	/* STATISTICS TASKS */
	
	function statistics()
	{
		JRequest::setVar('view','statistics');
		JRequest::setVar('layout','default');
		parent::display();
	}
	
	
	function viewstatistic()
	{
		JRequest::setVar('view','statistics');
		JRequest::setVar('layout','edit');
		parent::display();
	}
	
	/* THEMES TASKS */
	
	function themes()
	{
		JRequest::setVar('view','themes');
		JRequest::setVar('layout','default');
		parent::display();
	}
	
	function edittheme()
	{
		JRequest::setVar('view','themes');
		JRequest::setVar('layout','edit');
		parent::display();
	}
	
	function edittemplate()
	{
		JRequest::setVar('view','themes');
		JRequest::setVar('layout','template');
		parent::display();
	}
	
	/* REPORTS TASKS */
	
	function reports()
	{
		JRequest::setVar('view','reports');
		JRequest::setVar('layout','default');
		parent::display();
	}
	
	function viewreport()
	{
		JRequest::setVar('view','reports');
		JRequest::setVar('layout','view');
		parent::display();
	}
	
	function users()
	{
		JRequest::setVar('view','users');
		JRequest::setVar('layout','default');
		JRequest::setVar('tmpl','component');
		parent::display();
	}
	
	
}
?>