]> git.mxchange.org Git - mailer.git/commitdiff
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 27afa7a1e4c6d35156abc0535795a12f09569eaf..4ac881be1c25e847869226a0f9fc08a599599003 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 9967f3b4365ecdb9415194db37ace2e9fd829bb9..e9e559138e952b77c901dd99c1283b930f6da3b9 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 56230b9022fba02148d2d21f6bcd3c7a1981015b..99c029890f7c38938072886f53007913bd52c03a 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 cf309d2f1cbcb343673e464a336bfb03c2f5ec16..e88441e131fa58f323fb9e3f76a41894e0ed211f 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 9df887c28295ed3d4158afd22aff862b8d6bcb32..27b3978a2112c8bc9a38ed928e0b70cc22ce8db5 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 bb2904d744f4e36c081bc8c57be2eca02b53a2f8..b9e64937b19817d4828b1def6d5f84092f07d152 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 593c030a522ea36560b1f025d3728257ce43cffb..12f1dd24c2c9d0ae97bcd82f0366e5c651986ff6 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 7bd4b1b515330c5e1b7e1456c6418ea863e28a43..0be210ce71a89b2e810f27866edbed29a397eac6 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 52037dd5c90163d10b11166c4182d76f0b748e1f..1ca24d5824c0fd6a998994a5b749c1d6a0e9cb15 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 a7eb9b6676f4af60f351efe1c55e4d4e9393fdfa..69a020c4281aa243eaf76b3844f0ac6a7f7bf3ce 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 bc5bbdfcdea337564f92a30bd4a25b4f0a4e18e5..3d0a93547e41f7f4493b25ceeb04d53dedf1c7ef 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 14cb33b936efb6e2545e291465cea39721a5fe07..d30f62a40fe1a999c45a4b4d8baf628d0b22ff2a 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 571340b12f2bd3f41a5b3ba05b4de1437cc79341..6c3acd0465dc7d2e9222908b00455ec54f2de7e4 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 3f28df112407f20140ab25decc065a3191e04fa8..08fa2e50c288b79126e14226ac601289b3c16cb7 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 8b94ed63dd79b33b2661d4282fc8dd4483606c8d..dd4690747d8c8775d117a2f0f2a6b1f34cd77210 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 b277e4df884e25cec91e3f4f1fbaa06943961ab0..fee1ace7fcac199a6f838d7fb5948a7df4023033 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 9569547236fc581cfe0164b8789707d4015074d4..60d0a12ae82317ccf094e31ff1ed7bdd5871a9ab 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 bb517ee40da7164de8e7d1b94e888bf8ecafe15a..27c051f4de9a3eec38fffd6df050476dbe11f906 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 6d9f21e24ad437000fde798f445814d57c93b623..e9de926ddfdea2ceb71d86ad130e6b398f70e6d2 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 5beeec64a1b6d8b1298fff82898dbb171c097ce6..6ca4d92483a2a791b414fd07e8c507c5699076f6 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 0bcedea964a741d69502d8d087d90dfc7dba78c3..7644cdc1998f1e1f89cd71ef79de3af8ee689e82 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>