/**
  * Gets a list of the actions that can be performed.
  *
  * @param   \JUser  $user       The user object.
  * @param   string  $component  The component access file path, component base path or option name.
  * @param   string  $assetName  The asset name
  * @param   integer $categoryId The category ID.
  * @param   integer $id         The item ID.
  *
  * @return  Object
  */
 public static function getActions(\JUser $user, $component, $assetName, $categoryId = 0, $id = 0)
 {
     $result = new Object();
     // New rules: If path is access file
     $path = $component;
     if (!is_file($path)) {
         // New rules: If path is component base path
         $path = $path . '/access.xml';
     }
     if (!is_file($path)) {
         $path = PathHelper::getAdmin($component) . '/etc/access.xml';
     }
     if (!is_file($path)) {
         $path = PathHelper::getAdmin($component) . '/access.xml';
     }
     if (!$id && !$categoryId) {
         $section = 'component';
     } elseif (!$id && $categoryId) {
         $section = 'category';
         $assetName .= '.category.' . $categoryId;
     } elseif ($id && !$categoryId) {
         $section = $assetName;
         $assetName .= '.' . $assetName . '.' . $id;
     } else {
         $section = $assetName;
         $assetName .= '.' . $assetName;
     }
     $actions = \JAccess::getActionsFromFile($path, "/access/section[@name='" . $section . "']/");
     foreach ($actions as $action) {
         $result->set($action->name, $user->authorise($action->name, $assetName));
     }
     return $result;
 }
 /**
  * Load all language files from component.
  *
  * @param   string $lang   Language tag.
  * @param   string $option Component option.
  *
  * @return  boolean
  */
 public static function loadAll($lang = 'en-GB', $option = null)
 {
     $folder = PathHelper::getAdmin($option) . '/language/' . $lang;
     if (is_dir($folder)) {
         $files = JFolder::files($folder);
     } else {
         return false;
     }
     $language = Container::getInstance()->get('language');
     foreach ($files as $file) {
         $file = explode('.', $file);
         if (array_pop($file) != 'ini') {
             continue;
         }
         array_shift($file);
         if (count($file) != 1 && $file[1] == 'sys') {
             continue;
         }
         $language->load(implode('.', $file), PathHelper::getAdmin($option));
     }
     return true;
 }
Example #3
0
 /**
  * Get config file path.
  *
  * @return  string
  */
 public static function getPath()
 {
     $type = static::$type;
     $ext = static::$type == 'yaml' ? 'yml' : $type;
     return PathHelper::getAdmin('COPYMODULES') . '/etc/config.' . $ext;
 }