-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
function mix_modules($my_modules, $every_modules){ | ||
//MIXE LES MODULES EN AJOUTANT UN ATTRIBUT "ISADDED"; => permet d'etre reutilisé | ||
$modules = array(); | ||
|
||
foreach ($every_modules as $module) { | ||
if (in_array($module, $my_modules)){ | ||
$module['isAdded'] = 1; | ||
} | ||
else $module['isAdded'] = 0; | ||
$modules[] = $module; | ||
} | ||
|
||
return $modules; | ||
} | ||
|
||
|
||
function get_modules() { | ||
//get every modules in the data base | ||
$sql = "SELECT * FROM module ORDER BY id"; | ||
$conn = new connection(); | ||
$conn->Connect(); | ||
$response = $conn->Conn->query($sql); | ||
|
||
$retour = array(); | ||
while ( $vResult = $response->fetch()) { | ||
$module = array(); | ||
$module[titre] = $vResult['titre']; | ||
$module[description] = $vResult['description']; | ||
$module[lien] = $vResult['lien']; | ||
$module[id] = $vResult['id']; | ||
$retour[] = $module; | ||
} | ||
return $retour; | ||
} | ||
|
||
|
||
function get_user_modules($login) { | ||
//get every module added by the user | ||
$sql = "SELECT * | ||
FROM module INNER JOIN menu_utilisateur | ||
ON module.id = menu_utilisateur.module | ||
WHERE menu_utilisateur.utilisateur = '".phpCAS::getUser()."';"; | ||
$conn = new connection(); | ||
$conn->Connect(); | ||
$response = $conn->Conn->query($sql); | ||
|
||
$retour = array(); | ||
while ( $vResult = $response->fetch()) { | ||
$module = array(); | ||
$module[titre] = $vResult['titre']; | ||
$module[description] = $vResult['description']; | ||
$module[lien] = $vResult['lien']; | ||
$module[id] = $vResult['id']; | ||
$retour[] = $module; | ||
} | ||
return $retour; | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
require_once 'check-cas-connection.php'; | ||
require_once "class/connection.php"; | ||
require_once "includes/functions.php"; | ||
|
||
|
||
|
||
|
||
//phpCAS::getUser(); | ||
|
||
//USER | ||
$my_modules = get_user_modules(phpCAS::getUser()); | ||
$every_modules = get_modules(); | ||
|
||
$modules = mix_modules($my_modules, $every_modules); | ||
|
||
display_modules($modules); | ||
|
||
function display_modules($modules) { | ||
?> | ||
<br> | ||
<br> | ||
<br> | ||
<div class="container"> | ||
<table class="table table-striped"> | ||
<thead> | ||
<tr> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<?php | ||
$n=count($modules); | ||
$i=0; | ||
while($i<$n){ | ||
write_module($modules[$i]); | ||
$i++; | ||
} ?> | ||
</table> | ||
<?php | ||
} | ||
function write_module($module){ | ||
?> | ||
<tr> | ||
<td><img src="<?php echo $module['img']; ?>" class="img-rounded" width=60% style="max-width:450px; min-width:100px" height=width></td> | ||
<td><table style="width:100%"> | ||
<thead> | ||
<tr> | ||
<th><?php echo $module['titre']; ?></th> | ||
<th><?php if ($module['isAdded']==0) { | ||
?> | ||
<button type="button" class="btn btn-success">Ajouter</button></th> | ||
|
||
<?php | ||
} | ||
else { ?> | ||
<button type="button" class="btn btn-danger">Supprimer</button></th> | ||
<?php } ?> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td><?php echo $module['description'];?></td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</td> | ||
</tr> | ||
<?php | ||
} | ||
?> |