Location: PHPKode > scripts > Purple Beanie Web Booking For Joomla > com_pbbooking/admin/controllers/configuration.php
<?php
/**
 * @package    PurpleBeanie.PBBooking
 * @subpackage Components
 * @link http://www.purplebeanie.com
 * @license    GNU/GPL
 */
 
// No direct access
 
defined( '_JEXEC' ) or die( 'Restricted access' );
 
jimport('joomla.application.component.controller');
 
/**
 * PBBooking Component Controller
 *
 * @package    PurpleBeanie.PBBooking
 * @subpackage Components
 */

class PbbookingsControllerconfiguration extends JController
{
	
	function __construct()
	{
	    parent::__construct();

	    // Register Extra tasks
	    $this->registerTask( 'add'  ,     'edit' );
	}
	
    /**
     * Method to display the view
     *
     * @access    public
     */
    function display()
    {	
		$sql = "select * from #__pbbooking_treatments";
		$db =& JFactory::getDBO();
		$db->setQuery( $sql );
		$treatments = $db->loadAssocList();
		JRequest::setVar('treatments',$treatments);
		JRequest::setVar( 'view', 'treatment' );
		JRequest::setVar( 'layout', 'default'  );
		

			$query = "SELECT path from #__pbbooking_cals where in_cal=1";
			$db->setQuery($query);
			$cals = $db->loadResultArray();

			$calprobs = 0;
			foreach($cals as $test) {
				if (file_exists($test)) {
				} else {
					$calprobs = 1;
				}
			}

			if ($calprobs == 0) {
				parent::display();
			} else {
				$this->setMessage( JText::sprintf( 'It appears your calendars are not configured correctly
					please ensure this configuration is fixed first.', $n ) );
				$this->setRedirect( 'index.php?option=com_pbbooking&controller=calendar&task=display' );
			}
		
        parent::display();
    }

	function edit()
	{
	    JRequest::setVar( 'view', 'configuration' );
	    JRequest::setVar( 'layout', 'form'  );
	    JRequest::setVar('hidemainmenu', 1);
		
			$db =& JFactory::getDBO();

			$query = "SELECT path from #__pbbooking_cals where in_cal=1";
			$db->setQuery($query);
			$cals = $db->loadResultArray();

			$calprobs = 0;
			foreach($cals as $test) {
				if (file_exists($test)) {
				} else {
					$calprobs = 1;
				}
			}

			if ($calprobs == 0) {
				parent::display();
			} else {
				$this->setMessage( JText::sprintf( 'It appears your calendars are not configured correctly
					please ensure this configuration is fixed first.', $n ) );
				$this->setRedirect( 'index.php?option=com_pbbooking&controller=calendar&task=display' );
			}
	
}
	
	function save() 
	{
		$sender_email = JRequest::getVar('sender_email');
		$email_body = $_POST['email_body'];
		$calendar_message = $_POST['calendar_message'];

		$email_subject = JRequest::getVar('email_subject');
		$site_url=JRequest::getVar('site_url');
		$id = JRequest::getVar('id');
		$timezone = JRequest::getVar('timezone');
		$block_same_day = JRequest::getVar('block_same_day');
				
		if ($id !=0) {
			$sql = sprintf("update #__pbbooking_config set sender_email = '%s',email_body='%s',email_subject='%s',site_url='%s',timezone='%s',block_same_day=%s,calendar_message='%s' where id = %s",
				$sender_email,$email_body,$email_subject,$site_url,$timezone,$block_same_day,$calendar_message,$id);
		} else {
			$sql = sprintf("insert into #__pbbooking_config (sender_email,email_body,email_subject,site_url,timezone,block_same_day,calendar_message) values ('%s','%s','%s','%s','%s','%s')",
				$sender_email,$email_body,$email_subject,$site_url,$timezone,$block_same_day,$calendar_message);
		}
		$db =& JFactory::getDBO();
		$db->setQuery( $sql );
		$db->Execute($sql);
		$this->setRedirect( 'index.php?option=com_pbbooking', null );
		
	}
}
Return current item: Purple Beanie Web Booking For Joomla