Naming convention applied, new wrapper introduced:
authorRoland Häder <roland@mxchange.org>
Sun, 11 Jul 2010 20:46:19 +0000 (20:46 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 11 Jul 2010 20:46:19 +0000 (20:46 +0000)
- Naming convention only allows foo_yes/foo_no (was: foo_y/foo_n)
- New wrapper isRefbackEnabled () introduced
- TODOs.txt updated

DOCS/TODOs.txt
inc/libs/refback_functions.php
inc/libs/register_functions.php
inc/libs/surfbar_functions.php
inc/modules/admin/what-config_refback.php
inc/modules/guest/what-sponsor_reg.php
inc/modules/member/what-refback.php
templates/de/html/guest/guest_cat_row.tpl
templates/de/html/guest/guest_sponsor_reg.tpl
templates/de/html/member/member_surfbar_edit_action_form.tpl

index 36eae95..3d9799b 100644 (file)
@@ -70,9 +70,9 @@
 ./inc/libs/rallye_functions.php:854:// @TODO Please document this function
 ./inc/libs/rallye_functions.php:910:           // Load count @TODO Can't we rewrite this to our API?
 ./inc/libs/refback_functions.php:61:           // @TODO Try to rewrite the following unset()
-./inc/libs/register_functions.php:296: // @TODO Rewrite these all to a single filter
-./inc/libs/register_functions.php:375: // @TODO Rewrite this to a filter
-./inc/libs/register_functions.php:382: // @TODO Wether the registration bonus should only be added to user directly or through referal system should be configurable
+./inc/libs/register_functions.php:292: // @TODO Rewrite these all to a single filter
+./inc/libs/register_functions.php:371: // @TODO Rewrite this to a filter
+./inc/libs/register_functions.php:378: // @TODO Wether the registration bonus should only be added to user directly or through referal system should be configurable
 ./inc/libs/surfbar_functions.php:1540:         // @TODO This can be somehow rewritten
 ./inc/libs/surfbar_functions.php:712:// @TODO Can't we use our new expression language instead of this ugly code?
 ./inc/libs/surfbar_functions.php:953:  // @TODO Invalid salt should be refused
index 844bc83..f3277f2 100644 (file)
@@ -417,5 +417,17 @@ function updateMemberRefbackPercents ($id, $percents) {
        return $status;
 }
 
+// Checks wether refback is enabled
+function isRefbackEnabled () {
+       // Do we have cache?
+       if (!isset($GLOBALS['is_refback_enabled'])) {
+               // Determine it
+               $GLOBALS['is_refback_enabled'] = (getConfig('refback_enabled') == 'Y');
+       } // END - if
+
+       // Return cache
+       return $GLOBALS['is_refback_enabled'];
+}
+
 // [EOF]
 ?>
index cfbca85..cae4765 100644 (file)
@@ -92,18 +92,14 @@ function registerGenerateCategoryTable ($mode, $return=false) {
                $OUT .= '<table border="0" cellspacing="0" cellpadding="0" width="100%">';
                while ($content = SQL_FETCHARRAY($result)) {
                        // Prepare array for the template
-                       $content = array(
-                               'cat'   => $content['cat'],
-                               'def_y' => '',
-                               'def_n' => '',
-                               'id'    => $content['id'],
-                       );
+                       $content['default_yes'] = '';
+                       $content['default_no']  = '';
 
                        // Mark categories
                        if ((postRequestParameter('cat', $content['id']) == 'Y') || ((getConfig('register_default') == 'Y') && (!isPostRequestParameterSet('cat', $content['id'])))) {
-                               $content['def_y'] = ' checked="checked"';
+                               $content['default_yes'] = ' checked="checked"';
                        } else {
-                               $content['def_n'] = ' checked="checked"';
+                               $content['default_no']  = ' checked="checked"';
                        }
 
                        // Load template and switch color
@@ -149,7 +145,7 @@ function FILTER_REGISTER_MUST_FILLOUT ($content) {
                if ($row['field_required'] == 'Y') $value = '<span class="guest_failed">(*)</span>';
 
                // Add it
-               $content['must_fillout_'.strtolower($row['field_name']).''] = $value;
+               $content['must_fillout_' . strtolower($row['field_name']) . ''] = $value;
        } // END - while
 
        // Free memory
index 490d672..8a4d323 100644 (file)
@@ -369,16 +369,16 @@ function SURFBAR_MEMBER_DISPLAY_ACTION_FORM ($action, $urlData) {
        // Include fields only for action 'edit'
        if ($action == 'edit') {
                // Default is not limited
-               $urlData['limited_y'] = '';
-               $urlData['limited_n'] = ' checked="checked"';
-               $urlData['limited']   = 'false';
+               $urlData['limited_yes'] = '';
+               $urlData['limited_no']  = ' checked="checked"';
+               $urlData['limited']     = 'false';
 
                // Is this URL limited?
                if (SURFBAR_GET_VIEWS_MAX() > 0) {
                        // Then rewrite form data
-                       $urlData['limited_y'] = ' checked="checked"';
-                       $urlData['limited_n'] = '';
-                       $urlData['limited']   = 'true';
+                       $urlData['limited_yes'] = ' checked="checked"';
+                       $urlData['limited_no']  = '';
+                       $urlData['limited']     = 'true';
                } // END - if
        } // END - if
 
index 1f9d023..4eddb53 100644 (file)
@@ -54,20 +54,19 @@ if (isFormSent()) {
        adminSaveSettingsFromPostData();
 } else {
        // Prepare content
-       $content = array();
+       $content = array(
+               'refback_enabled_n' => '',
+               'refback_enabled_y' => ''
+       );
 
        // Translate Y/N switches
-       switch (getConfig('refback_enabled')) {
-               case 'Y': // Refback enabled
-                       $content['refback_enabled_y'] = ' checked="checked"';
-                       $content['refback_enabled_n'] = '';
-                       break;
-
-               case 'N': // Refback disabled
-                       $content['refback_enabled_y'] = '';
-                       $content['refback_enabled_n'] = ' checked="checked"';
-                       break;
-       } // END - switch
+       if (isRefbackEnabled()) {
+               // Enabled
+               $content['refback_enabled_y'] = ' checked="checked"';
+       } else {
+               // Disabled
+               $content['refback_enabled_n'] = ' checked="checked"';
+       }
 
        // Load template
        loadTemplate('admin_config_refback', false, $content);
index a689431..ed92a13 100644 (file)
@@ -302,7 +302,7 @@ ORDER BY
                $content['payment_list'] = $OUT;
 
                // Init a lot array elements
-               foreach (array('company','position','tax_ident','gender_m','gender_f','gender_c','surname','family','street_nr1','street_nr2','country','zip','city','phone','fix','cell','email','url','rec_y','rec_n','form_errors','refid') as $entry) {
+               foreach (array('company','position','tax_ident','gender_m','gender_f','gender_c','surname','family','street_nr1','street_nr2','country','zip','city','phone','fix','cell','email','url','receive_warnings_y','receive_warnings_n','form_errors','refid') as $entry) {
                        $content[$entry]   = '';
                } // END - foreach
 
@@ -322,11 +322,11 @@ ORDER BY
                        $content['gender_' . strtolower(postRequestParameter('gender'))] = ' selected="selected"';
 
                        // Init receive selection
-                       $content['rec_y'] = '';
-                       $content['rec_n'] = '';
+                       $content['receive_warnings_y'] = '';
+                       $content['receive_warnings_n'] = '';
 
                        // Check for receive_warnings
-                       $content['rec_' . strtolower(postRequestParameter('receive_warnings'))] = ' selected="selected"';
+                       $content['receive_warnings_' . strtolower(postRequestParameter('receive_warnings'))] = ' selected="selected"';
                        $OUT = '';
 
                        // Errors found?
index b69124c..0900fcb 100644 (file)
@@ -43,7 +43,7 @@ if (!defined('__SECURITY')) {
 } elseif (!isMember()) {
        // User is not logged in
        redirectToIndexMemberOnlyModule();
-} elseif (getConfig('refback_enabled') != 'Y') {
+} elseif (!isRefbackEnabled()) {
        // Output message
        loadTemplate('admin_settings_saved', false, '{--MEMBER_REFBACK_DISABLED--}');
 
index a3c1cf8..39d0bca 100644 (file)
@@ -2,10 +2,10 @@
        <td class="register_right {%template,ColorSwitch%}">$content[cat]</td>
        <td width="20" class="guest_normal {%template,ColorSwitch%}">
                {--YES--}
-               <input type="radio" class="guest_normal" name="cat[$content[id]]" value="Y"$content[def_y] />
+               <input type="radio" class="guest_normal" name="cat[$content[id]]" value="Y"$content[default_yes] />
        </td>
        <td width="20" class="guest_normal {%template,ColorSwitch%}">
                {--NO--}
-               <input type="radio" class="guest_normal" name="cat[$content[id]]" value="N"$content[def_n] />
+               <input type="radio" class="guest_normal" name="cat[$content[id]]" value="N"$content[default_no] />
        </td>
 </tr>
index c6b133e..7d47336 100644 (file)
   </td>
   <td>
     <select name="receive_warnings" class="guest_select" size="1">
-      <option value="Y"$content[rec_y]>{--YES--}</option>
-      <option value="N"$content[rec_n]>{--NO--}</option>
+      <option value="Y"$content[receive_warnings_y]>{--YES--}</option>
+      <option value="N"$content[receive_warnings_n]>{--NO--}</option>
     </select>
   </td>
 </tr>
index ab0056d..c05251e 100644 (file)
@@ -11,8 +11,8 @@
 
        <div class="member_input" style="padding-top:5px;padding-bottom:5px">
                Soll die Anzahl Aufrufe begrenzt werden?<br />
-               <input type="radio" id="limited_no" onfocus="return FocusLimitedNo()" name="limited" value="N"$content[limited_n] /> {--NO--}
-               <input type="radio" id="limited_yes" onfocus="return FocusLimitedYes()" name="limited" value="Y"$content[limited_y] /> {--YES--}
+               <input type="radio" id="limited_no" onfocus="return FocusLimitedNo()" name="limited" value="N"$content[limited_no] /> {--NO--}
+               <input type="radio" id="limited_yes" onfocus="return FocusLimitedYes()" name="limited" value="Y"$content[limited_yes] /> {--YES--}
        </div>
 
        <div class="member_input bottom" style="padding-top:5px;padding-bottom:5px">