Location: PHPKode > projects > injooosm > administrator/components/com_injooosm/controllers/terrain.php
<?php
/**
 * Joomla! 1.5 component injooosm
 *
 * @version $Id: terrains.php 2009-11-22 14:03:00$
 * @author Christian Knorr
 * @package injooosm
 * @subpackage backend
 * @license GNU/GPL
 * @filesource
 *
 */

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

jimport( 'joomla.appliterrainion.component.controller' );
require_once( JPATH_COMPONENT.DS.'helpers'.DS.'helper.php' );
JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_injooosm'.DS.'tables');

/**
 * Controller Class terrainegories
 */
class injooosmControllerTerrain extends injooosmController  {

    function save()  {
        global $mainframe;
        
        // Check for request forgeries
        JRequest::checkToken() or jexit( 'Invalid Token' );

        $model = $this->getModel('terrain');
        $model->save();

        // redirect to terrains overview
        $link = JRoute::_( "index.php?option=com_injooosm&task=terrain&controller=terrain",false);
        $this->setRedirect($link, JText::_('OSM_TERRAIN_SAVED'));
    }

        /**
         * @uses injooosmModelterrain::publish
         * @return redirect
         */
	function publish()
	{
		// Check for request forgeries
		JRequest::checkToken() or jexit( 'Invalid Token' );

		$cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
		JArrayHelper::toInteger($cid);

		if (count( $cid ) < 1) {
			JError::raiseError(500, JText::_( 'Select an item to publish' ) );
		}

		$model = $this->getModel('terrain');
		if(!$model->publish($cid, 1)) {
			echo "<script> alert('".$model->getError(true)."'); window.history.go(-1); </script>\n";
		}

		$this->setRedirect( JRoute::_('index.php?option=com_injooosm&task=terrain&controller=terrain', false ));
	}

        /**
         * @uses injooosmModelterrain::publish
         * @return redirect
         */
	function unpublish()
	{
		// Check for request forgeries
		JRequest::checkToken() or jexit( 'Invalid Token' );

		$cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
		JArrayHelper::toInteger($cid);

		if (count( $cid ) < 1) {
			JError::raiseError(500, JText::_( 'Select an item to unpublish' ) );
		}

		$model = $this->getModel('terrain');
		if(!$model->publish($cid, 0)) {
			echo "<script> alert('".$model->getError(true)."'); window.history.go(-1); </script>\n";
		}

		$this->setRedirect( JRoute::_('index.php?option=com_injooosm&task=terrain&controller=terrain', false ));
	}

        /**
         * @uses injooosmModelterrain::delete
         * @return redirect
         */
	function remove()
	{
		// Check for request forgeries
		JRequest::checkToken() or jexit( 'Invalid Token' );

		$cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
		JArrayHelper::toInteger($cid);

		if (count( $cid ) < 1) {
			JError::raiseError(500, JText::_( 'Select an item to delete' ) );
		}

		$model = $this->getModel('terrain');
		if(!$model->delete($cid)) {
			echo "<script> alert('".$model->getError(true)."'); window.history.go(-1); </script>\n";
		}

		$this->setRedirect( JRoute::_('index.php?option=com_injooosm&task=terrain&controller=terrain', false ));
	}

}
Return current item: injooosm