Function generateGenderSelectionBox() introduced, some cleanups:
authorRoland Häder <roland@mxchange.org>
Tue, 28 Jun 2011 05:25:17 +0000 (05:25 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 28 Jun 2011 05:25:17 +0000 (05:25 +0000)
- Function generateGenderSelectionBox() introduced which will generate a
  selection box for the gender
- Some minor cleanups/improvements here and there
- TODOs.txt updated

21 files changed:
DOCS/TODOs.txt
beg.php
inc/libs/rallye_functions.php
inc/modules/admin/overview-inc.php
inc/modules/admin/what-edit_sponsor.php
inc/modules/admin/what-edit_user.php
inc/modules/admin/what-list_payouts.php
inc/modules/admin/what-list_refs.php
inc/modules/admin/what-list_unconfirmed.php
inc/modules/guest/what-register.php
inc/modules/guest/what-sponsor_reg.php
inc/modules/member/what-mydata.php
inc/modules/sponsor/account.php
inc/template-functions.php
templates/de/html/admin/admin_add_sponsor.tpl
templates/de/html/admin/admin_edit_sponsor_edit.tpl
templates/de/html/admin/admin_edit_user.tpl
templates/de/html/guest/guest_register.tpl
templates/de/html/guest/guest_sponsor_reg.tpl
templates/de/html/member/member_mydata_edit.tpl
templates/de/html/sponsor/sponsor_account_form.tpl

index 27afa7a..4ac881b 100644 (file)
 ./inc/modules/guest/what-mediadata.php:181:// @TODO Rewrite all these if-blocks to filters
 ./inc/modules/guest/what-mediadata.php:68:     // @TODO Find a better formular than this one
 ./inc/modules/guest/what-rallyes.php:89:       // @TODO Reactivate this: $content['admin'] = '<a href="{%url=modules.php?module=index&amp;what=impressum&amp;admin=' . $adminId . '%}">' . $login . '</a>';
-./inc/modules/guest/what-sponsor_reg.php:295:                  // @TODO Maybe a default referal id?
+./inc/modules/guest/what-sponsor_reg.php:287:                  // @TODO Maybe a default referal id?
 ./inc/modules/guest/what-stats.php:100:                // @TODO This can be somehow rewritten
 ./inc/modules/guest/what-stats.php:74:// @TODO This can be rewritten in a dynamic include
 ./inc/modules/member/what-beg2.php:87:         // @TODO points->beg_points
 ./inc/mysql-manager.php:368:   // @TODO Try to rewrite this to one or more functions
 ./inc/mysql-manager.php:44:// @TODO Can we cache this?
 ./inc/revision-functions.php:169:// @TODO This function does also set and get in 'cache_array'
-./inc/template-functions.php:1048:                     // @TODO Deprecate this thing
-./inc/template-functions.php:1059:                     // @TODO Deprecate this thing
-./inc/template-functions.php:1146:     // @TODO This can be easily moved out after the merge from EL branch to this is complete
-./inc/template-functions.php:1179:             // @TODO Add a little more infos here
-./inc/template-functions.php:1490:// @TODO Lame description for this function
-./inc/template-functions.php:1512:                     // @TODO Move this in a filter
+./inc/template-functions.php:1050:                     // @TODO Deprecate this thing
+./inc/template-functions.php:1061:                     // @TODO Deprecate this thing
+./inc/template-functions.php:1148:     // @TODO This can be easily moved out after the merge from EL branch to this is complete
+./inc/template-functions.php:1181:             // @TODO Add a little more infos here
+./inc/template-functions.php:1492:// @TODO Lame description for this function
+./inc/template-functions.php:1514:                     // @TODO Move this in a filter
 ./inc/template-functions.php:189:       * @TODO On some pages this is buggy
 ./inc/template-functions.php:265:      // @TODO Remove this sanity-check if all is fine
 ./inc/template-functions.php:578:// @TODO $simple/$constants are deprecated
diff --git a/beg.php b/beg.php
index 9967f3b..e9e5591 100644 (file)
--- a/beg.php
+++ b/beg.php
@@ -198,8 +198,10 @@ if (isGetRequestParameterSet('userid')) {
                $errorCode = getCode('BEG_SAME_AS_OWN');
        }
 
-       // Reload to index module
-       if ((!empty($errorCode)) && (!empty($errorCode))) redirectToUrl('modules.php?module=index&amp;code=' . $errorCode . '&amp;ext=beg');
+       // Reload to index module if an error happens
+       if (!empty($errorCode)) {
+               redirectToUrl('modules.php?module=index&amp;code=' . $errorCode . '&amp;ext=beg');
+       } // END - if
 } else {
        // No userid entered
        redirectToUrl('modules.php?module=index');
index 56230b9..99c0298 100644 (file)
@@ -577,8 +577,8 @@ LIMIT %s",
                ), __FUNCTION__, __LINE__);
        while ($content = SQL_FETCHARRAY($result)) {
                // Construct the message masked and add it
-               $ret .= sprintf("%s %s %s (%s) - %s\n",
-                       translateGender($content['gender']),
+               $ret .= sprintf("{%%pipe,translateGender=%s%} %s %s (%s) - %s\n",
+                       $content['gender'],
                        $content['surname'],
                        $content['family'],
                        $content['email'],
index cf309d2..e88441e 100644 (file)
@@ -174,7 +174,7 @@ LIMIT 1",
                                                $content = getUserDataArray();
 
                                                // Generate HTML list entry
-                                               $add = '<li>{--ADMIN_MEMBER_UID--}: <strong>' . generateUserProfileLink($taskData['userid'], 'user_data') . ' (<a href="' . generateEmailLink($content['email'], 'user_data') . '">' . translateGender($content['gender']) . ' ' . $content['surname'] . ' ' . $content['family'] . '</a>)</strong></li>';
+                                               $add = '<li>{--ADMIN_MEMBER_UID--}: <strong>' . generateUserProfileLink($taskData['userid'], 'user_data') . ' (<a href="' . generateEmailLink($content['email'], 'user_data') . '">{%pipe,translateGender=' . $content['gender'] . '%} ' . $content['surname'] . ' ' . $content['family'] . '</a>)</strong></li>';
                                        } else {
                                                // Invalid userid, so log and zero it
                                                logDebugMessage(__FUNCTION__, __LINE__, 'fetchUserData() failed: userid=' . $taskData['userid'] . ' not found.');
index 9df887c..27b3978 100644 (file)
@@ -60,15 +60,6 @@ LIMIT 1",
                // Load sponsor details
                $content = SQL_FETCHARRAY($result_main);
 
-               // Prepare all data for the template
-               // Init gender
-               foreach (array('m', 'f', 'c') as $gender) {
-                       $content['gender_' . $gender] = '';
-               } // END - foreach
-
-               // Check for gender selection
-               $content['gender_' . strtolower($content['gender'])] = ' selected="selected"';
-
                //  Warning because low points
                $content['receive_warnings'] = addSelectionBox('yn', $content['receive_warnings'], 'receive_warning');
                $content['warning_interval'] = createTimeSelections($content['warning_interval'], 'warning_interval', 'MWDh');
index bb2904d..b9e6493 100644 (file)
@@ -121,14 +121,6 @@ LIMIT 1",
                // Load entry
                $content = SQL_FETCHARRAY($result_main);
 
-               // Init entries
-               foreach (array('gender_m','gender_f','gender_c') as $entry) {
-                       $content[$entry] = '';
-               } // END - foreach
-
-               // Prepare selections
-               $content['gender_' . strtolower($content['gender'])] = ' selected="selected"';
-
                // Load template
                loadTemplate('admin_edit_user', false, $content);
        }
index 593c030..12f1dd2 100644 (file)
@@ -165,7 +165,7 @@ LIMIT 1",
                                $content = array(
                                        'task' => $taskId,
                                        'pid'  => bigintval(getRequestParameter('pid')),
-                                       'user' => '<a href="' . generateEmailLink(getUserData('email'), 'user_data') . '">' . translateGender(getUserData('gender')) . ' ' . getUserData('surname') . ' ' . getUserData('family') . '</a>',
+                                       'user' => '<a href="' . generateEmailLink(getUserData('email'), 'user_data') . '">{%pipe,translateGender=' . getUserData('gender') . '%} ' . getUserData('surname') . ' ' . getUserData('family') . '</a>',
                                );
 
                                // Load template
@@ -196,7 +196,7 @@ LIMIT 1",
                                $content = array(
                                        'task' => $taskId,
                                        'pid'  => bigintval(getRequestParameter('pid')),
-                                       'user' => '<a href="' . generateEmailLink(getUserData('email'), 'user_data') . '">' . translateGender(getUserData('gender')) . ' ' . getUserData('surname') . ' ' . getUserData('family') . '</a>',
+                                       'user' => '<a href="' . generateEmailLink(getUserData('email'), 'user_data') . '">{%pipe,translateGender=' . getUserData('gender') . '%} ' . getUserData('surname') . ' ' . getUserData('family') . '</a>',
                                );
 
                                // Load template
index 7bd4b1b..0be210c 100644 (file)
@@ -117,7 +117,9 @@ ORDER BY
                                                                );
 
                                                                // Check if referal count is larger 0 and update link
-                                                               if ($refs_cnt > 0) $content['refs_link'] = generateUserProfileLink(getUserData('userid'), $refs_cnt, 'list_refs');
+                                                               if ($refs_cnt > 0) {
+                                                                       $content['refs_link'] = generateUserProfileLink(getUserData('userid'), $refs_cnt, 'list_refs');
+                                                               } // END - if
 
                                                                // Load template for level one
                                                                $OUT_REFS .= loadTemplate('admin_list_refs_row', true, $content);
index 52037dd..1ca24d5 100644 (file)
@@ -162,7 +162,7 @@ LIMIT %s",
                                                'userid' => $row['userid'],
                                                'link'   => $mailType,
                                                'id'     => $ID,
-                                               'email'  => '<a href="' . generateEmailLink($row['email'], 'user_data') . '">' . translateGender($row['gender']) . ' ' . $row['surname'] . ' ' . $row['family'] . '</a>',
+                                               'email'  => '<a href="' . generateEmailLink($row['email'], 'user_data') . '">{%pipe,translateGender=' . $row['gender'] . '%} ' . $row['surname'] . ' ' . $row['family'] . '</a>',
                                                'status' => $row['status'],
                                        );
 
