<?php
/**
 * @version $Id: header.php 248 2008-05-23 10:40:56Z elkuku $
 * @package		prot_conf
 * @subpackage	
 * @author		EasyJoomla {@link http://www.easy-joomla.org Easy-Joomla.org}
 * @author		Jays.Soho {@link http://jays.survey-partner.com}
 * @author		Efthimios Mavrogeorgiadis
 * @author		Created on 25-Feb-2009
 */

// no direct access
defined( '_JEXEC' ) or die( ';)' );

jimport( 'joomla.application.component.model' );

require_once( JPATH_COMPONENT.DS.'libraries'.DS.'protconf.class.php' );
require_once( JPATH_COMPONENT.DS.'libraries'.DS.'pat_fileperm.class.php' );

/**
 * prot_conf Model
 *
 * @package    prot_conf
 * @subpackage Models
 */
class prot_confModelpermit extends JModel
{
	var $oldf = '';
	var $file = '';
	var $newf = '';
	
	function __construct()
	{
	 	parent::__construct();
	}//function
	
	function set_var()
	{	
		$this->oldf = new protectConfigureOld();
		
		$this->newf = new protectConfigureNew();
		
		$this->file = new file_perm();
		
		$this->oldf->set_main_path(JPATH_SITE);
		$this->oldf->set_old_file_details();
		
	}
	
	function permit()
	{
		$oldf = $this->oldf;
		$file = $this->file;
		
		$permissions = JRequest::getVar('perm');	
		
		if ( $permissions['type'] != '-' ) {
       	 	return '1'.$permissions['type'];
    	}	else {
        	$file = new file_perm();
        	$file->set_file($oldf->full_file_pn);
       		$file->set_permission_array($permissions);
        	if ( !chmod($oldf->full_file_pn, octdec($file->_current_permission)) ) {
				return '2';
       		 }	else {
			   return '0';
       		 }
   		}
	}
	
}
