diff --git a/ajax/cronservice/cancelRegistration.php b/ajax/cronservice/cancelRegistration.php new file mode 100644 index 0000000000000000000000000000000000000000..abfd1d526695a5b2bb420932818752689c3cea99 --- /dev/null +++ b/ajax/cronservice/cancelRegistration.php @@ -0,0 +1,16 @@ +<?php + +/** + * Requests the server to cancel the registration + * + * @param - The email which was used for registration. + */ +QUI::$Ajax->registerFunction( + 'package_quiqqer_cron_ajax_cronservice_cancelRegistration', + function () { + $CronService = new \QUI\Cron\CronService(); + $CronService->cancelRegistration(); + }, + array(), + '' +); diff --git a/bin/CronServiceWindow.css b/bin/CronServiceWindow.css index e6e391b04bb2da384b243af5748eedf4dea5de4f..826d0880acfae36c82afc003c866a46f4133a99e 100644 --- a/bin/CronServiceWindow.css +++ b/bin/CronServiceWindow.css @@ -1,7 +1,7 @@ .quiqqer-cron-cronservicewindow-btn-openRegistration { - margin : 30px auto 0 auto; float : right; + margin : 30px auto 0 auto; } .quiqqer-cron-cronserviceWindow h2 { @@ -28,8 +28,8 @@ } .quiqqer-cron-cronservicewindow-buttons { - text-align : center; margin-top : 40px; + text-align : center; width : 100%; } @@ -71,16 +71,24 @@ } .quiqqer-cron-cronservicewindow-registration-txt-email { - width : 100%; margin-top : 6px; + width : 100%; } .quiqqer-cron-cronservicewindow-btn-register { - margin-top : 20px; float : right; + margin-top : 20px; } .quiqqer-cron-cronservicewindow-registration-success-btn-confirm { float : right; margin : 15px 0 0 0; +} + +.quiqqer-cron-cronservicewindow-registration-success-btn-cancel-text { + overflow : hidden; + text-align : center; + text-overflow : ellipsis; + white-space : nowrap; + width : 100%; } \ No newline at end of file diff --git a/bin/CronServiceWindow.js b/bin/CronServiceWindow.js index 7fdd731ddcd3ba135c11110fa4536e77c3b6a2dd..f48c08a6e7a3ae4cc5f204583b3f7063fe600590 100644 --- a/bin/CronServiceWindow.js +++ b/bin/CronServiceWindow.js @@ -108,9 +108,7 @@ define('package/quiqqer/cron/bin/CronServiceWindow', [ // Register/Unregister Button - if (self.status) - // Get the button text : register or unregister - { + if (self.status) { var btnText = QUILocale.get(lg, 'cron.window.cronservice.content.btn.register'); } if (self.registered) { @@ -119,20 +117,41 @@ define('package/quiqqer/cron/bin/CronServiceWindow', [ var Button = null; if (self.status == 2) { + // Resend Activation Button Button = new QUIButton({ text : QUILocale.get(lg, 'cron.window.cronservice.content.btn.resend.activation.mail'), textimage: 'fa fa-envelope-o', events : { - onClick: function (Button) { + onClick: function () { self.resendActivationMail(); } }, styles : { 'float': 'none', - margin : '0 auto', - width : 200 + width : 'calc(50% - 5px)' } }); + + // Cancel Registration Button + new QUIButton({ + text : '<span class="quiqqer-cron-cronservicewindow-registration-success-btn-cancel-text">' + QUILocale.get(lg, 'cron.window.cronservice.registration.button.text.cancel') + '</span>', + events: { + onClick: function (Button) { + Button.setAttribute('text', QUILocale.get('quiqqer/cron', 'cron.window.cronservice.content.btn.unregister.confirm')); + if (Button.getAttribute('clickcnt') == 1) { + self.cancelRegistration().then(function () { + self.refresh(); + }); + } + Button.setAttribute('clickcnt', 1); + } + }, + styles: { + 'float': 'none', + margin : '0 10px 0 0', + width : 'calc(50% - 5px)' + } + }).inject(Buttons); } else { Button = new QUIButton({ text : btnText, @@ -216,9 +235,12 @@ define('package/quiqqer/cron/bin/CronServiceWindow', [ }).inject(this.$Elm).show(); }, + /** + * Shows the registration success sheet, which contains information about the activation email + */ showRegistrationSuccess: function () { var self = this; - + new QUISheets({ header : true, icon : 'fa fa-cloud', @@ -281,6 +303,23 @@ define('package/quiqqer/cron/bin/CronServiceWindow', [ }); }, + /** + * Cancels the registration + * @returns {*} + */ + cancelRegistration: function () { + return new Promise(function (resolve, reject) { + QUIAjax.get('package_quiqqer_cron_ajax_cronservice_cancelRegistration', resolve, { + 'package': lg, + onError : reject + }); + }); + }, + + /** + * Sends the activation mail again + * @returns {*} + */ resendActivationMail: function () { return new Promise(function (resolve, reject) { QUIAjax.get('package_quiqqer_cron_ajax_cronservice_resendActivation', resolve, { diff --git a/locale.xml b/locale.xml index 4ea8685fc47617e2dbce68c9591cea8b4a59ea5e..ab4e64bec090a2826303a7f52b2218186231922a 100644 --- a/locale.xml +++ b/locale.xml @@ -448,5 +448,9 @@ This is works with an external server on which QUIQQER systems can register them <de><![CDATA[Verstanden]]></de> <en><![CDATA[Okay]]></en> </locale> + <locale name="cron.window.cronservice.registration.button.text.cancel"> + <de><![CDATA[Registrierung abbrechen]]></de> + <en><![CDATA[Cancel registration]]></en> + </locale> </groups> </locales> \ No newline at end of file diff --git a/src/QUI/Cron/CronService.php b/src/QUI/Cron/CronService.php index 578d7cbe28730236b1f8a6bc63c8ab5b119be364..db503c698425a9b91829f43a7db0bdcaebdb8674 100644 --- a/src/QUI/Cron/CronService.php +++ b/src/QUI/Cron/CronService.php @@ -8,7 +8,7 @@ use QUI\System\Log; class CronService { - const CRONSERVICE_URL = "https://cron.quiqqer.com"; + const CRONSERVICE_URL = "http://server.cronservice.flo.pcsg"; private $domain; private $https; @@ -112,7 +112,6 @@ class CronService */ public function resendActivationMail() { - if (!isset($this->domain) || empty($this->domain)) { throw new Exception("Could not get the instances domain."); } @@ -125,6 +124,24 @@ class CronService ); } + /** + * Attempts to cancel the registration on the server + * @throws Exception + */ + public function cancelRegistration() + { + Log::addDebug(""); + if (!isset($this->domain) || empty($this->domain)) { + throw new Exception("Could not get the instances domain."); + } + + $this->makeServerAjaxCall( + "package_pcsg_cronservice_ajax_cancelRegistration", + array( + "domain" => $this->domain + ) + ); + } /** * Sends an ajax request to the cronservice server. @@ -277,4 +294,5 @@ class CronService return $token; } + }