<?php
/**
 * @package Joomla
 * @subpackage Abook
 * @copyright (C) 2010 Ugolotti Federica
 * @license GNU/GPL, see LICENSE.php
 * Abook is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License 2
 * as published by the Free Software Foundation.

 * Abook is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with Abook; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

defined( '_JEXEC' ) or die( 'Restricted access' );

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

class AbookController extends JController
{
	function display()
	{
		$this->checkimagefolder();

		/*if ( ! JRequest::getCmd( 'view' ) ) {
                        JRequest::setVar('view', 'books' );
                }*/
		parent::display();
	}
	
	function checkimagefolder() {
		$config =& JComponentHelper::getParams( 'com_abook' );
		$imgfolder=$config->get( 'img_path' );
		if (JFolder::exists( JPATH_SITE.'/images/'.$imgfolder)==false) {
			$msg=JFactory::getApplication();
                        $msg1=$msg->enqueueMessage( JText::_( 'YOU MUST CREATE THE FOLDER').' '.JPATH_SITE.'/images/'.$imgfolder, 'error' );
			return $msg1;
		}
		return;
	}
}