index a7eb9b6..69a020c 100644 (file)
@@ -114,7 +114,7 @@ if ((isFormSent()) && (isRegistrationDataComplete())) {
                default: // Default is the US date format... :)
                        $content['birthday_selection'] = addSelectionBox('month', postRequestParameter('month')).addSelectionBox('day', postRequestParameter('day')).addSelectionBox('year', postRequestParameter('year'));
                        break;
-       }
+       } // END - switch
 
        // Adds a table for the guests with all visible categories
        $content['category_selection'] = registerGenerateCategoryTable('guest', true);
@@ -134,20 +134,22 @@ if ((isFormSent()) && (isRegistrationDataComplete())) {
        // You may want to modify the register_header.tpl.xx file and not this script when you add your scripts etc. :-)
        $content['header_content'] = loadTemplate('register_header', true);
 
-       // Other values
-       $content['surname']   = SQL_ESCAPE(postRequestParameter('surname'));
-       $content['family']    = SQL_ESCAPE(postRequestParameter('family'));
-       $content['street_nr'] = SQL_ESCAPE(postRequestParameter('street_nr'));
-       $content['zip']       = '';
+       // ZIP codes are numerical values
+       $content['zip'] = '';
        if (isPostRequestParameterSet('zip')) {
-               $content['zip']       = bigintval(postRequestParameter('zip'));
+               $content['zip'] = bigintval(postRequestParameter('zip'));
        } // END - if
-       $content['city']      = SQL_ESCAPE(postRequestParameter('city'));
-       $content['email']     = SQL_ESCAPE(postRequestParameter('email'));
+
+       // Other values
+       foreach (array('gender', 'surname', 'family', 'street_nr', 'city', 'email') as $entry) {
+               $content[$entry] = SQL_ESCAPE(postRequestParameter($entry));
+       } // END - foreach
 
        // The admin may see all
        $whereStatement = "WHERE `is_active`='Y'";
-       if (isAdmin()) $whereStatement = '';
+       if (isAdmin()) {
+               $whereStatement = '';
+       } // END - if
 
        // Prepare country selection box
        $OUT  = '<select name="country_code" class="form_select" size="1">';
index bc5bbdf..3d0a935 100644 (file)
@@ -263,14 +263,6 @@ ORDER BY
                                $content[$entry]    = secureString(postRequestParameter($entry));
                        } // END - foreach
 
