/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

  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. defined('_JEXEC') or die;
  10. /**
  11. * Contact component helper.
  12. *
  13. * @package Joomla.Administrator
  14. * @subpackage com_contact
  15. * @since 1.6
  16. */
  17. class ContactHelper
  18. {
  19. /**
  20. * Configure the Linkbar.
  21. *
  22. * @param string $vName The name of the active view.
  23. *
  24. * @return void
  25. * @since 1.6
  26. */
  27. public static function addSubmenu($vName)
  28. {
  29. JSubMenuHelper::addEntry(
  30. JText::_('COM_CONTACT_SUBMENU_CONTACTS'),
  31. 'index.php?option=com_contact&view=contacts',
  32. $vName == 'contacts'
  33. );
  34. JSubMenuHelper::addEntry(
  35. JText::_('COM_CONTACT_SUBMENU_CATEGORIES'),
  36. 'index.php?option=com_categories&extension=com_contact',
  37. $vName == 'categories'
  38. );
  39. if ($vName == 'categories')
  40. {
  41. JToolbarHelper::title(
  42. JText::sprintf('COM_CATEGORIES_CATEGORIES_TITLE', JText::_('com_contact')),
  43. 'contact-categories');
  44. }
  45. }
  46. /**
  47. * Gets a list of the actions that can be performed.
  48. *
  49. * @param int The category ID.
  50. * @param int The contact ID.
  51. *
  52. * @return JObject
  53. * @since 1.6
  54. */
  55. public static function getActions($categoryId = 0, $contactId = 0)
  56. {
  57. $user = JFactory::getUser();
  58. $result = new JObject;
  59. if (empty($contactId) && empty($categoryId)) {
  60. $assetName = 'com_contact';
  61. $level = 'component';
  62. }
  63. elseif (empty($contactId)) {
  64. $assetName = 'com_contact.category.'.(int) $categoryId;
  65. $level = 'category';
  66. }
  67. else {
  68. $assetName = 'com_contact.contact.'.(int) $contactId;
  69. $level = 'category';
  70. }
  71. $actions = JAccess::getActions('com_contact', $level);
  72. foreach ($actions as $action) {
  73. $result->set($action->name, $user->authorise($action->name, $assetName));
  74. }
  75. return $result;
  76. }
  77. }