Fixes/rewrites for ext-surfbar:
authorRoland Häder <roland@mxchange.org>
Mon, 11 Jul 2011 16:35:51 +0000 (16:35 +0000)
committerRoland Häder <roland@mxchange.org>
Mon, 11 Jul 2011 16:35:51 +0000 (16:35 +0000)
- Filter FILTER_SURFBAR_CHANGE_URL_STATUS() basicly finished
- Removed die() on two places
- Added missing message id
- Renamed template to conform with naming scheme
- TODOs.txt updated

.gitattributes
DOCS/TODOs.txt
inc/filter/surfbar_filter.php
inc/language/surfbar_de.php
inc/libs/surfbar_functions.php
inc/modules/member/what-surfbar_book.php
templates/de/emails/admin/admin_surfbar_url_active_depleted.tpl [new file with mode: 0644]
templates/de/emails/admin/admin_surfbar_url_depleted.tpl

index 8a971b1d325997c1a6d8e08993ca99ee529ef896..330eed08c1525d4af0d7e08abd7b33ded0a7cfe9 100644 (file)
@@ -827,6 +827,7 @@ templates/de/emails/admin/admin_support-ordr.tpl svneol=native#text/plain
 templates/de/emails/admin/admin_support-reflink.tpl svneol=native#text/plain
 templates/de/emails/admin/admin_support-unconfirmed.tpl svneol=native#text/plain
 templates/de/emails/admin/admin_surfbar_url_active_deleted.tpl svneol=native#text/plain
+templates/de/emails/admin/admin_surfbar_url_active_depleted.tpl svneol=native#text/plain
 templates/de/emails/admin/admin_surfbar_url_active_pending.tpl svneol=native#text/plain
 templates/de/emails/admin/admin_surfbar_url_active_stopped.tpl svneol=native#text/plain
 templates/de/emails/admin/admin_surfbar_url_confirmed.tpl svneol=native#text/plain
index 90f60d4c2e67594a1c2d3a326ccb7daab9def5d3..c6d84be1453307b2eaaa2b77b14dcb11dd1dd337 100644 (file)
 ./inc/libs/register_functions.php:367: // @TODO Wether the registration bonus should only be added to user directly or through referal system should be configurable
 ./inc/libs/sponsor_functions.php:159:                                  // @TODO Rewrite this to API function
 ./inc/libs/sponsor_functions.php:430:                  // @TODO Rewrite this to API function
-./inc/libs/surfbar_functions.php:1078: // @TODO Try to rewrite the following unset()
-./inc/libs/surfbar_functions.php:1595:         // @TODO This can be somehow rewritten
-./inc/libs/surfbar_functions.php:708:// @TODO Can't we use our new expression language instead of this ugly code?
-./inc/libs/surfbar_functions.php:997:  // @TODO Invalid salt should be refused
+./inc/libs/surfbar_functions.php:1000: // @TODO Invalid salt should be refused
+./inc/libs/surfbar_functions.php:1081: // @TODO Try to rewrite the following unset()
+./inc/libs/surfbar_functions.php:1598:         // @TODO This can be somehow rewritten
+./inc/libs/surfbar_functions.php:711:// @TODO Can't we use our new expression language instead of this ugly code?
 ./inc/libs/task_functions.php:247:             // @TODO These can be rewritten to filter
 ./inc/libs/task_functions.php:51:// @TODO Move all extension-dependent queries into filters
 ./inc/libs/theme_functions.php:93:     // @TODO Can't this be rewritten to an API function?
 ./inc/mysql-manager.php:44:// @TODO Can we cache this?
 ./inc/purge/purge-inact.php:55:        // @TODO Rewrite these if() blocks to a filter
 ./inc/revision-functions.php:169:// @TODO This function does also set and get in 'cache_array'
