account.notification.php 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. global $myUser;
  3. global $conf;
  4. User::check('notification', 'read');
  5. require_once(__DIR__.SLASH.'Notification.class.php');
  6. $myUser->loadPreferences();
  7. //$userPreferences = Notification::getNotificationPreferences($myUser->login);
  8. $userPreferences = Notification::settingPreferences($myUser->login);
  9. $categories = array();
  10. foreach(Notification::types() as $slug => $type):
  11. $type['slug'] = $slug;
  12. if(!isset($type['category'])) $type['category'] = 'Général';
  13. if(!isset($categories[slugify($type['category'])])) $categories[slugify($type['category'])] = array('label'=>$type['category'],'items'=>array());
  14. $categories[slugify($type['category'])]['items'][] = $type;
  15. endforeach;
  16. ?>
  17. <div class="row">
  18. <div class="col-md-12" id="notification_preference">
  19. <br>
  20. <div onclick="notification_user_save_preference()" class="btn btn-success float-right"><i class="fas fa-check"></i> Enregistrer</div>
  21. <h3>Notifications</h3>
  22. <div class="clear"></div>
  23. <hr>
  24. <div class="row">
  25. <div class="col-md-12 notification_categories" id="notification_categories">
  26. <h5>Suivre les catégories : </h5>
  27. <div class="row">
  28. <div class="col-3">
  29. <div class="nav flex-column nav-pills" id="v-pills-tab" role="tablist" aria-orientation="vertical">
  30. <?php
  31. $i = 0;
  32. foreach($categories as $categorySlug=>$category): ?>
  33. <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>
  34. <?php
  35. $i++;
  36. endforeach; ?>
  37. </div>
  38. </div>
  39. <div class="col-9">
  40. <div class="tab-content" id="v-pills-tabContent">
  41. <?php
  42. $i = 0;
  43. foreach($categories as $categorySlug=>$category): ?>
  44. <div class="tab-pane fade show <?php echo $i==0?'active':'' ?>" id="category-<?php echo $categorySlug ?>" role="tabpanel" aria-labelledby="v-pills-home-tab">
  45. <?php foreach($category['items'] as $type): ?>
  46. <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">
  47. <div class="d-flex w-100 justify-content-between">
  48. <h5 class="mb-1" style="color:<?php echo $type['color']; ?>;"><i class="<?php echo $type['icon']; ?>"></i> <?php echo $type['label']; ?></h5>
  49. </div>
  50. <p class="mb-3"><?php echo $type['description']; ?>.</p>
  51. <ul class="notificationType">
  52. <?php
  53. $methods = array();
  54. Plugin::callHook("notification_methods", array(&$methods));
  55. foreach ($methods as $method) {
  56. $slug = $type['slug'].'_'.$method['slug'];
  57. $checked = ($userPreferences[$type['slug']][$type['slug'].'_'.$method['slug']]) ? 'checked="checked"': '';
  58. ?>
  59. <li class="d-inline-block">
  60. <input data-type="checkbox" data-category="<?php echo $type['slug']; ?>" data-method="<?php echo $method['slug']; ?>" id="<?php echo $slug; ?>" <?php echo $checked ?> class="form-check-input">
  61. <label for="<?php echo $slug; ?>" class="pointer">
  62. <i class="<?php echo $method['icon'] ?>"></i>
  63. <?php echo $method['label'] ?>
  64. </label><br>
  65. <small class="ml-1 text-muted"><?php echo $method['explain']; ?></small>
  66. </li>
  67. <?php
  68. }
  69. ?>
  70. </ul>
  71. </div>
  72. <?php
  73. $i++;
  74. endforeach; ?>
  75. </div>
  76. <?php endforeach; ?>
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. </div><br>