From 33a0df306585412f1a3a15ed9b4e9075a7ad245b Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sun, 24 Jul 2016 19:18:55 +0200 Subject: [PATCH] =?UTF-8?q?Corrections=20suite=20aux=20pb=20relev=C3=A9s?= =?UTF-8?q?=20par=20le=20serveur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manager/Database.php | 14 ++++++++------ manager/ModuleRequest.php | 4 ++-- manager/ORM/Rows.php | 28 ++++++++++++++-------------- manager/Repo.php | 4 ++-- manager/module/userDefault.php | 1 - manager/repo/admin.php | 2 +- manager/repo/machine.php | 2 +- manager/repo/machine_cluster.php | 4 ++-- manager/repo/user.php | 2 +- manager/repo/user_cluster.php | 4 ++-- manager/repo/warehouse.php | 2 +- test/automate.php | 4 ++-- 12 files changed, 36 insertions(+), 35 deletions(-) diff --git a/manager/Database.php b/manager/Database.php index 34e20a1..300bf17 100755 --- a/manager/Database.php +++ b/manager/Database.php @@ -6,10 +6,12 @@ class Database{ /* ATTRIBUTS STATIQUES */ - public static $config_path = [ - 'local' => __ROOT__.'/config/database-local.json', - 'remote' => __ROOT__.'/config/database.json' - ]; + public static function config_path(){ + return [ + 'local' => __ROOT__.'/config/database-local.json', + 'remote' => __ROOT__.'/config/database.json' + ]; + } private static $pdo; private static $instance; @@ -49,9 +51,9 @@ // chargement de la configuration du server SQL if( !checkdnsrr($_SERVER['SERVER_NAME'], 'NS') ) - $conf = json_decode( file_get_contents(self::$config_path['local']), true ); + $conf = json_decode( file_get_contents(self::config_path()['local']), true ); else - $conf = json_decode( file_get_contents(self::$config_path['remote']), true ); + $conf = json_decode( file_get_contents(self::config_path()['remote']), true ); // creation de l'instance en fonction des parametres self::$instance = new DataBase($conf['host'], $conf['dbname'], $conf['user'], $conf['password']); diff --git a/manager/ModuleRequest.php b/manager/ModuleRequest.php index 7799f67..bec9cc9 100755 --- a/manager/ModuleRequest.php +++ b/manager/ModuleRequest.php @@ -8,7 +8,7 @@ class ModuleRequest{ // Constantes - public static $config_path = __ROOT__.'/config/modules.json'; + public static function config_path(){ return __ROOT__.'/config/modules.json'; } public static $default_options = [ 'download' => false ]; @@ -47,7 +47,7 @@ /* [0] On met a jour la configuration =========================================================*/ // Modules specifies - $this->modules = json_decode( file_get_contents(self::$config_path), true ); + $this->modules = json_decode( file_get_contents(self::config_path()), true ); // Gestion de l'erreur de parsage if( $this->modules == null ){ diff --git a/manager/ORM/Rows.php b/manager/ORM/Rows.php index cf19cd4..d8ca17b 100644 --- a/manager/ORM/Rows.php +++ b/manager/ORM/Rows.php @@ -10,16 +10,16 @@ /* CONSTANTES */ - const COND_EQUAL = '__=__'; - const COND_NOTEQ = '__<>__'; - const COND_INF = '__<__'; - const COND_SUP = '__>__'; - const COND_INFEQ = '__<=__'; - const COND_SUPEQ = '__>=__'; - const COND_LIKE = '__LIKE__'; - const COND_IN = '__IN__'; + const COND_EQUAL = '__=__'; + const COND_NOTEQ = '__<>__'; + const COND_INF = '__<__'; + const COND_SUP = '__>__'; + const COND_INFEQ = '__<=__'; + const COND_SUPEQ = '__>=__'; + const COND_LIKE = '__LIKE__'; + const COND_IN = '__IN__'; - const DEFAULT = '__DEFAULT__'; // Valeur DEFAULT (pour insertion) + const INSERT_DEFAULT = '__DEFAULT__'; // Valeur DEFAULT (pour insertion) /* Attributs */ private $where; // Tableau associatif contenant les conditions @@ -550,11 +550,11 @@ $type = $this->schema['columns'][$field]['type']; // {1} Si de type INT/FLOAT et pas numérique, on retire le champ // - if( in_array($type, ['int', 'float']) && !is_numeric($value) && $value != self::DEFAULT ) + if( in_array($type, ['int', 'float']) && !is_numeric($value) && $value != self::INSERT_DEFAULT ) unset($cleared[$i][$field]); // {2} Si de type TEXT/VARCHAR et pas string, on retire le champ // - if( in_array($type, ['text', 'varchar']) && !is_string($value) && $value != self::DEFAULT ) + if( in_array($type, ['text', 'varchar']) && !is_string($value) && $value != self::INSERT_DEFAULT ) unset($cleared[$i][$field]); } @@ -595,8 +595,8 @@ // Si l'entrée est donnée if( isset($set[$field]) ) - if( $set[$field] == self::DEFAULT ) $requestS .= 'DEFAULT'; // On insère directement les valeurs 'DEFAULT' - else $requestS .= ':insert_'.$field.'_'.$i; + if( $set[$field] == self::INSERT_DEFAULT ) $requestS .= 'DEFAULT'; // On insère directement les valeurs 'DEFAULT' + else $requestS .= ':insert_'.$field.'_'.$i; else $requestS .= 'DEFAULT'; @@ -620,7 +620,7 @@ /* (1) On bind les paramètres */ foreach($cleared as $i=>$set) foreach($this->schema['columns'] as $field=>$column) - if( isset($set[$field]) && $set[$field] != self::DEFAULT ) + if( isset($set[$field]) && $set[$field] != self::INSERT_DEFAULT ) $bound[':insert_'.$field.'_'.$i] = $set[$field]; diff --git a/manager/Repo.php b/manager/Repo.php index b101947..8bd0c5a 100755 --- a/manager/Repo.php +++ b/manager/Repo.php @@ -19,7 +19,7 @@ class Repo{ // Constantes - public static $config_path = __ROOT__.'/config/repositories.json'; + public static function config_path(){ return __ROOT__.'/config/repositories.json'; } // Attributs prives utiles (initialisation) @@ -56,7 +56,7 @@ /* [0] On met a jour la configuration =========================================================*/ // Modules specifies - $this->repositories = json_decode( file_get_contents(self::$config_path), true ); + $this->repositories = json_decode( file_get_contents(self::config_path()), true ); // Gestion de l'erreur de parsage if( $this->repositories == null ){ diff --git a/manager/module/userDefault.php b/manager/module/userDefault.php index 6a9e8a1..2eefe9a 100755 --- a/manager/module/userDefault.php +++ b/manager/module/userDefault.php @@ -5,7 +5,6 @@ use \manager\sessionManager; use \manager\ManagerError; use \manager\Repo; - use \manager\repo\cluster as clusterRepo; class userDefault{ diff --git a/manager/repo/admin.php b/manager/repo/admin.php index d3a0069..696f635 100644 --- a/manager/repo/admin.php +++ b/manager/repo/admin.php @@ -25,7 +25,7 @@ =========================================================*/ $inserted = Table::get('admin') ->insert([ - 'id_admin' => Rows::DEFAULT, + 'id_admin' => Rows::INSERT_DEFAULT, 'username' => $username, 'mail' => $mail, 'password' => sessionManager::secure_hash( $password ), diff --git a/manager/repo/machine.php b/manager/repo/machine.php index 67d1bcc..5adfdc9 100755 --- a/manager/repo/machine.php +++ b/manager/repo/machine.php @@ -25,7 +25,7 @@ /* [1] Creation de la machine =========================================================*/ $inserted = Table::get('machine')->insert([ - 'id_machine' => Rows::DEFAULT, + 'id_machine' => Rows::INSERT_DEFAULT, 'id_warehouse' => $id_warehouse, 'name' => $name, 'token' => sessionManager::secure_hash( uniqid() ) diff --git a/manager/repo/machine_cluster.php b/manager/repo/machine_cluster.php index cfa51cd..11930a0 100644 --- a/manager/repo/machine_cluster.php +++ b/manager/repo/machine_cluster.php @@ -25,7 +25,7 @@ =========================================================*/ $inserted = Table::get('machine_cluster') ->insert([ - 'id_machine_cluster' => Rows::DEFAULT, + 'id_machine_cluster' => Rows::INSERT_DEFAULT, 'id_warehouse' => $id_warehouse, 'name' => $name ]); @@ -109,7 +109,7 @@ /* (1) On insère la relation */ $inserted = Table::get('machine_cluster_merge') ->insert([ - 'id_machine_cluster_merge' => Rows::DEFAULT, + 'id_machine_cluster_merge' => Rows::INSERT_DEFAULT, 'id_machine_cluster' => $id_machine_cluster, 'id_machine' => $id_machine ]); diff --git a/manager/repo/user.php b/manager/repo/user.php index 81572f4..4f142cc 100755 --- a/manager/repo/user.php +++ b/manager/repo/user.php @@ -26,7 +26,7 @@ /* [1] On retourne l'id_user ou FALSE si erreur =========================================================*/ $inserted = Table::get('user')->insert([ - 'id_user' => Rows::DEFAULT, + 'id_user' => Rows::INSERT_DEFAULT, 'id_warehouse' => $id_warehouse, 'code' => $code, 'username' => $username, diff --git a/manager/repo/user_cluster.php b/manager/repo/user_cluster.php index 06ebc87..013d9d1 100644 --- a/manager/repo/user_cluster.php +++ b/manager/repo/user_cluster.php @@ -25,7 +25,7 @@ =========================================================*/ $inserted = Table::get('user_cluster') ->insert([ - 'id_user_cluster' => Rows::DEFAULT, + 'id_user_cluster' => Rows::INSERT_DEFAULT, 'id_warehouse' => $id_warehouse, 'name' => $name ]); @@ -109,7 +109,7 @@ /* (1) On insère la relation */ $inserted = Table::get('user_cluster_merge') ->insert([ - 'id_user_cluster_merge' => Rows::DEFAULT, + 'id_user_cluster_merge' => Rows::INSERT_DEFAULT, 'id_user_cluster' => $id_user_cluster, 'id_user' => $id_user ]); diff --git a/manager/repo/warehouse.php b/manager/repo/warehouse.php index 6981e4e..2a90a84 100644 --- a/manager/repo/warehouse.php +++ b/manager/repo/warehouse.php @@ -24,7 +24,7 @@ =========================================================*/ $created = Table::get('warehouse') ->insert([ - 'id_warehouse' => Rows::DEFAULT, + 'id_warehouse' => Rows::INSERT_DEFAULT, 'name' => $name, 'password' => sessionManager::secure_hash( $password ), 'token' => sessionManager::secure_hash( uniqid() ) diff --git a/test/automate.php b/test/automate.php index 874280c..6f28c9a 100755 --- a/test/automate.php +++ b/test/automate.php @@ -404,7 +404,7 @@ // $insert = Table::get('user') // ->insert([ // [ - // 'id_user' => Rows::DEFAULT, + // 'id_user' => Rows::INSERT_DEFAULT, // 'id_warehouse' => 7, // 'code' => 'AA-AA-AA-AA', // 'username' => 'AA', @@ -413,7 +413,7 @@ // 'mail' => 'AA@AA.AA' // ], // [ - // 'id_user' => Rows::DEFAULT, + // 'id_user' => Rows::INSERT_DEFAULT, // 'id_warehouse' => 7, // 'code' => 'BB-BB-BB-BB', // 'username' => 'BB',