-./inc/template-functions.php:1063:                     // @TODO Deprecate this thing
-./inc/template-functions.php:1074:                     // @TODO Deprecate this thing
-./inc/template-functions.php:1167:     // @TODO This can be easily moved out after the merge from EL branch to this is complete
-./inc/template-functions.php:1200:             // @TODO Add a little more infos here
-./inc/template-functions.php:1511:// @TODO Lame description for this function
-./inc/template-functions.php:1533:                     // @TODO Move this in a filter
+./inc/template-functions.php:1066:                     // @TODO Deprecate this thing
+./inc/template-functions.php:1077:                     // @TODO Deprecate this thing
+./inc/template-functions.php:1170:     // @TODO This can be easily moved out after the merge from EL branch to this is complete
+./inc/template-functions.php:1203:             // @TODO Add a little more infos here
+./inc/template-functions.php:1514:// @TODO Lame description for this function
+./inc/template-functions.php:1536:                     // @TODO Move this in a filter
 ./inc/template-functions.php:189:       * @TODO On some pages this is buggy
 ./inc/template-functions.php:266:              // @TODO Remove this sanity-check if all is fine
-./inc/template-functions.php:591:// @TODO $simple/$constants are deprecated
-./inc/template-functions.php:617:      // @TODO Do only use $content and deprecate $GLOBALS and $DATA in templates
+./inc/template-functions.php:594:// @TODO $simple/$constants are deprecated
+./inc/template-functions.php:620:      // @TODO Do only use $content and deprecate $GLOBALS and $DATA in templates
 ./inc/wrapper-functions.php:130:// @TODO Implement $compress
 ./inc/wrapper-functions.php:137:// @TODO Implement $decompress
 ./inc/wrapper-functions.php:514:// @TODO Do some more sanity check here
 ./templates/de/emails/add-points.tpl:1:<!-- @DEPRECATED //-->
 ./templates/de/emails/admin/admin_coupon.tpl:1:<!-- @DEPRECATED //-->
 ./templates/de/emails/admin/admin_del_surfbar_urls.tpl:1:<!-- @DEPRECATED //-->
+./templates/de/emails/admin/admin_surfbar_url_depleted.tpl:1:<!-- @DEPRECATED //-->
 ./templates/de/emails/admin-del_links.tpl:1:<!-- @DEPRECATED //-->
 ./templates/de/emails/back-admin.tpl:1:<!-- @DEPRECATED //-->
 ./templates/de/emails/back-member.tpl:1:<!-- @DEPRECATED //-->
