]> git.mxchange.org Git - mailer.git/blobdiff - inc/email-functions.php
Extension ext-user for sub id tracking continued:
[mailer.git] / inc / email-functions.php
index ced06aa03725df374534e08ab6966f8f6daadd92..bb4f0e55eb863de23c59bcfdc2a14ac1454b2797 100644 (file)
@@ -223,5 +223,50 @@ function doTemplateAddExtraHtmlMailHeaders ($templateName, $clear, $extraHeaders
        return $extraHeaders;
 }
 
+// Send mails for del/edit/lock build modes
+// @TODO $rawUserId is currently unused
+function sendGenericBuildMails ($mode, $tableName, $content, $id, $subjectPart = '', $userIdColumn = array('userid'), $rawUserId = array('userid')) {
+       // $tableName must be an array
+       if ((!is_array($tableName)) || (count($tableName) != 1)) {
+               // $tableName is no array
+               reportBug(__FUNCTION__, __LINE__, 'tableName[]=' . gettype($tableName) . '!=array: userIdColumn=' . $userIdColumn);
+       } elseif ((!is_array($userIdColumn)) || (count($userIdColumn) != 1)) {
+               // $tableName is no array
+               reportBug(__FUNCTION__, __LINE__, 'userIdColumn[]=' . gettype($userIdColumn) . '!=array: userIdColumn=' . $userIdColumn);
+       } // END - if
+
+       // Default subject is the subject part
+       $subject = $subjectPart;
+
+       // Is the subject part not set?
+       if (empty($subjectPart)) {
+               // Then use it from the mode
+               $subject = strtoupper($mode);
+       } // END - if
+
+       // Is the raw userid set?
+       if (postRequestElement($userIdColumn[0], $id) > 0) {
+               // Load email template
+               if (!empty($subjectPart)) {
+                       $mail = loadEmailTemplate('member_' . $mode . '_' . strtolower($subjectPart) . '_' . $tableName[0], $content);
+               } else {
+                       $mail = loadEmailTemplate('member_' . $mode . '_' . $tableName[0], $content);
+               }
+
+               // Send email out
+               sendEmail(postRequestElement($userIdColumn[0], $id), strtoupper('{--MEMBER_' . $subject . '_' . $tableName[0] . '_SUBJECT--}'), $mail);
+       } // END - if
+
+       // Generate subject
+       $subject = strtoupper('{--ADMIN_' . $subject . '_' . $tableName[0] . '_SUBJECT--}');
+
+       // Send admin notification out
+       if (!empty($subjectPart)) {
+               sendAdminNotification($subject, 'admin_' . $mode . '_' . strtolower($subjectPart) . '_' . $tableName[0], $content, postRequestElement($userIdColumn[0], $id));
+       } else {
+               sendAdminNotification($subject, 'admin_' . $mode . '_' . $tableName[0], $content, postRequestElement($userIdColumn[0], $id));
+       }
+}
+
 // [EOF]
 ?>