56 if (isset(self::$global_mail_services_cache[self::CACHE_TYPE_REF_ID]) &&
57 null !== self::$global_mail_services_cache[self::CACHE_TYPE_REF_ID]) {
58 return (
int) self::$global_mail_services_cache[self::CACHE_TYPE_REF_ID];
62 if (!MAIL_SETTINGS_ID) {
63 $res = $DIC->database()->queryF(
65 SELECT object_reference.ref_id FROM object_reference, tree, object_data 66 WHERE tree.parent = %s 67 AND object_data.type = %s 68 AND object_reference.ref_id = tree.child 69 AND object_reference.obj_id = object_data.obj_id',
70 array(
'integer',
'text'),
71 array(SYSTEM_FOLDER_ID,
'mail')
74 while ($row = $DIC->database()->fetchAssoc(
$res)) {
75 self::$global_mail_services_cache[self::CACHE_TYPE_REF_ID] = $row[
'ref_id'];
78 self::$global_mail_services_cache[self::CACHE_TYPE_REF_ID] = MAIL_SETTINGS_ID;
81 return (
int) self::$global_mail_services_cache[self::CACHE_TYPE_REF_ID];
95 public static function getNewMailsData(
int $usr_id,
int $leftInterval = 0) : array
103 $cacheKey = implode(
'_', [self::CACHE_TYPE_NEW_MAILS, $usr_id, $leftInterval]);
106 isset(self::$global_mail_services_cache[$cacheKey]) &&
107 null !== self::$global_mail_services_cache[$cacheKey]) {
108 return self::$global_mail_services_cache[$cacheKey];
112 SELECT COUNT(mail_id) cnt, MAX(send_time) send_time 114 WHERE folder_id = %s AND user_id = %s AND m_status = %s 116 if ($leftInterval > 0) {
117 $query .=
' AND send_time > ' . $DIC->database()->quote(date(
'Y-m-d H:i:s', $leftInterval),
'timestamp');
120 $res = $DIC->database()->queryF(
122 [
'integer',
'integer',
'text'],
123 [0, $usr_id,
'unread']
125 $row = $DIC->database()->fetchAssoc(
$res);
128 SELECT COUNT(mail_id) cnt, MAX(m.send_time) send_time 130 INNER JOIN mail_obj_data mo 131 ON mo.user_id = m.user_id 132 AND mo.obj_id = m.folder_id 135 AND m.m_status = %s';
136 if ($leftInterval > 0) {
137 $query .=
' AND m.send_time > ' . $DIC->database()->quote(date(
'Y-m-d H:i:s', $leftInterval),
'timestamp');
140 $res = $DIC->database()->queryF(
142 [
'text',
'integer',
'text'],
143 [
'inbox', $usr_id,
'unread']
145 $row2 = $DIC->database()->fetchAssoc(
$res);
147 self::$global_mail_services_cache[$cacheKey] = [
148 'count' => (int) ($row[
'cnt'] + $row2[
'cnt']),
150 (
string) $row[
'send_time'],
151 (
string) $row2[
'send_time']
155 return self::$global_mail_services_cache[$cacheKey];
static getNewMailsData(int $usr_id, int $leftInterval=0)
Determines the number of new mails for the passed user id and stores this information in a local cach...
static $global_mail_services_cache
foreach($_POST as $key=> $value) $res
const CACHE_TYPE_NEW_MAILS
static getMailObjectRefId()
Determines the reference id of the mail object and stores this information in a local cache variable...