widget.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. global $myUser;
  3. require_once(__DIR__.SLASH.'Notification.class.php');
  4. require_once(__DIR__.SLASH.'UserNotification.class.php');
  5. $types = $widget->data('types');
  6. $types = $types==''? array('announcement'):$types;
  7. $max = $widget->data('notification-number');
  8. $max = $max =="" ? 5 : $max ;
  9. $maxlength = $widget->data('notification-length');
  10. $maxlength = $maxlength =="" ? 250 : $maxlength ;
  11. $userNotifications = UserNotification::byUser($myUser,array(
  12. 'limit' => $max,
  13. 'unread' => false,
  14. 'types' => $types,
  15. ));
  16. ?>
  17. <div class="notification-container">
  18. <h5 class="text-uppercase"><i class="far fa-bell"></i> Alertes</h5>
  19. <ul class="notification-widget-list">
  20. <?php foreach($userNotifications as $infos):
  21. $infos['created-relative'] = isset($_['synthesis']) ? relative_time($infos['created'], null, 7) : relative_time($infos['created'], null, 7, true);
  22. $meta = json_decode($infos['meta']);
  23. $infos['link'] = 'index.php?module=notification#'.$infos['id'];
  24. $type = Notification::types($infos['type']);
  25. ?>
  26. <li>
  27. <h5 onclick="document.location.href='<?php echo $infos['link']; ?>';" class="pointer mb-0 mt-1" style="color: <?php echo $type['color']; ?>;">
  28. <div><i title="<?php echo $type['label'] ?>" class="<?php echo $type['icon'] ?>"></i> <?php echo $infos['label']; ?></div>
  29. <small class="text-muted d-block"><i class="far fa-clock"></i> <?php echo $infos['created-relative']; ?></small>
  30. </h5>
  31. <p class=""><?php echo truncate($infos['html'],$maxlength,array('html'=>true)); ?></p>
  32. <a class="btn btn-link d-block w-100 text-center" href="<?php echo $infos['link']; ?>">+ d'informations</a>
  33. </li>
  34. <?php endforeach; ?>
  35. </ul>
  36. </div>