diff --git a/.github/workflows/spSync.yml b/.github/workflows/spSync.yml new file mode 100644 index 0000000..49501ba --- /dev/null +++ b/.github/workflows/spSync.yml @@ -0,0 +1,67 @@ +name: SyncToSp +# Controls when the action will run. +on: + push: + branches: + - "34" + +# 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=34,35" \ + "${{ steps.construct_url.outputs.url }}" + + - name: Echo URL + run: | + echo "The URL is: ${{ steps.construct_url.outputs.url }}" diff --git a/OjtControlPanelPlugin.php b/OjtControlPanelPlugin.php index b0e8251..cb2d76a 100644 --- a/OjtControlPanelPlugin.php +++ b/OjtControlPanelPlugin.php @@ -43,7 +43,7 @@ class OjtControlPanelPlugin 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) @@ -815,7 +815,8 @@ public function getPluginDownloadLink($pluginToken, $license = false): array 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) { diff --git a/OjtPageHandler.php b/OjtPageHandler.php index c73096d..0b38c59 100644 --- a/OjtPageHandler.php +++ b/OjtPageHandler.php @@ -155,7 +155,7 @@ public function saveSettings($args, $request) { $this->ojtPlugin->updateSetting(Application::CONTEXT_SITE, 'enable_diagnostic', filter_var($request->getUserVar('enable_diagnostic'), FILTER_VALIDATE_BOOLEAN)); $this->ojtPlugin->updateSetting($this->contextId, 'show_support_link_ojs', filter_var($request->getUserVar('show_support_link_ojs'), FILTER_VALIDATE_BOOLEAN)); - + $json['error'] = 0; $json['msg'] = 'Save Success'; return showJson($json); @@ -272,7 +272,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); @@ -537,6 +537,7 @@ public function installPlugin($args, $request) if ($pluginInstance instanceof Plugin) { if ($license && !$update) { $pluginInstance->updateSetting($this->contextId, 'license', $license); + $pluginInstance->updateSetting($this->contextId, 'status_validated', $downloadLink['status_validation']); } Hook::call('OJT::pluginInstalled', array($pluginInstance)); }