cms.user.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. $protect = 0;
  17. }
  18. $id_form = '<input type="hidden" name="id" value="' . $user["id"] . '">';
  19. }
  20. ?>
  21. <header class="d-flex flex-column flex-md-row align-items-md-center p-3 bg-light row">
  22. <div class="col-11">
  23. <h2 class="bd-title" id="content">
  24. <span><?php echo $titre ?></span>
  25. </h2>
  26. <?php if(isset($user["id"]) AND session::getId() != $user["id"]){ ?>
  27. <div style="float:right; margin: -30px;">
  28. <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>
  29. </div>
  30. <?php } ?>
  31. <?php if(isset($user["last_connect"])){ echo '<h6>Dernière connexion : ' . $user["last_connect"] .'</h6>'; } ?>
  32. </div>
  33. </header>
  34. <br />
  35. <form method="post" action="/submit.php" oninput='password2.setCustomValidity(password2.value != password.value ? "Les mots de passe ne sont pas identiques" : "")'>
  36. <input type="hidden" name="from" value="user">
  37. <?php
  38. echo $id_form;
  39. ?>
  40. <div class="form-group">
  41. <label>Type de compte</label>
  42. <?php if($protect == 0): ?>
  43. <select name="id_type" class="form-select">
  44. <option value="2"<?php if(isset($user["id_type"]) AND $user["id_type"] == 2){ echo " selected"; } ?>>Contrôleur QRCode (émargement)</option>
  45. <option value="3"<?php if(isset($user["id_type"]) AND $user["id_type"] == 3){ echo " selected"; } ?>>Assitance sociale</option>
  46. <option value="1"<?php if(isset($user["id_type"]) AND $user["id_type"] == 1){ echo " selected"; } ?>>Administrateur</option>
  47. </select>
  48. <?php endif; ?>
  49. <?php if($protect == 1): ?>
  50. <input type="text" class="form-control" value="<?php
  51. if($user["id_type"] == 1){ echo "Administrateur"; }
  52. elseif($user["id_type"] == 2){ echo "Contrôleur QRCode (émargement)"; }
  53. elseif($user["id_type"] == 3){ echo "Assitance sociale"; }
  54. ?>" readonly="readonly" />
  55. <input type="hidden" name="id_type" value="<?php echo $user["id_type"] ?>">
  56. <?php endif; ?>
  57. </div>
  58. <br />
  59. <div class="form-group">
  60. <label>Prénom</label>
  61. <input type="text" class="form-control" value="<?php
  62. if (isset($user["prenom"])) {
  63. echo $user["prenom"];
  64. }
  65. ?>" name="prenom" placeholder="" required>
  66. </div>
  67. <br />
  68. <div class="form-group">
  69. <label>nom</label>
  70. <input type="text" class="form-control" value="<?php
  71. if (isset($user["nom"])) {
  72. echo $user["nom"];
  73. }
  74. ?>" name="nom" placeholder="" required>
  75. </div>
  76. <br />
  77. <div class="form-group">
  78. <label>Email</label>
  79. <input type="email" class="form-control" value="<?php
  80. if (isset($user["email"])) {
  81. echo $user["email"];
  82. }
  83. ?>" name="email" placeholder="" required>
  84. </div>
  85. <br />
  86. <div class="form-group">
  87. <label>Mot de passe</label>
  88. <input type="password" class="form-control" minlength="8" maxlength="25" value="" name="password" placeholder="" <?php if(core::ifGet("add")){ echo "required"; } ?>>
  89. </div>
  90. <br />
  91. <div class="form-group">
  92. <label>Confirmation du mot de passe</label>
  93. <input type="password" class="form-control" value="" name="password2" placeholder="" <?php if(core::ifGet("add")){ echo "required"; } ?>>
  94. </div>
  95. <br />
  96. <div class="form-group">
  97. <label>Google Authenticator</label>
  98. <select name="googleAuthenticator" class="form-select">
  99. <option value="0"<?php if(isset($user["googleAuthenticator"]) AND $user["googleAuthenticator"] == 0){ echo " selected"; } ?>>Désactivée</option>
  100. <option value="1"<?php if(isset($user["googleAuthenticator"]) AND $user["googleAuthenticator"] == 1){ echo " selected"; } ?>>Activée</option>
  101. </select>
  102. </div>
  103. <br />
  104. <?php if(isset($user["googleAuthenticator"]) AND $user["googleAuthenticator"] == 1 AND $protect == 1) { ?>
  105. <div class="card text-center" style="width: 18rem;">
  106. <?php
  107. $qrCodeUrl = googleAuthenticator::getGoogleUrl("CMS CSE Invent: " . ENVIRONNEMENT, user::getMyGoogleAuthenticator(session::getId()));
  108. myQrcode::printQRCode($qrCodeUrl);
  109. ?>
  110. <div class="card-footer text-body-secondary">
  111. QRCode à scanner dans votre application Google Authenticator<br />
  112. <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>
  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>