]> git.mxchange.org Git - friendica.git/blobdiff - src/App.php
Add Install Mode (Part 2)
[friendica.git] / src / App.php
index 5ff7eab04dd070e341524b872bc06ce9b31ec043..b285218f483c7fed8d2d3ca26bd9b3c504bf8eec 100644 (file)
@@ -32,6 +32,10 @@ require_once 'include/text.php';
  */
 class App
 {
+       const MODE_NORMAL = 0;
+       const MODE_INSTALL = 1;
+       const MODE_MAINTENANCE = 2;
+
        public $module_loaded = false;
        public $module_class = null;
        public $query_string;
@@ -52,7 +56,7 @@ class App
        public $argv;
        public $argc;
        public $module;
-       public $install_mode = false;
+       public $mode = App::MODE_NORMAL;
        public $pager;
        public $strings;
        public $basepath;
@@ -289,6 +293,14 @@ class App
                // Register template engines
                $this->register_template_engine('Friendica\Render\FriendicaSmartyEngine');
 
+               /**
+                * Load the configuration file which contains our DB credentials.
+                * Ignore errors. If the file doesn't exist or is empty, we are running in
+                * installation mode.    *
+                */
+               $this->mode = ((file_exists('.htconfig.php') && filesize('.htconfig.php')) ? App::MODE_NORMAL : App::MODE_INSTALL);
+
+
                self::$a = $this;
        }
 
@@ -1068,4 +1080,19 @@ class App
 
                return $sender_email;
        }
+
+       /**
+        * @note Checks, if the App is in the Maintenance-Mode
+        *
+        * @return boolean
+        */
+       public function checkMaintenanceMode()
+       {
+               if (Config::get('system', 'maintenance')) {
+                       $this->mode = App::MODE_MAINTENANCE;
+                       return true;
+               }
+
+               return false;
+       }
 }