Page de modification des rôles + checkbox hack

This commit is contained in:
xdrm-brackets 2015-11-20 10:32:07 +01:00
parent c7f2a01964
commit c663e62d93
3 changed files with 77 additions and 4 deletions

View File

@ -392,4 +392,50 @@ tr.grayscale input:focus{
#CONTAINER > section div.partlist > span.active{
background-color: #2dcc70;
color: #fff;
}
/* CHECKBOXES (HACK) */
td input[type=checkbox]{
display: none;
}
td input[type=checkbox] + label{
/* position */
display: inline-block;
position: relative;
width: 1em;
height: 1em;
margin-bottom: -.25em;
/* border */
border-radius: 3px;
border: 1px solid #7c7c7c;
/* background */
background: transparent none center center no-repeat;
background-size: auto 100%;
/* animation */
transition: all .2s ease-in-out;
-moz-transition: all .2s ease-in-out;
-webkit-transition: all .2s ease-in-out;
-ms-transition: all .2s ease-in-out;
-o-transition: all .2s ease-in-out;
/* extra */
cursor: pointer;
user-select: none;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
-o-user-select: none;
}
/* @checked */
td input[type=checkbox]:checked + label{
border-color: #2dcc70;
background-image: url(../src/validate.svg);
}

View File

@ -95,12 +95,22 @@ class userRepo extends DBAccess{
*
*/
public static function getRoleUsers(){
$getListeEnseignants = DataBase::getPDO()->query("SELECT DISTINCT identifiant as id, nom, prenom
$getListeUtilisateurs = DataBase::getPDO()->query("SELECT DISTINCT identifiant as id, nom, prenom, droits as role
FROM utilisateur
WHERE droits <> 'student'
ORDER BY identifiant ASC");
return DataBase::delNumeric( $getListeEnseignants->fetchAll() );
// si aucun résultat, on retourne false
if( !($userlist=$getListeUtilisateurs->fetchAll()) )
return false;
$userlist = DataBase::delNumeric( $userlist );
// sinon on met les rôles sous forme de tableau
foreach($userlist as $iter=>$user)
$userlist[$iter]['role'] = explode(',', $user['role']);
return $userlist;
}

View File

@ -31,9 +31,26 @@ if( permission('admin') ){
if( $answer->request == 'success' ){ // si aucune erreur
echo "<section name='attributionrole' data-title='Rôles'>";
echo "<section name='attributionrole' data-title='Rôles' class='basic' >";
var_dump( $answer->userlist );
// var_dump( $answer->userlist );
echo "<table class='basic col4'><tbody>";
foreach($answer->userlist as $user){
echo "<tr>";
echo "<td><span class='link'>".$user['id']."</span></td>";
echo "<td>".$user['prenom']."</td>";
echo "<td>".$user['nom']."</td>";
// si l'utilisateur est admin
if( in_array('admin', $user['role']) )
echo "<td><input type='checkbox' id='".$user['id']."' checked><label for='".$user['id']."'></label> admin</td>";
else
echo "<td><input type='checkbox' id='".$user['id']."'><label for='".$user['id']."'></label> admin</td>";
echo "</tr>";
}
echo "</tbody></table>";
echo "</section>";