Skip to content

Commit

Permalink
Merge pull request #60 from openjournalteam/53-permission
Browse files Browse the repository at this point in the history
Fix error when installing plugin because ojs root folder is restricted to write
  • Loading branch information
rahmanramsi authored Nov 28, 2023
2 parents cebd988 + 50591f4 commit 5ddec4e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
modules
node_modules/
error.log
error.log
.DS_Store
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
18 changes: 6 additions & 12 deletions OjtPlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions version.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<version>
<application>ojtPlugin</application>
<type>plugins.generic</type>
<release>2.0.7.0</release>
<date>2023-10-21</date>
<release>2.0.7.1</release>
<date>2023-11-28</date>
<lazy-load>0</lazy-load>
<class>OjtPlugin</class>
</version>

0 comments on commit 5ddec4e

Please sign in to comment.