From: Roland Häder Date: Mon, 11 Jul 2011 16:35:51 +0000 (+0000) Subject: Fixes/rewrites for ext-surfbar: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=3482b953460718915a60361a1073206654abde9e;p=mailer.git Fixes/rewrites for ext-surfbar: - 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 --- diff --git a/.gitattributes b/.gitattributes index 8a971b1d32..330eed08c1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index 90f60d4c2e..c6d84be145 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -80,10 +80,10 @@ ./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? @@ -188,16 +188,16 @@ ./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 @@ -266,6 +266,7 @@ ./templates/de/emails/add-points.tpl:1: ./templates/de/emails/admin/admin_coupon.tpl:1: ./templates/de/emails/admin/admin_del_surfbar_urls.tpl:1: +./templates/de/emails/admin/admin_surfbar_url_depleted.tpl:1: ./templates/de/emails/admin-del_links.tpl:1: ./templates/de/emails/back-admin.tpl:1: ./templates/de/emails/back-member.tpl:1: diff --git a/inc/filter/surfbar_filter.php b/inc/filter/surfbar_filter.php index e2e26f7a5d..0039754f2f 100644 --- a/inc/filter/surfbar_filter.php +++ b/inc/filter/surfbar_filter.php @@ -42,7 +42,24 @@ if (!defined('__SECURITY')) { // Filter for changing URL status function FILTER_SURFBAR_CHANGE_URL_STATUS ($filterData) { - die('
'.print_r($filterData, true).'
'); + // 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; } diff --git a/inc/language/surfbar_de.php b/inc/language/surfbar_de.php index 8ee9be6d9e..5c86862ddf 100644 --- a/inc/language/surfbar_de.php +++ b/inc/language/surfbar_de.php @@ -171,6 +171,7 @@ addMessages(array( 'ADMIN_SURFBAR_NOTIFY_URL_MIGRATED_DELETED_SUBJECT' => "[Surfbar:] Mitglied hat migrierte URL gelöscht", 'ADMIN_SURFBAR_NOTIFY_URL_MIGRATED_MIGRATED_SUBJECT' => "[Surfbar:] Mitglied hat migrierte URL geä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 diff --git a/inc/libs/surfbar_functions.php b/inc/libs/surfbar_functions.php index 61a901eade..da2d55ded9 100644 --- a/inc/libs/surfbar_functions.php +++ b/inc/libs/surfbar_functions.php @@ -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; } diff --git a/inc/modules/member/what-surfbar_book.php b/inc/modules/member/what-surfbar_book.php index bf1e88ce19..9846af2bd1 100644 --- a/inc/modules/member/what-surfbar_book.php +++ b/inc/modules/member/what-surfbar_book.php @@ -66,7 +66,6 @@ if (!SURFBAR_IF_USER_BOOK_MORE_URLS()) { $message = '{--MEMBER_SURFBAR_URL_NOT_ADDED--}'; // Register the new URL - die(postRequestParameter('limit').'=
'.print_r($_POST,true).'
'); $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 index 0000000000..6120511e4d --- /dev/null +++ b/templates/de/emails/admin/admin_surfbar_url_active_depleted.tpl @@ -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 übrig: {%pipe,translateComma=$content[url_views_max]%} +------------------------------------------ +Vergütung/Aufruf: $content[reward] {?POINTS?} +------------------------------------------ +Kosten/Aufruf: $content[costs] {?POINTS?} +------------------------------------------ +ID in der Surfbar: $content[url_id] +------------------------------------------ + +Mit freundlichen Grüßen, + Ihr {?MAIN_TITLE?} Script + +{?URL?}/admin.php diff --git a/templates/de/emails/admin/admin_surfbar_url_depleted.tpl b/templates/de/emails/admin/admin_surfbar_url_depleted.tpl index 6120511e4d..11f5d85d80 100644 --- a/templates/de/emails/admin/admin_surfbar_url_depleted.tpl +++ b/templates/de/emails/admin/admin_surfbar_url_depleted.tpl @@ -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 übrig: {%pipe,translateComma=$content[url_views_max]%} ------------------------------------------- -Vergütung/Aufruf: $content[reward] {?POINTS?} ------------------------------------------- -Kosten/Aufruf: $content[costs] {?POINTS?} ------------------------------------------- -ID in der Surfbar: $content[url_id] ------------------------------------------- - -Mit freundlichen Grüßen, - Ihr {?MAIN_TITLE?} Script - -{?URL?}/admin.php +