2
0

cms.user.php 7.6 KB

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