cms.user.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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"; } ?>>Assistance 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="5"<?php if(isset($user["id_type"]) AND $user["id_type"] == 5){ echo " selected"; } ?>>Membre du Bureau du CSE</option>
  60. <option value="6"<?php if(isset($user["id_type"]) AND $user["id_type"] == 6){ echo " selected"; } ?>>Elu du CSE</option>
  61. <option value="1"<?php if(isset($user["id_type"]) AND $user["id_type"] == 1){ echo " selected"; } ?>>Administrateur</option>
  62. </select>
  63. <?php endif; ?>
  64. <?php if($protect == 1 OR $protect == 2): ?>
  65. <input type="text" class="form-control" value="<?php
  66. if($user["id_type"] == 1){ echo "Administrateur"; }
  67. elseif($user["id_type"] == 2){ echo "Contrôleur QRCode (émargement)"; }
  68. elseif($user["id_type"] == 3){ echo "Assistance sociale"; }
  69. elseif($user["id_type"] == 4){ echo "Modérateur du CMS"; }
  70. elseif($user["id_type"] == 5){ echo "Membre du Bureau du CSE"; }
  71. elseif($user["id_type"] == 6){ echo "Elu du CSE"; }
  72. ?>" readonly="readonly" />
  73. <input type="hidden" name="id_type" value="<?php echo $user["id_type"] ?>">
  74. <?php endif; ?>
  75. </div>
  76. <br />
  77. <div class="form-group">
  78. <label>Prénom</label>
  79. <input type="text" class="form-control" value="<?php
  80. if (isset($user["prenom"])) {
  81. echo $user["prenom"];
  82. }
  83. ?>" name="prenom" placeholder="" <?php if($protect == 2){ echo 'readonly="readonly"'; } else { echo 'required'; } ?>>
  84. </div>
  85. <br />
  86. <div class="form-group">
  87. <label>nom</label>
  88. <input type="text" class="form-control" value="<?php
  89. if (isset($user["nom"])) {
  90. echo $user["nom"];
  91. }
  92. ?>" name="nom" placeholder="" <?php if($protect == 2){ echo 'readonly="readonly"'; } else { echo 'required'; } ?>>
  93. </div>
  94. <br />
  95. <div class="form-group">
  96. <label>Email</label>
  97. <input type="email" class="form-control" value="<?php
  98. if (isset($user["email"])) {
  99. echo $user["email"];
  100. }
  101. ?>" name="email" placeholder="" <?php if($protect == 2){ echo 'readonly="readonly"'; } else { echo 'required'; } ?>>
  102. </div>
  103. <br />
  104. <?php if($protect != 2): ?>
  105. <div class="form-group">
  106. <label>Mot de passe</label>
  107. <input type="password" class="form-control" minlength="8" maxlength="25" value="" name="password" placeholder="" <?php if(core::ifGet("add")){ echo "required"; } ?>>
  108. </div>
  109. <br />
  110. <div class="form-group">
  111. <label>Confirmation du mot de passe</label>
  112. <input type="password" class="form-control" value="" name="password2" placeholder="" <?php if(core::ifGet("add")){ echo "required"; } ?>>
  113. </div>
  114. <br />
  115. <div class="form-group">
  116. <label>Google Authenticator</label>
  117. <select name="googleAuthenticator" class="form-select">
  118. <option value="0"<?php if(isset($user["googleAuthenticator"]) AND $user["googleAuthenticator"] == 0){ echo " selected"; } ?>>Désactivée</option>
  119. <option value="1"<?php if(isset($user["googleAuthenticator"]) AND $user["googleAuthenticator"] == 1){ echo " selected"; } ?>>Activée</option>
  120. </select>
  121. </div>
  122. <br />
  123. <?php endif; ?>
  124. <?php if(isset($user["googleAuthenticator"]) AND $user["googleAuthenticator"] == 1 AND $protect == 1): ?>
  125. <div class="card text-center" style="width: 18rem;">
  126. <?php
  127. $qrCodeUrl = googleAuthenticator::getGoogleUrl("CMS CSE Invent: " . ENVIRONNEMENT, user::getMyGoogleAuthenticator(session::getId()));
  128. myQrcode::printQRCode($qrCodeUrl);
  129. ?>
  130. <div class="card-footer text-body-secondary">
  131. QRCode à scanner dans votre application Google Authenticator<br />
  132. <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>
  133. </div>
  134. </div>
  135. <br />
  136. <?php endif; ?>
  137. <?php if($protect == 0): ?>
  138. <div class="form-group">
  139. <label>Etat du compte</label>
  140. <select name="actif" class="form-select">
  141. <option value="0"<?php if(isset($user["actif"]) AND $user["actif"] == 0){ echo " selected"; } ?>>Compte désactivé</option>
  142. <option value="1"<?php if(isset($user["actif"]) AND $user["actif"] == 1){ echo " selected"; } ?>>Compte activé</option>
  143. </select>
  144. </div>
  145. <br />
  146. <?php endif; ?>
  147. <?php if($protect == 1): ?>
  148. <input type="hidden" name="actif" value="<?php echo $user["actif"] ?>">
  149. <?php endif; ?>
  150. <input class="btn btn-primary btn-lg" style="width: 100%; margin-bottom:20px;" type="submit" value="<?php echo $submit ?>">
  151. </form>