added php code to get settings from database to react state
add onchange events to change state on field change
This commit is contained in:
		
							
								
								
									
										26
									
								
								api/Settings.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								api/Settings.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
<?php
 | 
			
		||||
require 'Database.php';
 | 
			
		||||
 | 
			
		||||
$conn = Database::getInstance()->getConnection();
 | 
			
		||||
 | 
			
		||||
if (isset($_POST['action'])) {
 | 
			
		||||
    $action = $_POST['action'];
 | 
			
		||||
    switch ($action) {
 | 
			
		||||
        case "loadGeneralSettings":
 | 
			
		||||
            $query = "SELECT * from settings";
 | 
			
		||||
 | 
			
		||||
            $result = $conn->query($query);
 | 
			
		||||
            if ($result->num_rows > 1) {
 | 
			
		||||
                // todo throw error
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            $r = mysqli_fetch_assoc($result);
 | 
			
		||||
            if ($r['password'] != "-1") {
 | 
			
		||||
                $r['passwordEnabled'] = true;
 | 
			
		||||
            } else {
 | 
			
		||||
                $r['passwordEnabled'] = true;
 | 
			
		||||
            }
 | 
			
		||||
            echo json_encode($r);
 | 
			
		||||
            break;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user