]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/admin/what-config_wernis.php
Wernis extension can now contact the API
[mailer.git] / inc / modules / admin / what-config_wernis.php
index ea86768545a0c198b50d8ab36e779058078e88a4..7650ae1bad076f26bad92b0ef7176ed5efd9582c 100644 (file)
@@ -41,14 +41,24 @@ if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))
 ADD_DESCR("admin", basename(__FILE__));
 
 if (isset($_POST['ok'])) {
-       // Save settings
-       ADMIN_SAVE_SETTINGS($_POST, "_config", "config='0'");
+       // First merge temporary the new API data into config
+       $CONFIG = array_merge($CONFIG, $_POST);
+
+       // Let's test the API first (hold your horses here, cowboy! Thanks. :) )
+       if (WERNIS_TEST_API()) {
+               // Save settings
+               ADMIN_SAVE_SETTINGS($_POST, "_config", "config='0'");
+       } else {
+               // Failed to test the API!
+               LOAD_TEMPLATE("admin_settings_saved", false, WERNIS_ERROR_MESSAGE());
+       }
 }  else {
        // Prepare data for template output
        $content = array(
                'min_amount' => $CONFIG['wernis_min_amount'],
                'api_id'     => $CONFIG['wernis_api_id'],
-               'api_md5'    => $CONFIG['wernis_api_md5']
+               'api_md5'    => $CONFIG['wernis_api_md5'],
+               'api_url'    => $CONFIG['wernis_api_url']
        );
 
        // Load template