Explorar o código

added id to PlexUsers function

CauseFX %!s(int64=5) %!d(string=hai) anos
pai
achega
083c65b3e5
Modificáronse 1 ficheiros con 19 adicións e 3 borrados
  1. 19 3
      api/functions/auth-functions.php

+ 19 - 3
api/functions/auth-functions.php

@@ -106,7 +106,7 @@ function checkPlexUser($username)
 	return false;
 }
 
-function allPlexUsers($newOnly = false)
+function allPlexUsers($newOnly = false, $friendsOnly = false)
 {
 	try {
 		if (!empty($GLOBALS['plexToken'])) {
@@ -127,13 +127,29 @@ function allPlexUsers($newOnly = false)
 								if (!$taken) {
 									$results[] = array(
 										'username' => (string)$child['username'],
-										'email' => (string)$child['email']
+										'email' => (string)$child['email'],
+										'id' => (string)$child['id'],
 									);
 								}
-							} else {
+							} elseif ($friendsOnly) {
+								$machineMatches = false;
+								foreach ($child->Server as $server) {
+									if ((string)$server['machineIdentifier'] == $GLOBALS['plexID']) {
+										$machineMatches = true;
+									}
+								}
+								if($machineMatches){
+									$results[] = array(
+										'username' => (string)$child['username'],
+										'email' => (string)$child['email'],
+										'id' => (string)$child['id'],
+									);
+								}
+							}else{
 								$results[] = array(
 									'username' => (string)$child['username'],
 									'email' => (string)$child['email'],
+									'id' => (string)$child['id'],
 								);
 							}