cms.user.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php
  2. if(core::ifGet("add")) {
  3. $id_form = '<input type="hidden" name="id" value="add">';
  4. $submit = "Ajouter un profil";
  5. $titre = "Ajouter un profil";
  6. } else {
  7. $databaseUser = new user();
  8. if(core::ifGet("id") and session::getId() != core::ifGet("id")){
  9. $user = $databaseUser->getUserById(core::getGet("id"));
  10. $submit = "Modifier ce profil";
  11. $titre = "Fiche de " . $user["prenom"] . " " . $user["nom"];
  12. $protect = 0;
  13. } else {
  14. $user = $databaseUser->getUserById(session::getId());
  15. $submit = "Modifier votre profil";
  16. $titre = "Votre fiche de profil";
  17. $protect = 1;
  18. }
  19. $id_form = '<input type="hidden" name="id" value="' . $user["id"] . '">';
  20. }
  21. ?>
  22. <header class="d-flex flex-column flex-md-row align-items-md-center p-3 bg-light row">
  23. <div class="col-11">
  24. <h2 class="bd-title" id="content">
  25. <span><?php echo $titre ?></span>
  26. </h2>
  27. <?php if(isset($user["id"]) AND session::getId() != $user["id"]){ ?>
  28. <div style="float:right; margin: -30px;">
  29. <a href="/submit.php?from=user-delete&id=<?php echo $user["id"] ?>" onclick="return confirm('Voulez-vous supprimer le compte de <?php echo $user["prenom"] . " " . $user["nom"]; ?> ?')" style="position: absolute; right: 0; margin: 0 40px 0 0;"><button type="submit" class="btn btn-outline-danger btn-sm"><span data-feather="trash-2"></span> Supprimer</button></a>
  30. </div>
  31. <?php } ?>
  32. <?php if(isset($user["last_connect"])){ echo '<h6>Dernière connexion : ' . $user["last_connect"] .'</h6>'; } ?>
  33. </div>
  34. </header>
  35. <br />
  36. <form method="post" action="/submit.php" oninput='password2.setCustomValidity(password2.value != password.value ? "Les mots de passe ne sont pas identiques" : "")'>
  37. <input type="hidden" name="from" value="user">
  38. <?php
  39. echo $id_form;
  40. ?>
  41. <div class="form-group">
  42. <label>Type de compte</label>
  43. <?php if($protect == 0): ?>
  44. <select name="id_type" class="form-select">
  45. <option value="2"<?php if(isset($user["id_type"]) AND $user["id_type"] == 2){ echo " selected"; } ?>>Contrôleur QRCode (émargement)</option>
  46. <option value="3"<?php if(isset($user["id_type"]) AND $user["id_type"] == 3){ echo " selected"; } ?>>Assitance sociale</option>
  47. <option value="1"<?php if(isset($user["id_type"]) AND $user["id_type"] == 1){ echo " selected"; } ?>>Administrateur</option>
  48. </select>
  49. <?php endif; ?>
  50. <?php if($protect == 1): ?>
  51. <input type="text" class="form-control" value="<?php
  52. if($user["id_type"] == 1){ echo "Administrateur"; }
  53. elseif($user["id_type"] == 2){ echo "Contrôleur QRCode (émargement)"; }
  54. elseif($user["id_type"] == 3){ echo "Assitance sociale"; }
  55. ?>" readonly="readonly" />
  56. <input type="hidden" name="id_type" value="<?php echo $user["id_type"] ?>">
  57. <?php endif; ?>
  58. </div>
  59. <br />
  60. <div class="form-group">
  61. <label>Prénom</label>
  62. <input type="text" class="form-control" value="<?php
  63. if (isset($user["prenom"])) {
  64. echo $user["prenom"];
  65. }
  66. ?>" name="prenom" placeholder="" required>
  67. </div>
  68. <br />
  69. <div class="form-group">
  70. <label>nom</label>
  71. <input type="text" class="form-control" value="<?php
  72. if (isset($user["nom"])) {
  73. echo $user["nom"];
  74. }
  75. ?>" name="nom" placeholder="" required>
  76. </div>
  77. <br />
  78. <div class="form-group">
  79. <label>Email</label>
  80. <input type="email" class="form-control" value="<?php
  81. if (isset($user["email"])) {
  82. echo $user["email"];
  83. }
  84. ?>" name="email" placeholder="" required>
  85. </div>
  86. <br />
  87. <div class="form-group">
  88. <label>Mot de passe</label>
  89. <input type="password" class="form-control" minlength="8" maxlength="25" value="" name="password" placeholder="" <?php if(core::ifGet("add")){ echo "required"; } ?>>
  90. </div>
  91. <br />
  92. <div class="form-group">
  93. <label>Confirmation du mot de passe</label>
  94. <input type="password" class="form-control" value="" name="password2" placeholder="" <?php if(core::ifGet("add")){ echo "required"; } ?>>
  95. </div>
  96. <br />
  97. <div class="form-group">
  98. <label>Google Authenticator</label>
  99. <select name="googleAuthenticator" class="form-select">
  100. <option value="0"<?php if(isset($user["googleAuthenticator"]) AND $user["googleAuthenticator"] == 0){ echo " selected"; } ?>>Désactivée</option>
  101. <option value="1"<?php if(isset($user["googleAuthenticator"]) AND $user["googleAuthenticator"] == 1){ echo " selected"; } ?>>Activée</option>
  102. </select>
  103. </div>
  104. <br />
  105. <?php if(isset($user["googleAuthenticator"]) AND $user["googleAuthenticator"] == 1) { ?>
  106. <div class="card text-center" style="width: 18rem;">
  107. <?php
  108. $qrCodeUrl = googleAuthenticator::getGoogleUrl("CSE Invent: " . ENVIRONNEMENT, user::getMyGoogleAuthenticator(session::getId()));
  109. myQrcode::printQRCode($qrCodeUrl);
  110. ?>
  111. <div class="card-footer text-body-secondary">
  112. QRCode à scanner dans votre application Google Authenticator
  113. </div>
  114. </div>
  115. <br />
  116. <?php } ?>
  117. <?php if($protect == 0): ?>
  118. <div class="form-group">
  119. <label>Etat du compte</label>
  120. <select name="actif" class="form-select">
  121. <option value="0"<?php if(isset($user["actif"]) AND $user["actif"] == 0){ echo " selected"; } ?>>Compte désactivé</option>
  122. <option value="1"<?php if(isset($user["actif"]) AND $user["actif"] == 1){ echo " selected"; } ?>>Compte activé</option>
  123. </select>
  124. </div>
  125. <br />
  126. <?php endif; ?>
  127. <?php if($protect == 1): ?>
  128. <input type="hidden" name="actif" value="<?php echo $user["actif"] ?>">
  129. <?php endif; ?>
  130. <input class="btn btn-primary btn-lg" style="width: 100%" type="submit" value="<?php echo $submit ?>">
  131. </form>