diff --git a/automate.php b/automate.php
index a0c84ef..9341a9f 100755
--- a/automate.php
+++ b/automate.php
@@ -1,13 +1,7 @@
\ No newline at end of file
diff --git a/config/repositories.json b/config/repositories.json
index 02c919b..5be92f0 100755
--- a/config/repositories.json
+++ b/config/repositories.json
@@ -2,25 +2,34 @@
"user" :[
"create",
+ "getAll",
"getById",
"getByCode",
- "getAll",
- "getGroup",
+ "getByUsername",
+
+ "getGroups",
"delete"
],
"machine" :[
- "get",
+ "create",
+
"getAll",
+ "getById",
+
"getGroup"
],
"group" :[
- "get",
+ "create",
+ "link",
+ "unlink",
+
"getAll",
- "getUser",
- "getMachine"
+ "getById",
+
+ "getMembers"
]
}
\ No newline at end of file
diff --git a/index.php b/index.php
index 2138ed7..4572487 100755
--- a/index.php
+++ b/index.php
@@ -1,7 +1,11 @@
get('settings/', function(){ include __ROOT__.'/view.php'; });
// Dispatcher
- $R->get('f(?:/([\w-]+))*/?', function(){ new \manager\ResourceDispatcher($_GET['url'], true); });
+ $R->get('f(?:/([\w-]+))*/?', function(){ new ResourceDispatcher($_GET['url'], true); });
// Api
$R->post('api/?', function(){
- $request = \manager\ModuleRequest::fromPost($_POST);
+ $request = ModuleRequest::fromPost($_POST);
$answer = $request->dispatch();
echo $answer->serialize();
diff --git a/manager/Database.php b/manager/Database.php
index 6f285a2..17a1fcc 100755
--- a/manager/Database.php
+++ b/manager/Database.php
@@ -1,6 +1,8 @@
host.';dbname='.$this->dbname, $this->username, $this->password);
// On signale que tout s'est bien passe
- self::$error = \manager\ManagerError::Success;
+ self::$error = ManagerError::Success;
}catch(Exception $e){
// On signale qu'il y a une erreur
- self::$error = \manager\ManagerError::PDOConnection;
+ self::$error = ManagerError::PDOConnection;
}
}
/* retourne une instance de la classe */
public static function getInstance(){
- if( self::$instance == null || self::$error != \manager\ManagerError::Success ){ // Si aucune instance existante OU erreur de connection
+ if( self::$instance == null || self::$error != ManagerError::Success ){ // Si aucune instance existante OU erreur de connection
// chargement de la configuration du server SQL
if( !isset($_SERVER['HTTP_HOST']) || isset($_SERVER['HTTP_HOST']) && $_SERVER['HTTP_HOST'] == 'stefproject' )
diff --git a/manager/ModuleAnswer.php b/manager/ModuleAnswer.php
index 808a4b3..493f95b 100755
--- a/manager/ModuleAnswer.php
+++ b/manager/ModuleAnswer.php
@@ -1,6 +1,7 @@
Tableau contenant le nom des classes
+ *
+ */
+ function autoload($classes){
+ foreach($classes as $class){
+ $name_only = substr(strrchr($class, '\\'), 1);
+ var_dump('use '.$class.' as '.$name_only.';');
+ eval('use '.$class.' as '.$name_only.';');
+ }
+ }
+
+
+
+
+
+
+
+
/* AUTOLOADER
*
@@ -30,9 +58,10 @@
$path = str_replace('\\', '/', $className) . '.php';
$path = __ROOT__.'/'.$path;
- // Si le fichier existe, on l'inclut
+ // Si le fichier existe
if( file_exists($path) )
- require_once $path;
+ require_once $path; // on inclue le fichier
+
}
// On definit l'autoloader comme autoloader (obvious)
diff --git a/manager/module/userDefault.php b/manager/module/userDefault.php
index db5885d..f1a7342 100755
--- a/manager/module/userDefault.php
+++ b/manager/module/userDefault.php
@@ -1,6 +1,10 @@
$users->answer()
@@ -37,54 +41,62 @@
public static function create($code=null, $username=null, $firstname=null, $lastname=null, $mail=null, $password=null, $status=null){
/* [1] Normalisation + verification des donnees
=========================================================*/
- $password_hash = \manager\sessionManager::secure_sha1($password);
+ $password_hash = sessionManager::secure_sha1($password);
- $correct_param = \manager\Database::check('user.code', $code);
- $correct_param = $correct_param && \manager\Database::check('user.username', $username);
- $correct_param = $correct_param && \manager\Database::check('user.firstname', $firstname);
- $correct_param = $correct_param && \manager\Database::check('user.lastname', $lastname);
- $correct_param = $correct_param && \manager\Database::check('user.mail', $mail);
- $correct_param = $correct_param && \manager\Database::check('user.password', $password_hash);
- $correct_param = $correct_param && \manager\Database::check('user.status', $status);
+ $correct_param = Database::check('user.code', $code);
+ $correct_param = $correct_param && Database::check('user.username', $username);
+ $correct_param = $correct_param && Database::check('user.firstname', $firstname);
+ $correct_param = $correct_param && Database::check('user.lastname', $lastname);
+ $correct_param = $correct_param && Database::check('user.mail', $mail);
+ $correct_param = $correct_param && Database::check('user.password', $password_hash);
+ $correct_param = $correct_param && Database::check('user.status', $status);
// Si les parametres ne sont pas corrects, on retourne une erreur
if( !$correct_param )
- return array('ModuleError' => \manager\ManagerError::ParamError);
+ return array('ModuleError' => ManagerError::ParamError);
+
+
/* [2] Creation de l'utilisateur
=========================================================*/
- $create_user = new \manager\Repo('user/create', array($code, $username, $firstname, $lastname, $mail, $password_hash, $status) );
+ $create_user = new Repo('user/create', array($code, $username, $firstname, $lastname, $mail, $password_hash, $status) );
$id_user = $create_user->answer();
// Si une erreur est retournee, on retourne une erreur
if( $id_user === false )
- return array('ModuleError' => \manager\ManagerError::ModuleError);
+ return array('ModuleError' => ManagerError::ModuleError);
+
+
/* [3] Creation du groupe de meme nom que l'username
=========================================================*/
- $create_group = new \manager\Repo('group/create', array($username) );
+ $create_group = new Repo('group/create', array($username) );
$id_group = $create_group->answer();
// Si une erreur est retournee, on retourne une erreur
if( $id_group === false )
- return array('ModuleError' => \manager\ManagerError::ModuleError);
+ return array('ModuleError' => ManagerError::ModuleError);
+
+
/* [4] Association au groupe
=========================================================*/
- $assoc_goup = new \manager\Repo('group/associate', array($id_user, $id_group));
+ $assoc_goup = new Repo('group/link', array($id_user, $id_group));
$id_assoc = $assoc_goup->answer();
// Si une erreur est retournee, on retourne une erreur
if( $id_assoc === false )
- return array('ModuleError' => \manager\ManagerError::ModuleError);
+ return array('ModuleError' => ManagerError::ModuleError);
+
+
/* [5] Gestion du retour
=========================================================*/
return array(
- 'ModuleError' => \manager\ManagerError::Success,
+ 'ModuleError' => ManagerError::Success,
'id_user' => $id_user
);
}
diff --git a/manager/repo/user.php b/manager/repo/user.php
index 926dacb..52b731d 100755
--- a/manager/repo/user.php
+++ b/manager/repo/user.php
@@ -1,9 +1,38 @@
Code RFID de l'utilisateur
+ * @username
- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.9-1ubuntu4.14 and PHPUnit 3.7.28 at Sat Feb 13 17:24:32 CET 2016. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.9-1ubuntu4.14 and PHPUnit 3.7.28 at Sat Feb 13 18:08:46 CET 2016.
diff --git a/phpunit/coverage/ManagerError.php.html b/phpunit/coverage/ManagerError.php.html index 6c9d4f8..6b44be9 100644 --- a/phpunit/coverage/ManagerError.php.html +++ b/phpunit/coverage/ManagerError.php.html @@ -220,7 +220,7 @@ Dead Code- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.9-1ubuntu4.14 and PHPUnit 3.7.28 at Sat Feb 13 17:24:32 CET 2016. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.9-1ubuntu4.14 and PHPUnit 3.7.28 at Sat Feb 13 18:08:46 CET 2016.
diff --git a/phpunit/coverage/ResourceDispatcher.php.html b/phpunit/coverage/ResourceDispatcher.php.html index 3272a19..04a862e 100644 --- a/phpunit/coverage/ResourceDispatcher.php.html +++ b/phpunit/coverage/ResourceDispatcher.php.html @@ -450,7 +450,7 @@ Dead Code- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.9-1ubuntu4.14 and PHPUnit 3.7.28 at Sat Feb 13 17:24:32 CET 2016. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.9-1ubuntu4.14 and PHPUnit 3.7.28 at Sat Feb 13 18:08:46 CET 2016.
diff --git a/phpunit/coverage/autoloader.php.html b/phpunit/coverage/autoloader.php.html index e37027e..32d8aab 100755 --- a/phpunit/coverage/autoloader.php.html +++ b/phpunit/coverage/autoloader.php.html @@ -153,7 +153,7 @@ Dead Code- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.9-1ubuntu4.14 and PHPUnit 3.7.28 at Sat Feb 13 17:24:32 CET 2016. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.9-1ubuntu4.14 and PHPUnit 3.7.28 at Sat Feb 13 18:08:46 CET 2016.
diff --git a/phpunit/coverage/index.dashboard.html b/phpunit/coverage/index.dashboard.html index a522a3d..d1e14ba 100755 --- a/phpunit/coverage/index.dashboard.html +++ b/phpunit/coverage/index.dashboard.html @@ -59,7 +59,7 @@ diff --git a/phpunit/coverage/index.html b/phpunit/coverage/index.html index ce19264..92f8c53 100755 --- a/phpunit/coverage/index.html +++ b/phpunit/coverage/index.html @@ -177,7 +177,7 @@ High: 70% to 100%- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.9-1ubuntu4.14 and PHPUnit 3.7.28 at Sat Feb 13 17:24:32 CET 2016. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.9-1ubuntu4.14 and PHPUnit 3.7.28 at Sat Feb 13 18:08:46 CET 2016.
diff --git a/phpunit/coverage/sessionManager.php.html b/phpunit/coverage/sessionManager.php.html index cb2a80b..c52bd9d 100644 --- a/phpunit/coverage/sessionManager.php.html +++ b/phpunit/coverage/sessionManager.php.html @@ -284,7 +284,7 @@ Dead Code- Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.9-1ubuntu4.14 and PHPUnit 3.7.28 at Sat Feb 13 17:24:32 CET 2016. + Generated by PHP_CodeCoverage 1.2.13 using PHP 5.5.9-1ubuntu4.14 and PHPUnit 3.7.28 at Sat Feb 13 18:08:46 CET 2016.
diff --git a/todo.md b/todo.md index 835a672..35a99aa 100755 --- a/todo.md +++ b/todo.md @@ -39,6 +39,7 @@ ######## # FAIT # ######## +- [x] Ajout de "use CLASS;" dans les fichiers pour simplifier la lisibilite - [x] [phpunit/sessionManager] test unitaires du manager de session php - [x] [ModuleAnswer] Gestion des erreurs au niveau interne des Modules - [x] [autoloader][phpunit/bootstrap.php] Correction des bugs de $_SERVER avec PHPUnit -> autoloader + bootstrap personnalise