2
0

cms.user.php 7.4 KB

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