diff --git a/CHANGELOG.md b/CHANGELOG.md index 707eb12..72dc3af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +### 3.0.1.1 : 21 Nov 2023 +- Fix error when installing plugin because ojs root folder is restricted to write + ### 3.0.1.0 : 21 Oct 2023 - Integration with OJT Support platform diff --git a/OjtControlPanelPlugin.php b/OjtControlPanelPlugin.php index dec64ad..7cdc132 100644 --- a/OjtControlPanelPlugin.php +++ b/OjtControlPanelPlugin.php @@ -399,16 +399,11 @@ public function updatePanel($url) } // Download file - $file_name = "OJTPanel.zip"; - - // place file to root of ojs - if (!$file = file_get_contents($url)) { - throw new Exception('Failed to download Plugin'); - } - if (!file_put_contents($file_name, $file)) { - throw new Exception('Failed to make a temporary plugin file'); - } - + $file_name = Config::getVar('files', 'files_dir') . DIRECTORY_SEPARATOR . 'OJTPanel.zip'; + $resource = \GuzzleHttp\Psr7\Utils::tryFopen($file_name, 'w'); + $stream = \GuzzleHttp\Psr7\Utils::streamFor($resource); + $this->getHttpClient()->request('GET', $url, ['sink' => $stream]); + $zip = new \ZipArchive; if (!$zip->open($file_name)) { unlink($file_name); @@ -637,7 +632,7 @@ public function installPlugin($url) $url = str_replace('https', 'http', $url); // Download file - $file_name = __DIR__ . DIRECTORY_SEPARATOR . 'OJTTemporaryFile.zip'; + $file_name = Config::getVar('files', 'files_dir') . DIRECTORY_SEPARATOR . 'OJTTemporaryFile.zip'; $resource = \GuzzleHttp\Psr7\Utils::tryFopen($file_name, 'w'); $stream = \GuzzleHttp\Psr7\Utils::streamFor($resource); $this->getHttpClient()->request('GET', $url, ['sink' => $stream]); diff --git a/version.xml b/version.xml index a10fd03..2748b4c 100644 --- a/version.xml +++ b/version.xml @@ -5,8 +5,8 @@ ojtControlPanel plugins.generic - 3.0.1.0 - 2023-10-21 + 3.0.1.1 + 2023-11-28 0 OjtControlPanelPlugin