diff --git a/.gitignore b/.gitignore index 01ffbb2..89e79ca 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ modules node_modules/ -error.log \ No newline at end of file +error.log +.DS_Store \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 86dfde8..73743ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +### 2.0.7.1 : 28 Nov 2023 +- Fix error when installing plugin because ojs root folder is restricted to write + ### 2.0.7.0 : 21 Oct 2023 - Integration with OJT Support platform diff --git a/OjtPlugin.inc.php b/OjtPlugin.inc.php index 96bc777..44de61e 100644 --- a/OjtPlugin.inc.php +++ b/OjtPlugin.inc.php @@ -386,16 +386,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); @@ -652,11 +647,10 @@ 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]); - // Extract file if (!class_exists('ZipArchive')) { unlink($file_name); diff --git a/version.xml b/version.xml index 3f23e86..4f6df44 100644 --- a/version.xml +++ b/version.xml @@ -5,8 +5,8 @@ ojtPlugin plugins.generic - 2.0.7.0 - 2023-10-21 + 2.0.7.1 + 2023-11-28 0 OjtPlugin