-                       // Init gender
-                       foreach (array('m', 'f', 'c') as $gender) {
-                               $content['gender_' . $gender] = '';
-                       } // END - foreach
-
-                       // Check for gender selection
-                       $content['gender_' . strtolower(postRequestParameter('gender'))] = ' selected="selected"';
-
                        // Init receive selection
                        $content['receive_warnings_y'] = '';
                        $content['receive_warnings_n'] = '';
index 14cb33b..d30f62a 100644 (file)
@@ -132,12 +132,7 @@ LIMIT 1",
                        // You cannot change your account
                        displayMessage($content['update_check']);
                } else {
-                       // He is allowed to change his profile
-                       foreach (array('gender_m','gender_f','gender_c') as $entry) {
-                               $content[$entry] = '';
-                       } // END - foreach
-
-                       $content['gender_' . strtolower($content['gender'])] = ' selected="selected"';
+                       // Init elements
                        $content['dob'] = '';
 
                        switch (getLanguage()) {
index 571340b..6c3acd0 100644 (file)
@@ -124,14 +124,6 @@ if (SQL_NUMROWS($result) == 1) {
                                $GLOBALS['sponsor_output'] = displayMessage('{--SPONSOR_NO_MESSAGE_GENERATED--}', true);
                        }
                } else {
-                       // Init gender
-                       foreach (array('m', 'f', 'c') as $gender) {
-                               $content['gender_' . $gender] = '';
-                       } // END - foreach
-
-                       // Check for gender selection
-                       $content['gender_' . strtolower($content['gender'])] = ' selected="selected"';
-
                        // Output formular
                        $GLOBALS['sponsor_output'] = loadTemplate('sponsor_account_form', true, $content);
                }
index 3f28df1..08fa2e5 100644 (file)
@@ -1027,7 +1027,9 @@ function createTimeSelections ($timestamp, $prefix = '', $display = '', $align =
 // Generate a list of administrative links to a given userid
 function generateMemberAdminActionLinks ($userid) {
        // Make sure userid is a number
-       if ($userid != bigintval($userid)) debug_report_bug(__FUNCTION__, __LINE__, 'userid is not a number!');
+       if ($userid != bigintval($userid)) {
+               debug_report_bug(__FUNCTION__, __LINE__, 'userid is not a number!');
+       } // END - if
 
        // Define all main targets
        $targetArray = array('del_user', 'edit_user', 'lock_user', 'add_points', 'sub_points');
@@ -1595,7 +1597,7 @@ function sendModeMails ($mod, $modes) {
 }
 
 // Generates a 'selection box' from given array
-function generateSelectionBoxFromArray ($options, $name, $optionValue, $optionContent = '', $extraName = '') {
+function generateSelectionBoxFromArray (array $options, $name, $optionValue, $optionContent = '', $extraName = '') {
        // Start the output
        $OUT = '<select name="' . $name . '" size="1" class="form_select">
 <option value="X" disabled="disabled">{--PLEASE_SELECT--}</option>';
@@ -1714,6 +1716,21 @@ function displayMessage ($message, $return = false) {
        return loadTemplate('admin_settings_saved', $return, $message);
 }
 
+// Generates a selection box for (maybe) given gender
+function generateGenderSelectionBox ($selectedGender = '') {
+       // Start the HTML code
+       $out  = '<select name="gender" size="1" class="form_select">';
+
+       // Add the options
+       $out .= generateOptionList('/ARRAY/', array('M', 'F', 'C'), array('{--GENDER_M--}', '{--GENDER_F--}', '{--GENDER_C--}'), $selectedGender);
+
+       // Finish HTML code
+       $out .= '</select>';
+
+       // Return the code
+       return $out;
+}
+
 //-----------------------------------------------------------------------------
 //                      Template helper functions for EL
 //-----------------------------------------------------------------------------
index 8b94ed6..dd46907 100644 (file)
                {--GENDER--}:
        </td>
        <td>
-               <select name="gender" class="form_select" size="1">
-                       <option value="M">{--GENDER_M--}</option>
-                       <option value="F">{--GENDER_F--}</option>
-                       <option value="C">{--GENDER_C--}</option>
-               </select>
+               {%pipe,generateGenderSelectionBox=$content[gender]%}
        </td>
 </tr>
 <tr>
index b277e4d..fee1ace 100644 (file)
                {--GENDER--}:
        </td>
        <td width="255">
-               <select name="gender" class="form_select" size="1">
-                       <option value="M"$content[gender_m]>{--GENDER_M--}</option>
-                       <option value="F"$content[gender_f]>{--GENDER_F--}</option>
-                       <option value="C"$content[gender_c]>{--GENDER_C--}</option>
-               </select>
+               {%pipe,generateGenderSelectionBox=$content[gender]%}
        </td>
 </tr>
 <tr>
index 9569547..60d0a12 100644 (file)
@@ -9,11 +9,7 @@
        <tr>
                <td width="195" align="right" height="21">{--GENDER--}:</td>
                <td width="195">
-                       <select name="gender" class="form_select" size="1">
-                               <option value="M"$content[gender_m]>{--GENDER_M--}</option>
-                               <option value="F"$content[gender_f]>{--GENDER_F--}</option>
-                               <option value="C"$content[gender_c]>{--GENDER_C--}</option>
-                       </select>
+                       {%pipe,generateGenderSelectionBox=$content[gender]%}
                </td>
        </tr>
        <tr>
index bb517ee..27c051f 100644 (file)
                                <td class="register_left">
                                        {--GENDER--}$content[must_fillout_gender]:
                                </td>
-                               <td class="register_right"><select name="gender"
-                                       size="1" class="form_select">
-                                       <option value="M">{--GENDER_M--}</option>
-                                       <option value="F">{--GENDER_F--}</option>
-                                       <option value="C">{--GENDER_C--}</option>
-                               </select></td>
+                               <td class="register_right">
+                                       {%pipe,generateGenderSelectionBox=$content[gender]%}
+                               </td>
                        </tr>
                        <tr>
                                <td class="register_left">{--SURNAME--}$content[must_fillout_surname],
index 6d9f21e..e9de926 100644 (file)
                {--GENDER--}:
        </td>
        <td>
-               <select name="gender" class="form_select" size="1">
-                       <option value="M"$content[gender_m]>{--GENDER_M--}</option>
-                       <option value="F"$content[gender_f]>{--GENDER_F--}</option>
-                       <option value="C"$content[gender_c]>{--GENDER_C--}</option>
-               </select>
+               {%pipe,generateGenderSelectionBox=$content[gender]%}
        </td>
 </tr>
 <tr>
index 5beeec6..6ca4d92 100644 (file)
@@ -9,11 +9,7 @@
        <tr>
                <td align="right">{--GENDER--}:</td>
                <td>
-                       <select name="gender" size="1" class="form_select">
-                               <option value="M"$content[gender_m]>{--GENDER_M--}</option>
-                               <option value="F"$content[gender_f]>{--GENDER_F--}</option>
-                               <option value="C"$content[gender_c]>{--GENDER_C--}</option>
-                       </select>
+                       {%pipe,generateGenderSelectionBox=$content[gender]%}
                </td>
        </tr>
        <tr>
index 0bcedea..7644cdc 100644 (file)
                {--GENDER--}:
        </td>
        <td class="bottom">
-               <select name="gender" class="form_select" size="1">
-                       <option value="M"$content[gender_m]>{--GENDER_M--}</option>
-                       <option value="F"$content[gender_f]>{--GENDER_F--}</option>
-                       <option value="C"$content[gender_c]>{--GENDER_C--}</option>
-               </select>
+               {%pipe,generateGenderSelectionBox=$content[gender]%}
        </td>
 </tr>
 <tr>