Location: PHPKode > projects > injooosm > administrator/components/com_injooosm/controllers/comments.php
<?php
/**
 * Joomla! 1.5 component injooosm
 *
 * @version $Id: comments.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.application.component.controller' );

class injooosmControllerComments extends injooosmController  {

        /**
         * 
         */
	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('comments');
		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=comments&controller=comments', false ));
	}

        /**
         *
         */
	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('comments');
		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=comments&controller=comments', false ));
	}

        /**
         * remove comments
         */
	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('comments');
		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=comments&controller=comments', false ));
	}

        /**
         * update a comment
         */
        function saveComment()  {

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

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

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