]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/register_functions.php
New naming convention applied to many functions, see #118 for details
[mailer.git] / inc / libs / register_functions.php
index 575f193a548304c1a68b9e10089c61a0083aa855..8ed526a227bdc66e81344fd1b042fa6d70ae22c1 100644 (file)
@@ -43,7 +43,7 @@ if (!defined('__SECURITY')) {
 }
 
 //
 }
 
 //
-function REGISTER_FILL_MUST_CONSTANTS () {
+function registerMustFillout () {
        $result = SQL_QUERY("SELECT field_name, field_required FROM `{!_MYSQL_PREFIX!}_must_register` ORDER BY `id`",
                __FUNCTION__, __LINE__);
 
        $result = SQL_QUERY("SELECT field_name, field_required FROM `{!_MYSQL_PREFIX!}_must_register` ORDER BY `id`",
                __FUNCTION__, __LINE__);
 
@@ -59,6 +59,7 @@ function REGISTER_FILL_MUST_CONSTANTS () {
        SQL_FREERESULT($result);
 
        // Also fill other constants
        SQL_FREERESULT($result);
 
        // Also fill other constants
+       // @TODO Rewrite these constants, too
        define('MUST_GENDER', "<div class=\"guest_failed\">&nbsp;(*)</div>");
        define('MUST_ADDY'  , "<div class=\"guest_failed\">&nbsp;(*)</div>");
        define('MUST_BIRTH' , "<div class=\"guest_failed\">&nbsp;(*)</div>");
        define('MUST_GENDER', "<div class=\"guest_failed\">&nbsp;(*)</div>");
        define('MUST_ADDY'  , "<div class=\"guest_failed\">&nbsp;(*)</div>");
        define('MUST_BIRTH' , "<div class=\"guest_failed\">&nbsp;(*)</div>");
@@ -82,7 +83,7 @@ function REGISTER_CHECK_REQUIRED_FIELDS (&$array) {
                        if ((empty($value)) && ($chk == 'Y') && (!$country))
                        {
                                // Required field not set
                        if ((empty($value)) && ($chk == 'Y') && (!$country))
                        {
                                // Required field not set
-                               $array[$key] = "!";
+                               $array[$key] = '!';
                                $ret = true;
                        }
                }
                                $ret = true;
                        }
                }
@@ -95,13 +96,13 @@ function REGISTER_CHECK_REQUIRED_FIELDS (&$array) {
 
 //
 function REGISTER_OUTPUT_REQUIRE_CHECK (&$array) {
 
 //
 function REGISTER_OUTPUT_REQUIRE_CHECK (&$array) {
-       $result = SQL_QUERY("SELECT field_name, field_required FROM `{!_MYSQL_PREFIX!}_must_register` ORDER BY `id`", __FUNCTION__, __LINE__);
+       $result = SQL_QUERY("SELECT `field_name`, `field_required` FROM `{!_MYSQL_PREFIX!}_must_register` ORDER BY `id`", __FUNCTION__, __LINE__);
        while ($content = SQL_FETCHARRAY($result)) {
        while ($content = SQL_FETCHARRAY($result)) {
-               if (($array[$content['field_name']] == "!") && ($content['field_required'] == 'Y')) {
+               if (($array[$content['field_name']] == '!') && ($content['field_required'] == 'Y')) {
                        // Empty entry found
                        $array[$content['field_name']] = '';
                        $OUT = constant('REGISTER_'.strtoupper($content['field_name']).'_REQUIRED');
                        // Empty entry found
                        $array[$content['field_name']] = '';
                        $OUT = constant('REGISTER_'.strtoupper($content['field_name']).'_REQUIRED');
-                       OUTPUT_HTML("<div class=\"register_failed\">".$OUT."</div>");
+                       registerOutputFailedMessage('', $OUT);
                } // END - if
        } // END - while
 
                } // END - if
        } // END - while
 
@@ -109,8 +110,8 @@ function REGISTER_OUTPUT_REQUIRE_CHECK (&$array) {
        SQL_FREERESULT($result);
 }
 
        SQL_FREERESULT($result);
 }
 
-//
-function REGISTER_ADD_CATEGORY_TABLE ($mode, $return=false) {
+// Generates a 'category table' for the registration form
+function registerGenerateCategoryTable ($mode, $return=false) {
        $OUT = '';
 
        // Guests are mostly not interested in how many members has
        $OUT = '';
 
        // Guests are mostly not interested in how many members has
@@ -121,7 +122,7 @@ function REGISTER_ADD_CATEGORY_TABLE ($mode, $return=false) {
        if (IS_ADMIN()) $AND = '';
 
        // Look for categories
        if (IS_ADMIN()) $AND = '';
 
        // Look for categories
-       $result = SQL_QUERY("SELECT id, cat, visible FROM `{!_MYSQL_PREFIX!}_cats` ".$AND." ORDER BY `sort`",
+       $result = SQL_QUERY("SELECT `id`, `cat`, `visible` FROM `{!_MYSQL_PREFIX!}_cats` ".$AND." ORDER BY `sort` ASC",
                __FUNCTION__, __LINE__);
 
        if (SQL_NUMROWS($result) > 0) {
                __FUNCTION__, __LINE__);
 
        if (SQL_NUMROWS($result) > 0) {
@@ -139,8 +140,8 @@ function REGISTER_ADD_CATEGORY_TABLE ($mode, $return=false) {
                        $content = array(
                                'sw'    => $SW,
                                'cat'   => $content['cat'],
                        $content = array(
                                'sw'    => $SW,
                                'cat'   => $content['cat'],
-                               'def_y' => "",
-                               'def_n' => "",
+                               'def_y' => '',
+                               'def_n' => '',
                                'id'    => $content['id'],
                        );
 
                                'id'    => $content['id'],
                        );
 
@@ -171,5 +172,15 @@ function REGISTER_ADD_CATEGORY_TABLE ($mode, $return=false) {
                OUTPUT_HTML($OUT);
        }
 }
                OUTPUT_HTML($OUT);
        }
 }
+
+// Outputs a 'failed message'
+function registerOutputFailedMessage ($messageId, $extra='') {
+       if (empty($messageId)) {
+               OUTPUT_HTML('<div class="register_failed">' . $extra . '</div>');
+       } else {
+               OUTPUT_HTML('<div class="register_failed">{--' . $messageId . '--}' . $extra . '</div>');
+       }
+}
+
 //
 ?>
 //
 ?>