]> git.mxchange.org Git - mailer.git/blobdiff - inc/functions.php
Rewrite of all mail templates with user data to new 'tag-like' functionality
[mailer.git] / inc / functions.php
index 9e3240ea54feb9c9ae6009f5765e6b80727da1ef..4df8f56b0d712e981ab6df255419c174142611e6 100644 (file)
@@ -400,7 +400,7 @@ function detectExtraTemplatePath ($template) {
 }
 
 // Loads an email template and compiles it
-function loadEmailTemplate ($template, $content = array(), $UID = '0') {
+function loadEmailTemplate ($template, $content = array(), $userid = '0') {
        global $DATA;
 
        // Make sure all template names are lowercase!
@@ -409,53 +409,33 @@ function loadEmailTemplate ($template, $content = array(), $UID = '0') {
        // Default 'nickname' if extension is not installed
        $nick = '---';
 
-       // Prepare IP number and User Agent
-       $REMOTE_ADDR     = detectRemoteAddr();
-       $HTTP_USER_AGENT = detectUserAgent();
-
-       // Default admin
-       $ADMIN = getConfig('MAIN_TITLE');
-
-       // Is the admin logged in?
-       if (isAdmin()) {
-               // Get admin id
-               $adminId = getCurrentAdminId();
-
-               // Load Admin data
-               $ADMIN = getAdminEmail($adminId);
-       } // END - if
-
        // Neutral email address is default
        $email = getConfig('WEBMASTER');
 
-       // Expiration in a nice output format
-       // NOTE: Use $content[expiration] in your templates instead of $EXPIRATION
-       if (getConfig('auto_purge') == '0') {
-               // Will never expire!
-               $EXPIRATION = getMessage('MAIL_WILL_NEVER_EXPIRE');
-       } else {
-               // Create nice date string
-               $EXPIRATION = createFancyTime(getConfig('auto_purge'));
-       }
-
        // Is content an array?
        if (is_array($content)) {
-               // Add expiration to array, $EXPIRATION is now deprecated!
-               $content['expiration'] = $EXPIRATION;
+               // Add expiration to array
+               if (getConfig('auto_purge') == '0') {
+                       // Will never expire!
+                       $content['expiration'] = getMessage('MAIL_WILL_NEVER_EXPIRE');
+               } else {
+                       // Create nice date string
+                       $content['expiration'] = createFancyTime(getConfig('auto_purge'));
+               }
        } // END - if
 
        // Load user's data
-       //* DEBUG: */ outputHtml(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):UID={$UID},template={$template},content[]=".gettype($content).'<br />');
-       if (($UID > 0) && (is_array($content))) {
+       //* DEBUG: */ outputHtml(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):UID={$userid},template={$template},content[]=".gettype($content).'<br />');
+       if (($userid > 0) && (is_array($content))) {
                // If nickname extension is installed, fetch nickname as well
-               if ((isExtensionActive('nickname')) && (isNicknameUsed($UID))) {
+               if ((isExtensionActive('nickname')) && (isNicknameUsed($userid))) {
                        //* DEBUG: */ outputHtml(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):NICKNAME!<br />");
                        // Load by nickname
-                       fetchUserData($UID, 'nickname');
+                       fetchUserData($userid, 'nickname');
                } else {
                        //* DEBUG: */ outputHtml(__FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):NO-NICK!<br />");
                        /// Load by userid
-                       fetchUserData($UID);
+                       fetchUserData($userid);
                }
 
                // Merge data if valid
@@ -473,7 +453,7 @@ function loadEmailTemplate ($template, $content = array(), $UID = '0') {
        if (isset($content['email'])) $email = $content['email'];
 
        // Store email for some functions in global data array
-       // @TODO Do only use $contentn, not $DATA or raw variables
+       // @TODO Do only use $content, not $DATA or raw variables
        $DATA['email'] = $email;
 
        // Base directory
@@ -519,7 +499,7 @@ function loadEmailTemplate ($template, $content = array(), $UID = '0') {
        // Is there some content?
        if (empty($newContent)) {
                // Compiling failed
-               $newContent = "Compiler error for template {$template}!\nUncompiled content:\n" . $GLOBALS['tpl_content'];
+               $newContent = "Compiler error for template " . $template . " !\nUncompiled content:\n" . $GLOBALS['tpl_content'];
 
                // Add last error if the required function exists
                if (function_exists('error_get_last')) $newContent .= "\n--------------------------------------\nDebug:\n".print_r(error_get_last(), true)."--------------------------------------\nPlease don't alter these informations!\nThanx.";
@@ -2596,8 +2576,7 @@ function debug_report_bug ($message = '', $sendEmail = true) {
                // Prepare content
                $content = array(
                        'message'     => trim($message),
-                       'backtrace'   => trim(debug_get_mailable_backtrace()),
-                       'request_uri' => trim(getRequestUri())
+                       'backtrace'   => trim(debug_get_mailable_backtrace())
                );
 
                // Send email to webmaster
@@ -3073,15 +3052,15 @@ function addNewBonusMail ($data, $mode = '', $output=true) {
        if ((empty($mode)) && (isset($data['mode']))) $mode = $data['mode'];
 
        // Generate receiver list
-       $RECEIVER = generateReceiverList($data['cat'], $data['receiver'], $mode);
+       $receiver = generateReceiverList($data['cat'], $data['receiver'], $mode);
 
        // Receivers added?
-       if (!empty($RECEIVER)) {
+       if (!empty($receiver)) {
                // Add bonus mail to queue
                addBonusMailToQueue(
                $data['subject'],
                $data['text'],
-               $RECEIVER,
+               $receiver,
                $data['points'],
                $data['seconds'],
                $data['url'],