X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Ffunctions.php;h=c00fee3cde06c00bfe9c3d4a095f32a2eaecaf25;hp=ada3d77a07fd812974e57ee25fbb13534c84a71b;hb=c3b4eaf29946349ff058691db2dcb615a5379bb2;hpb=5d89789720c77e954b2eba28c00ec710dd28900d diff --git a/inc/functions.php b/inc/functions.php index ada3d77a07..c00fee3cde 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -16,7 +16,7 @@ * $Author:: $ * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * - * Copyright (c) 2009, 2010 by Mailer Developer Team * + * Copyright (c) 2009 - 2011 by Mailer Developer Team * * For more information visit: http://www.mxchange.org * * * * This program is free software; you can redistribute it and/or modify * @@ -427,6 +427,9 @@ function translateGender ($gender) { // "Translates" the user status function translateUserStatus ($status) { + // Default status is unknown if something goes through + $ret = '{--ACCOUNT_STATUS_UNKNOWN--}'; + // Generate message depending on status switch ($status) { case 'UNCONFIRMED': @@ -775,7 +778,7 @@ function createFancyTime ($stamp) { // Get data array with years/months/weeks/days/... $data = createTimeSelections($stamp, '', '', '', true); $ret = ''; - foreach($data as $k => $v) { + foreach ($data as $k => $v) { if ($v > 0) { // Value is greater than 0 "eval" data to return string $ret .= ', ' . $v . ' {--_' . strtoupper($k) . '--}'; @@ -1685,13 +1688,16 @@ function changeDataInFile ($FQFN, $comment, $prefix, $suffix, $DATA, $seek=0) { // An error was detected! return false; } + // Send notification to admin -function sendAdminNotification ($subject, $templateName, $content=array(), $userid = '0') { +function sendAdminNotification ($subject, $templateName, $content = array(), $userid = '0') { if ((isExtensionInstalledAndNewer('admins', '0.4.1')) && (function_exists('sendAdminsEmails'))) { // Send new way + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'admins=Y,subject=' . $subject . ',templateName=' . $templateName); sendAdminsEmails($subject, $templateName, $content, $userid); } else { - // Send out out-dated way + // Send out-dated way + /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'admins=N,subject=' . $subject . ',templateName=' . $templateName); $message = loadEmailTemplate($templateName, $content, $userid); sendAdminEmails($subject, $message); } @@ -1705,7 +1711,7 @@ function logDebugMessage ($funcFile, $line, $message, $force=true) { $message = str_replace("\r", '', str_replace("\n", '', $message)); // Log this message away - appendLineToFile(getCachePath() . 'debug.log', generateDateTime(time(), '4') . '|' . getModule(false) . '|' . basename($funcFile) . '|' . $line . '|' . $message); + appendLineToFile(getPath() . getCachePath() . 'debug.log', generateDateTime(time(), '4') . '|' . getModule(false) . '|' . basename($funcFile) . '|' . $line . '|' . $message); } // END - if } @@ -1844,7 +1850,7 @@ function rebuildCache ($cache, $inc = '', $force = false) { // Include file given? if (!empty($inc)) { // Construct FQFN - $inc = sprintf("inc/loader/load_cache-%s.php", $inc); + $inc = sprintf("inc/loader/load-%s.php", $inc); // Is the include there? if (isIncludeReadable($inc)) { @@ -2327,7 +2333,10 @@ function isSpider () { $userAgent = trim(strtolower(detectUserAgent(true))); // It should not be empty, if so it is better a spider/bot - if (empty($userAgent)) return true; + if (empty($userAgent)) { + // It is a spider/bot + return true; + } // END - if // Is it a spider? return ((strpos($userAgent, 'spider') !== false) || (strpos($userAgent, 'slurp') !== false) || (strpos($userAgent, 'bot') !== false) || (strpos($userAgent, 'archiver') !== false)); @@ -2421,7 +2430,7 @@ function capitalizeUnderscoreString ($str) { // "Walk" through all elements and make them lower-case but first upper-case foreach ($strArray as $part) { // Capitalize the string part - $capitalized .= ucfirst(strtolower($part)); + $capitalized .= firstCharUpperCase($part); } // END - foreach // Store the converted string in cache array @@ -2432,6 +2441,54 @@ function capitalizeUnderscoreString ($str) { return $GLOBALS[__FUNCTION__][$str]; } +// Generate admin links for mail order +// mailType can be: 'mid' or 'bid' +function generateAdminMailLinks ($mailType, $mailId) { + // Init variables + $OUT = ''; + $table = ''; + + // Default column for mail status is 'data_type' + // @TODO Rename column data_type to e.g. mail_status + $statusColumn = 'data_type'; + + // Which mail do we have? + switch ($mailType) { + case 'bid': // Bonus mail + $table = 'bonus'; + break; + + case 'mid': // Member mail + $table = 'pool'; + break; + + default: // Handle unsupported types + logDebugMessage(__FUNCTION__, __LINE__, 'Unsupported mail type ' . $mailType . ' for mailId=' . $mailId . ' detected.'); + $OUT = '
{%message,ADMIN_UNSUPPORTED_MAIL_TYPE_DETECTED=' . $mailType . '%}
'; + break; + } // END - switch + + // Is the mail type supported? + if (!empty($table)) { + // Query for the mail + $result = SQL_QUERY_ESC("SELECT `id`, `%s` AS `mail_status` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `id`=%s LIMIT 1", + array($statusColumn, $table, bigintval($mailId)), __FILE__, __LINE__); + + // Do we have one entry there? + if (SQL_NUMROWS($result) == 1) { + // Load the entry + $content = SQL_FETCHARRAY($result); + die('
'.print_r($content, true).'
'); + } // END - if + + // Free result + SQL_FREERESULT($result); + } // END - if + + // Return generated HTML code + return $OUT; +} + //----------------------------------------------------------------------------- // Automatically re-created functions, all taken from user comments on www.php.net //-----------------------------------------------------------------------------