From 7a393b16445b74f9b82c3ba3a889f4b2a861a2da Mon Sep 17 00:00:00 2001 From: Pierre Date: Fri, 26 May 2017 09:36:20 +0200 Subject: [PATCH] Created components class & default userID --- classes/components.php | 34 +++++++++++++++++++++++++++++ classes/components/accountImage.php | 21 ++++++++++++++++++ functions/user.php | 4 ++++ index.php | 8 +++++-- init.php | 12 +++++++++- 5 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 classes/components.php create mode 100644 classes/components/accountImage.php diff --git a/classes/components.php b/classes/components.php new file mode 100644 index 0000000..42c8152 --- /dev/null +++ b/classes/components.php @@ -0,0 +1,34 @@ +$object) + $this->{$name} = $object; + } + + /** + * Class registration + * + * @param String $className The name of the class to register + * @param Object $object The object to register + */ + public static function register($className, $object){ + self::$objects[$className] = $object; + } +} \ No newline at end of file diff --git a/classes/components/accountImage.php b/classes/components/accountImage.php new file mode 100644 index 0000000..333fefc --- /dev/null +++ b/classes/components/accountImage.php @@ -0,0 +1,21 @@ +config->get("site_mode") == "debug"){ +if($cs->config->get("site_mode") == "debug"){ //DEBUG ONLY $_POST['serviceName'] = "testService"; $_POST['serviceToken'] = "testPasswd"; } @@ -50,6 +50,10 @@ if(isset($_POST['userToken1']) AND isset($_POST['userToken2'])){ //Else save userID define("userID", $userID); } +else { + //Defined userID is number 0 + define("userID", 0); +} /** * Handle Rest requests diff --git a/init.php b/init.php index 787f2ca..73e05d7 100644 --- a/init.php +++ b/init.php @@ -13,6 +13,11 @@ foreach(glob(PROJECT_PATH."classes/*.php") as $classFile){ require_once $classFile; } +//Include components +foreach(glob(PROJECT_PATH."classes/components/*.php") as $classFile){ + require_once $classFile; +} + //Include functions foreach(glob(PROJECT_PATH."functions/*.php") as $funcFile){ require_once $funcFile; @@ -53,4 +58,9 @@ unset($tokens); //Add user object $user = new User(); $cs->register("user", $user); -unset($user); \ No newline at end of file +unset($user); + +//Add components object +$components = new Components(); +$cs->register("components", $components); +unset($components); \ No newline at end of file