From 51315c98823f7cb6e5e6e3fdcd174f0859c0445a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 7 Oct 2008 00:05:35 +0000 Subject: [PATCH] Listing of notifications added --- .gitattributes | 1 + inc/databases.php | 2 +- inc/extensions/ext-bonus.php | 26 ++-- inc/functions.php | 3 + inc/language/task_de.php | 4 +- inc/libs/task_functions.php | 13 +- inc/mails/beg_mails.php | 4 +- inc/mails/birthday_mails.php | 2 +- inc/mails/bonus_mails.php | 38 ++---- inc/modules/admin/what-config_bonus.php | 1 + inc/modules/admin/what-email_details.php | 5 +- inc/modules/admin/what-list_notifications.php | 118 ++++++++++++++++++ 12 files changed, 171 insertions(+), 46 deletions(-) create mode 100644 inc/modules/admin/what-list_notifications.php diff --git a/.gitattributes b/.gitattributes index 9b5b302633..ee4d863368 100644 --- a/.gitattributes +++ b/.gitattributes @@ -354,6 +354,7 @@ inc/modules/admin/what-list_holiday.php -text inc/modules/admin/what-list_links.php -text inc/modules/admin/what-list_newsletter.php -text inc/modules/admin/what-list_norefs.php -text +inc/modules/admin/what-list_notifications.php -text inc/modules/admin/what-list_payouts.php -text inc/modules/admin/what-list_primera.php -text inc/modules/admin/what-list_rallyes.php -text diff --git a/inc/databases.php b/inc/databases.php index b7724243b1..8506ba36a8 100644 --- a/inc/databases.php +++ b/inc/databases.php @@ -113,7 +113,7 @@ define('USAGE_BASE', "usage"); define('SERVER_URL', "http://www.mxchange.org"); // This current patch level -define('CURR_SVN_REVISION', "469"); +define('CURR_SVN_REVISION', "470"); // Take a prime number which is long (if you know a longer one please try it out!) define('_PRIME', 591623); diff --git a/inc/extensions/ext-bonus.php b/inc/extensions/ext-bonus.php index 9e22079fe4..b1270ac323 100644 --- a/inc/extensions/ext-bonus.php +++ b/inc/extensions/ext-bonus.php @@ -38,13 +38,13 @@ if (!defined('__SECURITY')) { } // Version of this extension -$EXT_VERSION = "0.8.6"; +$EXT_VERSION = "0.8.7"; // Auto-set extension version if (empty($EXT_VER)) $EXT_VER = $EXT_VERSION; // Version history array (add more with , "0.1" and so on) -$EXT_VER_HISTORY = array("0.0", "0.1.6", "0.2.0", "0.2.1", "0.2.2", "0.2.3", "0.2.4", "0.2.5", "0.2.6", "0.2.7", "0.2.8", "0.2.9", "0.3.0", "0.3.1", "0.3.2", "0.3.3", "0.3.4", "0.3.5", "0.3.6", "0.3.7", "0.3.8", "0.3.9", "0.4.0", "0.4.1", "0.4.2", "0.4.3", "0.4.4", "0.4.5", "0.4.6", "0.4.7", "0.4.8", "0.4.9", "0.5.0", "0.5.1", "0.5.2", "0.5.3", "0.5.4", "0.5.5", "0.5.6", "0.5.7", "0.5.8", "0.5.9", "0.6.0", "0.6.1", "0.6.2", "0.6.3", "0.6.4", "0.6.5", "0.6.6", "0.6.7", "0.6.8", "0.6.9", "0.7.0", "0.7.1", "0.7.2", "0.7.3", "0.7.4", "0.7.5", "0.7.6", "0.7.7", "0.7.8", "0.7.9", "0.8.0", "0.8.1", "0.8.2", "0.8.3", "0.8.4", "0.8.5", "0.8.6"); +$EXT_VER_HISTORY = array("0.0", "0.1.6", "0.2.0", "0.2.1", "0.2.2", "0.2.3", "0.2.4", "0.2.5", "0.2.6", "0.2.7", "0.2.8", "0.2.9", "0.3.0", "0.3.1", "0.3.2", "0.3.3", "0.3.4", "0.3.5", "0.3.6", "0.3.7", "0.3.8", "0.3.9", "0.4.0", "0.4.1", "0.4.2", "0.4.3", "0.4.4", "0.4.5", "0.4.6", "0.4.7", "0.4.8", "0.4.9", "0.5.0", "0.5.1", "0.5.2", "0.5.3", "0.5.4", "0.5.5", "0.5.6", "0.5.7", "0.5.8", "0.5.9", "0.6.0", "0.6.1", "0.6.2", "0.6.3", "0.6.4", "0.6.5", "0.6.6", "0.6.7", "0.6.8", "0.6.9", "0.7.0", "0.7.1", "0.7.2", "0.7.3", "0.7.4", "0.7.5", "0.7.6", "0.7.7", "0.7.8", "0.7.9", "0.8.0", "0.8.1", "0.8.2", "0.8.3", "0.8.4", "0.8.5", "0.8.6", "0.8.7"); switch ($EXT_LOAD_MODE) { @@ -80,7 +80,7 @@ PRIMARY KEY (id) case "remove": // Do stuff when removing extension // SQL commands to run - $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_admin_menu WHERE what IN ('bonus','config_bonus','send_bonus','list_bonus') LIMIT 4"; + $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_admin_menu WHERE what IN ('bonus','config_bonus','send_bonus','list_bonus','list_notifications') LIMIT 5"; $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_member_menu WHERE what='bonus' LIMIT 1"; $SQLs[] = "DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_guest_menu WHERE action='bonus' LIMIT 1"; $SQLs[] = "ALTER TABLE "._MYSQL_PREFIX."_user_links MODIFY link_type ENUM('NORMAL') NOT NULL DEFAULT 'NORMAL'"; @@ -526,29 +526,31 @@ WHERE last_online < ".$mark." ORDER BY userid"; case "0.8.6": // SQL queries for v0.8.6 $UPDATE_NOTES = "Fehlerhinweis bei deaktivierter Erweiterung verbessert."; break; + + case "0.8.7": // SQL queries for v0.8.7 + $SQLs[] = "INSERT INTO "._MYSQL_PREFIX."_admin_menu (`action`,`what`,`title`,`descr`,`sort`) VALUES ('email','list_notifications','Benachrichtigungen','Listet alle an die Mitglieder ausgesandten Benachrichtigungen auf.', 10)"; + + // Update notes + $UPDATE_NOTES = "Benachrichtigungsmails für z.B. Bettel- oder Aktiv-Rallye werden nun angezeigt."; + break; } break; default: // Do stuff when extension is loaded - if (isBooleanConstantAndTrue('__DAILY_RESET') && (!DEBUG_MODE) && ($CSS != 1)) - { + if (isBooleanConstantAndTrue('__DAILY_RESET') && (!DEBUG_MODE) && ($CSS != 1)) { // Daily reset was run so let's check if active rallye is activated - if ($_CONFIG['bonus_active'] == "Y") - { + if ($_CONFIG['bonus_active'] == "Y") { // Run active rallye if($_CONFIG['bonus_stats'] > 0) $INC_POOL[] = sprintf("%sinc/stats_bonus.php", PATH); $INC_POOL[] = sprintf("%sinc/monthly/monthly_bonus.php", PATH); - } - else - { + } else { // Reset points $INC_POOL[] = sprintf("%sinc/reset/reset_bonus.php", PATH); } } // Check for bonus rallye is active and send mails out - if (($_CONFIG['bonus_active'] == "Y") && ($_CONFIG['bonus_new_mem_notify'] == "Y")) - { + if (($_CONFIG['bonus_active'] == "Y") && ($_CONFIG['bonus_new_mem_notify'] == "Y")) { // Include file for sending out mails $INC_POOL[] = sprintf("%sinc/mails/bonus_mails.php", PATH); } diff --git a/inc/functions.php b/inc/functions.php index 28ecf9e432..6ec587a530 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -2374,6 +2374,9 @@ function GET_DIR_AS_ARRAY ($baseDir, $prefix) { // Close directory closedir($dirPointer); + // Sort array + asort($INCs); + // Return array with include files return $INCs; } diff --git a/inc/language/task_de.php b/inc/language/task_de.php index 24801c6ba1..f8907f0d07 100644 --- a/inc/language/task_de.php +++ b/inc/language/task_de.php @@ -119,7 +119,9 @@ define('TASK_ADMIN_LIST_ACCOUNT_NOREF_TITLE', "Es wurden Accounts ohne Werber-ID define('TASK_ADMIN_LIST_SURFBAR_URLS_ALL', "Alle URLs in Surfbar"); define('TASK_ADMIN_LIST_SURFBAR_URLS_ALL_TITLE', "In der Surfbar sind URLs gebucht worden."); define('TASK_ADMIN_LIST_SURFBAR_URLS_PENDING', "Wartende URLs in Surfbar"); -define('TASK_ADMIN_LIST_SURFBAR_URLS_PENDING_TITLE', "Es warten noch URLs auf Freischaltung für die Surfbar"); +define('TASK_ADMIN_LIST_SURFBAR_URLS_PENDING_TITLE', "Es warten noch URLs auf Freischaltung für die Surfbar."); +define('TASK_ADMIN_LIST_NOTIFICATIONS', "Alle Benachrichtigungen"); +define('TASK_ADMIN_LIST_NOTIFICATIONS_TITLE', "Es sind ausgesandte,vergütete Benachrichtigungen vorhanden."); // ?> diff --git a/inc/libs/task_functions.php b/inc/libs/task_functions.php index 426309f221..78808132a0 100644 --- a/inc/libs/task_functions.php +++ b/inc/libs/task_functions.php @@ -255,7 +255,7 @@ function OUTPUT_ADVANCED_OVERVIEW (&$result_main) // Sent bonus mails // if (GET_EXT_VERSION("bonus") >= "0.1.8") { - $result = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_bonus WHERE data_type='SEND'", __FILE__, __LINE__); + $result = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_bonus WHERE data_type='SEND' AND is_notify='N'", __FILE__, __LINE__); $value = SQL_NUMROWS($result); SQL_FREERESULT($result); @@ -359,12 +359,21 @@ ORDER BY d.userid"; $LAST = sprintf(" AND last_online >= (UNIX_TIMESTAMP() - %s)", $_CONFIG['ap_inactive_since']); } - $SQLs[] = "SELECT ".$USE." AS active_bonus FROM "._MYSQL_PREFIX."_user_data + $SQLs[] = "SELECT ".$USE." AS active_bonus +FROM "._MYSQL_PREFIX."_user_data WHERE status='CONFIRMED' AND ".$USE.">0".$LAST." ORDER BY active_bonus DESC, userid"; $WHATs[] = "list_bonus"; $DESCRs[] = TASK_ADMIN_LIST_BONUS; $TITLEs[] = TASK_ADMIN_LIST_BONUS_TITLE; + + if (GET_EXT_VERSION("bonus") >= "0.8.7") { + // List all notifications + $SQLs[] = "SELECT id FROM "._MYSQL_PREFIX."_bonus WHERE is_notify='Y' ORDER BY timestamp DESC"; + $WHATs[] = "list_notiftications"; + $DESCRs[] = TASK_ADMIN_LIST_NOTIFICATIONS; + $TITLEs[] = TASK_ADMIN_LIST_NOTIFICATIONS_TITLE; + } } if (GET_EXT_VERSION("beg") >= "0.1.2") { diff --git a/inc/mails/beg_mails.php b/inc/mails/beg_mails.php index 3247190093..545b552a69 100644 --- a/inc/mails/beg_mails.php +++ b/inc/mails/beg_mails.php @@ -41,7 +41,7 @@ if (!defined('__SECURITY')) { // Do not execute when script is in CSS mode global $CSS; -if (($CSS == 1) || (!defined('__DAILY_RESET'))) return; +if ($CSS == 1) return; // Create timemark from saved month $mark = mktime(0, 0, 0, $_CONFIG['last_month'], date("d", time()), date('Y', time())); @@ -133,7 +133,7 @@ SET beg_ral_notify='%s', beg_ral_%s_notify='%s' WHERE userid=%s LIMIT 1", { // Send normal notification mail to the members $MSG = LOAD_EMAIL_TEMPLATE("beg_".$MODE."_notify", array(), $uid); - SEND_EMAIL($email, $SUBJECT, $MSG); + SEND_EMAIL($uid, $SUBJECT, $MSG); } } diff --git a/inc/mails/birthday_mails.php b/inc/mails/birthday_mails.php index 83d8eb4ea8..71a616909f 100644 --- a/inc/mails/birthday_mails.php +++ b/inc/mails/birthday_mails.php @@ -96,7 +96,7 @@ if (SQL_NUMROWS($result_birthday) > 0) { } // Send email - SEND_EMAIL($email, HAPPY_BIRTHDAY, $msg); + SEND_EMAIL($uid, HAPPY_BIRTHDAY, $msg); // Remember him that he has received a birthday mail $result_bd = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET birthday_sent=UNIX_TIMESTAMP() WHERE userid=%s LIMIT 1", diff --git a/inc/mails/bonus_mails.php b/inc/mails/bonus_mails.php index 50726857f9..ad84a3454d 100644 --- a/inc/mails/bonus_mails.php +++ b/inc/mails/bonus_mails.php @@ -41,7 +41,7 @@ if (!defined('__SECURITY')) { // Do not execute when script is in CSS mode global $CSS; -if (($CSS == 1) || (!defined('__DAILY_RESET'))) return; +if ($CSS == 1) return; // Create timemark from saved month $mark = mktime(0, 0, 0, $_CONFIG['last_month'], date("d", time()), date('Y', time())); @@ -52,36 +52,29 @@ $SQL = "SELECT userid, email FROM "._MYSQL_PREFIX."_user_data WHERE (bonus_ral_n switch ($_CONFIG['bonus_active']) { case 'Y': // Active rallye is activated - if ($_CONFIG['bonus_en_notify'] == "Y") - { + if ($_CONFIG['bonus_en_notify'] == "Y") { // Okay, let's check for member accounts $SQL .= "= 0 OR (bonus_ral_notify > 0 AND bonus_ral_en_notify < bonus_ral_di_notify)"; $MODE = "en"; - } - else - { + } else { // Do not notify! $SQL = ""; } break; case 'N': // Active rallye is deactivated - if ($_CONFIG['bonus_di_notify'] == "Y") - { + if ($_CONFIG['bonus_di_notify'] == "Y") { // Okay, let's check for member accounts $SQL .= " > 0 AND bonus_ral_di_notify < bonus_ral_en_notify"; $MODE = "di"; - } - else - { + } else { // Do not notify! $SQL = ""; } break; } -if (!empty($SQL)) -{ +if (!empty($SQL)) { // The SQL command needs to be finisched here (only confirmed accounts!) $SQL .= ") AND status='CONFIRMED' ORDER BY last_online ASC"; @@ -98,33 +91,27 @@ if (!empty($SQL)) // Check for accounts to be notified $result_main = SQL_QUERY($SQL, __FILE__, __LINE__); - if (SQL_NUMROWS($result_main) > 0) - { + if (SQL_NUMROWS($result_main) > 0) { // Okay lets notify all users! - while(list($uid, $email) = SQL_FETCHROW($result_main)) - { + while(list($uid, $email) = SQL_FETCHROW($result_main)) { // Update account $result_update = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET bonus_ral_notify='%s', bonus_ral_%s_notify='%s' WHERE userid=%s LIMIT 1", array(time(), $MODE, time(), $uid), __FILE__, __LINE__); // Load email template and send it to the user! - if ($MAIL_MODE) - { + if ($MAIL_MODE) { // Add userid to queue $UIDs[] = $uid; - } - else - { + } else { // Send normal notification mail to the members $MSG = LOAD_EMAIL_TEMPLATE("bonus_".$MODE."_notify", array(), $uid); - SEND_EMAIL($email, $SUBJECT, $MSG); + SEND_EMAIL($uid, $SUBJECT, $MSG); } } // Shall I send out bonus mails? - if ($MAIL_MODE) - { + if ($MAIL_MODE) { // Okay, make array to string $RECEIVER = implode(";", $UIDs); $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_bonus @@ -147,5 +134,6 @@ VALUES ('%s','%s','%s','%s','%s','NEW', UNIX_TIMESTAMP(), '%s','%s','%s','%s','Y // Free memory SQL_FREERESULT($result_main); } + // ?> diff --git a/inc/modules/admin/what-config_bonus.php b/inc/modules/admin/what-config_bonus.php index 6515531d3a..21f8293287 100644 --- a/inc/modules/admin/what-config_bonus.php +++ b/inc/modules/admin/what-config_bonus.php @@ -72,6 +72,7 @@ if (isset($_POST['ok'])) // Include sending out mails if ((($_CONFIG['bonus_active'] == "Y") && ($_CONFIG['bonus_en_notify'] == "Y")) || (($_CONFIG['bonus_active'] == "N") && ($_CONFIG['bonus_di_notify'] == "Y"))) { + // Send mails out! include(PATH."inc/mails/bonus_mails.php"); } } else { diff --git a/inc/modules/admin/what-email_details.php b/inc/modules/admin/what-email_details.php index 6762cc915f..7d1d652217 100644 --- a/inc/modules/admin/what-email_details.php +++ b/inc/modules/admin/what-email_details.php @@ -85,8 +85,9 @@ if ((EXT_IS_ACTIVE("bonus")) && ($WHO == _ALL)) { // Bonus mails sent by you // 0 1 2 3 4 5 6 7 8 9 10 11 12 $SQL2 = "SELECT id, subject, text, receivers, points, time, data_type, timestamp, url, cat_id, target_send, mails_sent, clicks - FROM "._MYSQL_PREFIX."_bonus - ORDER BY timestamp DESC"; + FROM "._MYSQL_PREFIX."_bonus + WHERE is_notify='N' + ORDER BY timestamp DESC"; // Check for maximum pages $result_bonus = SQL_QUERY($SQL2, __FILE__, __LINE__); diff --git a/inc/modules/admin/what-list_notifications.php b/inc/modules/admin/what-list_notifications.php new file mode 100644 index 0000000000..439c77f5d6 --- /dev/null +++ b/inc/modules/admin/what-list_notifications.php @@ -0,0 +1,118 @@ + 0) && (!empty($SQL2))) { + // Run SQL query for notification mails + $result_bonus = SQL_QUERY($SQL2, __FILE__, __LINE__); + + // Load bonus mails only when extension is active + if (SQL_NUMROWS($result_bonus) > 0) { + // Calculate pages + $PAGES = round(SQL_NUMROWS($result_bonus) / $_CONFIG['mails_page'] + 0.5); + + // List emails + $OUT = ""; $content = array(); + while ($bonus = SQL_FETCHARRAY($result_bonus)) { + // Calculate unconfirmed emails + $bonus['unconfirmed'] = $bonus['mails_sent'] - $bonus['clicks']; + + // Add link? + if ($bonus['unconfirmed'] > 0) { + // Add link to list_unconfirmed what-file + $bonus['unconfirmed'] = "".$bonus['unconfirmed'].""; + } // END - if + + // Prepare content + $content = $bonus; + $content['time'] = CREATE_FANCY_TIME($content['time']); + $content['category'] = GET_CATEGORY($content['cat_id']); + $content['receivers'] = str_replace(";", ", ", $content['receivers']); + $content['type'] = TRANSLATE_POOL_TYPE($content['data_type']); + $content['frametester'] = FRAMETESTER($content['url']); + $content['timestamp'] = MAKE_DATETIME($content['timestamp'], "0"); + + // Load row template + $OUT .= LOAD_TEMPLATE("admin_list_bonus_emails_row", true, $content); + } + + // Add navigation (without change box but with colspan=3) + $content['nav'] = ""; + if ($PAGES > 1) $content['nav'] = ADD_EMAIL_NAV($PAGES, $_CONFIG['mails_page'], false, "3", true); + + // Prepare content + $content['rows'] = $OUT; + + // Load main template + LOAD_TEMPLATE("admin_list_bonus_emails", false, $content); + } +} + +// +?> -- 2.39.5