<?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.view');
jimport('joomla.html.html');
jimport('joomla.html.behavior');
/**
 * MarketplaceViewMpusers 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 MarketplaceViewMpusers extends JViewLegacy
{
    protected $items;
    protected $pagination;
    protected $state;
    public $filterForm;
    public $activeFilters;
    public $sortColumn;
    public $sortDirection;
    public $searchterms;
    /**
     * Display function
     *
     * @param [type] $tpl var
     * 
     * @return void
     */
    function display($tpl = null)
    {
        global $option;
        $this->items = $this->get('Items');
        $this->pagination = $this->get('Pagination');
        $this->state = $this->get('State');
        $this->filterForm    = $this->get('FilterForm');
        $this->activeFilters = $this->get('ActiveFilters');
        $this->canDo         = JHelperContent::getActions('com_marketplace');
        $app=JFactory::getApplication();
        if (count($errors = $this->get('Errors'))) {
            JError::raiseError(500, implode('<br />', $errors));
            return false;
        }
        JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
        $this->addToolBar();
        $this->sidebar = JHtmlSidebar::render();
        parent::display($tpl);
    }
    /**
     * AddToolbar function
     *
     * @return void
     */
    protected function addToolbar()
    {
        $user  = JFactory::getUser();
        JToolbarHelper::title(
            JText::_('COM_MARKETPLACE_VIEW_MARKETPLACE_TITLE'), 'mpusers'
        );
        JToolbarHelper::divider();
        JToolbarHelper::publish(
            'mpusers.activate', 'COM_USERS_TOOLBAR_ACTIVATE', true
        );
        JToolbarHelper::unpublish('mpusers.block', 'COM_USERS_TOOLBAR_BLOCK', true);
        JToolbarHelper::custom(
            'mpusers.unblock', 'unblock.png', 'unblock_f2.png',
            'COM_USERS_TOOLBAR_UNBLOCK', true
        );
        JToolbarHelper::divider();
        JToolbarHelper::custom(
            'mpusers.synchronizeuser', 'addseller', '', 'MAKE_SELLER', true
        );
        JToolBarHelper::preferences('com_marketplace');
    }
    /**
     * GetSortFields function
     *
     * @return void
     */
    protected function getSortFields()
    {
        return array(
            'a.name' => JText::_('COM_USERS_HEADING_NAME'),
            'a.username' => JText::_('JGLOBAL_USERNAME'),
            'a.block' => JText::_('COM_USERS_HEADING_ENABLED'),
            'a.activation' => JText::_('COM_USERS_HEADING_ACTIVATED'),
            'a.email' => JText::_('JGLOBAL_EMAIL'),
            'a.lastvisitDate' => JText::_('COM_USERS_HEADING_LAST_VISIT_DATE'),
            'a.registerDate' => JText::_('COM_USERS_HEADING_REGISTRATION_DATE'),
            'a.id' => JText::_('JGRID_HEADING_ID')
        );
    }
}
