diff --git a/build/api/core/Checker.php b/build/api/core/Checker.php index 108cb3e..1c49345 100755 --- a/build/api/core/Checker.php +++ b/build/api/core/Checker.php @@ -106,7 +106,7 @@ break; case 'alphanumeric': - return $checker && is_string($value) && preg_match('/^[\w\.-]+$/ui', $value); + return $checker && is_string($value) && preg_match('/^[\w\. -]+$/ui', $value); break; case 'letters': @@ -124,7 +124,8 @@ // Boolean case 'boolean': - return $checker && ( is_bool($value) || $value === 'false' || $value === 'true' ); + case 'bool': + return $checker && is_bool($value); break; // Objet non vide @@ -138,7 +139,7 @@ break; case 'numeric': - return $checker && (is_numeric($value) || $value == null || $value == 'null'); + return $checker && (is_numeric($value) || $value == null); break; case "float": diff --git a/build/api/module/professor/filterController.php b/build/api/module/professor/filterController.php new file mode 100644 index 0000000..3fa8235 --- /dev/null +++ b/build/api/module/professor/filterController.php @@ -0,0 +1,109 @@ + [OPT] Array of formation IDS + * @ues [OPT] Array of UE codes + * + * @return matches Array of matching professor IDs + * + ---------------------------------------------------------*/ + public static function post($args){ + + $formations = null; + $ues = null; + extract($args); + + /** @var ue $ue_repo */ + $ue_repo = Repo::getRepo('ue'); + + + /* (1) If no filter -> return error + ---------------------------------------------------------*/ + /* (1) Exit if no filter */ + if( is_null($formations) && is_null($ues) ) + return ['error' => new Error(Err::MissingParam, 'You must give at least 1 parameter')]; + + /* (2) Init. result array (only keys used for unicity) */ + $matches_uniq = []; + + + + /* (2) Filter by formation + ---------------------------------------------------------*/ + if( !is_null($formations) ){ + + /** @var formation $form_repo */ + $form_repo = Repo::getRepo('formation'); + + /* (1) For each formation -> get request */ + foreach($formations as $form_id){ + + // 1. Ignore if wrong format + if( !is_numeric($form_id) || intval($form_id) !== $form_id ) + continue; + + // 2. Get from repo + $fetched_ids = $form_repo->getProfessors($form_id); + + // 3. Add in unique set + foreach($fetched_ids as $prof_id) + $matches_uniq[ intval($prof_id) ] = null; + + + } + + } + + + + /* (3) Filter by ue + ---------------------------------------------------------*/ + if( !is_null($ues) ){ + + /** @var ue $ue_repo */ + $ue_repo = Repo::getRepo('ue'); + + /* (1) For each ue -> get request */ + foreach($ues as $ue_code){ + + // 1. Ignore if wrong format + if( !is_string($ue_code) || strlen($ue_code) < 1 ) + continue; + + // 2. Get from repo + $fetched_ids = $ue_repo->getProfessors($ue_code); + + // 3. Add in unique set + foreach($fetched_ids as $prof_id) + $matches_uniq[ intval($prof_id) ] = null; + + } + + } + + + + return ['matches' => array_keys($matches_uniq)]; + + } + +} \ No newline at end of file diff --git a/build/api/module/professorController.php b/build/api/module/professorController.php index 6f41d84..823e99e 100644 --- a/build/api/module/professorController.php +++ b/build/api/module/professorController.php @@ -25,7 +25,7 @@ class professorController{ ---------------------------------------------------------*/ public static function get($args){ $prof_id = null; - $with_vh = ''; + $with_vh = 0; extract($args); /* Get the professor repo */ @@ -35,8 +35,7 @@ class professorController{ /* (1) If with VH data ---------------------------------------------------------*/ - - if( $with_vh == 1 ){ + if( is_int($with_vh) && $with_vh === 1 ){ /* (1) Get All professors or 1 by its id (if set) */ $fetched = $prof_repo->getWithVH($prof_id); diff --git a/build/api/module/rootController.php b/build/api/module/rootController.php index 4195916..b210dfb 100644 --- a/build/api/module/rootController.php +++ b/build/api/module/rootController.php @@ -10,7 +10,7 @@ /* Generates the API documentation * */ - public function get($args){ + public function post($args){ extract($args); return [ 'args' => $args ]; diff --git a/build/database/repo/ue.php b/build/database/repo/ue.php index 8e89c6f..2c0f82c 100644 --- a/build/database/repo/ue.php +++ b/build/database/repo/ue.php @@ -188,4 +188,44 @@ class ue extends Repo_i { return $fetched; } + + + /* (7) Gets all professors who teaches a UE by code + * + * @code The UE code + * + * @return professors The professors' UID matching the @code of the UE + * + ---------------------------------------------------------*/ + public function getProfessors(String $code) : array{ + + /* (1) Prepare statement */ + $st = $this->pdo->prepare("SELECT p.idProfesseur + FROM Professeur p, UE u + WHERE ( + p.idProfesseur IN ( SELECT p_cr.idProfesseur FROM Professeur p_cr, Cours c WHERE c.Professeur_idProfesseur = p_cr.idProfesseur AND c.UE_code = u.code ) + OR p.idProfesseur IN ( SELECT p_td.idProfesseur FROM Professeur p_td, TD t WHERE t.Professeur_idProfesseur = p_td.idProfesseur AND t.UE_code = u.code ) + OR p.idProfesseur IN ( SELECT p_tp.idProfesseur FROM Professeur p_tp, TP t WHERE t.Professeur_idProfesseur = p_tp.idProfesseur AND t.UE_code = u.code ) + ) + AND u.code = :ue_code;"); + + /* (2) Bind params and execute statement */ + if( is_bool($st) ) return []; + $success = $st->execute([ ':ue_code' => $code ]); + + /* (3) Manage error */ + if( !$success ) + return []; + + /* (4) Get data */ + $fetched = $st->fetchAll(); + + /* (5) Return [] on no result */ + if( $fetched === false ) + return []; + + /* (6) Return data */ + return $fetched; + + } } \ No newline at end of file diff --git a/config/modules.json b/config/modules.json index ab1f435..3d6a035 100644 --- a/config/modules.json +++ b/config/modules.json @@ -1,9 +1,21 @@ { - "GET": { + "POST": { "des": "Returns the API documentation", "per": [], "par": { - "URL0": { "des": "Method name", "typ": "varchar(1,30)", "ren": "method_name", "opt": true, "def": null } + "URL0": { "des": "Method name", "typ": "varchar(1,30)", "ren": "method_name", "opt": true, "def": null }, + "mixed": { "des": "mixed type", "typ": "mixed", "opt": true }, + "id": { "des": "id type", "typ": "id", "opt": true }, + "text": { "des": "text type", "typ": "text", "opt": true }, + "mail": { "des": "mail type", "typ": "mail", "opt": true }, + "alphanumeric": { "des": "alphanumeric type", "typ": "alphanumeric", "opt": true }, + "letters": { "des": "letters type", "typ": "letters", "opt": true }, + "array": { "des": "array type", "typ": "array", "opt": true }, + "array_id": { "des": "array type", "typ": "array", "opt": true }, + "boolean": { "des": "boolean type", "typ": "boolean", "opt": true }, + "object": { "des": "object type", "typ": "object", "opt": true }, + "numeric": { "des": "numeric type", "typ": "numeric", "opt": true }, + "float": { "des": "float type", "typ": "float", "opt": true } } }, diff --git a/public_html/page/fiche.php b/public_html/page/fiche.php new file mode 100644 index 0000000..13d3b0d --- /dev/null +++ b/public_html/page/fiche.php @@ -0,0 +1,48 @@ + + + + + + + + + + Gestion des enseignants + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/public_html/page/settings.php b/public_html/page/settings.php new file mode 100644 index 0000000..dfea50c --- /dev/null +++ b/public_html/page/settings.php @@ -0,0 +1,48 @@ + + + + + + + + + + Gestion des enseignants + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/public_html/page/ue.php b/public_html/page/ue.php new file mode 100644 index 0000000..9241273 --- /dev/null +++ b/public_html/page/ue.php @@ -0,0 +1,48 @@ + + + + + + + + + + Gestion des enseignants + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js index 5029084..2a75ec5 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,5 +1,5 @@ -var path = require('path') -var webpack = require('webpack') +var path = require('path'); +var webpack = require('webpack'); const ExtractTextPlugin = require("extract-text-webpack-plugin"); @@ -50,15 +50,51 @@ module.exports = [ { }, { - name: "teacher", - entry: './webpack/page/teacher.js', - output: { - path: path.resolve(__dirname, './public_html/js/bundle'), - publicPath: '/js/bundle/', - filename: 'teacher@0.js' - }, - module: mod_common, - devtool: (process.env.NODE_ENV==='development') ? '#eval-source-map' : false + name: "teacher", + entry: './webpack/page/teacher.js', + output: { + path: path.resolve(__dirname, './public_html/js/bundle'), + publicPath: '/js/bundle/', + filename: 'teacher@0.js' + }, + module: mod_common, + devtool: (process.env.NODE_ENV==='development') ? '#eval-source-map' : false + +}, { + + name: "ue", + entry: './webpack/page/ue.js', + output: { + path: path.resolve(__dirname, './public_html/js/bundle'), + publicPath: '/js/bundle/', + filename: 'ue@0.js' + }, + module: mod_common, + devtool: (process.env.NODE_ENV==='development') ? '#eval-source-map' : false + +}, { + + name: "fiche", + entry: './webpack/page/fiche.js', + output: { + path: path.resolve(__dirname, './public_html/js/bundle'), + publicPath: '/js/bundle/', + filename: 'fiche@0.js' + }, + module: mod_common, + devtool: (process.env.NODE_ENV==='development') ? '#eval-source-map' : false + +}, { + + name: "settings", + entry: './webpack/page/settings.js', + output: { + path: path.resolve(__dirname, './public_html/js/bundle'), + publicPath: '/js/bundle/', + filename: 'settings@0.js' + }, + module: mod_common, + devtool: (process.env.NODE_ENV==='development') ? '#eval-source-map' : false }, { diff --git a/webpack/component/fiche/view.vue b/webpack/component/fiche/view.vue new file mode 100644 index 0000000..966eef4 --- /dev/null +++ b/webpack/component/fiche/view.vue @@ -0,0 +1,23 @@ + + + + + + \ No newline at end of file diff --git a/webpack/component/settings/view.vue b/webpack/component/settings/view.vue new file mode 100644 index 0000000..39c13cc --- /dev/null +++ b/webpack/component/settings/view.vue @@ -0,0 +1,23 @@ + + + + + + \ No newline at end of file diff --git a/webpack/component/ue/view.vue b/webpack/component/ue/view.vue new file mode 100644 index 0000000..c549486 --- /dev/null +++ b/webpack/component/ue/view.vue @@ -0,0 +1,53 @@ + + + + + +s \ No newline at end of file diff --git a/webpack/data/fiche.js b/webpack/data/fiche.js new file mode 100644 index 0000000..e69de29 diff --git a/webpack/data/settings.js b/webpack/data/settings.js new file mode 100644 index 0000000..e69de29 diff --git a/webpack/data/teacher.js b/webpack/data/teacher.js index 4ee7bbf..2205720 100644 --- a/webpack/data/teacher.js +++ b/webpack/data/teacher.js @@ -69,7 +69,7 @@ gstore.add('filter_handler', function(){ element.remClass('filter-hidden'); // 3.2. Only hide if does not match filter - if( rs.professors.indexOf(local_ptr[e].idProfesseur) <= -1 ) + if( rs.matches.indexOf(local_ptr[e].idProfesseur) <= -1 ) element.addClass('filter-hidden'); } diff --git a/webpack/data/ue.js b/webpack/data/ue.js new file mode 100644 index 0000000..00d6875 --- /dev/null +++ b/webpack/data/ue.js @@ -0,0 +1,16 @@ +/* (1) Load UEs +---------------------------------------------------------*/ +/* (1) Initialize list */ +gstore.add('ues', []); + +/* (2) Get UEs */ +api.call('GET ue', { vh: true }, function(rs) { + + // {1} If error -> abort // + if(rs.error !== 0) + return console.log('No UE found, error: ' + rs.error); + + // {2} Store UEs // + console.log(rs); + gstore.get.ues = rs.ues; +}); diff --git a/webpack/page/fiche.js b/webpack/page/fiche.js new file mode 100644 index 0000000..c7035a3 --- /dev/null +++ b/webpack/page/fiche.js @@ -0,0 +1,35 @@ +/* (1) Imports +---------------------------------------------------------*/ +/* (1) NPM libs */ +import Vue from 'vue' +import VueRouter from 'vue-router' +import routes from '../routes/fiche' + +/* (2) Vues */ +import wrapper_vue from '../vue/wrapper.vue' + +/* (3) Data */ +require('../data/common'); +require('../data/fiche'); + + + + +/* (2) Initialisation +---------------------------------------------------------*/ +/* (1) Init Router */ +const router = new VueRouter({ + mode: 'history', + routes: routes[0] +}); + +/* (2) Store router in gstore */ +gstore.add('router', router); + +/* (3) Render view */ +Vue.use(VueRouter); +new Vue({ + el: '#main-vue', + router, + render: h => h(wrapper_vue) +}); \ No newline at end of file diff --git a/webpack/page/settings.js b/webpack/page/settings.js new file mode 100644 index 0000000..856afe2 --- /dev/null +++ b/webpack/page/settings.js @@ -0,0 +1,35 @@ +/* (1) Imports +---------------------------------------------------------*/ +/* (1) NPM libs */ +import Vue from 'vue' +import VueRouter from 'vue-router' +import routes from '../routes/settings' + +/* (2) Vues */ +import wrapper_vue from '../vue/wrapper.vue' + +/* (3) Data */ +require('../data/common'); +require('../data/settings'); + + + + +/* (2) Initialisation +---------------------------------------------------------*/ +/* (1) Init Router */ +const router = new VueRouter({ + mode: 'history', + routes: routes[0] +}); + +/* (2) Store router in gstore */ +gstore.add('router', router); + +/* (3) Render view */ +Vue.use(VueRouter); +new Vue({ + el: '#main-vue', + router, + render: h => h(wrapper_vue) +}); \ No newline at end of file diff --git a/webpack/page/ue.js b/webpack/page/ue.js new file mode 100644 index 0000000..88019ac --- /dev/null +++ b/webpack/page/ue.js @@ -0,0 +1,35 @@ +/* (1) Imports +---------------------------------------------------------*/ +/* (1) NPM libs */ +import Vue from 'vue' +import VueRouter from 'vue-router' +import routes from '../routes/ue' + +/* (2) Vues */ +import wrapper_vue from '../vue/wrapper.vue' + +/* (3) Data */ +require('../data/common'); +require('../data/ue'); + + + + +/* (2) Initialisation +---------------------------------------------------------*/ +/* (1) Init Router */ +const router = new VueRouter({ + mode: 'history', + routes: routes[0] +}); + +/* (2) Store router in gstore */ +gstore.add('router', router); + +/* (3) Render view */ +Vue.use(VueRouter); +new Vue({ + el: '#main-vue', + router, + render: h => h(wrapper_vue) +}); \ No newline at end of file diff --git a/webpack/routes/fiche.js b/webpack/routes/fiche.js new file mode 100644 index 0000000..475cac6 --- /dev/null +++ b/webpack/routes/fiche.js @@ -0,0 +1,11 @@ +export default{ 0: [ + + { + path: '/fiche/view/', + component: require('../component/fiche/view.vue').default + }, { + path: '*', + redirect: '/fiche/view/' + } + +]} \ No newline at end of file diff --git a/webpack/routes/settings.js b/webpack/routes/settings.js new file mode 100644 index 0000000..767a198 --- /dev/null +++ b/webpack/routes/settings.js @@ -0,0 +1,11 @@ +export default{ 0: [ + + { + path: '/settings/view/', + component: require('../component/settings/view.vue').default + }, { + path: '*', + redirect: '/settings/view/' + } + +]} \ No newline at end of file diff --git a/webpack/routes/ue.js b/webpack/routes/ue.js new file mode 100644 index 0000000..613f7d8 --- /dev/null +++ b/webpack/routes/ue.js @@ -0,0 +1,11 @@ +export default{ 0: [ + + { + path: '/ue/view/', + component: require('../component/ue/view.vue').default + }, { + path: '*', + redirect: '/ue/view/' + } + +]} \ No newline at end of file