can('notification','read')) return; ?>
{{{html}}}
'.$infos['html'].'
'; $mail->message .= (isset($infos['meta']['link'])) ? 'Accéder à l\'outil' : ''; $usermail = User::byLogin($recipient); $mail->recipients['to'][] = $usermail->mail; $mail->send(); } ); $sendTypes[] = array( 'slug' => 'interface', 'label' => 'Interface', 'explain' => 'Visualisation via l\'ERP', 'icon' => 'far fa-bell', 'callback' => function($recipient, $infos, $notification){ if($infos['pinned'] == 1) return; if(!isset($recipient)) throw new Exception("Aucun destinataires n\'a été renseignés pour l\'envoi de notifications à travers l\'ERP"); $userNotification = new UserNotification(); $userNotification->notification = $notification->id; $userNotification->user = $recipient; $userNotification->read = 0; $userNotification->save(); } ); } function notification_cron($time){ global $_; if(date('H:i', $time)!= '03:00' && !isset($_['force-notification'])) return; Plugin::need('notification/Notification'); Notification::clear(); } Plugin::addHook('widget',function(&$models){ $model = new DashboardWidget(); $model->icon = 'fas fa-bell'; $model->headerBackground = '#ffbe5c'; $model->description = 'Affiche un menu sélectionné'; $model->label = 'Notification'; $model->width = 3; $model->height = 3; $model->model = 'notification'; $model->css = array(__DIR__.'/css/widget.css?v='.time()); $model->js = array(__DIR__.'/js/widget.js?v='.time()); $model->content = function(&$widget){ global $myUser; User::check_access('notification','read'); Plugin::need('dashboard/DashboardWidget'); $widget->title = 'Dernières alertes'; if(empty($widget->meta['label'])) $widget->meta['label'] = 'Bloc Menu'; if(empty($widget->meta['url'])) $widget->meta['url'] = ''; if(empty($widget->meta['color'])) $widget->meta['color'] = '#007bff'; ob_start(); require_once(__DIR__.SLASH.'Notification.class.php'); require_once(__DIR__.SLASH.'UserNotification.class.php'); $types = isset($widget->meta['types'])? explode(',',$widget->meta['types']) :array('announcement'); $max = isset($widget->meta['notification-number'])?$widget->meta['notification-number']:5; $maxlength = isset($widget->meta['notification-length'])?$widget->meta['notification-length']:250 ; $userNotifications = UserNotification::byUser($myUser,array( 'limit' => $max, 'unread' => false, 'types' => $types, )); ?>