Opps, not all elements for sprintf() has been set.
[mailer.git] / inc / libs / wernis_functions.php
index ad801cc17db010466014effe03b0b6ebe1f7837f..263e40935d67291ca4f4e33c84b604d0e37058ce 100644 (file)
@@ -219,8 +219,8 @@ function doAdminTestWernisApi () {
 
        // Prepare the request data
        $requestData = array(
-               't_uid'       => getWernisRefid(),
-               't_md5'       => getWernisPassMd5()
+               't_uid' => getWernisRefid(),
+               't_md5' => getWernisPassMd5()
        );
 
        // Return the result from the lower functions
@@ -268,6 +268,7 @@ function executeWernisApiWithdraw ($wdsId, $userMd5, $amount) {
        // Return the result from the lower functions
        $return = sendWernisApiRequest('book.php', $requestData);
 
+       // Did it went smoothly?
        if (isHttpResponseStatusOkay($return)) {
                // All fine!
                $result = TRUE;
@@ -529,13 +530,10 @@ function doDisplayWernisUserRegistrationForm () {
 
 // Finish user registration with WDS66 API
 function doWernisFinishUserRegistration ($challenge, $challengeResponse, $status) {
-       // Check status from GET parameters and stored value
-       if (($status == '1') && (isFormSent('wernis_register'))) {
-               // Form has been sent
-               die(__FUNCTION__ . ':' . __LINE__ . ': Reached!');
-       } elseif ($status == '1') {
+       // Is the status 1? (= all fine with API call)
+       if ($status == '1') {
                // Get mapped data based on challenge
-               $return = getWernisMapedDataFromApiByChallenge($challenge, $status);
+               $return = getWernisMappedDataFromApiByChallenge($challenge, $status);
 
                // Is the array filled?
                if ((count($return['mapped_data']) > 0) && (empty($return['message']))) {
@@ -545,7 +543,6 @@ function doWernisFinishUserRegistration ($challenge, $challengeResponse, $status
                        // Add missing elements
                        $return['mapped_data']['gender']               = NULL;
                        $return['mapped_data']['birthday_selection']   = generateDayMonthYearSelectionBox($return['mapped_data']['birth_day'], $return['mapped_data']['birth_month'], $return['mapped_data']['birth_year']);
-                       $return['mapped_data']['status']               = bigintval(getRequestElement('status'));
                        $return['mapped_data']['challenge']            = getRequestElement('challenge');
                        $return['mapped_data']['__challenge_response'] = getRequestElement('__challenge_response');
 
@@ -566,7 +563,7 @@ function doWernisFinishUserRegistration ($challenge, $challengeResponse, $status
 }
 
 // "Getter" for mapped data by calling the API and given challenge and status
-function getWernisMapedDataFromApiByChallenge ($challenge, $status) {
+function getWernisMappedDataFromApiByChallenge ($challenge, $status) {
        // Get stored registration data
        $rows = getWernisRegistrationDataByKey('api_redirect_challenge', $challenge);
 
@@ -669,15 +666,16 @@ function updateWernisRegistrationDataByKey ($updatedColumn, $key, $oldValue, $ne
        sqlQueryEscaped("UPDATE
        `{?_MYSQL_PREFIX?}_wernis_regs`
 SET
-       `%s`='%s'
+       `%s` = '%s'
 WHERE
-       `%s`='%s' AND
+       `%s` = '%s' AND
        `%s` != '%s'
 LIMIT 1",
                array(
                        $updatedColumn,
                        $newValue,
                        $key,
+                       $oldValue,
                        $updatedColumn,
                        $oldValue
                ), __FUNCTION__, __LINE__
@@ -730,6 +728,24 @@ LIMIT %d",
        return $rows;
 }
 
+// Do local user registration with data from WDS66 API
+function doWernisUserRegistration () {
+       // Call generic registration function
+       $status = doGenericUserRegistration();
+
+       // Does this went fine?
+       if ($status === FALSE) {
+               // No, then abort here silently
+               return FALSE;
+       } // END - if
+
+       // Make sure the user id is valid
+       assert(isset($GLOBALS['register_userid']));
+       assert(isValidId($GLOBALS['register_userid']));
+
+       // Generic registration is finished, so add more data:
+}
+
 //-----------------------------------------------------------------------------
 //                      Auth status callback functions
 //-----------------------------------------------------------------------------
@@ -800,7 +816,7 @@ function doWernisAuthAccepted ($args) {
        // auth_key and wernis_userid must be set
        assert(isset($args['auth_key']));
        assert(isset($args['wernis_userid']));
-       die(__FUNCTION__ . '<pre>'.print_r($args, TRUE).'</pre>');
+       die(__FUNCTION__ . ':' . __LINE__ . '<pre>' . print_r($args, TRUE) . '</pre>');
 }
 
 //-----------------------------------------------------------------------------