コード例 #1
0
 /**
  * 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;
 }
コード例 #2
0
 /**
  * Check button access.
  *
  * @param string $name   The button name.
  * @param array  $button The button config array.
  *
  * @return  boolean Allow this button or not.
  */
 protected function checkAccess($name, $button)
 {
     // No access set, means yes.
     if (!isset($button['access'])) {
         return true;
     } elseif (is_string($button['access'])) {
         return $this->access->get($button['access']);
     }
     // If we get FALSE, just return it.
     return $button['access'];
 }
コード例 #3
0
 /**
  * Get a page and save it as file.
  *
  * @param   string $url    A url to request.
  * @param   string $path   A system path with file name to save it.
  * @param   array  $option An option array to override CURL OPT.
  *
  * @return  Object Object with success or fail information.
  */
 public static function download($url, $path = null, $option = array())
 {
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.path');
     $url = new \JUri($url);
     $path = \JPath::clean($path);
     // $folder_path = JPATH_ROOT.DS.'files'.DS.$url->task_id ;
     if (substr($path, -1) == DIRECTORY_SEPARATOR) {
         $file_name = basename($url);
         $file_path = $path . $file_name;
         $folder_path = $path;
     } else {
         $file_path = $path;
         $folder_path = str_replace(basename($path), '', $file_path);
     }
     \JPath::setPermissions($folder_path, 644, 755);
     if (!\is_dir($folder_path)) {
         \JFolder::create($folder_path);
     }
     $fp = fopen($file_path, 'w+');
     $ch = curl_init();
     $options = array(CURLOPT_URL => UriHelper::safe($url), CURLOPT_RETURNTRANSFER => true, CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.163 Safari/535.1", CURLOPT_FOLLOWLOCATION => !ini_get('open_basedir') ? true : false, CURLOPT_FILE => $fp, CURLOPT_SSL_VERIFYPEER => false);
     // Merge option
     foreach ($option as $key => $opt) {
         if (isset($option[$key])) {
             $options[$key] = $option[$key];
         }
     }
     curl_setopt_array($ch, $options);
     curl_exec($ch);
     $errno = curl_errno($ch);
     $errmsg = curl_error($ch);
     curl_close($ch);
     fclose($fp);
     if ($errno) {
         $return = new Object();
         $return->set('errorCode', $errno);
         $return->set('errorMsg', $errmsg);
         return $return;
     } else {
         $return = new Object();
         $return->set('filePath', $file_path);
         return $return;
     }
 }
コード例 #4
0
 /**
  * Method to test isNull().
  *
  * @param \Windwalker\Object\Object $object
  * @param bool                      $expect
  *
  * @return void
  *
  * @covers       \Windwalker\Object\Object::isNull
  * @dataProvider objectProvider
  */
 public function testIsNull(Object $object, $expect)
 {
     $this->assertSame($expect, $object->isNull());
 }