Location: PHPKode > projects > injooosm > administrator/components/com_injooosm/controllers/files.php
<?php
/**
 * Joomla! 1.5 component injooosm
 *
 * @version $Id: files.php 2010-02-08 14:10:00$
 * @author Christian Knorr
 * @package injooosm
 * @subpackage backend
 * @license GNU/GPL
 * @filesource
 *
 */

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

jimport( 'joomla.application.component.controller' );
require_once( JPATH_COMPONENT.DS.'helpers'.DS.'helper.php' );
JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_injooosm'.DS.'tables');
/**
 * Controller Class Files
 */
class injooosmControllerFiles extends injooosmController  {

        /**
         * @uses injooosmModelFiles::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('files');
		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=files&controller=files', false ));
	}

        /**
         * @uses injooosmModelFiles::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('files');
		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=files&controller=files', false ));
	}


        /**
         * @uses injooosmModelFiles::accessregistered
         * @return redirect
         */
	function accessregistered()
	{
		// 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('files');
		if(!$model->access($cid, 1)) {
			echo "<script> alert('".$model->getError(true)."'); window.history.go(-1); </script>\n";
		}

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

        /**
         * @uses injooosmModelFiles::accessspecial
         * @return redirect
         */
	function accessspecial()
	{
		// 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('files');
		if(!$model->access($cid, 2)) {
			echo "<script> alert('".$model->getError(true)."'); window.history.go(-1); </script>\n";
		}

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

        /**
         * @uses injooosmModelFiles::accessspecial
         * @return redirect
         */
	function accesspublic()
	{
		// 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('files');
		if(!$model->access($cid, 0)) {
			echo "<script> alert('".$model->getError(true)."'); window.history.go(-1); </script>\n";
		}

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

        /**
         * @uses injooosmModelFiles::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('files');
		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=files&controller=files', false ));
	}

        /**
         *
         */
        function savefile()  {

		// Check for request forgeries
		JRequest::checkToken() or jexit( 'Invalid Token' );

                $model = $this->getModel('files');
		if(!$model->saveFile()) {
// 			echo "<script> alert('".$model->getError(true)."'); window.history.go(-1); </script>\n";
			echo "<script> alert('Error');</script>";
// 			$this->setRedirect( JRoute::_('index.php?option=com_injooosm&task=files&controller=files', false ));
		} else
			$this->setRedirect( JRoute::_('index.php?option=com_injooosm&task=files&controller=files', false ));
        }

        function savefiles() {
		// Check for request forgeries
		JRequest::checkToken() or jexit( 'Invalid Token' );

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

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

        function updatefile()  {
		// Check for request forgeries
		JRequest::checkToken() or jexit( 'Invalid Token' );

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

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

	function fetchJPTfiles() {
		JRequest::checkToken() or jexit( 'Invalid Token' );
                $model = $this->getModel('files');
		echo($model->_fetchJPTfiles());
	}
}
Return current item: injooosm