Parcourir la source

More Email work
Fix Plex Invnite when on local machine

causefx il y a 8 ans
Parent
commit
66acb3c55c
2 fichiers modifiés avec 28 ajouts et 5 suppressions
  1. 3 3
      ajax.php
  2. 25 2
      functions.php

+ 3 - 3
ajax.php

@@ -118,17 +118,17 @@ switch ($_SERVER['REQUEST_METHOD']) {
 			 	break;
 			case 'validate-invite':
 				$response = inviteCodes("check", $_POST['invitecode']);
-				$response['notify'] = sendResult($response, "check", $_POST['checkurl'], "CODE_SUCCESS", "CODE_ERROR");
+				$response['notify'] = sendResult($response, "check", 'Invite System', "CODE_SUCCESS", "CODE_ERROR");
 				break;
 			case 'use-invite':
 				if(inviteCodes("check", $_POST['invitecode'])){
 					$response = inviteCodes("use", $_POST['invitecode'], $_POST['inviteuser']);
-					$response['notify'] = sendResult(plexUserShare($_POST['inviteuser']), "check", $_POST['checkurl'], "INVITE_SUCCESS", "INVITE_ERROR");
+					$response['notify'] = sendResult(plexUserShare($_POST['inviteuser']), "check", 'Invite System', "INVITE_SUCCESS", "INVITE_ERROR");
 				}
 				break;
 			case 'join-plex':
 				$response = plexJoin($_POST['joinuser'], $_POST['joinemail'], $_POST['joinpassword']);
-				$response['notify'] = sendResult($response, "check", $_POST['checkurl'], "JOIN_SUCCESS", "JOIN_ERROR");
+				$response['notify'] = sendResult($response, "check", 'Invite System', "JOIN_SUCCESS", "JOIN_ERROR");
 				break;
             default: // Stuff that you need admin for
                 qualifyUser('admin', true);

+ 25 - 2
functions.php

@@ -4002,7 +4002,18 @@ function inviteCodes($action, $code = null, $usedBy = null) {
 					require_once("user.php");
 					$GLOBALS['USER'] = new User('registration_callback');
 				}
-				sendEmail($GLOBALS['USER']->adminEmail, "Admin", "Plex Invite Used", orgEmail("PLEX Invite Used", "Look who joined the cool club", "Admin", "Hey, The User: $usedBy has redeemd their invite code: [$code], their IP Address was: $currentIP", null, null, "What Next?", "Well, That is up to you.  You can go check on them if you like."));
+				$emailTemplate = array(
+					'type' => 'mass',
+					'body' => 'The user: {user} has reddemed the code: {inviteCode} his IP Address was '.$currentIP,
+					'subject' => 'Invite Code '.$code.' Has Been Used',
+					'user' => $usedBy,
+					'password' => null,
+					'inviteCode' => $code,
+				);
+				$emailTemplate = emailTemplate($emailTemplate);
+				$subject = $emailTemplate['subject'];
+				$body = buildEmail($emailTemplate);
+				sendEmail($GLOBALS['USER']->adminEmail, "Admin", $subject, $body);
 			}
 			return (!empty($invites) ? true : false );
 			break;
@@ -4829,6 +4840,7 @@ function buildMenu($array){
 }
 
 function requestInvite($email, $username){
+	//sendEmail($email, $username = "Organizr User", $subject, $body, $cc = null, $bcc = null)
 	sendEmail($GLOBALS['USER']->adminEmail, "Admin", "Plex Invite Request", orgEmail("PLEX Invite Request", "Look who wants to join the cool club", "Admin", "Hey, The User: $user has requested access to your Plex Library.", "Generate Invite", null, "What Next?", "Well, That is up to you.  You can go check on them if you like."));
 
 }
@@ -4907,7 +4919,18 @@ function massEmail($to, $subject, $message){
 		$GLOBALS['file_db'] = new PDO('sqlite:'.DATABASE_LOCATION.'users.db');
 		$GLOBALS['file_db']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 	}
-	sendEmail(null, null, $subject, orgEmail("Message From Admin", "Important Information", "There", $message, null, null, "Thank You!", "Thanks for taking the time to read this message from me."),$GLOBALS['USER']->adminEmail,$to);
+	$emailTemplate = array(
+		'type' => 'mass',
+		'body' => $message,
+		'subject' => $subject,
+		'user' => null,
+		'password' => null,
+		'inviteCode' => null,
+	);
+	$emailTemplate = emailTemplate($emailTemplate);
+	$subject = $emailTemplate['subject'];
+	$body = buildEmail($emailTemplate);
+	sendEmail(null, null, $subject, $body, $GLOBALS['USER']->adminEmail,$to);
 }
 
 function q2a($q){