Ver Fonte

add demo function start

CauseFX há 4 anos atrás
pai
commit
a0b25e8414
2 ficheiros alterados com 26 adições e 3 exclusões
  1. 2 3
      api/classes/organizr.class.php
  2. 24 0
      api/functions/demo-functions.php

+ 2 - 3
api/classes/organizr.class.php

@@ -10,6 +10,7 @@ class Organizr
 	use AuthFunctions;
 	use BackupFunctions;
 	use ConfigFunctions;
+	use DemoFunctions;
 	use HomepageConnectFunctions;
 	use HomepageFunctions;
 	use LogFunctions;
@@ -2905,17 +2906,15 @@ class Organizr
 				[
 					'type' => 'input',
 					'name' => 'overseerrFallbackUser',
-					'label' => 'Overseerr Fallback User',
+					'label' => 'Overseerr Fallback Email',
 					'value' => $this->config['overseerrFallbackUser'],
 					'help' => 'DO NOT SET THIS TO YOUR ADMIN ACCOUNT. We recommend you create a local account as a "catch all" for when Organizr is unable to perform SSO.  Organizr will request a User Token based off of this user credentials',
-					'attr' => 'disabled'
 				],
 				[
 					'type' => 'password-alt',
 					'name' => 'overseerrFallbackPassword',
 					'label' => 'Overseerr Fallback Password',
 					'value' => $this->config['overseerrFallbackPassword'],
-					'attr' => 'disabled'
 				],
 				[
 					'type' => 'switch',

+ 24 - 0
api/functions/demo-functions.php

@@ -0,0 +1,24 @@
+<?php
+/** @noinspection PhpUndefinedFieldInspection */
+
+trait DemoFunctions
+{
+	public function demoData($file = null)
+	{
+		if (!$file) {
+			$this->setResponse(422, 'Demo file was not supplied');
+			return false;
+		}
+		$path = dirname(__DIR__, 1) . DIRECTORY_SEPARATOR . 'demo_data' . DIRECTORY_SEPARATOR . $file;
+		if (file_exists($path)) {
+			
+			$data = file_get_contents($path);
+			$data = json_decode($data, true);
+			$this->setResponse(200, 'Demo data for file: ' . $file, $data['response']['data']);
+			return $data;
+		} else {
+			$this->setResponse(404, 'Demo data was not found for file: ' . $file);
+			return false;
+		}
+	}
+}