/administrator/components/com_contact/helpers/contact.php
PHP | 85 lines | 46 code | 8 blank | 31 comment | 7 complexity | 436b69fad39b98cc0722f3098c384eeb MD5 | raw file
Possible License(s): LGPL-2.1
1<?php 2/** 3 * @package Joomla.Administrator 4 * @subpackage com_contact 5 * 6 * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved. 7 * @license GNU General Public License version 2 or later; see LICENSE.txt 8 */ 9 10defined('_JEXEC') or die; 11 12/** 13 * Contact component helper. 14 * 15 * @package Joomla.Administrator 16 * @subpackage com_contact 17 * @since 1.6 18 */ 19class ContactHelper 20{ 21 /** 22 * Configure the Linkbar. 23 * 24 * @param string $vName The name of the active view. 25 * 26 * @return void 27 * @since 1.6 28 */ 29 public static function addSubmenu($vName) 30 { 31 JSubMenuHelper::addEntry( 32 JText::_('COM_CONTACT_SUBMENU_CONTACTS'), 33 'index.php?option=com_contact&view=contacts', 34 $vName == 'contacts' 35 ); 36 JSubMenuHelper::addEntry( 37 JText::_('COM_CONTACT_SUBMENU_CATEGORIES'), 38 'index.php?option=com_categories&extension=com_contact', 39 $vName == 'categories' 40 ); 41 42 if ($vName == 'categories') 43 { 44 JToolbarHelper::title( 45 JText::sprintf('COM_CATEGORIES_CATEGORIES_TITLE', JText::_('com_contact')), 46 'contact-categories'); 47 } 48 } 49 50 /** 51 * Gets a list of the actions that can be performed. 52 * 53 * @param int The category ID. 54 * @param int The contact ID. 55 * 56 * @return JObject 57 * @since 1.6 58 */ 59 public static function getActions($categoryId = 0, $contactId = 0) 60 { 61 $user = JFactory::getUser(); 62 $result = new JObject; 63 64 if (empty($contactId) && empty($categoryId)) { 65 $assetName = 'com_contact'; 66 $level = 'component'; 67 } 68 elseif (empty($contactId)) { 69 $assetName = 'com_contact.category.'.(int) $categoryId; 70 $level = 'category'; 71 } 72 else { 73 $assetName = 'com_contact.contact.'.(int) $contactId; 74 $level = 'category'; 75 } 76 77 $actions = JAccess::getActions('com_contact', $level); 78 79 foreach ($actions as $action) { 80 $result->set($action->name, $user->authorise($action->name, $assetName)); 81 } 82 83 return $result; 84 } 85}