Renamed ifSqlHasZeroNums() to ifSqlHasZeroNumRows() and improved some queries.
[mailer.git] / inc / modules / guest / what-sponsor_reg.php
index 8a19eb5607ad1e9e5b2f66d2e9138b4ab55ea45c..cb93271c33f44e364cf55f95666a1f69fd86c1fd 100644 (file)
  * -------------------------------------------------------------------- *
  * Kurzbeschreibung  : Anmeldeformular fuer Sponsoren                   *
  * -------------------------------------------------------------------- *
- * $Revision::                                                        $ *
- * $Date::                                                            $ *
- * $Tag:: 0.2.1-FINAL                                                 $ *
- * $Author::                                                          $ *
- * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009 - 2012 by Mailer Developer Team                   *
+ * Copyright (c) 2009 - 2015 by Mailer Developer Team                   *
  * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -182,7 +177,7 @@ if (isFormSent()) {
                                array_push($formErrors, '{--SPONSOR_PASSWORD2_EMPTY--}');
                        }
                }
-       } elseif (strlen(postRequestElement('password1')) < getPassLen()) {
+       } elseif (strlen(postRequestElement('password1')) < getMinPasswordLength()) {
                // Password is to short!
                array_push($formErrors, '{--SPONSOR_PASSWORD_TOO_SHORT--}');
        }
@@ -194,10 +189,10 @@ if (isFormSent()) {
        } // END - if
 
        // If there is something wrong/missing stop registration
-       if (count($formErrors) > 0) unsetPostRequestElement('ok');
+       if (isFilledArray($formErrors)) unsetPostRequestElement('ok');
 } // END - if
 
-if ((isFormSent()) && (count($formErrors) == 0)) {
+if ((isFormSent()) && (!isFilledArray($formErrors))) {
        // Generate message array
        $messageArray = array(
                'failed' => '{--SPONSOR_REGISTRATION_FAILED--}',
@@ -205,7 +200,7 @@ if ((isFormSent()) && (count($formErrors) == 0)) {
        );
 
        // Calulate points
-       $result = SQL_QUERY_ESC('SELECT
+       $result = sqlQueryEscaped('SELECT
        (`pay_rate` * `pay_min_count`) AS `points`,
        `pay_min_count`,
        `pay_currency`
@@ -215,10 +210,10 @@ WHERE
        `id`=%s
 LIMIT 1',
                array(postRequestElement('pay_type')), __FILE__, __LINE__);
-       list($points, $pay, $curr) = SQL_FETCHROW($result);
+       list($points, $pay, $curr) = sqlFetchRow($result);
 
        // Free memory
-       SQL_FREERESULT($result);
+       sqlFreeResult($result);
 
        // Add points to array
        postRequestElement('points_amount', $points);
@@ -233,7 +228,7 @@ LIMIT 1',
        displayMessage($message);
 } else {
        // Check for payment types
-       $result = SQL_QUERY('SELECT
+       $result = sqlQuery('SELECT
        `id`,
        `pay_name`,
        `pay_rate`,
@@ -241,12 +236,13 @@ LIMIT 1',
        `pay_min_count`
 FROM
        `{?_MYSQL_PREFIX?}_sponsor_paytypes`
-ORDER BY 
+ORDER BY
        `pay_name` ASC', __FILE__, __LINE__);
-       if (!SQL_HASZERONUMS($result)) {
+
+       if (!ifSqlHasZeroNumRows($result)) {
                // Load all types...
                $OUT = '';
-               while ($content = SQL_FETCHARRAY($result)) {
+               while ($content = sqlFetchArray($result)) {
                        // Prepare content for output
                        $content['res'] = translateComma($content['pay_rate'] * $content['pay_min_count']);
 
@@ -263,7 +259,7 @@ ORDER BY
                } // END - foreach
 
                // Check for invalid entries
-               if (count($formErrors) > 0) {
+               if (isFilledArray($formErrors)) {
                        // Some found... :-(
                        foreach (array('company','position','tax_ident','surname','family','street_nr1','street_nr2','country','zip','city','phone','fax','cell','email','url') as $entry) {
                                $content[$entry]    = postRequestElement($entry);
@@ -278,8 +274,8 @@ ORDER BY
                        $OUT = '';
 
                        // Errors found?
-                       if (count($formErrors) > 0) {
-                               $OUT = displayMessage('{--SPONSOR_REGISTER_SOMETHING_MISSING--}', TRUE);
+                       if (isFilledArray($formErrors)) {
+                               $OUT = returnMessage('{--SPONSOR_REGISTER_SOMETHING_MISSING--}');
                                $OUT .= '<ol>';
                                foreach ($formErrors as $error) {
                                        $OUT .= '<li>' . $error . '</li>';
@@ -291,10 +287,10 @@ ORDER BY
                        $content['form_errors'] = $OUT;
 
                        // @TODO Maybe a default referral id?
-                       $content['refid'] = 0;
+                       $content['refid'] = NULL;
 
                        // Is the referral id valid?
-                       if ((isPostRequestElementSet('refid')) && (isValidUserId(postRequestElement('refid')))) {
+                       if ((isPostRequestElementSet('refid')) && (isValidId(postRequestElement('refid')))) {
                                // Transfer referral id
                                $content['refid'] = bigintval(postRequestElement('refid'));
                        } // END - if
@@ -308,7 +304,7 @@ ORDER BY
        }
 
        // Free memory
-       SQL_FREERESULT($result);
+       sqlFreeResult($result);
 }
 
 // [EOF]