widget.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 =="" ? 150 : $maxlength ;
  11. $userNotifications = UserNotification::byUser($myUser,array(
  12. 'limit' => $max,
  13. 'unread' => false,
  14. 'types' => $types,
  15. ));
  16. ?>
  17. <div class="notificationContainer">
  18. <h4><i class="far fa-bell"></i> ALERTES</h4>
  19. <ul class="notification-widget-list">
  20. <?php
  21. foreach($userNotifications as $infos):
  22. $infos['created-relative'] = isset($_['synthesis']) ? relative_time($infos['created'], null, 7) : relative_time($infos['created'], null, 7, true);
  23. $meta = json_decode($infos['meta']);
  24. $infos['link'] = 'index.php?module=notification#'.$infos['id'];
  25. $type = Notification::types($infos['type']);
  26. ?>
  27. <li>
  28. <h5 onclick="document.location.href='<?php echo $infos['link']; ?>';" class="pointer mb-0"><i title="<?php echo $type['label'] ?>" class="<?php echo $type['icon'] ?>"></i> <?php echo $infos['label']; ?> <small class="text-muted"> - <i class="far fa-clock"></i> <?php echo $infos['created-relative']; ?></small></h5>
  29. <p class="mt-2"><?php echo truncate($infos['html'],$maxlength,array('html'=>true)); ?></p>
  30. <a class="btn btn-link" href="<?php echo $infos['link']; ?>">+ d'information</a>
  31. </li>
  32. <?php endforeach; ?>
  33. </ul>
  34. </div>