mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-08-15 10:52:30 +02:00
* Notifications: configurable number of days (default 30), after which older notifications get automatic deleted
This commit is contained in:
@ -22,11 +22,6 @@ class notifications_ajax
|
||||
*/
|
||||
const _appname = 'notifications';
|
||||
|
||||
/**
|
||||
* Mailappname
|
||||
*/
|
||||
const _mailappname = 'mail';
|
||||
|
||||
/**
|
||||
* Notification table in SQL database
|
||||
*/
|
||||
@ -40,7 +35,7 @@ class notifications_ajax
|
||||
/**
|
||||
* Do NOT consider notifications older than this
|
||||
*/
|
||||
const CUT_OFF_DATE = '-30days';
|
||||
static public $cut_off_date = '-30days';
|
||||
|
||||
/**
|
||||
* holds account object for user to notify
|
||||
@ -49,13 +44,6 @@ class notifications_ajax
|
||||
*/
|
||||
private $recipient;
|
||||
|
||||
/**
|
||||
* holds config object (sitewide application config)
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* holds preferences array of user to notify
|
||||
*
|
||||
@ -91,7 +79,7 @@ class notifications_ajax
|
||||
public function __construct()
|
||||
{
|
||||
$this->response = Api\Json\Response::get();
|
||||
$this->recipient = (object)$GLOBALS['egw']->accounts->read($GLOBALS['egw_info']['user']['account_id']);
|
||||
$this->recipient = (object)$GLOBALS['egw_info']['user'];
|
||||
|
||||
$this->db = $GLOBALS['egw']->db;
|
||||
|
||||
@ -187,7 +175,7 @@ class notifications_ajax
|
||||
$notify_ids[] = $data;
|
||||
}
|
||||
}
|
||||
$cut_off = $this->db->quote(Api\DateTime::to(self::CUT_OFF_DATE, Api\DateTime::DATABASE));
|
||||
$cut_off = $this->db->quote(Api\DateTime::to(self::$cut_off_date, Api\DateTime::DATABASE));
|
||||
try {
|
||||
foreach($app_ids as $app => $ids)
|
||||
{
|
||||
@ -243,4 +231,14 @@ class notifications_ajax
|
||||
$this->response->apply('app.notifications.append', array($entries['rows']??[], $browserNotify, $entries['total']??0));
|
||||
return true;
|
||||
}
|
||||
|
||||
public function initStatic()
|
||||
{
|
||||
$config = Api\Config::read(self::_appname);
|
||||
|
||||
if (!empty($config['popup_cut_off_days']) && $config['popup_cut_off_days'] > 0)
|
||||
{
|
||||
self::$cut_off_date = "-$config[popup_cut_off_days]days";
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user