<?php
/**
 * Adodis Blog package
 * @author J-Extension <contact@jextn.com>
 * @link http://www.jextn.com
 * @copyright (C) 2012 - 2013 J-Extension
 * @license GNU/GPL, see LICENSE.php for full license.
**/

defined('_JEXEC') or die( 'Restricted Access' );

jimport('joomla.application.component.view');

class AdodisBlogViewUsers extends JView
{
	protected $items;
	protected $pagination;
	protected $state;

	/**
	 * Display the view
	 */
	function display( $tpl = null )
	{
		$model				= $this->getModel();
		$this->items		= $this->get('Items');
		$this->pagination	= $this->get('Pagination');
		$this->state		= $this->get('State');
		$this->user			= JFactory::getUser();
		$this->filteruser 	= $model->filterUser($this->state->get('filter.user'));
		// Check for errors.
		if (count($errors = $this->get('Errors'))) {
			JError::raiseError(500, implode("\n", $errors));
			return false;
		}

		// Preprocess the list of items to find ordering divisions.
		// TODO: Complete the ordering stuff with nested sets
		foreach ($this->items as &$item) {
			$item->order_up = true;
			$item->order_dn = true;
		}

		$this->addToolbar();

		parent::display( $tpl );
	}

	/**
	 * Add the page title and toolbar.
	 */
	protected function addToolbar()
	{
		// Initialize variables
		$canDo		= AdodisBlogHelper::getActions($this->state->get('filter.category_id'));

		JToolBarHelper::title( JText::_('COM_ADODISBLOG').' : '.JText::_('COM_ADODISBLOG_MANAGE_BLOGS'), 'adodisblog.png');

		if ($canDo->get('core.edit.state')) {
			JToolBarHelper::divider();
			JToolBarHelper::custom('users.unBlockUser', 'user.png', 'user.png','COM_ADODISBLOG_UNBLOCK', true);
			JToolBarHelper::custom('users.blockUser', 'blocked_user.png', 'blocked_user.png', 'COM_ADODISBLOG_BLOCK', true);
			JToolBarHelper::divider();

		}
		JToolBarHelper::cancel('users.cancel', 'JTOOLBAR_CANCEL');

		if ($canDo->get('core.admin')) {
			JToolBarHelper::divider();
			JToolBarHelper::preferences('com_adodisblog');
		}
	}
}
?>