Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/spSync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: SyncToSp
# Controls when the action will run.
on:
push:
branches:
- "33"

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@master

- name: Get branch name
id: branch-name
uses: tj-actions/branch-name@v6

- name: Install xmllint to read version.xml
run: sudo apt-get update -y && sudo apt-get install -y libxml2-utils

- name: Extract data from the version.xml
id: extract_xml
run: |
name=$(xmllint --xpath "string(/version/application)" version.xml)
version=$(xmllint --xpath "string(/version/release)" version.xml)
class=$(xmllint --xpath "string(/version/class)" version.xml)
echo "name=$name" >> $GITHUB_OUTPUT
echo "version=$version" >> $GITHUB_OUTPUT
echo "class=$class" >> $GITHUB_OUTPUT

- name: Create folder and removing .gitignore, .git & .github dir,
run: |
mkdir -p ./sp_upload
rsync -a ./ ./sp_upload/${{steps.extract_xml.outputs.name}}
rm -rf ./sp_upload/${{steps.extract_xml.outputs.name}}/.git*
rm -rf ./sp_upload/${{steps.extract_xml.outputs.name}}/sp_upload

- name: Zip the repo and Pack to zipped folder before uploading
uses: vimtor/action-zip@v1
with:
files: ./sp_upload
dest: ./zipped/${{steps.extract_xml.outputs.name}}.zip

- name: Construct URL
id: construct_url
run: |
url="https://sp.openjournaltheme.com/api/v1/product/update-version"
echo "url=$url" >> $GITHUB_OUTPUT

- name: Upload to SP with zip file
run: |
curl -A "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36" \
-X POST \
-F "file=@./zipped/${{steps.extract_xml.outputs.name}}.zip" \
-F "key=g4Tj9qL2xWz8RkD1s" \
-F "class=${{ steps.extract_xml.outputs.class }}" \
-F "version=${{ steps.extract_xml.outputs.version }}" \
-F "platform_version=${{ steps.branch-name.outputs.current_branch }}" \
"${{ steps.construct_url.outputs.url }}"

- name: Echo URL
run: |
echo "The URL is: ${{ steps.construct_url.outputs.url }}"
5 changes: 3 additions & 2 deletions OjtPageHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public function submitBug($args, $request)

public function checkUpdate($args, $request)
{
$url = 'https://openjournaltheme.com/index.php/wp-json/openjournalvalidation/v1/ojtplugin/check_update';
$url = 'https://sp.openjournaltheme.com/api/v1/product/control-panel';
try {
$response = $this->ojtPlugin->getHttpClient()->get($url);
$json = json_decode((string) $response->getBody(), true);
Expand Down Expand Up @@ -553,7 +553,7 @@ public function installPlugin($args, $request)
// Try newer 'license' setting first, then fall back to 'licenseMain' for backward compatibility
$license = $pluginInstance->getSetting($this->contextId, 'license');

if(!$license) {
if (!$license) {
$license = $pluginInstance->getSetting($this->contextId, 'licenseMain');
}
}
Expand Down Expand Up @@ -628,6 +628,7 @@ public function installPlugin($args, $request)
// Apply license setting (backward compatible with licenseMain)
if ($pluginInstance instanceof Plugin && $license && !$update) {
$pluginInstance->updateSetting($this->contextId, 'licenseMain', $license);
$pluginInstance->updateSetting($this->contextId, 'status_validated', $downloadLink['status_validation']);
}

// Clean up staging base path if empty
Expand Down
17 changes: 9 additions & 8 deletions OjtPlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class OjtPlugin extends GenericPlugin

public $registeredModule;

const API = "https://openjournaltheme.com/index.php/wp-json/openjournalvalidation/v3";
const API = "https://sp.openjournaltheme.com/api/v1";
const SERVICE_API = "https://sp.openjournaltheme.com/";

public function register($category, $path, $mainContextId = null)
Expand Down Expand Up @@ -533,7 +533,7 @@ public static function reportToServicePanel($plugin, $isGlobalPlugin = false, $p
if ($isGlobalPlugin) {
$headers['Client-Url'] = $plugin->getRequest()->getBaseUrl();
} else {
$headers ['Client-Url'] = $ojtPlugin->getJournalURL();
$headers['Client-Url'] = $ojtPlugin->getJournalURL();
}

try {
Expand Down Expand Up @@ -592,7 +592,7 @@ public function updatePanel($url)

// Download 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]);
Expand Down Expand Up @@ -710,7 +710,7 @@ public function setPageHandler($hookName, $params)

return true;
}

switch ($page) {
case 'ojt':
define('HANDLER_CLASS', 'OjtPageHandler');
Expand Down Expand Up @@ -806,7 +806,7 @@ public function uninstallPlugin($plugin)

// Send notification to discord about the deletion error in uninstallPlugin
// $this->sendDiscordNotification($plugin->name, $data);

// Re-throw for proper error handling at caller level
throw $th;
}
Expand All @@ -825,7 +825,7 @@ public function recursiveDelete($dirPath, $deleteParent = true)
throw new \Exception("Can't remove plugins, please check folder permission for: " . $path->getPathname());
};
}

foreach ($paths as $path) {
if ($path->isFile()) {
if (!unlink($path->getPathname())) {
Expand All @@ -837,7 +837,7 @@ public function recursiveDelete($dirPath, $deleteParent = true)
}
}
}

if ($deleteParent) {
rmdir($dirPath);
}
Expand Down Expand Up @@ -873,7 +873,8 @@ public function getPluginDownloadLink($pluginToken, $license = false, $journalUr

if (isset($response['error']) && $response['error']) throw new Exception($response['msg']);

$result['product'] = $response['data']['download_link'];
$result['product'] = $response['data']['download_link'];
$result['status_validation'] = $response['data']['status_validation'] ?? 0;

$dependencies = [];
foreach ($response['data']['dependencies'] as $dependency) {
Expand Down