From ff4d5a5f0551d0603e1f75df375dc4ae40ab3c35 Mon Sep 17 00:00:00 2001 From: DhaniAM Date: Tue, 28 Oct 2025 11:09:26 +0800 Subject: [PATCH 1/5] Updated API url to SP --- OjtPageHandler.inc.php | 8 ++++++-- OjtPlugin.inc.php | 19 ++++++++++--------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/OjtPageHandler.inc.php b/OjtPageHandler.inc.php index 74623e2..b2bf4f5 100644 --- a/OjtPageHandler.inc.php +++ b/OjtPageHandler.inc.php @@ -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); @@ -442,7 +442,7 @@ public function installPlugin($args, $request) // the updated one is license $license = $pluginInstance->getSetting($this->contextId, 'license'); - if(!$license) { + if (!$license) { $license = $pluginInstance->getSetting($this->contextId, 'licenseMain'); } } @@ -472,6 +472,10 @@ public function installPlugin($args, $request) // Applying input license to plugin setting if ($pluginInstance instanceof Plugin && $license && !$update) { $pluginInstance->updateSetting($this->contextId, 'licenseMain', $license); + + if (method_exists($pluginInstance, 'updateStatusValidation')) { + $pluginInstance->updateStatusValidation($downloadLink['status_validation']); + } } diff --git a/OjtPlugin.inc.php b/OjtPlugin.inc.php index 66b9533..bfebc11 100644 --- a/OjtPlugin.inc.php +++ b/OjtPlugin.inc.php @@ -23,7 +23,8 @@ class OjtPlugin extends GenericPlugin public $registeredModule; - const API = "https://openjournaltheme.com/index.php/wp-json/openjournalvalidation/v3"; + const API = "http://sp.openjournaltheme.com/api/v1"; + const SERVICE_API = "https://sp.openjournaltheme.com/"; public function register($category, $path, $mainContextId = null) @@ -212,7 +213,7 @@ function fatalHandler() } } - foreach($standalonePlugins as $plugin) { + foreach ($standalonePlugins as $plugin) { if ($this->str_contains($error['file'], $plugin['name'])) { $folders = explode('/', $error['file']); $key = array_search('generic', $folders); @@ -474,7 +475,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 { @@ -533,7 +534,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]); @@ -638,13 +639,13 @@ public function setPageHandler($hookName, $params) $page = $params[0]; $op = &$params[1]; - if($page === 'ojt' && $op === 'api') { + if ($page === 'ojt' && $op === 'api') { define('HANDLER_CLASS', 'OjtPluginApiHandler'); $this->import('OjtPluginApiHandler'); return true; } - + switch ($page) { case 'ojt': define('HANDLER_CLASS', 'OjtPageHandler'); @@ -724,7 +725,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; } @@ -743,7 +744,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())) { @@ -755,7 +756,7 @@ public function recursiveDelete($dirPath, $deleteParent = true) } } } - + if ($deleteParent) { rmdir($dirPath); } From 13ba6c235f78e9978a33334cca7b02255147442e Mon Sep 17 00:00:00 2001 From: DhaniAM Date: Tue, 28 Oct 2025 11:30:43 +0800 Subject: [PATCH 2/5] Added spSync.yml --- .github/workflows/spSync.yml | 67 ++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/spSync.yml diff --git a/.github/workflows/spSync.yml b/.github/workflows/spSync.yml new file mode 100644 index 0000000..ef3ba61 --- /dev/null +++ b/.github/workflows/spSync.yml @@ -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.class}} + rm -rf ./sp_upload/${{steps.extract_xml.outputs.class}}/.git* + rm -rf ./sp_upload/${{steps.extract_xml.outputs.class}}/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.class}}.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.class}}.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 }}" \ No newline at end of file From c5dc9b08f50d70566272f403d5be32344f35e35f Mon Sep 17 00:00:00 2001 From: DhaniAM Date: Tue, 28 Oct 2025 11:31:03 +0800 Subject: [PATCH 3/5] Fixed API url --- OjtPlugin.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OjtPlugin.inc.php b/OjtPlugin.inc.php index bfebc11..47676fa 100644 --- a/OjtPlugin.inc.php +++ b/OjtPlugin.inc.php @@ -23,7 +23,7 @@ class OjtPlugin extends GenericPlugin public $registeredModule; - const API = "http://sp.openjournaltheme.com/api/v1"; + const API = "https://sp.openjournaltheme.com/api/v1"; const SERVICE_API = "https://sp.openjournaltheme.com/"; From 8eb7b50f1273bf1371b7e3c3123499ad11f36426 Mon Sep 17 00:00:00 2001 From: DhaniAM <72007649+DhaniAM@users.noreply.github.com> Date: Mon, 5 Jan 2026 16:45:04 +0800 Subject: [PATCH 4/5] Update spSync to use 'name' instead of 'class' for folder name --- .github/workflows/spSync.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/spSync.yml b/.github/workflows/spSync.yml index ef3ba61..af4e96d 100644 --- a/.github/workflows/spSync.yml +++ b/.github/workflows/spSync.yml @@ -35,15 +35,15 @@ jobs: - name: Create folder and removing .gitignore, .git & .github dir, run: | mkdir -p ./sp_upload - rsync -a ./ ./sp_upload/${{steps.extract_xml.outputs.class}} - rm -rf ./sp_upload/${{steps.extract_xml.outputs.class}}/.git* - rm -rf ./sp_upload/${{steps.extract_xml.outputs.class}}/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.class}}.zip + dest: ./zipped/${{steps.extract_xml.outputs.name}}.zip - name: Construct URL id: construct_url @@ -55,7 +55,7 @@ jobs: 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.class}}.zip" \ + -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 }}" \ @@ -64,4 +64,4 @@ jobs: - name: Echo URL run: | - echo "The URL is: ${{ steps.construct_url.outputs.url }}" \ No newline at end of file + echo "The URL is: ${{ steps.construct_url.outputs.url }}" From 883945f90ddca3472c9845f07f09debddb79fc84 Mon Sep 17 00:00:00 2001 From: DhaniAM Date: Wed, 14 Jan 2026 16:53:49 +0800 Subject: [PATCH 5/5] Activate product validation during installation --- OjtPageHandler.inc.php | 5 +---- OjtPlugin.inc.php | 3 ++- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/OjtPageHandler.inc.php b/OjtPageHandler.inc.php index bcab713..561258e 100644 --- a/OjtPageHandler.inc.php +++ b/OjtPageHandler.inc.php @@ -628,10 +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); - - if (method_exists($pluginInstance, 'updateStatusValidation')) { - $pluginInstance->updateStatusValidation($downloadLink['status_validation']); - } + $pluginInstance->updateSetting($this->contextId, 'status_validated', $downloadLink['status_validation']); } // Clean up staging base path if empty diff --git a/OjtPlugin.inc.php b/OjtPlugin.inc.php index a69756b..737d2df 100644 --- a/OjtPlugin.inc.php +++ b/OjtPlugin.inc.php @@ -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) {