Even more rewrites/fixes from EL branch (please report any broken part after you...
[mailer.git] / inc / libs / surfbar_functions.php
index 01173c9de3033f72a4ceca5cc46c3f8c4f4c8cc4..6716188e18beb2db07f90446beb5c3292fd587a1 100644 (file)
@@ -216,7 +216,7 @@ function SURFBAR_MEMBER_ACTIONS ($urlId, $status) {
 }
 
 // Do the member form request
-function SURFBAR_MEMBER_DO_FORM ($formData, $URLs) {
+function SURFBAR_MEMBER_DO_FORM ($formData, $urlArray) {
        // By default no action is performed
        $performed = false;
 
@@ -227,10 +227,10 @@ function SURFBAR_MEMBER_DO_FORM ($formData, $URLs) {
        } elseif ((!isset($formData['id'])) || (!isset($formData['action']))) {
                // Important form elements are missing!
                return false;
-       } elseif (!isset($URLs[$formData['id']])) {
+       } elseif (!isset($urlArray[$formData['id']])) {
                // id not found in cache
                return false;
-       } elseif (!SURFBAR_VALIDATE_MEMBER_ACTION_STATUS($formData['action'], $URLs[$formData['id']]['url_status'])) {
+       } elseif (!SURFBAR_VALIDATE_MEMBER_ACTION_STATUS($formData['action'], $urlArray[$formData['id']]['url_status'])) {
                // Action not allowed for current URL status
                return false;
        }
@@ -250,10 +250,10 @@ function SURFBAR_MEMBER_DO_FORM ($formData, $URLs) {
        // Is the function there?
        if (function_exists($functionName)) {
                // Add new status
-               $URLs[$formData['id']]['new_status'] = SURFBAR_GET_NEW_STATUS('new_status');
+               $urlArray[$formData['id']]['new_status'] = SURFBAR_GET_NEW_STATUS('new_status');
 
                // Extract URL data for call-back
-               $urlData = array(merge_array($URLs[$formData['id']], array($action => $formData)));
+               $urlData = array(merge_array($urlArray[$formData['id']], array($action => $formData)));
 
                // Action found so execute it
                $performed = call_user_func_array($functionName, $urlData);
@@ -298,7 +298,7 @@ function SURFBAR_VALIDATE_MEMBER_ACTION_STATUS ($action, $status) {
 function SURFBAR_MEMBER_RETREAT_ACTION ($urlData) {
        // Create the data array for next function call
        $data = array(
-       $urlData['id'] => $urlData
+               $urlData['id'] => $urlData
        );
 
        // Simply change the status here
@@ -493,7 +493,7 @@ function SURFBAR_HANDLE_LOW_POINTS () {
                if ((time() - $userids['notified'][$userid]) >= getConfig('surfbar_low_interval')) {
                        // Prepare content
                        $content = array(
-                               'userid'      => $userid,
+                               'userid'   => $userid,
                                'low'      => translateComma(getConfig('surfbar_warn_low_points')),
                                'points'   => translateComma($userids['points'][$userid]),
                                'notified' => generateDateTime($userids['notified'][$userid]),
@@ -560,7 +560,7 @@ function SURFBAR_GET_URL_DATA ($searchTerm, $column = 'url_id', $order = 'url_id
 FROM
        `{?_MYSQL_PREFIX?}_surfbar_urls`
 WHERE
-       `%s`='%s'".$add."
+       `%s`='%s'" . $add . "
 ORDER BY
        `%s` %s
 %s",
@@ -626,9 +626,6 @@ function SURFBAR_REGISTER_URL ($url, $userid, $status = 'PENDING', $addMode = 'r
                return false;
        } // END - if
 
-       // Translate status and limit
-       $content['limit'] = translateSurfbarLimit($content['limit']);
-
        // If in reg-mode we notify admin
        if (($addMode == 'reg') || (getConfig('surfbar_notify_admin_unlock') == 'Y')) {
                // Notify admin even when he as unlocked an email
@@ -724,12 +721,8 @@ function SURFBAR_NOTIFY_USER ($messageType, $content) {
 // @TODO Can't we use our new expression language instead of this ugly code?
 function SURFBAR_PREPARE_CONTENT_FOR_TEMPLATE ($content) {
        // Prepare some code
-       if (isset($content['url_status']))      $content['url_status']      = translateSurfbarUrlStatus($content['url_status']);
        if (isset($content['url_registered']))  $content['url_registered']  = generateDateTime($content['url_registered'], 2);
        if (isset($content['url_last_locked'])) $content['url_last_locked'] = generateDateTime($content['url_last_locked'], 2);
-       if (isset($content['url_views_total'])) $content['url_views_total'] = translateComma($content['url_views_total']);
-       if (isset($content['url_views_allowed']))   $content['url_views_allowed']   = translateComma($content['url_views_allowed']);
-       if (isset($content['views_max']))       $content['views_max']       = translateComma($content['views_max']);
 
        // Return translated content
        return $content;
@@ -819,7 +812,7 @@ function SURFBAR_DETERMINE_TEMPLATE_NAME() {
        if (isGetRequestParameterSet('frame')) {
                // Use the frame as a template name part... ;-)
                $templateName = sprintf("surfbar_frame_%s",
-               getRequestParameter('frame')
+                       getRequestParameter('frame')
                );
        } // END - if
 
@@ -1502,7 +1495,7 @@ GROUP BY
 // Load all URLs of the current user and return it as an array
 function SURFBAR_GET_USER_URLS () {
        // Init array
-       $URLs = array();
+       $urlArray = array();
 
        // Begin the query
        $result = SQL_QUERY_ESC("SELECT
@@ -1530,7 +1523,7 @@ ORDER BY
                // Load all rows
                while ($row = SQL_FETCHARRAY($result)) {
                        // Add the row
-                       $URLs[$row['id']] = $row;
+                       $urlArray[$row['id']] = $row;
                } // END - while
        } // END - if
 
@@ -1538,7 +1531,7 @@ ORDER BY
        SQL_FREERESULT($result);
 
        // Return the array
-       return $URLs;
+       return $urlArray;
 }
 
 // "Getter" for member action array for given status
@@ -1756,14 +1749,14 @@ function SURFBAR_GET_DATA ($element) {
                // Then take it
                $data = $GLOBALS['surfbar_cache'][$element];
        } else { // END - if
-               print("<pre>");
+               print('<pre>');
                print_r($GLOBALS['surfbar_cache']);
-               print("</pre>");
-               debug_report_bug();
+               print('</pre>');
+               debug_report_bug('Element ' . $element . ' not found.');
        }
 
        // Return result
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "element[$element]={$data}", false);
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'element[' . $element . ']=[' . gettype($data) . ']' . $data, false);
        return $data;
 }