1 <?php
  2 /**
  3  * @package     Joomla.Platform
  4  * @subpackage  Access
  5  *
  6  * @copyright   Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
  7  * @license     GNU General Public License version 2 or later; see LICENSE
  8  */
  9 
 10 defined('JPATH_PLATFORM') or die;
 11 
 12 /**
 13  * Wrapper class for JAccess
 14  *
 15  * @package     Joomla.Platform
 16  * @subpackage  User
 17  * @since       3.4
 18  */
 19 class JAccessWrapperAccess
 20 {
 21     /**
 22      * Helper wrapper method for addUserToGroup
 23      *
 24      * @return void
 25      *
 26      * @see     JAccess::clearStatics
 27      * @since   3.4
 28      */
 29     public function clearStatics()
 30     {
 31         return JAccess::clearStatics();
 32     }
 33 
 34     /**
 35      * Helper wrapper method for check
 36      *
 37      * @param   integer  $userId  Id of the user for which to check authorisation.
 38      * @param   string   $action  The name of the action to authorise.
 39      * @param   mixed    $asset   Integer asset id or the name of the asset as a string.  Defaults to the global asset node.
 40      *
 41      * @return boolean  True if authorised.
 42      *
 43      * @see     JAccess::check()
 44      * @since   3.4
 45      */
 46     public function check($userId, $action, $asset = null)
 47     {
 48         return JAccess::check($userId, $action, $asset);
 49     }
 50 
 51     /**
 52      * Helper wrapper method for checkGroup
 53      *
 54      * @param   integer  $groupId  The path to the group for which to check authorisation.
 55      * @param   string   $action   The name of the action to authorise.
 56      * @param   mixed    $asset    Integer asset id or the name of the asset as a string.  Defaults to the global asset node.
 57      *
 58      * @return  boolean  True if authorised.
 59      *
 60      * @see     JAccess::checkGroup()
 61      * @since   3.4
 62      */
 63     public function checkGroup($groupId, $action, $asset = null)
 64     {
 65         return JAccess::checkGroup($groupId, $action, $asset);
 66     }
 67 
 68     /**
 69      * Helper wrapper method for getAssetRules
 70      *
 71      * @param   mixed    $asset      Integer asset id or the name of the asset as a string.
 72      * @param   boolean  $recursive  True to return the rules object with inherited rules.
 73      *
 74      * @return  JAccessRules   JAccessRules object for the asset.
 75      *
 76      * @see     JAccess::getAssetRules
 77      * @since   3.4
 78      */
 79     public function getAssetRules($asset, $recursive = false)
 80     {
 81         return JAccess::getAssetRules($asset, $recursive);
 82     }
 83 
 84     /**
 85      * Helper wrapper method for getGroupsByUser
 86      *
 87      * @param   integer  $userId     Id of the user for which to get the list of groups.
 88      * @param   boolean  $recursive  True to include inherited user groups.
 89      *
 90      * @return  array    List of user group ids to which the user is mapped.
 91      *
 92      * @see     JAccess::getGroupsByUser()
 93      * @since   3.4
 94      */
 95     public function getGroupsByUser($userId, $recursive = true)
 96     {
 97         return JAccess::getGroupsByUser($userId, $recursive);
 98     }
 99 
100     /**
101      * Helper wrapper method for getUsersByGroup
102      *
103      * @param   integer  $groupId    The group Id
104      * @param   boolean  $recursive  Recursively include all child groups (optional)
105      *
106      * @return  array
107      *
108      * @see     JAccess::getUsersByGroup()
109      * @since   3.4
110      */
111     public function getUsersByGroup($groupId, $recursive = false)
112     {
113         return JAccess::getUsersByGroup($groupId, $recursive);
114     }
115 
116     /**
117      * Helper wrapper method for getAuthorisedViewLevels
118      *
119      * @param   integer  $userId  Id of the user for which to get the list of authorised view levels.
120      *
121      * @return  array    List of view levels for which the user is authorised.
122      *
123      * @see     JAccess::getAuthorisedViewLevels()
124      * @since   3.4
125      */
126     public function getAuthorisedViewLevels($userId)
127     {
128         return JAccess::getAuthorisedViewLevels($userId);
129     }
130 
131     /**
132      * Helper wrapper method for getActions
133      *
134      * @param   string  $component  The component from which to retrieve the actions.
135      * @param   string  $section    The name of the section within the component from which to retrieve the actions.
136      *
137      * @return array  List of actions available for the given component and section.
138      *
139      * @see     JAccess::getActions()
140      * @since   3.4
141      */
142     public function getActions($component, $section = 'component')
143     {
144         return JAccess::getActions($component, $section);
145     }
146 
147     /**
148      * Helper wrapper method for getActionsFromFile
149      *
150      * @param   string  $file   The path to the XML file.
151      * @param   string  $xpath  An optional xpath to search for the fields.
152      *
153      * @return  boolean|array   False if case of error or the list of actions available.
154      *
155      * @see     JAccess::getActionsFromFile()
156      * @since   3.4
157      */
158     public function getActionsFromFile($file, $xpath = '/access/section[@name=\'component\']/')
159     {
160         return JAccess::getActionsFromFile($file, $xpath);
161     }
162 
163     /**
164      * Helper wrapper method for getActionsFromData
165      *
166      * @param   string|SimpleXMLElement  $data   The XML string or an XML element.
167      * @param   string                   $xpath  An optional xpath to search for the fields.
168      *
169      * @return  boolean|array   False if case of error or the list of actions available.
170      *
171      * @see     JAccess::getActionsFromData()
172      * @since   3.4
173      */
174     public function getActionsFromData($data, $xpath = '/access/section[@name=\'component\']/')
175     {
176         return JAccess::getActionsFromData($data, $xpath);
177     }
178 }
179