account.notification.php 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. global $myUser;
  3. if(!$myUser->connected()) throw new Exception('Vous devez être connecté pour accéder à cette fonctionnalité');
  4. if(!$myUser->can('notification', 'read')) return;
  5. require_once(__DIR__.SLASH.'Notification.class.php');
  6. $myUser->loadPreferences();
  7. $sendMail = $myUser->preference('notification_send_mail');
  8. $userAlerts = json_decode($myUser->preference('notification_categories'),true);
  9. $userAlerts = !$userAlerts ? array() : $userAlerts;
  10. $categories = array();
  11. foreach(Notification::types() as $slug => $type):
  12. $type['slug'] = $slug;
  13. if(!isset($type['category'])) $type['category'] = 'Général';
  14. if(!isset($categories[slugify($type['category'])])) $categories[slugify($type['category'])] = array('label'=>$type['category'],'items'=>array());
  15. $categories[slugify($type['category'])]['items'][] = $type;
  16. endforeach;
  17. ?>
  18. <div class="row">
  19. <div class="col-md-12" id="notification_preference">
  20. <br>
  21. <div onclick="notification_user_save_preference()" class="btn btn-success right"><i class="fas fa-check"></i> Enregistrer</div>
  22. <h3>Notifications</h3>
  23. <hr>
  24. <div class="row">
  25. <div class="col-md-12">
  26. <label for="notification_send_mail">Envoyer mes notifications à cette adresse mail : </label>
  27. <input id="notification_send_mail" name="notification_send_mail" class="form-control" placeholder="j.doe@email.com" value="<?php echo !empty($sendMail) ? $sendMail : $myUser->mail;; ?>" type="text"><br>
  28. </div>
  29. <div class="col-md-12 notification_categories" id="notification_categories">
  30. <h5>Suivre les catégories : </h5>
  31. <div class="row">
  32. <div class="col-3">
  33. <div class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical">
  34. <?php
  35. $i = 0;
  36. foreach($categories as $categorySlug=>$category): ?>
  37. <a class="nav-link <?php echo $i==0?'active':'' ?>" id="v-pills-home-tab" data-toggle="pill" href="#category-<?php echo $categorySlug ?>" role="tab" aria-controls="v-pills-home" aria-selected="true"><i class="far fa-bookmark"></i> <?php echo $category['label'] ?></a>
  38. <?php
  39. $i++;
  40. endforeach; ?>
  41. </div>
  42. </div>
  43. <div class="col-9">
  44. <div class="tab-content" id="v-pills-tabContent">
  45. <?php
  46. $i = 0;
  47. foreach($categories as $categorySlug=>$category): ?>
  48. <div class="tab-pane fade show <?php echo $i==0?'active':'' ?>" id="category-<?php echo $categorySlug ?>" role="tabpanel" aria-labelledby="v-pills-home-tab">
  49. <?php foreach($category['items'] as $type): ?>
  50. <div data-slug="<?php echo $type['slug']; ?>" class="list-group-item list-group-item-action flex-column align-items-start category no-select mb-2">
  51. <div class="d-flex w-100 justify-content-between">
  52. <h5 class="mb-1" style="color:<?php echo $type['color']; ?>;"><i class="<?php echo $type['icon']; ?>"></i> <?php echo $type['label']; ?></h5>
  53. <small>
  54. <input data-type="checkbox" <?php echo in_array($type['slug'], $userAlerts) ? 'checked="checked"' : '' ?> class="form-check-input">
  55. </small>
  56. </div>
  57. <p class="mb-1"><?php echo $type['description']; ?></p>
  58. <small>Cochez la case pour être averti par e-mail.</small>
  59. </div>
  60. <?php
  61. $i++;
  62. endforeach; ?>
  63. </div>
  64. <?php endforeach; ?>
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. </div><br>