index e2e26f7a5dec2574f08a9015643b2cec276287c4..0039754f2f7291af35dbca92003f45a219d2d96a 100644 (file)
@@ -42,7 +42,24 @@ if (!defined('__SECURITY')) {
 
 // Filter for changing URL status
 function FILTER_SURFBAR_CHANGE_URL_STATUS ($filterData) {
-       die('<pre>'.print_r($filterData, true).'</pre>');
+       // Prepare content for notification routines
+       $filterData['data'][$filterData['url_id']]['url_userid']  = $filterData['data'][$filterData['url_id']]['url_userid'];
+       $filterData['data'][$filterData['url_id']]['frametester'] = '{%pipe,generateFrametesterUrl=' . $filterData['data'][$filterData['url_id']]['url'] . '%}';
+       $filterData['data'][$filterData['url_id']]['reward']      = '{%config,translateComma=surfbar_static_reward%}';
+       $filterData['data'][$filterData['url_id']]['costs']       = '{%config,translateComma=surfbar_static_costs%}';
+
+       // Do some dirty fixing here:
+       if (($filterData['data'][$filterData['url_id']]['url_status'] == 'STOPPED') && ($filterData['new_status'] == 'pending')) {
+               // Fix for template change
+               $filterData['new_status'] = 'continued';
+       } // END - if
+
+       // Send admin notification
+       SURFBAR_NOTIFY_ADMIN('url_' . strtolower($filterData['data'][$filterData['url_id']]['url_status']) . '_' . $filterData['new_status'], $filterData['data'][$filterData['url_id']]);
+
+       // Send user notification
+       SURFBAR_NOTIFY_USER('url_' . strtolower($filterData['data'][$filterData['url_id']]['url_status']) . '_' . $filterData['new_status'], $filterData['data'][$filterData['url_id']]);
+
        // Return filter data
        return $filterData;
 }
index 8ee9be6d9e46f69b55df1c614a99a8ad23197375..5c86862ddf8c10f152dbf09c7f9825bb44bc0245 100644 (file)
@@ -171,6 +171,7 @@ addMessages(array(
        'ADMIN_SURFBAR_NOTIFY_URL_MIGRATED_DELETED_SUBJECT' => "[Surfbar:] Mitglied hat migrierte URL gel&ouml;scht",
        'ADMIN_SURFBAR_NOTIFY_URL_MIGRATED_MIGRATED_SUBJECT' => "[Surfbar:] Mitglied hat migrierte URL ge&auml;ndert",
        'ADMIN_SURFBAR_NOTIFY_URL_MIGRATED_PENDING_SUBJECT' => "[Surfbar:] Mitglied hat migrierte URL gebucht",
+       'ADMIN_SURFBAR_NOTIFY_URL_ACTIVE_DEPLETED_SUBJECT' => "[Surfbar:] Maximale Views einer URL erreicht",
        'ADMIN_SURFBAR_NOTIFY_DEFAULT_SUBJECT' => "Problem in Surfbar-Betreff (%s)",
 
        // Auto-generated admin subject lines
index 61a901eadecbae88820ea361a6324d5442dce625..da2d55ded961963e2f6b848f4091084825bc5fe8 100644 (file)
@@ -178,7 +178,6 @@ function SURFBAR_MEMBER_ADD_URL ($url, $limit) {
        }
 
        // Register the new URL
-       die('limit='.$limit);
        return SURFBAR_REGISTER_URL($url, getMemberId(), 'PENDING', 'reg', array('limit' => $limit));
 }
 
@@ -452,6 +451,7 @@ function SURFBAR_HANDLE_SELF_MAINTENANCE () {
        // Handle low-points amounts
        SURFBAR_HANDLE_LOW_POINTS();
 }
+
 // Handle URLs which limit has depleted
 function SURFBAR_HANDLE_DEPLETED_VIEWS () {
        // Get all URLs
@@ -465,7 +465,9 @@ function SURFBAR_HANDLE_DEPLETED_VIEWS () {
                        $data = $urlData;
 
                        // Rewrite array for next call
-                       $urlData[$id] = $data;
+                       $urlData = array(
+                               $id => $data
+                       );
 
                        // Handle the status
                        SURFBAR_CHANGE_STATUS($id, 'ACTIVE', 'DEPLETED', $urlData);
@@ -1059,11 +1061,11 @@ function SURFBAR_LOCKDOWN_ID ($urlId) {
        //* DEBUG: */ debugOutput('LOCK!');
        ///* DEBUG: */ return;
        // Just add it to the database
-       SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_locks` (`locks_userid`, `locks_url_id`) VALUES (%s, %s)",
+       SQL_QUERY_ESC('INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_locks` (`locks_userid`, `locks_url_id`) VALUES (%s, %s)',
                array(getMemberId(), bigintval($urlId)), __FUNCTION__, __LINE__);
 
        // Remove the salt from database
-       SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_surfbar_salts` WHERE `salts_url_id`=%s AND `salts_userid`=%s LIMIT 1",
+       SQL_QUERY_ESC('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_surfbar_salts` WHERE `salts_url_id`=%s AND `salts_userid`=%s LIMIT 1',
                array(bigintval($urlId), getMemberId()), __FUNCTION__, __LINE__);
 }
 
@@ -1094,15 +1096,15 @@ function SURFBAR_UPDATE_INSERT_STATS_RECORD () {
        // Do we have a limit?
        if ($allowed > 0) {
                // Then count views_max down!
-               $add .= ", `views_max`=`views_max`-1";
+               $add .= ', `url_views_max`=`url_views_max`-1';
        } // END - if
 
        // Update URL stats
-       SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_surfbar_urls` SET `url_views_total`=`url_views_total`+1".$add." WHERE `url_id`=%s LIMIT 1",
+       SQL_QUERY_ESC('UPDATE `{?_MYSQL_PREFIX?}_surfbar_urls` SET `url_views_total`=`url_views_total`+1' . $add . ' WHERE `url_id`=%s LIMIT 1',
                array(SURFBAR_GET_ID()), __FUNCTION__, __LINE__);
 
        // Update the stats entry
-       SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_surfbar_stats` SET `stats_count`=`stats_count`+1 WHERE `stats_userid`=%s AND `stats_url_id`=%s LIMIT 1",
+       SQL_QUERY_ESC('UPDATE `{?_MYSQL_PREFIX?}_surfbar_stats` SET `stats_count`=`stats_count`+1 WHERE `stats_userid`=%s AND `stats_url_id`=%s LIMIT 1',
                array(
                        getMemberId(),
                        SURFBAR_GET_ID()
@@ -1111,7 +1113,7 @@ function SURFBAR_UPDATE_INSERT_STATS_RECORD () {
        // Was that update okay?
        if (SQL_HASZEROAFFECTED()) {
                // No, then insert entry
-               SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_stats` (`stats_userid`, `stats_url_id`, `stats_count`) VALUES (%s,%s,1)",
+               SQL_QUERY_ESC('INSERT INTO `{?_MYSQL_PREFIX?}_surfbar_stats` (`stats_userid`, `stats_url_id`, `stats_count`) VALUES (%s,%s,1)',
                        array(
                                getMemberId(),
                                SURFBAR_GET_ID()
@@ -1315,7 +1317,7 @@ function SURFBAR_DETERMINE_WAIT_TIME () {
 
 // Changes the status of an URL from given to other
 function SURFBAR_CHANGE_STATUS ($urlId, $prevStatus, $newStatus, $data=array()) {
-       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',prevStatus=' . $prevStatus . ',newStatus=' . $newStatus . ' - ENTERED!');
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',prevStatus=' . $prevStatus . ',newStatus=' . $newStatus . ' - ENTERED!');
        // Make new status always lower-case
        $newStatus = strtolower($newStatus);
 
@@ -1368,26 +1370,8 @@ function SURFBAR_CHANGE_STATUS ($urlId, $prevStatus, $newStatus, $data=array())
        // Extract data from it again
        $data = $filterData['data'];
 
-       // Prepare content for notification routines
-       $data[$urlId]['url_userid']  = $data[$urlId]['url_userid'];
-       $data[$urlId]['frametester'] = '{%pipe,generateFrametesterUrl=' . $data[$urlId]['url'] . '%}';
-       $data[$urlId]['reward']      = '{%config,translateComma=surfbar_static_reward%}';
-       $data[$urlId]['costs']       = '{%config,translateComma=surfbar_static_costs%}';
-
-       // Do some dirty fixing here:
-       if (($data[$urlId]['url_status'] == 'STOPPED') && ($newStatus == 'pending')) {
-               // Fix for template change
-               $newStatus = 'continued';
-       } // END - if
-
-       // Send admin notification
-       SURFBAR_NOTIFY_ADMIN('url_' . strtolower($data[$urlId]['url_status']) . '_' . $newStatus, $data[$urlId]);
-
-       // Send user notification
-       SURFBAR_NOTIFY_USER('url_' . strtolower($data[$urlId]['url_status']) . '_' . $newStatus, $data[$urlId]);
-
        // All done!
-       /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',prevStatus=' . $prevStatus . ',newStatus=' . $newStatus . ' - EXIT!');
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'urlId=' . $urlId . ',prevStatus=' . $prevStatus . ',newStatus=' . $newStatus . ' - EXIT!');
        return true;
 }
 
index bf1e88ce19b5630e17a65a9f8ead249dc4f9ad55..9846af2bd1989559de4c7318dbcde2fc1139aa5f 100644 (file)
@@ -66,7 +66,6 @@ if (!SURFBAR_IF_USER_BOOK_MORE_URLS()) {
        $message = '{--MEMBER_SURFBAR_URL_NOT_ADDED--}';
 
        // Register the new URL
-       die(postRequestParameter('limit').'=<pre>'.print_r($_POST,true).'</pre>');
        $insertId = SURFBAR_MEMBER_ADD_URL(postRequestParameter('url'), postRequestParameter('limit'));
 
        // Was this fine?
diff --git a/templates/de/emails/admin/admin_surfbar_url_active_depleted.tpl b/templates/de/emails/admin/admin_surfbar_url_active_depleted.tpl
new file mode 100644 (file)
index 0000000..6120511
--- /dev/null
@@ -0,0 +1,34 @@
+Hallo Administrator,
+
+eine URL wurde soeben automatisch angehalten, da die maximalen Views verbraucht sind.
+
+Hier sind alle Daten dazu:
+------------------------------------------
+Gebuchte URL: $content[url]
+------------------------------------------
+Email: {%user,email=$userid%}
+------------------------------------------
+Framekiller-Test:
+{%pipe,generateFrametesterUrl=$content[url]%}
+------------------------------------------
+Mitglieder-Id: $content[url_userid]
+------------------------------------------
+URL angemeldet: $content[url_registered]
+------------------------------------------
+Gesamteinblendungen: {%pipe,translateComma=$content[url_views_total]%}
+------------------------------------------
+Maximale Einblendungen: {%pipe,translateComma=$content[url_views_allowed]%}
+------------------------------------------
+Davon &uuml;brig: {%pipe,translateComma=$content[url_views_max]%}
+------------------------------------------
+Verg&uuml;tung/Aufruf: $content[reward] {?POINTS?}
+------------------------------------------
+Kosten/Aufruf: $content[costs] {?POINTS?}
+------------------------------------------
+ID in der Surfbar: $content[url_id]
+------------------------------------------
+
+Mit freundlichen Gr&uuml;&szlig;en,
+  Ihr {?MAIN_TITLE?} Script
+
+{?URL?}/admin.php
index 6120511e4df821e6f757c5ea7b10c9054751dae0..11f5d85d80b1ca4d16cf4c19e14af24e5ec2a60f 100644 (file)
@@ -1,34 +1 @@
-Hallo Administrator,
-
-eine URL wurde soeben automatisch angehalten, da die maximalen Views verbraucht sind.
-
-Hier sind alle Daten dazu:
-------------------------------------------
-Gebuchte URL: $content[url]
-------------------------------------------
-Email: {%user,email=$userid%}
-------------------------------------------
-Framekiller-Test:
-{%pipe,generateFrametesterUrl=$content[url]%}
-------------------------------------------
-Mitglieder-Id: $content[url_userid]
-------------------------------------------
-URL angemeldet: $content[url_registered]
-------------------------------------------
-Gesamteinblendungen: {%pipe,translateComma=$content[url_views_total]%}
-------------------------------------------
-Maximale Einblendungen: {%pipe,translateComma=$content[url_views_allowed]%}
-------------------------------------------
-Davon &uuml;brig: {%pipe,translateComma=$content[url_views_max]%}
-------------------------------------------
-Verg&uuml;tung/Aufruf: $content[reward] {?POINTS?}
-------------------------------------------
-Kosten/Aufruf: $content[costs] {?POINTS?}
-------------------------------------------
-ID in der Surfbar: $content[url_id]
-------------------------------------------
-
-Mit freundlichen Gr&uuml;&szlig;en,
-  Ihr {?MAIN_TITLE?} Script
-
-{?URL?}/admin.php
+<!-- @DEPRECATED //-->