Translation of status/reward now happens after the record was inserted
[mailer.git] / inc / libs / surfbar_functions.php
index f00ee9abe9ee37e1a11d3d6483ec498dfc808e8f..8cd6082367ad4998b136abddcd4e26ef568095f1 100644 (file)
@@ -122,6 +122,10 @@ function SURFBAR_REGISTER_URL ($url, $uid, $reward, $status="PENDING", $addMode=
        // Insert the URL into database
        $content['insert_id'] = SURFBAR_INSERT_URL_BY_ARRAY($content);
 
+       // Translate status and reward
+       $content['status'] = SURFBAR_TRANSLATE_STATUS($content['status']);
+       $content['reward'] = TRANSLATE_COMMA($content['reward']);
+
        // If in reg-mode we notify admin
        if (($addMode == "reg") || ($_CONFIG['surfbar_notify_admin_unlock'] == "Y")) {
                // Notify admin even when he as unlocked an email
@@ -137,16 +141,14 @@ function SURFBAR_REGISTER_URL ($url, $uid, $reward, $status="PENDING", $addMode=
 // Inserts an url by given data array and return the insert id
 function SURFBAR_INSERT_URL_BY_ARRAY ($urlData) {
        // Just run the insert query for now
-       /*
        SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_surfbar_urls (userid, url, reward, status) VALUES(%s, '%s', %s, '%s')",
                array(
-                       bigintval($urlData['userid']),
+                       bigintval($urlData['uid']),
                        bigintval($urlData['url']),
                        (float)$urlData['reward'],
                        $urlData['status']
                ), __FILE__, __LINE__
        );
-       */
 
        // Return insert id
        return SQL_INSERTID();
@@ -168,7 +170,7 @@ function SURFBAR_NOTIFY_ADMIN ($messageType, $content) {
 // Notify the user about the performed action
 function SURFBAR_NOTIFY_USER ($messageType, $content) {
        // Prepare template name
-       $templateName = sprintf("admin_surfbar_%s", $messageType);
+       $templateName = sprintf("member_surfbar_%s", $messageType);
 
        // Prepare subject
        $eval = sprintf("\$subject = MEMBER_SURFBAR_NOTIFY_%s_SUBJECT;",
@@ -182,5 +184,22 @@ function SURFBAR_NOTIFY_USER ($messageType, $content) {
        // Send the email
        SEND_EMAIL($content['uid'], $subject, $mailText);
 }
+// Translate the URL status
+function SURFBAR_TRANSLATE_STATUS ($status) {
+       // Create constant name
+       $constantName = sprintf("SURFBAR_URL_STATUS_%s", strtoupper($status));
+
+       // Set default translated status
+       $statusTranslated = "!".$constantName."!";
+
+       // Generate eval() command
+       if (defined($constantName)) {
+               $eval = "\$statusTranslated = ".$constantName.";";
+               eval($eval);
+       } // END - if
+
+       // Return result
+       return $statusTranslated;
+}
 //
 ?>