method notify documentation in bbn\Appui\Notification
function($notification)
{
if (bbn\Str::isUid($notification)) {
$notification = $this->get($notification);
}
if (\is_array($notification)
&& bbn\Str::isUid($notification[$this->fields['id']])
&& bbn\Str::isUid($notification[$this->fields['id_content']])
&& bbn\Str::isUid($notification[$this->fields['id_user']])
&& ($id_user = $notification[$this->fields['id_user']])
&& !empty($notification[$this->class_cfg['arch']['content']['title']])
&& !empty($notification[$this->class_cfg['arch']['content']['content']])
&& empty($notification[$this->fields['read']])
&& ($cfg = $this->getCfg($id_user, $notification[$this->class_cfg['arch']['content']['id_option']]))
) {
$mtime = bbn\X::microtime();
$dpath = bbn\Mvc::getUserDataPath($id_user, 'appui-notification');
$ucfg = $this->user->getClassCfg();
$sessions = $this->db->selectAll(
$ucfg['tables']['sessions'], [
$ucfg['arch']['sessions']['id'],
$ucfg['arch']['sessions']['sess_id']
], [
$ucfg['arch']['sessions']['id_user'] => $id_user,
$ucfg['arch']['sessions']['opened'] => 1
]
);
// Web notification
if (empty($notification[$this->fields['web']])
&& !empty($cfg['web'])
&& !empty($sessions)
&& empty($notification[$this->fields['mail']])
) {
foreach ($sessions as $sess) {
$path = $dpath . "web/{$sess->id}/";
if (bbn\File\Dir::createPath($path) && !\is_file($path . "$mtime.json")) {
$notification[$this->fields['web']] = $mtime;
$notification[$this->fields['dt_web']] = date('Y-m-d H:i:s', $mtime);
file_put_contents($path . "$mtime.json", \json_encode($notification));
}
}
}
// Browser notification
elseif (empty($notification[$this->fields['browser']])
&& !empty($cfg['browser'])
&& !empty($sessions)
&& empty($notification[$this->fields['mail']])
) {
foreach ($sessions as $sess) {
$path = $dpath . "browser/{$sess->id}/";
if (bbn\File\Dir::createPath($path) && !\is_file($path . "$mtime.json")) {
$notification[$this->fields['browser']] = $mtime;
$notification[$this->fields['dt_browser']] = date('Y-m-d H:i:s', $mtime);
file_put_contents($path . "$mtime.json", \json_encode($notification));
}
}
}
// Mail notification
elseif (empty($notification[$this->fields['mail']]) && !empty($cfg['mail'])) {
$creation = strtotime($notification[$this->class_cfg['arch']['content']['creation']]);
if (($cfg['mail'] === 'immediately')
|| (($cfg['mail'] === 'daily')
&& (time() > strtotime('00:00:00 +1 day', $creation)))
|| (($cfg['mail'] === 'default')
&& (time() > strtotime('+1 hour', $creation)))
) {
$notification[$this->fields['mail']] = $mtime;
$this->_send_grouped_mail($notification, $cfg['mail']);
}
}
// App notification
//else if (empty($notification[$this->fields['mobile']]) && !empty($cfg['mobile'])) {}
return $this->_update($notification[$this->fields['id']], $notification);
}
return null;
}
BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2023
BBN Solutions