/administrator/components/com_contact/helpers/contact.php
https://bitbucket.org/eternaware/joomus · PHP · 85 lines · 46 code · 8 blank · 31 comment · 7 complexity · 436b69fad39b98cc0722f3098c384eeb MD5 · raw file
- <?php
- /**
- * @package Joomla.Administrator
- * @subpackage com_contact
- *
- * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
- * @license GNU General Public License version 2 or later; see LICENSE.txt
- */
- defined('_JEXEC') or die;
- /**
- * Contact component helper.
- *
- * @package Joomla.Administrator
- * @subpackage com_contact
- * @since 1.6
- */
- class ContactHelper
- {
- /**
- * Configure the Linkbar.
- *
- * @param string $vName The name of the active view.
- *
- * @return void
- * @since 1.6
- */
- public static function addSubmenu($vName)
- {
- JSubMenuHelper::addEntry(
- JText::_('COM_CONTACT_SUBMENU_CONTACTS'),
- 'index.php?option=com_contact&view=contacts',
- $vName == 'contacts'
- );
- JSubMenuHelper::addEntry(
- JText::_('COM_CONTACT_SUBMENU_CATEGORIES'),
- 'index.php?option=com_categories&extension=com_contact',
- $vName == 'categories'
- );
- if ($vName == 'categories')
- {
- JToolbarHelper::title(
- JText::sprintf('COM_CATEGORIES_CATEGORIES_TITLE', JText::_('com_contact')),
- 'contact-categories');
- }
- }
- /**
- * Gets a list of the actions that can be performed.
- *
- * @param int The category ID.
- * @param int The contact ID.
- *
- * @return JObject
- * @since 1.6
- */
- public static function getActions($categoryId = 0, $contactId = 0)
- {
- $user = JFactory::getUser();
- $result = new JObject;
- if (empty($contactId) && empty($categoryId)) {
- $assetName = 'com_contact';
- $level = 'component';
- }
- elseif (empty($contactId)) {
- $assetName = 'com_contact.category.'.(int) $categoryId;
- $level = 'category';
- }
- else {
- $assetName = 'com_contact.contact.'.(int) $contactId;
- $level = 'category';
- }
- $actions = JAccess::getActions('com_contact', $level);
- foreach ($actions as $action) {
- $result->set($action->name, $user->authorise($action->name, $assetName));
- }
- return $result;
- }
- }