From: Roland Häder Date: Mon, 12 Jul 2010 13:04:46 +0000 (+0000) Subject: New wrapper functions introduced, TODOs.txt updated X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=506745902f724f253446f545671eb2d562f1725b;p=mailer.git New wrapper functions introduced, TODOs.txt updated --- diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index ed68af11d6..faa90f4b64 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -71,8 +71,8 @@ ./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: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/register_functions.php:365: // @TODO Rewrite this to a filter +./inc/libs/register_functions.php:372: // @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 diff --git a/inc/extensions/ext-beg.php b/inc/extensions/ext-beg.php index e8a0107f50..fffd62d727 100644 --- a/inc/extensions/ext-beg.php +++ b/inc/extensions/ext-beg.php @@ -292,7 +292,7 @@ PRIMARY KEY (id) $result_ext = SQL_QUERY("DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_beg_ips` WHERE `timeout` < (UNIX_TIMESTAMP() - ".($OLD + 60*60).")", __FILE__, __LINE__); // Check for beg rallye is active and send mails out - if ((isBegRallyeEnabled()) && (getConfig('beg_new_member_notify') == 'Y')) { + if ((isBegRallyeEnabled()) && (isBegNewMemberNotifyEnabled())) { // Include file for sending out mails addIncludeToPool('notify', 'inc/mails/beg_mails.php'); } // END - if diff --git a/inc/extensions/ext-bonus.php b/inc/extensions/ext-bonus.php index cb0bd0fab9..2e83eba753 100644 --- a/inc/extensions/ext-bonus.php +++ b/inc/extensions/ext-bonus.php @@ -588,7 +588,7 @@ WHERE `last_online` < ".$mark." ORDER BY `userid` ASC"); case 'init': // Do stuff when extension is initialized // Check for bonus rallye is active and send mails out - if ((isExtensionInstalledAndNewer('bonus', '0.9.1')) && (isBonusRallyeActive()) && (getConfig('bonus_new_member_notify') == 'Y')) { + if ((isBonusRallyeActive()) && (isBonusNewMemberNotifyEnabled())) { // Include file for sending out mails addIncludeToPool('notify', 'inc/mails/bonus_mails.php'); } // END - if diff --git a/inc/libs/beg_functions.php b/inc/libs/beg_functions.php index e7faa39850..4a22933c8f 100644 --- a/inc/libs/beg_functions.php +++ b/inc/libs/beg_functions.php @@ -79,6 +79,18 @@ function isBegRallyeEnabled () { return $GLOBALS['is_beg_rallye_enabled']; } +// Checks wether beg_rallye is enabled +function isBegNewMemberNotifyEnabled () { + // Do we have cache? + if (!isset($GLOBALS['is_beg_new_member_notify_enabled'])) { + // Determine it + $GLOBALS['is_beg_new_member_notify_enabled'] = ((isExtensionInstalledAndNewer('beg', '0.2.7')) && (getConfig('beg_new_member_notify') == 'Y')); + } // END - if + + // Return cache + return $GLOBALS['is_beg_new_member_notify_enabled']; +} + // "Getter" for beg_userid function getBegUserid () { // Do we have cache? diff --git a/inc/libs/bonus_functions.php b/inc/libs/bonus_functions.php index 25a7974dde..556cb91018 100644 --- a/inc/libs/bonus_functions.php +++ b/inc/libs/bonus_functions.php @@ -314,6 +314,10 @@ LIMIT 1', } } +/////////////////////////////////////////////////////////////////////////////// +// Wrapper functions // +/////////////////////////////////////////////////////////////////////////////// + // Determines wether the "bonus rallye" is active function isBonusRallyeActive () { // Do we have cache? @@ -326,5 +330,17 @@ function isBonusRallyeActive () { return $GLOBALS['bonus_rallye_active']; } +// Determines wether the "bonus new_member_notify" is active +function isBonusNewMemberNotifyEnabled () { + // Do we have cache? + if (!isset($GLOBALS['bonus_new_member_notify_active'])) { + // Just determine it + $GLOBALS['bonus_new_member_notify_active'] = (getConfig('bonus_new_member_notify') == 'Y'); + } // END - if + + // Return cache + return $GLOBALS['bonus_new_member_notify_active']; +} + // [EOF] ?> diff --git a/inc/libs/register_functions.php b/inc/libs/register_functions.php index cae47656e6..8a3880c940 100644 --- a/inc/libs/register_functions.php +++ b/inc/libs/register_functions.php @@ -294,28 +294,22 @@ function doRegistration () { $GLOBALS['register_sql_data'] = ''; if (isExtensionInstalledAndNewer('theme', '0.0.8')) { // Okay, add design here - $GLOBALS['register_sql_columns'] = ', `curr_theme`'; - $GLOBALS['register_sql_data'] = ", '" . getCurrentTheme() . "'"; + $GLOBALS['register_sql_columns'] .= ', `curr_theme`'; + $GLOBALS['register_sql_data'] .= ", '" . getCurrentTheme() . "'"; } // END - if // Check if I shall disable sending mail to newly registered members out about active/begging rallye // // First comes first: begging rallye - if (isExtensionInstalledAndNewer('beg', '0.2.8')) { - // Okay, shall I disable now? - if (getConfig('beg_new_member_notify') != 'Y') { - $GLOBALS['register_sql_columns'] .= ', `beg_rallye_enable_notify`, `beg_rallye_disable_notify`'; - $GLOBALS['register_sql_data'] .= ', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()'; - } // END - if + if (!isBegNewMemberNotifyEnabled()) { + $GLOBALS['register_sql_columns'] .= ', `beg_rallye_enable_notify`, `beg_rallye_disable_notify`'; + $GLOBALS['register_sql_data'] .= ', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()'; } // END - if // Second: active rallye - if (isExtensionInstalledAndNewer('bonus', '0.9.2')) { - // Okay, shall I disable now? - if (getConfig('bonus_new_member_notify') != 'Y') { - $GLOBALS['register_sql_columns'] .= ', `bonus_rallye_enable_notify`, `bonus_rallye_disable_notify`'; - $GLOBALS['register_sql_data'] .= ', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()'; - } // END - if + if (!isBonusNewMemberNotifyEnabled()) { + $GLOBALS['register_sql_columns'] .= ', `bonus_rallye_enable_notify`, `bonus_rallye_disable_notify`'; + $GLOBALS['register_sql_data'] .= ', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()'; } // END - if // Write user data to table