Browse Source

Finally fix ombi limit to user

causefx 7 years ago
parent
commit
f84df7926d
1 changed files with 44 additions and 38 deletions
  1. 44 38
      api/functions/homepage-connect-functions.php

+ 44 - 38
api/functions/homepage-connect-functions.php

@@ -1954,55 +1954,61 @@ function getOmbiRequests($type = "both")
 					$movie = json_decode($movie->body, true);
 					//$movie = array_reverse($movie);
 					foreach ($movie as $key => $value) {
-						$requests[] = array(
-							'test' => $value,
-							'id' => $value['theMovieDbId'],
-							'title' => $value['title'],
-							'overview' => $value['overview'],
-							'poster' => (isset($value['posterPath']) && $value['posterPath'] !== '') ? 'https://image.tmdb.org/t/p/w300/' . $value['posterPath'] : '',
-							'background' => (isset($value['background']) && $value['background'] !== '') ? 'https://image.tmdb.org/t/p/w1280/' . $value['background'] : '',
-							'approved' => $value['approved'],
-							'available' => $value['available'],
-							'denied' => $value['denied'],
-							'deniedReason' => $value['deniedReason'],
-							'user' => $value['requestedUser']['userName'],
-							'userAlias' => $value['requestedUser']['userAlias'],
-							'request_id' => $value['id'],
-							'request_date' => $value['requestedDate'],
-							'release_date' => $value['releaseDate'],
-							'type' => 'movie',
-							'icon' => 'mdi mdi-filmstrip',
-							'color' => 'palette-Deep-Purple-900 bg white',
-						);
-					}
-				}
-				if (isset($tv) && (is_array($tv) || is_object($tv))) {
-					$tv = json_decode($tv->body, true);
-					foreach ($tv as $key => $value) {
-						if (count($value['childRequests']) > 0) {
+						$proceed = (($GLOBALS['ombiLimitUser']) && strtolower($GLOBALS['organizrUser']['username']) == strtolower($value['requestedUser']['userName'])) || (!$GLOBALS['ombiLimitUser']) || qualifyRequest(1) ? true : false;
+						if ($proceed) {
 							$requests[] = array(
 								'test' => $value,
-								'id' => $value['tvDbId'],
+								'id' => $value['theMovieDbId'],
 								'title' => $value['title'],
 								'overview' => $value['overview'],
-								'poster' => $value['posterPath'],
+								'poster' => (isset($value['posterPath']) && $value['posterPath'] !== '') ? 'https://image.tmdb.org/t/p/w300/' . $value['posterPath'] : '',
 								'background' => (isset($value['background']) && $value['background'] !== '') ? 'https://image.tmdb.org/t/p/w1280/' . $value['background'] : '',
-								'approved' => $value['childRequests'][0]['approved'],
-								'available' => $value['childRequests'][0]['available'],
-								'denied' => $value['childRequests'][0]['denied'],
-								'deniedReason' => $value['childRequests'][0]['deniedReason'],
-								'user' => $value['childRequests'][0]['requestedUser']['userName'],
-								'userAlias' => $value['childRequests'][0]['requestedUser']['userAlias'],
+								'approved' => $value['approved'],
+								'available' => $value['available'],
+								'denied' => $value['denied'],
+								'deniedReason' => $value['deniedReason'],
+								'user' => $value['requestedUser']['userName'],
+								'userAlias' => $value['requestedUser']['userAlias'],
 								'request_id' => $value['id'],
-								'request_date' => $value['childRequests'][0]['requestedDate'],
+								'request_date' => $value['requestedDate'],
 								'release_date' => $value['releaseDate'],
-								'type' => 'tv',
-								'icon' => 'mdi mdi-television',
-								'color' => 'grayish-blue-bg',
+								'type' => 'movie',
+								'icon' => 'mdi mdi-filmstrip',
+								'color' => 'palette-Deep-Purple-900 bg white',
 							);
 						}
 					}
 				}
+				if (isset($tv) && (is_array($tv) || is_object($tv))) {
+					$tv = json_decode($tv->body, true);
+					foreach ($tv as $key => $value) {
+						if (count($value['childRequests']) > 0) {
+							$proceed = (($GLOBALS['ombiLimitUser']) && strtolower($GLOBALS['organizrUser']['username']) == strtolower($value['childRequests'][0]['requestedUser']['userName'])) || (!$GLOBALS['ombiLimitUser']) || qualifyRequest(1) ? true : false;
+							if ($proceed) {
+								$requests[] = array(
+									'test' => $value,
+									'id' => $value['tvDbId'],
+									'title' => $value['title'],
+									'overview' => $value['overview'],
+									'poster' => $value['posterPath'],
+									'background' => (isset($value['background']) && $value['background'] !== '') ? 'https://image.tmdb.org/t/p/w1280/' . $value['background'] : '',
+									'approved' => $value['childRequests'][0]['approved'],
+									'available' => $value['childRequests'][0]['available'],
+									'denied' => $value['childRequests'][0]['denied'],
+									'deniedReason' => $value['childRequests'][0]['deniedReason'],
+									'user' => $value['childRequests'][0]['requestedUser']['userName'],
+									'userAlias' => $value['childRequests'][0]['requestedUser']['userAlias'],
+									'request_id' => $value['id'],
+									'request_date' => $value['childRequests'][0]['requestedDate'],
+									'release_date' => $value['releaseDate'],
+									'type' => 'tv',
+									'icon' => 'mdi mdi-television',
+									'color' => 'grayish-blue-bg',
+								);
+							}
+						}
+					}
+				}
 				//sort here
 				usort($requests, function ($item1, $item2) {
 					if ($item1['request_date'] == $item2['request_date']) {