UpdateDatabase/VerifyConfig.php
authorEdward <edward@roojs.com>
Thu, 4 Oct 2018 02:54:43 +0000 (10:54 +0800)
committerEdward <edward@roojs.com>
Thu, 4 Oct 2018 02:54:43 +0000 (10:54 +0800)
UpdateDatabase/VerifyConfig.php

index 3ac00fa..fae95b5 100644 (file)
@@ -1,8 +1,70 @@
 <?php
 
-/* 
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
+require_once 'Pman.php';
 
+class Pman_Core_UpdateDatabase_VerifyConfig extends Pman
+{
+    static $cli_opts = array(
+
+    );
+    
+    function getAuth()
+    {
+        if ($_SERVER['HTTP_HOST'] == 'localhost') {
+            return true;
+        }
+        
+        $this->getAuthUser();
+        
+        if(empty($this->authUser)) {
+            return false;
+        }
+        
+        return true;
+    }
+    
+    function get($base, $opts = array())
+    {
+        $requirements = array();
+        
+        $ff = HTML_FlexyFramework::get();
+        
+        foreach($this->modulesList() as $m) {
+            
+            $fd = $ff->rootDir. "/Pman/$m/UpdateDatabase.php";
+            
+            if (!file_exists($fd)) {
+                continue;
+            }
+            
+            require_once $fd;
+            $cls = new ReflectionClass('Pman_'. $m . '_UpdateDatabase');
+            $props = $cls->getDefaultProperties();
+            
+            if(!empty($props['required_variable'])) {
+                $requirements = array_merge($requirements, $props['required_variable']);
+            }
+        }
+        
+        $error = array();
+        
+        foreach ($requirements as $k => $v){
+            
+            if(empty($ff->{$k})){
+                $error[] = "Missing Config: {$k} Config";
+                continue;
+            }
+            
+            foreach ($v as $r){
+                
+                if(isset($ff->{$k}[$r])){
+                    continue;
+                }
+                
+                $error[] = "Missing Config: {$k} - {$r}";
+            }
+        }
+        
+        return $error;
+    }
+}
\ No newline at end of file