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

class jegroupbuyHelper
{
	/**
	 * Configure the Linkbar.
	 *
	 * @param	string	The name of the active view.
	 *
	 * @return	void
	 * @since	1.6
	 */
	public static function addSubmenu($submenu)
	{
		JSubMenuHelper::addEntry(JText::_('JE_SUBMENU_PRODUCT_MESSAGES'), 'index.php?option=com_jegroupbuy&view=products', $submenu == 'products');
		JSubMenuHelper::addEntry(JText::_('JE_SUBMENU_STORE_MESSAGES'), 'index.php?option=com_jegroupbuy&view=stores', $submenu == 'stores');
		JSubMenuHelper::addEntry(JText::_('JE_SUBMENU_COUPON_TEMPLATE'), 'index.php?option=com_jegroupbuy&task=templates.edit&id=1', $submenu == 'templates');
		JSubMenuHelper::addEntry(JText::_('JE_SUBMENU_ORDER_MESSAGES'), 'index.php?option=com_jegroupbuy&view=orders', $submenu == 'orders');
		JSubMenuHelper::addEntry(JText::_('JE_SUBMENU_COUPON_SETTINGS'), 'index.php?option=com_jegroupbuy&task=settings.edit&id=1', $submenu == 'settings');
		JSubMenuHelper::addEntry(JText::_('JE_SUBMENU_CATEGORIES'), 'index.php?option=com_categories&view=categories&extension=com_jegroupbuy', $submenu == 'categories');


		// set some global property
		$document = JFactory::getDocument();

		if ($submenu == 'categories')
		{
			$document->setTitle(JText::_('JE_ADMINISTRATION_CATEGORIES'));
		}
	}
	/**
	 * Get the actions
	 */
	public static function getActions($messageId = 0)
	{
		$user	= JFactory::getUser();
		$result	= new JObject;

		if (empty($messageId)) {
			$assetName = 'com_jegroupbuy';
		}
		else {
			$assetName = 'com_jegroupbuy.message.'.(int) $messageId;
		}

		$actions = array(
			'core.admin', 'core.manage', 'core.create', 'core.edit', 'core.edit.state', 'core.delete'
		);

		foreach ($actions as $action) {
			$result->set($action,	$user->authorise($action, $assetName));
		}

		return $result;
	}
}
