<?php
/**
 * Marketplace - Component Marketplace 
 * ******************************************************************
 *
 * PHP version 7.0
 *
 * @category   Component
 * @package    Joomla
 * @author     WebKul software private limited <support@webkul.com>
 * @copyright  2010 WebKul software private limited
 * @license    http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 * @version    GIT:5.2
 * @filesource http://store.webkul.com
 * @link       Technical Support:  webkul.uvdesk.com
 * ******************************************************************
 */
// no direct access
defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.controller');
if (!class_exists('MarketplaceControllerFeedback')) {
    /**
     * MarketplaceControllerFeedback class
     * 
     * @category Component
     * @package  Joomla
     * @author   WebKul software private limited <support@webkul.com>
     * @license  http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
     * @link     Technical Support:  webkul.uvdesk.com
     */
    class MarketplaceControllerFeedback extends JControllerLegacy
    {
        public $jinput;
        /**
         * __construct function
         */
        function __construct()
        {
            $this->jinput=JFactory::getApplication()->input;
            parent::__construct();
        }
        /**
         * Approve function
         *
         * @return void
         */
        function approve()
        { 
            $cid  = $this->jinput->get('cid', array(0), 'post', 'array');
            if (!is_array($cid) || count($cid) < 1) {
                JError::raiseError(
                    500,
                    JText::_('SELECT_UNPUBLISH')
                );
            }
            $model = $this->getModel('feedback');
            if (!$model->approvefeedback($cid)) {
                echo "<script> alert('".$model->getError().
                "'); window.history.go(-1); </script>\n";
            }
            $total = count($cid);
            $msg  = $total.' '.JText::_('APPROVE_FEEDBACK');
            $this->setRedirect(
                'index.php?option=com_marketplace&view=feedback',
                $msg
            );
        }
        /**
         * Reject function
         *
         * @return void
         */
        function reject()
        {
            $cid  = $this->jinput->get('cid', array(0), 'post', 'array');
            if (!is_array($cid) || count($cid) < 1) {
                JError::raiseError(
                    500,
                    JText::_('SELECT_UNPUBLISH')
                );
            }
            $model = &$this->getModel('feedback');
            if (!$model->rejectfeedback($cid)) {
                echo "<script> alert('".$model->getError()
                ."'); window.history.go(-1); </script>\n";
            }
            $total = count($cid);
            $msg  = $total.' '.JText::_('REJECT_FEEDBACK');
            $this->setRedirect(
                'index.php?option=com_marketplace&view=feedback',
                $msg
            );
        }
        /**
         * Remove function
         *
         * @return void
         */
        function remove()
        {
            global $option;
            $cid = $this->jinput->get('cid', array(0), 'post', 'array');
            if (!is_array($cid) || count($cid) < 1) {
                JError::raiseError(500, JText::_('SELECT_DELETE'));
            }
            $model = $this->getModel('feedback');
            $msg = $model->delete($cid);
            $cache = &JFactory::getCache('com_marketplace');
            $cache->clean();
            $this->setRedirect(
                'index.php?option=com_marketplace&view=feedback',
                $msg
            );
        }
    }
}
